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 solve(ss, ts):
    u_ss = list(set(ss))
    u_ts = list(set(ts))
    ss_dict = {}
    ts_dict = {}
    for u in u_ss:
        ss_dict[u] = ss.count(u)
    for u in u_ts:
        ts_dict[u] = ts.count(u)
    ans_dict = {}
    for u in list(ss_dict.keys()) + list(ts_dict.keys()):
        ss_dict[u] = ss_dict[u] if u in list(ss_dict.keys()) else 0
        ts_dict[u] = ts_dict[u] if u in list(ts_dict.keys()) else 0

        ans_dict[u] = ss_dict[u] - ts_dict[u]
    ans = max(list(ans_dict.values()))
    if ans < 0:
        ans = 0
    return ans

if __name__ == '__main__':
    N = int(input())
    ss = []
    ts = []
    for _ in range(N):
       ss = ss + [input()] 
    M = int(input())
    for _ in range(M):
       ts = ts + [input()] 

    print(solve(ss, ts))

Solution (Python):
import collections

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

count_s = collections.Counter(s)
count_t = collections.Counter(t)
ans = 0
for key in count_s:
    point = count_s[key]
    if key in count_t.keys():
         point -= count_t[key]
    
    if ans < point:
        ans = point
print(ans)

Solution (Python):
N = int(input())
Blue_Cards = []
for i in range(N):
    Blue_Cards. append(input())
M = int(input())
Red_Cards = []
for n in range(M):
    Red_Cards. append(input())
Q = 0
for l in range(N):
    P = int(Blue_Cards. count(Blue_Cards[l]))-int(Red_Cards. count(Blue_Cards[l]))
    if P > Q:
        Q = P
print(Q)

Solution (Python):
a=[]
b=[]
x=0
y=0
z=x-y
ans=[]

N=int(input())
for i in range(N):
  c=input()
  a.append(c)
M=int(input())
for i in range(M):
  c=input()
  b.append(c)
  
for i in a:
  for j in a:
    if(i==j):
      x+=1
  for k in b:
    if(i==k):
      y+=1
  z=x-y
  if(z<=0):
    z=0
  ans.append(z)
  x=0
  y=0
  z=0

d=max(ans)
print(d)

Solution (Python):


def main():
	N = int(input())
	s = []
	for i in range(N):
		s.append(input())
	M = int(input())
	t = []
	for i in range(M):
		t.append(input())

	s_uniq = list(set(s))
	s_dict = {}
	for i in range(len(s_uniq)):
		s_dict[s_uniq[i]] = s.count(s_uniq[i])
	t_uniq = list(set(t))
	t_dict = {}
	for i in range(len(t_uniq)):
		t_dict[t_uniq[i]] = t.count(t_uniq[i])

	u_list = []
	for i in range(len(s_uniq)):
		if s_uniq[i] in t_dict.keys():
			u_list.append(s_dict[s_uniq[i]] - t_dict[s_uniq[i]])
		else:
			u_list.append(s_dict[s_uniq[i]])
	if max(u_list) < 1:
		print(0)
	else:
		print(max(u_list))

if __name__ == '__main__':
    main()

Solution (Python):

from collections import Counter

def main():
    bCardNum = int(input())
    bCard = [input() for s in range(bCardNum)]
    
    rCardNum = int(input())
    rCard = [input() for s in range(rCardNum)]
    


    
    uniq_bCard = list(set(bCard))

    
    result = 0
    
    count_bCard = Counter(bCard)
    count_rCard = Counter(rCard)
    
    for string in uniq_bCard:
        tmp = count_bCard[string] - count_rCard[string]
        if(tmp > result):
            result = tmp
    
    print(result)
    
if __name__=="__main__":
    main()

Solution (Python):





