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

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

M = int(input())
t = []
for i in range(M):
    t.append(input())
    
cnt = {}

for S in s:
    if S not in cnt.keys():
        cnt[S] = 1
    else:
        cnt[S] += 1

for T in t:
    if T not in cnt.keys():
        cnt[T] = -1
    else:
        cnt[T] -= 1
        
if max(cnt.values()) < 0:
    print(0)
else:
    print(max(cnt.values()))

Solution (Python):
from collections import Counter

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

for _ in range(int(input())):
    t = input()
    if t in s:
        s.remove(t)

if len(s) == 0:
    print(0)
else:
    c = Counter(s)
    print(c.most_common(1)[0][1])

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()
cost = [1 for i in range(N)]
for i in range(N):
    for j in s[i+1:]:
        if s[i] == j :
            cost[i] += 1
    for j in t:
        if s[i] == j:
            cost[i] -= 1

ans = max(cost)
if ans > 0 :
    print(ans)
else :
    print(0)

Solution (Python):
N = int(input())
sl = [input() for i in range(N)]
M = int(input())
tl = [input() for i in range(M)]
ans = 0
for s in sl:
    tmp = sl.count(s)
    if s in tl:
        tmp -= tl.count(s)
    ans = max(ans, tmp)
print(ans)

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

c = 0
for i in a:
    d = a.count(i)-b.count(i)
    c = max(c,d)
print(c)

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

word = {}

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

M = int(input())

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

money = max(word.values())

if money >= 0:
    print(money)
else:
    print(0)

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

result = [n.count(a) - m.count(a) for a in n]
max_ = max(result)
if max_ < 0:
    print(0)
else:
    print(max_)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append([str(input()),1])
m=int(input())
for i in range(m):
    s.append([str(input()),-1])
s.sort()
x=s[0][0]
max_s=0
a=0
for i in range(n+m):
    if x==s[i][0]:
        a+=s[i][1]
    else:
        x=s[i][0]
        max_s=max(max_s,a)
        a=s[i][1]
print(max(a,max_s))

Solution (Python):
N=int(input())
wordcount={}
for i in range(N):
  s=str(input())
  wordcount[s]=wordcount.get(s,0)+1
M=int(input())
for i in range(M):
  s=str(input())
  wordcount[s]=wordcount.get(s,0)-1
counter=wordcount.values()
f=max(counter)
if f>=0:
  print(f)
else:
  print(0)

Solution (Python):
N=int(input())
D = {}
for _ in range(N):
  s = input().strip()
  if s not in D:
  	D[s] = 0
  D[s] += 1

M=int(input())
for _ in range(M):
  s = input().strip()
  if s not in D:
  	D[s] = 0
  D[s] -= 1
print(max(list(D.values()) + [0]))

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

max_count = -9999
for i in range(len(s)):

    

    if (s.count(s[i]) - t.count(s[i])) > max_count:
        max_count = s.count(s[i]) - t.count(s[i])

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

Solution (Python):
from collections import Counter

n = int(input())
blue_ls = [input() for _ in range(n)]
m = int(input())
red_ls = [input() for _ in range(m)]

blue_counter = Counter(blue_ls)
red_counter = Counter(red_ls)
diff_counter = blue_counter - red_counter

if diff_counter:
    print(diff_counter.most_common(1)[0][1])
else:
    print("0")

Solution (Python):
n = int(input())
d = {}
for i in range(n):
      s = input()
      if not s in d.keys():
            d.setdefault(s,0)
      d[s]+=1
m = int(input())
for i in range(m):
      s = input()
      if s in d.keys():
            d[s] -= 1
ans = 0
for i in d.keys():
      ans = max(ans, d[i])
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)]

dic = defaultdict(int)

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

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

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

s.sort()
word = ""
max = 0
for i in range(n):
  if s[i] == word:
    continue
    
  word = s[i]
  points = s.count(word) - t.count(word)
  if points > max:
    max = points

print(max)

Solution (Python):
n = int(input())
blue = {}
for i in range(n):
    w = input()
    blue[w] = blue.get(w, 0) + 1