if __name__ == '__main__':
    blue_card_count = int(input())
    blue_cards = list()

    for i in range(blue_card_count):
        blue_cards.append(input())

    red_card_count = int(input())
    red_cards = list()

    for i in range(red_card_count):
        red_cards.append(input())

    count_max = 0

    set_blue_card = set(blue_cards)

    for blue_card in set_blue_card:
        candidate = blue_cards.count(blue_card) - red_cards.count(blue_card)
        if candidate > count_max:
            count_max = candidate

    print(count_max)

Solution (Python):
from collections import Counter

n = int(raw_input())
li = list()
for i in range(0,n):
    li.append(raw_input())
count = Counter(li)
m = int(raw_input())
for i in range(0,m):
    s = raw_input()
    if count[s] != 0:
        count[s] -= 1
print count.most_common(1)[0][1]

Solution (Python):
def main():
    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 = []
    
    for i in s:
        ans.append( s.count(i) - t.count(i))
    
    ans = max(ans)
    if ans < 0:
        ans = 0
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):


N = int(input())
ao = {}
ao2 = []
memo = {}
for i in range(N):
    ao_t = input()
    ao2.append(ao_t)

M = int(input())
aka = {}
aka2 = []
for i in range(M):
    aka_t  = input()
    aka2.append(aka_t)


for i in ao2:
    try:
        ao[i] += 1
    except:
        ao[i] = 1

for i in aka2:
    try:
        aka[i] += 1
    except:
        aka[i] = 1




ans = 0
meno = 0

memo2 = {}

for k, v in ao.items():
    try:
        memo = aka[k]
        memo2[k] = v - memo
    except:
        memo2[k] = v

flag = 0
for k, v in sorted(memo2.items(), key=lambda x: -x[1]):
    if flag == 0:
        if v < 0:
            print(0)
        else:
            print(v)
    flag = 1

Solution (Python):


b = []
r = []


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

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


br = b + r
for i in range(len(br)):
    
    count_b = 0
    count_r = 0
    
    s = br[i]
    
    for j in range(len(b)):
        if (b[j] == s):
            count_b += 1
    
    for j in range(len(r)):
        if (r[j] == s):
            count_r += 1
    
    diff = count_b - count_r
    if (i == 0):
        X = diff
    elif (diff > X):
        X = diff
if (X < 0):
    X = 0

print(X)

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

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

count = {}
for s in blue:
    if s in count:
        count[s] += 1
    else:
        count[s] = 1
for t in red:
    if t in count:
        count[t] -= 1
    else:
        count[t] = -1

values = list(count.values())
keys = list(count.keys())
maxCount = max(values)
if maxCount > 0:
    print ( maxCount)
else:
    print (0)

Solution (Python):
def abc091_b():
    from collections import Counter
    _strs = []
    _strt = []
    _max = 0
    _n = int(input())
    for i in range(_n):
        _strs.append(str(input()))
    _m = int(input())
    for i in range(_m):
        _strt.append(str(input()))
    _strs2 = list(set(_strs))
    for element in _strs2:
        _score = Counter(_strs)[element] - Counter(_strt)[element]
        if _score > _max:
            _max = _score
    print(_max)


abc091_b()

Solution (Python):
import sys


def main():
    N = int(sys.stdin.readline())
    s = [x[:-1] if x[-1] == '\n' else x for x in [sys.stdin.readline()
                                                  for _ in range(N)]]
    M = int(sys.stdin.readline())
    t = [x[:-1] if x[-1] == '\n' else x for x in [sys.stdin.readline()
                                                  for _ in range(M)]]
    spam = [len([y for y in s if x == y]) -
            len([y for y in t if x == y]) for x in s]
    print(max(spam + [0]))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
Flag = 0
TmpNum = 0
Count = 0
Data = [[0 for i in range(2)]  for j in range(N)]

for i in range(N):
    TmpS = input()
    Num = i
    if Num == 0:
        Data[i][0] = TmpS
        Data[i][1] = 1
        Count += 1
    else:
        Flag = 0
        for i2 in range(Num):
            if TmpS == Data[i2][0]:
                Flag = 1
                TmpNum = i2
                break
        
        if Flag == 1:
            Data[TmpNum][1] += 1
        else:
            Data[Count][0] = TmpS
            Data[Count][1] = 1
            Count += 1