m = int(input())
red = {}
for i in range(m):
    w = input()
    red[w] = red.get(w, 0) + 1

pt_lst = []
for i in blue:
    pt = blue[i] - red.get(i, 0)
    pt_lst.append(pt)

pt = max(pt_lst)
if pt < 0:
    pt = 0

print(pt)

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

blue_list=list()
for i in range (N):
    N_ = str(input())
    blue_list.append(N_)

M = int(input())
red_list=list()
for i in range (M):
    M_ = str(input())
    red_list.append(M_) 

output_final=0
for i in range (0,N):
    objective=blue_list[i]
    plus=blue_list.count(objective)
    minus=red_list.count(objective)
    output=plus-minus
    if output>=output_final:
        output_final=output
print (output_final)

Solution (Python):
from collections import Counter
s,t = [],[]

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

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

sd = Counter(s)
td = Counter(t)
sd.subtract(td)

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

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 = list(set(s))
max = 0
for word in words:
    count = s.count(word) - t.count(word)
    if count > max:
        max = count

print(max)

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

maxmoney = 0
maxword = "aaaaa"
for i in range(N):
    money = 0
    for j in range(N):
        if S[i]==S[j]:
            money = money + 1
    for j in range(M):
        if S[i] == T[j]:
            money = money - 1
    if money > maxmoney:
        maxmoney = money
        maxword = S[i]
print(maxmoney)

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

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


    
s_set = set(s)
money = 0
for word in s_set:
    cur = s.count(word)-t.count(word)
    if cur > money:
        money = cur
if money < 0:
    money = 0
print(money)

Solution (Python):
n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
x = 0
for w in set(blue):
    tmp = blue.count(w) - red.count(w)
    if tmp > x:
        x = tmp
print(x)

Solution (Python):
N=int(input())
list_s=[str(input()) for s in range(N)]
M=int(input())
list_t=[str(input()) for t in range(M)]
X=0
C=0
for i in range(N):
  A=list_s.count(list_s[i])
  B=list_t.count(list_s[i])
  if (A-B)>X:
    X=A-B
for i in range(M):
  A=list_s.count(list_t[i])
  B=list_t.count(list_t[i])
  if (A-B)>X:
    X=A-B

print(X)

Solution (Python):
import math
import sys
from collections import Counter
def getinputdata():

    
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
m = int(arr_data[n+1][0])




arr_blue=[]
arr_red=[]
for v in range(1,1+n):
    
    arr_blue.append(arr_data[v][0])
    
for v in range(n+1+1,n+1+1+m):
    
    arr_red.append(arr_data[v][0])


list01=Counter(arr_blue)
list02=Counter(arr_red)




maxdata=0
    
for k in list01:
    

    
    if maxdata<list01[k]-list02[k]:
        
        maxdata=list01[k]-list02[k]
        
print(maxdata)

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

for word in set(blue):
    ans_n = blue.count(word) - red.count(word)
    if ans_n > ans:
        ans = ans_n
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)]
blue_dic = defaultdict(int)
red_dic = defaultdict(int)
res = 0
for i in range(n):
    blue_dic[s[i]] += 1
for i in range(m):
    red_dic[t[i]] += 1
for i in range(n):
    res = max(res, blue_dic[s[i]] - red_dic[s[i]])
print(res)

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

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

str_list = set(s + t)

X = 0

for i in str_list:
  tmp = 0
  for j in s:
    if i == j:
      tmp += 1
  for j in t:
    if i == j:
      tmp -= 1
  if tmp > X:
    X = tmp

print(X)

Solution (Python):
N = int(input())
a = [input() for i in range(N)]
M = int(input())
b = [input() for i in range(M)]
 
k = [0]
 
for x in a:
  temp = a.count(x)-b.count(x)
  k.append(temp)
for y in b:
  temp = a.count(y)-b.count(y)
  k.append(temp)
print(max(k))

Solution (Python):
def main():
    m = int(input())
    count = {}
    for i in range(m):
        s = input()
        count.setdefault(s, 0)
        count[s] += 1

    n = int(input())
    for i in range(n):
        s = input()
        count.setdefault(s, 0)
        count[s] -= 1

    mx = max(count.values())
    print(mx if mx > 0 else 0)


if __name__ == '__main__':
    main()

Solution (Python):


from collections import defaultdict


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    ans = defaultdict(int)
    for i in range(N):
        key = input()
        ans[key] += 1
    M = get_next_int()
    for i in range(M):
        key = input()
        ans[key] -= 1
    max_val = max(ans.values())
    value = 0 if max_val < 0 else max_val
    print(value)


solve()

Solution (Python):
ans = 0

n = int(raw_input())
blue = []
for i in range(0, n):
	blue.append(raw_input())

m = int(raw_input())
red = []
for i in range(0, m):
	red.append(raw_input())

while blue != []:
	countblue = 0
	countred = 0
	blueword = blue[0]
	while blueword in blue:
		countblue = countblue + 1
		blue.remove(blueword)
	while blueword in red:
		countred = countred + 1
		red.remove(blueword)
	if countblue - countred > ans:
		ans = countblue - countred

print ans

Solution (Python):
if __name__ == '__main__':
    n = input()
    s = {}
    for i in range(n):
        a = raw_input()
        if a not in s.keys():
            s[a] = 1
        else:
            s[a] += 1
    m = input()
    t = {}
    for i in range(m):
        a = raw_input()
        if a not in t.keys():
            t[a] = 1
        else:
            t[a] += 1
    m = 0
    for a in s.keys():
        if a in t.keys():
            m = max(m, s[a] - t[a])
        else:
            m = max(m, s[a])
    print m

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

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

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

for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            s[i] = ""
            t[j] = ""


max_score = 0
for i in range(n):
    if s[i]!="" and s.count(s[i])>=max_score:
        max_score = s.count(s[i])
print(max_score)

Solution (Python):
import collections

def solve(N, blues, M, reds):
    blue_count = collections.Counter(blues)
    red_count  = collections.Counter(reds)

    if len(blue_count - red_count) == 0:
        return 0

    return (blue_count - red_count).most_common()[0][1]

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

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

print(solve(N, blues, M, reds))

Solution (Python):
from collections import Counter

N = int(input())
plus = Counter([input() for _ in range(N)])
M = int(input())
minus = Counter([input() for _ in range(M)])

ans = 0
for k, v in dict(plus).items():
    if minus[k]:
        ans = max(ans, v - minus[k])
    else:
        ans = max(ans, v)

print(ans)

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

Solution (Python):
N=int(input())
s=[]
for i in range(N):
    s+=[input()]
M=int(input())
t=[]
for j in range(M):
    t+=[input()]
u=[]
for k in range(N):
    u.append(s.count(s[k])-t.count(s[k]))
if max(u)<0:
    print("0")
else:
    print(max(u))

Solution (Python):

N = int(input())
s = [str(input()) for i in range(N)]
M = int(input())
t = [str(input()) for i in range(M)]
ans = 0

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

print(ans)

Solution (Python):
N = int(input())
s = {}
t_get = 0
for i in range(N):
    tmp = input()
    if (tmp in s.keys()) == False:
        s[tmp] = 1
    else:
        s[tmp] += 1

M = int(input())
for i in range(M):
    tmp = input()
    if(tmp in s.keys()) == False:
        s[tmp] = -1
    else:
        s[tmp] -= 1

for value in s.values():
    if value > t_get:
        t_get = value
print(t_get)

Solution (Python):


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

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

result = 0
trash = []
for w in s:
    if w not in trash:
        tmp = s.count(w) - t.count(w)
        if tmp > result:
            result = tmp
        trash.append(w)

print(result)

Solution (Python):

blue = int(input())
bluelist = []
redlist = []
for i in range(blue):
    bluelist.append(input())
red = int(input())
for i in range(red):
    redlist.append(input())
maxyen = 0
for x in bluelist:
    yen = bluelist.count(x) - redlist.count(x)
    if yen > maxyen:
        maxyen = yen
print(maxyen)