M = int(input())
for i in range(M):
    TmpS = input()
    for i2 in range(Count):
        if TmpS == Data[i2][0]:
            Data[i2][1] -= 1
            break

Data = sorted(Data, key=lambda x: x[1],  reverse=True) 

Ans = Data[0][1]
if Ans < 0:
    Ans = 0

print(Ans)

Solution (Python):
from collections import Counter

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

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

pointmax = 0

for a in s:
    ans = s[a] - t[a]
    if(ans > pointmax):
        pointmax = ans

print(pointmax)

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()))
    
from collections import Counter
import numpy as np
counter = Counter(s)
sw = []
sc = []
for word, cnt in counter.most_common():
    sw.append(word)
    sc.append(cnt)
counter2 = Counter(t)
tw = []
tc = []
for word, cnt in counter2.most_common():
    tw.append(word)
    tc.append(cnt)
    
sw = np.array(sw)
sc = np.array(sc)
tw = np.array(tw)
tc = np.array(tc)

anslist = []
for i in range(len(sw)):
    anslist.append(sc[i] - sum((sw[i] == tw)*tc))
ans = max(anslist)
if(ans < 0):
    print("0")
else:
    print(ans)

Solution (Python):
from collections import defaultdict

b = defaultdict(lambda :0)
r = defaultdict(lambda :0)

b[""] = 0

n = int(input())
for i in range(n):
    a = input()
    a.replace("\r","")
    b[a] += 1
m = int(input())
for i in range(m):
    a = input()
    a.replace("\r","")
    r[a] += 1
      
b_keys = list(b.keys())
r_keys = list(r.keys())
all_keys = list(set(b_keys).union(set(r_keys)))
pays = defaultdict(lambda :0)

for i in all_keys: 
    pays[i] = b[i] - r[i]

print(max(pays.values()))

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

M = int(input())
for i in range(M):
    t_i = input()
    if t_i not in point:
        continue
    else:
        point[t_i]-=1

ans = 0
for i in point.keys():
    ans = max(ans, point[i])

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

Solution (Python):
N = int(input())
b = []
for i in range(N):
    string = input()
    b.append(string)
r = []
M = int(input())
for i in range(M):
    r.append(input())

bd = {}
for a in b:
    if a not in bd:
        bd[a] = 0
    bd[a] += 1
rd = {}
for a in r:
    if a not in rd:
        rd[a] = 0
    rd[a] += 1

counter = []
keys = set(bd) | set(rd)
for key in keys:
    tmp = 0
    if key in bd:
        tmp += bd[key]
    if key in rd:
        tmp -= rd[key]
    counter.append(tmp)
foo = max(counter)
if foo > 0:
    print(foo)
else:
    print(0)

Solution (Python):
blue=[]
red=[]
point=0
point_blue=0
point_red=0

N=int(input())
for i in range(N):
    blue+=[input()]
M=int(input())
for i in range(M):
    red+=[input()]

for i in blue:
    point_blue=blue.count(i)
    point_red=red.count(i)
    if point_blue-point_red>point:
        point=point_blue-point_red

print(point)

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

max = 0
for b in blue:
    if max < blue.count(b) - red.count(b):
        max = blue.count(b) - red.count(b)
        
print(max)

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

s = Counter(S)
t = Counter(T)
for k1,v1 in s.items():
  for k2,v2 in t.items():
    if k1==k2:
      s[k1] -= v2
print(max(max(s.values()),0))

Solution (Python):


def main():
    N = int(input())
    s = [input() for i in range(N)]
    M = int(input())
    t = [input() for i in range(M)]
    max_point = 0

    for a in s:
        add_point = s.count(a)
        sub_point = t.count(a)
        max_point = max(add_point - sub_point,max_point)

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

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