Solution (Python):
N = int(input())
s = {0:0}
for i in range(N):
    tmp = input()
    if tmp in s.keys():
        s[tmp]+=1
    else:
        s[tmp] = 1
M = int(input())
for i in range(M):
    tmp = input()
    if tmp in s.keys():
        s[tmp]-=1
    else:
        s[tmp] = -1

print(max(s.values()))

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



max_score = 0

for e in s:
    score = s.count(e) - t.count(e)
    if score > max_score:
        max_score = score

print(max_score)

Solution (Python):
N = int(input())
d = {}

for _ in range(N):
    k = input()
    if k not in d:
        d[k] = 1
    else:
        d[k] += 1

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



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

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
while len(s) > 0:

    i += 1
    s_tmp = s[0]
    ans_tmp = s.count(s_tmp) - t.count(s_tmp)

    while s.count(s_tmp) > 0:
        s.remove(s_tmp)
    while t.count(s_tmp) > 0:
        t.remove(s_tmp)

    if ans_tmp > ans:
        ans = ans_tmp

print (max(ans, 0))

Solution (Python):

mc = []
nc = []

M = int(input())
for m in range(0,M):
	mc.append(input())

N = int(input())
for n in range(0,N):
	nc.append(input())

max_num = 0
for i in range(0,M):
	stre = mc[i]
	count_dict = mc.count(stre) + nc.count(stre)*-1
	if (max_num <= count_dict):
		max_num = count_dict
	
print(max_num)

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)

SC.subtract(TC)
k, v = SC.most_common()[0]

print(max(v, 0))

Solution (Python):
from collections import Counter, defaultdict
s = Counter([input() for i in range(int(input()))])
d = Counter([input() for i in range(int(input()))])
s = s - d
try:
    print(sorted([x for x in s.items()], key=lambda x: x[1])[-1][-1])
except:
    print(0)

Solution (Python):


N = int(input())
bl = [input() for i in range(N)]
M = int(input())
rl = [input() for i in range(M)]

yenResult = 0
for i in set(bl):
    yen = 0
    yen += bl.count(i)
    yen -= rl.count(i)
    if yen > yenResult:
        yenResult = yen
print(yenResult)

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

result_yen = 0
for i in set(bl):
    yen = 0
    yen += bl.count(i)
    yen -= rl.count(i)
    if yen > result_yen:
        result_yen = yen
print(0 if result_yen == 0 else result_yen)

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

M= int(input())
b=[]
for i in range(M):
    b.append(input())
    
c=[]
for s in set(a+b):
    c.append(a.count(s)-b.count(s))

print(max(0,max(c)))

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

num_minus = int(input())
str_minus = []
for i in range(num_minus):
    str_minus.append(input())

cost_list = []
for s in set(str_plus + str_minus):
    cost_list.append(str_plus.count(s) - str_minus.count(s))

print(max(0, max(cost_list)))

Solution (Python):
from collections import Counter

n = int(input())
nlist=[]
for i in range(n):
  nlist.append(input())
m = int(input())
mlist = []
for j in range(m):
  mlist.append(input())
cn = Counter(nlist)
cm = Counter(mlist)
csum = cn-cm
if not csum.most_common():
  print(0)
else:
  print(csum.most_common()[0][1])

Solution (Python):
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
set_s = list(set(s))
max_yen = -9999
for x in range(len(set_s)):
    yen = s.count(set_s[x]) - t.count(set_s[x])
    if yen > max_yen:
        max_yen = yen
if max_yen < 0:
    print("0")
else:
    print(max_yen)

Solution (Python):
cnt_dict = {}

N = int(input())
for _ in range(N):
    s = input()
    if cnt_dict.get(s) is not None:
        cnt_dict[s] += 1
    else:
        cnt_dict[s] = 1

M = int(input())
for _ in range(M):
    t = input()
    if cnt_dict.get(t) is not None:
        cnt_dict[t] -= 1


ans =  max(cnt_dict.items(), key=lambda x:x[1])[1]
if ans > 0:
    print(ans)
else:
    print(0)

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