d={}
for s in S:
    if s in d:
        d[s]+=1
    else:
        d[s]=1
for t in T:
    if t in d:
        d[t]-=1
ans=0
for i in d.values():
    if i>=0 and i>ans:
        ans=i
print(ans)

Solution (Python):


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

M = int(input())
t = []
for i in range(0,M):
    data = input()
    t.append(data)

st = s + t

plus  = []
minus = []
for i in st:
    p = 0
    m = 0
    for j in s:
        if i == j:
            p = p + 1
        else:
            pass
    for j in t:
        if i == j:
            m = m - 1
        else:
            pass
            
    plus.append(p)
    minus.append(m)

pmax=0
for i,j in zip(plus,minus):
    if 0 < (i + j) and pmax <(i + j):
        pmax = i + j
    else:
        pass

print(pmax)

Solution (Python):
n=int(input())
blue=[input() for i in range(n)]
m=int(input())
red=[input() for j in range(m)]
point=0
for word in blue:
    if blue.count(word)-red.count(word)>point:
        point=blue.count(word)-red.count(word)

print(point)

Solution (Python):
from collections import defaultdict

if __name__ == '__main__':
    N = int(input().strip())
    s = [input().strip() for _ in range(N)]
    M = int(input().strip())
    t = [input().strip() for _ in range(M)]

    d = defaultdict(int)
    d[""] = 0

    for word in s:
        d[word] += 1

    for word in t:
        d[word] -= 1

    max_key = None
    max_value = -1
    for (key, value) in d.items():
        if max_key is None:
            max_key = key
            max_value = value
            continue

        if max_value < value:
            max_key = key
            max_value = value

    print(max_value)

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

Solution (Python):
if __name__ == "__main__":
    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()))
    s_dict = {}
    for ele in s:
        if ele in s_dict.keys():
            s_dict[ele] += 1
        else:
            s_dict[ele] = 1
    t_dict = {}
    for ele in t:
        if ele in t_dict.keys():
            t_dict[ele] += 1
        else:
            t_dict[ele] = 1
    buf = list(set(s + t))
    max = 0
    for ele in buf:
        s_num = 0
        t_num = 0
        if ele in s_dict.keys():
            s_num = s_dict[ele]
        if ele in t_dict.keys():
            t_num = t_dict[ele]
        if (s_num - t_num) > max:
            max = s_num - t_num
    print(max)

Solution (Python):
N = int(input())
i = 0
jj = []
s = []
while i < N:
	s.append(input())
	i += 1
M = int(input())
j = 0
t = []
while j < M:
	t.append(input())
	j += 1
for ss in s:
	if ss in t:
		jj.append(s.count(ss)-t.count(ss))
	else:
		jj.append(s.count(ss))
balance = max(jj)
if balance < 0:
	balance = 0
print(balance)

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

m = int(input())
t = {}
for i in range(m):
    r = input()
    if r in t:
        t[r] += 1
    else:
        t[r] = 1

temp = 0
for b in s.keys():
    val = 0
    if b in t.keys():
        val = s[b] - t[b]
    else:
        val = s[b]
    if val > temp:
        temp = val

print(temp)

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

dct={}
for strings in s:
    dct.setdefault(strings,0)
    dct[strings]+=1
    
for strings in t:
    if strings in dct:
        dct[strings]-=1

if max(dct.values())>=1:
    print(max(dct.values()))
else:
    print("0")

Solution (Python):
from collections import defaultdict

d = defaultdict(lambda: 0)

def get_card(num, mode):
    for _ in range(num):
        w = input()
        if mode == 'blue':
            d[w] += 1
        elif mode == 'red':
            d[w] -= 1

            
if __name__ == '__main__':
    n = int(input())
    get_card(n, mode='blue')
    m = int(input())
    get_card(m, mode='red')
    ans = sorted(d.items(), key=lambda x: x[1], reverse=True)
    if ans[0][1] >= 0:
        print(ans[0][1])
    else:
        print(0)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s.sort()
s.append("unkounkounkounko")

m=int(input())
ss=[]
for i in range(m):
    ss.append(input())
ss.sort()
ss.append("unkounkounkounko")


s_number=[]
k=1
for i in range(n):
    if s[i]!=s[i+1]:
        s_number.append([s[i],k])
        k=1
    else:
        k+=1

ss_number=[]
k=1
for i in range(m):
    if ss[i]!=ss[i+1]:
        ss_number.append([ss[i],k])
        k=1
    else:
        k+=1

point=0
point_m=[]
for i in range(len(s_number)):
    point=s_number[i][1]
    for j in range(len(ss_number)):

        if s_number[i][0]==ss_number[j][0]:
            point=max(0, s_number[i][1]-ss_number[j][1])
    point_m.append(point)






print(max(point_m))

Solution (Python):
from collections import Counter

def max_earn(blue_cards, red_cards):
    blue_dict = Counter(blue_cards)
    red_dict = Counter(red_cards)
    maximum = 0
    for (k, v) in blue_dict.items():
        if k in red_dict:
            maximum = max(maximum, v - red_dict[k])
        else:
            maximum = max(maximum, v)
    return maximum


if __name__ == '__main__':
    blue_cards = [raw_input() for _ in xrange(int(raw_input()))]
    red_cards = [raw_input() for _ in xrange(int(raw_input()))]
    print max_earn(blue_cards, red_cards)

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

for j in range(int(input())):
    l = input()
    if l in dic:
        dic[l] -= 1

maximum = 0

for key in dic:
    if dic[key] > maximum:
        maximum = dic[key]
        
print(maximum)

Solution (Python):
n = int(raw_input())
blue = {}
red = {}

for a in range(n):
  q = raw_input()
  if q not in blue:
    blue[q] = 1
    red[q] = 0
  else:
    blue[q] += 1

m = int(raw_input())
for a in range(m):
  q = raw_input()
  if q not in red:
    red[q] = 1
    if q not in blue:
      blue[q] = 0
  else:
    red[q] += 1

ans = 0

for a in blue:
  if ans < (blue[a] - red[a]):
    ans = blue[a] - red[a]
print ans

Solution (Python):

from collections import Counter


N = int(input())
p = {}

for _ in range(N):
    s = input()
    if s not in p.keys():
        p[s] = 1
    else:
        p[s] += 1

M = int(input())

for _ in range(M):
    t = input()
    if t not in p.keys():
        p[t] = -1
    else:
        p[t] -= 1

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

Solution (Python):
N = int(input())
S_list = []
for _ in range(N):
    S_list.append(input())
M = int(input())
T_list = []
for _ in range(M):
    T_list.append(input())

dict_ = {0: 0}
for s in S_list:
    if s not in dict_.keys():
        dict_[s] = 1
    else:
        dict_[s] += 1
for t in T_list:
    if t not in dict_.keys():
        dict_[t] = -1
    else:
        dict_[t] -= 1

print(max(dict_.values()))

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

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    a=input()
    if a in d:
        d[a]+=1
    else:
        d[a]=1
m = int(input())
for i in range(m):
    a=input()
    if a in d:
        d[a]-=1
    else:
        d[a]=-1
m=max(d.values())
if m<0:
    m=0
print(m)

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

M=int(input())
t=['b']*M
for k in range(M):
	t[k] = input()

ans = 0
tmp = 0

for i in range(N):
	tmp = int(s.count(s[i]) - t.count(s[i]))
	if ans < tmp:
		ans = tmp

print(ans)

Solution (Python):
n = int(input())
cs = {}
for i in range(n):
    si = input()
    if si in cs:
        cs[si] += 1
    else:
        cs[si] = 1
m = int(input())
ct = {}
for i in range(m):
    ti = input()
    if ti in ct:
        ct[ti] += 1
    else:
        ct[ti] = 1