maxX = 0
word = set(Blue+Red)
for w in word:
    x = Blue.count(w) - Red.count(w)
    if x > maxX:
        maxX = x

print(maxX)

Solution (Python):
n = int(input())
blue =[]
red = []
result = 0

for i in range (n):
  word = input()
  blue.append(word)
  
m = int(input())

for i in range (m):
  word = input()
  red.append(word)

for word in blue:
  temp = blue.count(word) - red.count(word)
  
  if temp > result:
    result = temp
    
print (result)

Solution (Python):
from collections import Counter
N = int(input())
s1 = [input() for i in range(N)]
c1 = Counter(s1)
M = int(input())
s2 = [input() for i in range(M)]
c2 = Counter(s2)

ans = 0
for k,v in c1.items():
    ans = max(ans, v - c2[k])
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
res = {}
for i in S:
    if i in S:
        if i in T:
            res[i] = S.count(i) - T.count(i)
        else:
            res[i] = S.count(i)
if max(res.values()) <= 0:
    print(0)
else:
    print(max(res.values()))

Solution (Python):
import sys

l={}
n = int(sys.stdin.readline())

for i in range(n):
    a = sys.stdin.readline().strip()
    if a in l.keys():
        l[a] += 1
    else:
        l[a] = 1

m = int(sys.stdin.readline())

for i in range(m):
    b = sys.stdin.readline().strip()
    if b in l.keys():
        l[b] -= 1

print(max(l.values()) if max(l.values()) > 0 else 0)

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

Solution (Python):
word_dic = {}
N = int(input())
for i in range(N):
    word = input()
    if word in word_dic.keys():
        word_dic[word] += 1
    else:
        word_dic[word] = 1
        
M = int(input())
for i in range(M):
    word = input()
    if word in word_dic.keys():
        word_dic[word] -= 1
        
score = max(word_dic.values())
if score < 0:
    score = 0
print(score)

Solution (Python):
list1 = []
list2 = []
tmp = 0
max = 0
n2 = input()
n = int(n2)
for i in range(n):
   list1.append(input())
m2 = input()
m = int(m2)
for i in range(m):
   list2.append(input())
for person in list1:
   tmp = 0
   for people in list1:
       if(people == person):
          tmp += 1
   for people in list2:
       if(people == person):
          tmp -= 1
   if(tmp > max):
       max = tmp
print(max)

Solution (Python):
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r :
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
    else:
        if res < c_b[k_b]:
            res = c_b[k_b]

print(res)

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

count = {s[i]: s.count(s[i]) - t.count(s[i]) for i in range(N) }

result = sorted(count.items(), key=lambda x: x[1], reverse=True)[0][1]
if result > 0:
    print(result)
else:
    print(0)

Solution (Python):
N = int(input())
dict_s = {}
for var in range(N):
    s = input()
    if s in dict_s:
        dict_s[s] += 1
    else:
        dict_s[s] = 1
M = int(input())
for var in range(M):
    t = input()
    if t in dict_s:
        dict_s[t] -= 1
dict_s[''] = 0
print (max(dict_s.values()))

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

M = int(input())
for var in range(M):
    t = input()
    if t in dict_s:
        dict_s[t] -= 1

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

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

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

tensu = []
for key in dict_s.keys():
    if key in dict_t:
        tensu.append(dict_s[key] - dict_t[key])
    else:
        tensu.append(dict_s[key])

tensu_max=max(tensu)
if tensu_max < 0:
    print(0)
else:
    print(tensu_max)

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 x in s:
    ans = max(ans, s.count(x) - t.count(x))
print(ans)

Solution (Python):
from collections import Counter
n=int(input())
a=[]
for i in range(n):
    a.append(input())
m=int(input())
b=[]
for i in range(m):
    b.append(input())
ans=0
a_counter=Counter(a)
b_counter=Counter(b)

for i in a_counter:
    d=a_counter[i]
    if i in b_counter:
        d-=b_counter[i]
    else:
        d=d
    ans=max(ans,d)
    d=0
print(ans)

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