res = 0
su = 0
for si in cs:
    su = cs[si]
    if si in ct:
        su -= ct[si]
    res = max(su, res)

print(res)

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

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

ans = 0
targets = list(set(s))
for target in targets:
    ans = max(ans, s.count(target) - t.count(target))

print(ans)

Solution (Python):
B = int(input())
b = {}
for i in range(B):
    a = input()
    if a in b:
        b[a] += 1
    else:
        b[a] = 1

R = int(input())
for i in range(R):
    a = input()
    if a in b:
        b[a] -= 1
    else:
        b[a] = -1
ans = max(b.values())
if max(b.values()) < 0:
    ans = 0

print(ans)

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

m = int(input())
array_t = []
for i in range(m):
    array_t.append(input())

sums = {}
for s in array_s:
    if not s in sums:
        sums[s] = 1
    else:
        sums[s] += 1

for t in array_t:
    if t in sums:
        sums[t] -= 1

max_x = 0
for key in sums.keys():
    if max_x < sums[key]:
        max_x = sums[key]

print(max_x)

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

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

print(ans)

Solution (Python):
n = int(input())
bdict = {}
rdict = {}
for i in range(0, n):
    line = input()
    if not (line in bdict):
        bdict[line] = 0
    bdict[line] += 1
m = int(input())
for i in range(0, m):
    line = input()
    if not (line in rdict):
        rdict[line] = 0
    rdict[line] += 1
ans = 0
temp = 0
for i in bdict.items():
    temp = i[1]
    if i[0] in rdict:
        temp -= rdict[i[0]]
    if temp > ans:
        ans = temp
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())
s_set = list(set(s))
max_s = 0
for i in range(len(s_set)):
    sum_s = 0
    for j in range(N):
        if s_set[i] == s[j]:
            sum_s += 1
    for j in range(M):
        if s_set[i] == t[j]:
            sum_s -= 1
    max_s = max(max_s, sum_s)

print(max_s)

Solution (Python):

num = int(input())

score = {}
for i in range(num):
    val = input()
    if val in score.keys():
        score[val] += 1
    else:
        score[val] = 1

num = int(input())
for i in range(num):
    val = input()
    if val in score.keys():
        score[val] -= 1

max_val = 0
for result in score.values():
    if max_val < result:
        max_val = result

print(max_val)

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

count = [0,]
for s_i in s:
   k = 0
   for i in range(N):
      if s_i == s[i]:
         k += 1
   for i in range(M):
      if s_i == t[i]:
         k -= 1
   count.append(k)


print(max(count))

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

for i in blue:
  bc  = blue.count(i)
  rc = red.count(i)
  if bc-rc>maxyen:
    maxyen = bc-rc
 
print(maxyen)

Solution (Python):
data = {}

n = int(input())
for i in range(n):
    string = input()
    if string in data.keys():
        data[string] += 1
    else:
        data[string] = 1

m = int(input())
for i in range(m):
    string = input()
    if string in data.keys():
        data[string] -= 1
    else:
        data[string] = -1