print(max(list(ret.values()) + [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())

s_set = set(s)
sub = []
for i in s_set:
    a = s.count(i)
    b = t.count(i)
    sub.append(a-b)
if max(sub) >0:
    print(max(sub))
else:
    print('0')

Solution (Python):


if __name__ == "__main__":
	N = int(input())
	blue_cards = [input() for i in range(N)]
	M = int(input())
	red_cards = [input() for i in range(M)]
	
	max_money = 0
	for word in blue_cards:
		money = 0
		for blue in blue_cards:
			if word == blue:
				money += 1
		for red in red_cards:
			if word == red:
				money -= 1
		if money > max_money:
			max_money = money
	print(max_money)

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

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

word_list = []
for i in s:
    if (i in word_list):
        continue
    else:
        word_list.append(i)

max_value = 0
for i in word_list:
    value = s.count(i) - t.count(i)
    if (max_value < value):
        max_value = value
print(max_value)

Solution (Python):
N = int(input())
d = {}
for i in range(N):
    c = input()
    d[c] = d.get(c, 0) + 1

M = int(input())
for i in range(M):
    c = input()
    d[c] = d.get(c, 0) - 1

print(max(max(d.items(), key=lambda x: x[1])[1], 0))

Solution (Python):
from collections import Counter

N = int(input())
blue = list(input() for _ in range(N))
M = int(input())
red = list(input() for _ in range(M))

blue2 = Counter(blue)
red2 = Counter(red)

blue2.subtract(red2)
for word, cnt in blue2.most_common(1):
    if cnt < 0:
        print(0)
    else:
        print(cnt)

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

total = []
i = 0
while i < n:
	counter = 0
	for k in range(n):
		if s[k] == s[i]:
			counter += 1
	for k in range(m):
		if t[k] == s[i]:
			counter += -1
	total.append(counter)
	i += 1

if max(total) >= 0:
	print(max(total))
else:
	print('0')

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

max_point = 0
for string in s:
    point = 0
    for i in s:
        if i == string:
            point += 1
    for j in t:
        if j == string:
            point -= 1
    if point > max_point:
        max_point = point
print(max_point)

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

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 str in s: 
    cou = s.count(str) - t.count(str) 
    ans = max(cou, ans)

print(ans)

Solution (Python):
d = {}
N = int(input())
for _ in range(N):
  c = input()
  d[c] = d.get(c, 0)+1
M = int(input())
for _ in range(M):
  c = input()
  d[c] = d.get(c, 0)-1
print(max(max(d.items(), key=lambda x: x[1])[1], 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())
ma=0
for i in s:
  ma=max(ma,s.count(i)-t.count(i))
print(ma)

Solution (Python):
N=int(input())
res={}
for dummy in range(N):
  s=input()
  if s not in res.keys():
    res[s]=1
  else:
    res[s]+=1
M=int(input())
for dummy in range(M):
  s=input()
  if s not in res.keys():
    res[s]=-1
  else:
    res[s]-=1
tmp=max(res.values())
if tmp<0:print('0')
else: print(tmp)

Solution (Python):
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for k in range(M)]
mx=[]
c=[]
for j in range(N):
    if(s[j] not in c):
        c.append(s[j])
for j in range(M):
    if (t[j] not in c):
        c.append(t[j])
for j in range(len(c)):
    mx.append(s.count(c[j])-t.count(c[j]))
if(max(mx)<0):print(0)
else:print(max(mx))

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

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

count=0

for i in set(s):
    value=s.count(i)-t.count(i)

    if value>count:
        count=value

print(count)

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

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

S = set()
blueCard = {}
for i in range(N):
	s = input()
	S.add(s)
	if s not in blueCard:
		blueCard[s] = 1
	else:
		blueCard[s] += 1

M = int(input())
redCard = {}
for i in range(M):
	t = input()
	S.add(t)
	if t not in redCard:
		redCard[t] = 1
	else:
		redCard[t] += 1

res = 0
for u in S:
	if u in blueCard and u not in redCard:
		res = max(res, blueCard[u])
	elif u in blueCard and u in redCard:
		res = max(res, blueCard[u] - redCard[u])
print(res)