print(max(0, max(data.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())

point_list = []
for i in range(n):
    point = 0
    for j in range(n):
        if s[i] == s[j]:
            point = point + 1
    for k in range(m):
        if s[i] == t[k]:
            point = point - 1
    point_list.append(point)
print(max(0, max(point_list)))

Solution (Python):
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    dic = {}
    for i in range(N):
        input_raw = read_func().strip().split()
        if input_raw[0] in dic:
            dic[input_raw[0]] += 1
        else:
            dic[input_raw[0]] = 1
    input_raw = read_func().strip().split()
    [M] = [int(input_raw[0])]
    for i in range(M):
        input_raw = read_func().strip().split()
        if input_raw[0] in dic:
            dic[input_raw[0]] -= 1

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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
lis = []
li = []
ans = 0
for i in range(n):lis.append(str(input()))
m = int(input())
for i in range(m):li.append(str(input()))
for i in range(n):
    cou = lis.count(lis[i])-li.count(lis[i])
    ans = max(ans,cou)
print(ans)

Solution (Python):
n = int(input())
word_dic = {}
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
        if word_dic[word] < 1:
            word_dic.pop(word)

if len(list(word_dic.keys())) == 0:
    print(0)
else:
    word_dic = sorted(word_dic.items(), key=lambda x: x[1])
    print(word_dic[-1][1])

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

cs=Counter(s)
ct=Counter(t)

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

print ans

Solution (Python):
rcards = dict()
bcards = dict()
N = int(input())
for i in range(0, N):
    s = input()
    if s not in bcards.keys():
        bcards[s] = 0
    bcards[s] += 1
M = int(input())
for i in range(0, M):
    s = input()
    if s not in rcards.keys():
        rcards[s] = 0
    rcards[s] += 1
ans = int()
for s in bcards.keys():
    tmp = bcards[s]
    if s in rcards.keys():
        tmp -= rcards[s]
    if ans < tmp:
        ans = tmp
print(ans)

Solution (Python):
from collections import Counter


def main():
    """
    blue: a, a, d
    red:  a, b, c

    a: 2-1= 1
    b,c: 0-1=-1
    d: 1-0=1
    """
    N = int(input())
    S = [input() for _ in range(N)]
    M = int(input())
    T = [input() for _ in range(M)]

    b = Counter(S)
    r = Counter(T)
    b_r = b - r

    ans = 0
    for word, count in b_r.most_common():
        ans = max(ans, count)
        break

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
words = {}

N = int(input())
for i in range(N):
    s = input()
    point = words.get(s, 0)
    words[s] = point+1

M = int(input())
for i in range(M):
    s = input()
    point = words.get(s, 0)
    words[s] = point-1

result = max(words.items(), key=lambda x:x[1])[1]
if result < 0:
    print(0)
else:
    print(result)

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

Set=set(S)

a=0
A=[0]
for i in Set:
    a=0
    if i in S:
        a+=S.count(i)
    if i in T:
        a-=T.count(i)
    A.append(a)

print(max(A))

Solution (Python):

N = int(input())
dict_res = {}
for i in range(N):
    char = input()
    if not char in dict_res:
        dict_res[char] = 1
    else:
        dict_res[char] += 1
M = int(input())
for i in range(M):
    char = input()
    if not char in dict_res:
        dict_res[char] = -1
    else:
        dict_res[char] -= 1
res = max(dict_res.values())
if res < 0:
    print(0)
else:
    print(res)

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

Solution (Python):
n=int(input())
sslis=[]
snumlis=[]
for i in range(n):
    s=input()
    if s in sslis:
        snumlis[sslis.index(s)]+=1
    else:
        sslis.append(s)
        snumlis.append(1)
m=int(input())
tslis=[]
tnumlis=[]
for i in range(m):
    s=input()
    if s in tslis:
        tnumlis[tslis.index(s)]+=1
    else:
        tslis.append(s)
        tnumlis.append(1)
b=0
for i in range(len(sslis)):
    a=0
    if sslis[i] in tslis:
        a=snumlis[i]-tnumlis[tslis.index(sslis[i])]
    else:
        a=snumlis[i]
    b=max(a,b)
print(b)

Solution (Python):
N = int(input())
s_list = []
for i in range(N):
    p = input()
    s_list.append(p)
M = int(input())
t_list = []
for i in range(M):
    p2 = input()
    t_list.append(p2)
s_count_list = [0 for i in range(N)]

for i in range(N):
    name = s_list[i]
    count = 0
    
    for k in range(N):
        if s_list[k] == name:
            count += 1
    for t in range(M):
        if t_list[t] == name:
            count -= 1
    s_count_list[i] = count
max_c = max(s_count_list)
if max_c < 0:
    max_c = 0
print(max_c)