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

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

s2=s[:]
set(s2)
ans=0
for i in s2:
    if ans<s.count(i)-t.count(i):
        ans=s.count(i)-t.count(i)
print(ans)

Solution (Python):
n = int(raw_input())
blue={}
for x in range(0, n):
  tmp=raw_input()
  if(tmp in blue):
	blue[tmp]+=1
  else:
    blue[tmp]=1

m = int(raw_input())
for x in range(m):
  tmp=raw_input()
  if(tmp in blue):
	blue[tmp]-=1
  else:
    blue[tmp]=-1

max=0
for key, val in blue.items():
  if(max<val):
    max=val

print max

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

x = 0
a = 0

for str in s:
    x = s.count(str) - t.count(str)
    if x > a:
        a = x

print(a)

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

a=[]
for i in range(n):
    a.append(s.count(s[i])-t.count(s[i]))

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

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

S=input()

ans=[]
tmp=[1,S]
ans.append(tmp)
count=1

for i in range(1,N):
    S=input()
    for j in range(count):
        if ans[j][1]==S:
            ans[j][0]+=1
            break
    else:
        tmp=[1,S]
        ans.append(tmp)
        count+=1

M=int(input())

for i in range(M):
    S=input()
    for j in range(count):
        if ans[j][1]==S:
            ans[j][0]-=1
            break

ans.sort()
ans.reverse()

if ans[0][0]<0:
    print(0)
else:
    print(ans[0][0])

Solution (Python):
from collections import Counter
 
n = int(input())
ss = Counter(input() for _ in range(n))
m = int(input())
ts = Counter(input() for _ in range(m))
answer = max(cs - ts[s] for s, cs in ss.items())
print(answer if answer > 0 else 0)

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

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

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

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


    cand = list(set(s))
    g = [s.count(c) - t.count(c) for c in cand]
    ans = max(g)
    if ans < 0:
        print(0)
    else:
        print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
import collections

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

cnt = collections.Counter()
for d in s:
    cnt[d] += 1
for d in t:
    cnt[d] += -1

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

Solution (Python):
N = int(input())
s_n = []
for i in range(N):
    s_n.append(input())
M = int(input())
for j in range(M):
    youso = input()
    if youso in s_n:
        s_n.remove(youso)
max_point = 0
for k in range(len(s_n)):
    max_point = [s_n.count(s_n[k]),max_point][s_n.count(s_n[k])<max_point]
print(max_point)

Solution (Python):
N = int(input())
s_list = [input() for i in range(N)]
M = int(input())
t_list = [input() for i in range(M)]
X = 0
for i in range(N):
	if s_list.count(s_list[i]) - t_list.count(s_list[i]) >= X:
		X = s_list.count(s_list[i]) - t_list.count(s_list[i])
print(X)

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

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

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

Solution (Python):
N = int(input())
S = list()
for _ in range(N):
    S.append(input())
M = int(input())
T = list()
for _ in range(M):
    T.append(input())

all_words = set(S+T) 
scores = [S.count(w) - T.count(w) for w in all_words]
print(max(0,max(scores)))

Solution (Python):
from collections import Counter

N=int(raw_input())
s=[raw_input() for j in xrange(N)]
st1 = Counter(s)

M=int(raw_input())
t=[raw_input() for j in xrange(M)]
st2 = Counter(t)

best = 0
for k,v in st1.items():
  score = v - st2[k]
  best = max(best, score)
print best

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())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
max_X = 0
count_X = [s.count(i) - t.count(i) for i in s]
max_X = max(count_X)
if max_X < 0:
	print(0)
else:
	print(max_X)

Solution (Python):
N = int(input())
s = []
ans_dict = {}
for i in range(N):
    s.append(input())
M = int(input())
t = []
for i in range(M):
    t.append(input())
for s_i in s:
    if s_i in ans_dict.keys():
        ans_dict[s_i] += 1
    else:
        ans_dict[s_i] = 1
for t_i in t:
    if t_i in ans_dict.keys():
        ans_dict[t_i] -= 1
    else:
        ans_dict[t_i] = 1

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

Solution (Python):
from collections import Counter

n = int(input())
ss = Counter(input() for _ in range(n))
m = int(input())
ts = Counter(input() for _ in range(m))
print(max(max(0, cs - ts[s]) for s, cs in ss.items()))

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

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

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

anslist = sorted(dictionary.items(), key = lambda x: -x[1])
ans = anslist[0][1]
if ans < 0: ans = 0
print(ans)

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()
  
score=0

for i in range(N):
  count=0
  for j in range(N):
    if S[i]==S[j]:
      count+=1
  for k in range(M):
    if S[i]==T[k]:
      count-=1
  if count>score:
    score=count
    
print(score)

Solution (Python):
d={}
for _ in [0]*int(input()):
    s=input()
    d[s]=d.get(s,0)+1
for _ in [0]*int(input()):
    s=input()
    d[s]=d.get(s,0)-1
print(max(sorted(d.items(), key=lambda x: x[1])[-1][1],0))

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

money = [0]

for i in S:
  cc = S.count(i)-T.count(i)
  money.append(cc)

print(max(money))

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

ans = 0
u = set(s + t)
for k in u:
    cnt1 = 0
    for l in s:
        if l == k:
            cnt1 += 1
    cnt2 = 0
    for m in t:
        if m == k:
            cnt2 -= 1
    if cnt1 + cnt2 >= ans:
        ans = cnt1 + cnt2

print(ans)

Solution (Python):
N = int(input())
red = list([input() for _ in range(N)])

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

redwords = set(red)

maxyen = 0
for word in redwords:
    red_count = red.count(word)
    blue_count = blue.count(word)
    if red_count - blue_count > maxyen:
        maxyen = red_count - blue_count

print(maxyen)

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

a = [s.count(i) - t.count(i) for i in s]
b = max(a)
if b < 0:
    print(0)
else:
    print(b)

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

T=[]
M = int(input())
for j in range(0,M):
	t = str(input())
	T.append(t)

S_uniq = list(set(S))

num = []
for p in S_uniq:
	s_count = S.count(p)
	t_count = T.count(p)
	counts = s_count - t_count
	num.append(counts)

num.sort()
num.reverse()
if(num[0] < 0):
	print("0")
else:
	print(num[0])

Solution (Python):
N=int(input())
blue=[]
red=[]
ans=0

target=""

for i in range(N):
    blue.append(input())
M=int(input())
for j in range(M):
    red.append(input())

for k in range(N):
    target=""
    target=blue[k]
    count=0
    for i in range(N):
        
        if target==blue[i]:
            count+=1
    for j in range(M):
        if target==red[j]:
            count-=1
    if count>ans:
        ans=count
        
print(ans)

Solution (Python):
n = int(input())
s = [input() for x in range(n)]
m = int(input())
t = [input() for x in range(m)]
ans = 0
for i in range(n):
	counter = 0
	for u in range(n):
		if s[i] == s[u]:
			counter += 1
	for x in range(m):
		if s[i] == t[x]:
			counter -= 1
	if ans <= counter:
		ans = counter
print(ans)

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

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

count_max = 0
for i in range(N):
    count = s.count(s[i]) - t.count(s[i])
    if count > count_max:
         count_max = count
            
print(count_max)

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

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

count_max = 0
for i in range(N):
    count = s.count(s[i]) - t.count(s[i])
    if count > count_max:
         count_max = count
            
print(count_max)

Solution (Python):
d={'':0}
for _ in[0]*int(input()):e=input();d[e]=d.get(e,0)+1
for _ in[0]*int(input()):e=input();d[e]=d.get(e,0)-1
print(max(d.values()))

Solution (Python):
d={'':0}
for _ in[0]*int(input()):e=input();d[e]=d.get(e,0)+1
for _ in[0]*int(input()):e=input();d[e]=d.get(e,0)-1

print(max(d.values()))

Solution (Python):
d={}
for _ in[0]*int(input()):e=input();d[e]=d.get(e,0)+1
for _ in[0]*int(input()):e=input();d[e]=d.get(e,0)-1
print(max(d[max(d,key=lambda x:d[x])],0))

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

for i in range(n):
    x.append(s.count(s[i]) - t.count(s[i]))
    
x

if max(x)>=0:
    print('{}'.format(max(x)))
else:
    print('0')

Solution (Python):
n = int(input())
words = ['']
nums = [0]
while n > 0:
    w = input()
    if w not in words:
        words.append(w)
        nums.append(1)
    else:
        index = words.index(w)
        nums[index] += 1
    n -= 1
m = int(input())
while m > 0:
    wb = input()
    if wb in words:
        index = words.index(wb)
        nums[index] -= 1
    m -= 1
print(max(nums))

Solution (Python):
n = int(input())
s = []
for i in range(n):
    s.append(input())
m = int(input())
t = []
for i in range(m):
    t.append(input())
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
s_t = s + t
s_t_unique = get_unique_list(s_t)
results = []
for i in range(len(s_t_unique)):
    s_count = s.count(s_t_unique[i])
    t_count = t.count(s_t_unique[i])
    result = s_count - t_count
    results.append(result)
if max(results) >= 0:
    print(max(results))
else: 
    print(0)

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

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

M = int(input())
T_count = dict()

for _ in range(M):
    tmp = input()
    if tmp not in T_count:
        T_count[tmp] = 1
    else:
        T_count[tmp] += 1

max_v = 0

for e in S_count:
    t = 0 if e not in T_count else T_count[e]

    if S_count[e] - t > max_v:
        max_v = S_count[e] - t

print(max_v)

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

red = []
blue = []

for i in range(N):
    red.append(input())

M = int(input())

for j in range(M):
    blue.append(input())
    

words = []
for i in range(N):
    if(red[i] not in words):
        words.append(red[i])

for j in range(M):
    if(blue[j] not in words):
        words.append(blue[j])

maximum = 0
for i in range(len(words)):
    money = red.count(words[i])-blue.count(words[i])
    maximum = max(money,maximum)

if maximum<=0:
    print(0)
else:
    print(maximum)

Solution (Python):
from collections import defaultdict

dict=defaultdict(int)

N=int(input())
for i in range(N):
  s=input()
  dict[s]+=1

M=int(input())
for i in range(M):
  s=input()
  dict[s]-=1

ans=0
for a,b in dict.items():
  ans=max(ans,b)
print(ans)

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

Sw = list(set(S))
Tw = list(set(T))

mm = 0
for i in Sw:
    tmp = S.count(i) - T.count(i)
    if mm < tmp:
        mm = tmp

for i in Tw:
    tmp = S.count(i) - T.count(i)
    if mm < tmp:
        mm = tmp

print(mm)

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

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

set_blue = set(list_blue)
set_red = set(list_red)
set_union = set_blue | set_red

list_count = [0 for i in range(len(set_union))]
k = 0

for str in set_union:
    for i in range(N):
        if list_blue[i] == str:
            list_count[k] += 1
    for j in range(M):
        if list_red[j] == str:
            list_count[k] -= 1
    k += 1

n_max = max(list_count)

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

Solution (Python):
from itertools import groupby

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

def main():
    for t in T:
        if t in S:
            S.remove(t)
    S.sort() 
    ans = [len(list(g)) for key, g in groupby(S)]
    print(max([0] + ans))

if __name__ == "__main__":
    main()

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

max_gain = 0
for i in range(N):
    blue = len([s[j] for j in range(N) if s[j] == s[i]])
    red = len([t[j] for j in range(M) if t[j] == s[i]])
    max_gain = max(max_gain, blue - red)

print(max_gain)

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

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

Solution (Python):
from sys import stdin

num_blue = stdin.readline().rstrip()
word_blue = []

for i in range(int(num_blue)) :
    word_blue.append(stdin.readline().rstrip())


num_red = stdin.readline().rstrip()
word_red = []

for i in range(int(num_red)) :
    word_red.append(stdin.readline().rstrip())

counter_max = 0

for i in range(int(num_blue)):
   counter = word_blue.count(word_blue[i]) - word_red.count(word_blue[i])
   if counter > counter_max:
       counter_max = counter
   
print(counter_max)

Solution (Python):
n = int(input())
blue = {}
i = 0
while i < n:
    temp = input()
    if temp in blue:
        blue[temp] += 1
    else:
        blue[temp] = 1
    i += 1


m = int(input())
red = {}
i = 0
while i < m:
    temp = input()
    if temp in red:
        red[temp] += 1
    else:
        red[temp] = 1
    i += 1


max_score = 0
score = 0
for key in blue.keys():
    if key not in red:
        score = blue[key]
    else:
        score = blue[key] - red[key]
    max_score = max(max_score, score)
    
if max_score < 0:
    print(0)
else:
    print(max_score)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = 0
for u in set(S):
    tmp = S.count(u) - T.count(u)
    if ans < tmp:
        ans = tmp
print(ans)

Solution (Python):
from collections import defaultdict
dd = defaultdict(int)
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):
    dd[S[i]] += 1
for i in range(M):
    dd[T[i]] += -1
ans = max(dd.values())
print(max(0,ans))

Solution (Python):

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

Solution (Python):
from collections import Counter

n = int(input())
l = []
for i in range(n):
    l.append(input())
n = int(input())
l2 = []
for i in range(n):
    l2.append(input())
l = Counter(l)
l2 = Counter(l2)
m = [0]
for i in l.keys():
    try:
        m.append(l[i] - l2[i])
    except:
        pass
print(max(m))

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

M = int(input())
T = []
for _ in range(M):
    T.append(input())
    
word = set(S+T)

value = [0]
for w in word:
    value.append(S.count(w)-T.count(w))
    
print(max(value))

Solution (Python):
def main():
    n = int(input())
    
    d = {'xxxxxxxx': 0}
    for i in range(0, n):
        s = input().strip()
        if s in d.keys():
            d[s] += 1
        else:
            d[s] = 1
    
    m = int(input())
    
    for i in range(0, m):
        s = input().strip()
        if s in d.keys():
            d[s] -= 1
        else:
            d[s] = -1

    print(max(d.values()) )

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter 
n=int(input())
ap=[input() for i in range(n)]
cp=Counter(ap)
m=int(input())
am=[input() for i in range(m)]
cm=Counter(am)
ans=0
for i in cp:
  ans=max(ans,cp[i]-cm[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())
cnt,ans=0,0
for i in range(n):
    temp=s[i]
    for j in range(n):
        if temp==s[j]:
            cnt+=1
    for j in range(m):
        if temp == t[j]:
            cnt-=1
    ans = max(ans,cnt)
    cnt=0
print(ans)

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

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

ans = []
for i in li:
    ans.append(max(0,li.count(i) - li2.count(i)))

print(max(ans))

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

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

Solution (Python):
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
M = int(input())
for i in range(M):
  s = input()
  if s in d:
    d[s] -= 1
  else:
    d[s] = -1
l = []
for thisKey in d:
  l.append(d[thisKey])
if max(l) >= 0:
  print(max(l))
else:
  print(0)

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

max = 0
for i in range(n):
    count = 0
    if blue_card[i] in red_card:
        count = blue_card.count(blue_card[i]) - red_card.count(blue_card[i]) 
    else:
        count = blue_card.count(blue_card[i])
    if count >= max:
        max = count
    
print(max)

Solution (Python):
from collections import Counter
n = int(raw_input())
a = [raw_input() for _ in range(n)]
c = Counter(a)
m = int(raw_input())
b = [raw_input() for _ in range(m)]
d = Counter(b)
i = 0
for k,ct in c.items():
    j = ct - d[k]
    i = max(i,j)
print i

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

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


max_s = 0
max_t = 0
get = 0

for word in s:
    max_s = s.count(word)
    max_t = t.count(word)
    if(get < max_s - max_t):
        get = max_s - max_t

print(get)

Solution (Python):
n = int(input())
s = list()
counter = 0

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

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

for word in s:
    counter = max(counter,s.count(word) -t.count(word))
print(counter)

Solution (Python):
n = int(input())
s = list()
counter = 0

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

for i in range(m):
    t.append(input())
    
for word in s:
    counter = max(counter,s.count(word) - t.count(word))
    
print(counter)

Solution (Python):



blue_count = int(input())
blue_list = []
for i in range(blue_count):
	blue_list.append(input())

red_count = int(input())
red_list = []
for i in range(red_count):
	red_list.append(input())


all_words = []

all_words.extend(blue_list)
all_words.extend(red_list)

all_words = list(set(all_words))


word_dict = {}
for word in all_words:
	word_dict[word] = 0

for word in blue_list:
	word_dict[word] += 1

for word in red_list:
	word_dict[word] -= 1

result_list = []
for key, value in word_dict.items():
	result_list.append(value)

result = max(result_list)

if result <= 0:
	ans = 0
else:
	ans = result

print(ans)

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

sum_max = 0
for i in range(n):
    sum_tmp = 0
    for j in range(n):
        if s[i] == s[j]:
            sum_tmp += 1
    for j in range(m):
        if s[i] == t[j]:
            sum_tmp -= 1
    if sum_tmp > sum_max:
        sum_max = 0
        sum_max += sum_tmp
print(sum_max)

Solution (Python):
D={"":0}
for i in range(input()):
  k=raw_input()
  D[k]=D.setdefault(k,0)+1
for i in range(input()):
  k=raw_input()
  D[k]=D.setdefault(k,0)-1
print max(D.values())

Solution (Python):
D = {}
for i in range(input()):
    k = raw_input()
    if not k in D:
        D[k] = 0
    D[k] += 1
for i in range(input()):
    k = raw_input()
    if not k in D:
        D[k] = 0
    D[k] -= 1
print max(0, max(D.values()))

Solution (Python):
ps = dict()
ss = []
n = int(input())
for _ in range(n):
    s = input()
    ss.append(s)
    if s in ps:
        ps[s] += 1
    else:
        ps[s] = 1
ts = []
m = int(input())
for _ in range(m):
    s = input()
    ts.append(s)
    if s in ps:
        ps[s] -= 1
    else:
        ps[s] = 1
ans = max(0, max(ps.values()))
print(ans)

Solution (Python):
N=int(input())
s={}
for i in range(N):
    ss=input().strip()
    if ss in s:
        s[ss]+=1
    else:
        s[ss]=1
M=int(input())
for i in range(M):
    ss=input().strip()
    if ss in s:
        s[ss]-=1
    else:
        s[ss]=-1
print(max(max(s.values()),0))

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

import collections
sc_tc = []
for i in s:
    if s.count(i) - t.count(i)> 0:
        sctc = s.count(i) - t.count(i)
    else:
        sctc = 0
    sc_tc.append(sctc)

print(max(sc_tc))

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

words = []

blue_cards = {}
for i in range(N):
  s = input()
  if s in blue_cards:
    blue_cards[s] = blue_cards[s] + 1
  else:
    blue_cards[s] = 1
  if s not in words:
    words.append(s)

M = int(input())

red_cards= {}
for i in range(M):
  s = input()
  if s in red_cards:
    red_cards[s] = red_cards[s] + 1
  else:
    red_cards[s] = 1
  if s not in words:
    words.append(s)

max_money = 0
for word in words:
  get_money, lose_money = 0, 0
  if word in blue_cards:
    get_money = blue_cards[word]
  if word in red_cards:
    lose_money = red_cards[word]
  max_money = max(max_money, get_money - lose_money)

print(max_money)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
num = {i:s.count(i) for i in set(s)}
out = [v-max(0,t.count(k)) for k, v in num.items()]
print(max(max(out),0))

Solution (Python):
from collections import Counter
n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
ts = [input() for _ in range(m)]

c0 = Counter(ss) - Counter(ts)
if c0:
    word, count = c0.most_common(1)[0]
    print(count)
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)]
print(max([0] + [blue.count(s) - red.count(s) for s in set(blue)]))

Solution (Python):
ps = dict()
ss = []
n = int(input())
for _ in range(n):
    s = input()
    ss.append(s)
    if s in ps:
        ps[s] += 1
    else:
        ps[s] = 1
ts = []
m = int(input())
for _ in range(m):
    s = input()
    ts.append(s)
    if s in ps:
        ps[s] -= 1
    else:
        ps[s] = 1
ans = max(0, max(ps.values()))
print(ans)

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

a = list(set(s))

ans = 0
for i in range(len(a)):
    count = 0
    for j in range(n):
        if s[j] == a[i]:
            count += 1
    for j in range(m):
        if t[j] == a[i]:
            count -= 1
    if count > ans:
        ans = count
print(ans)

Solution (Python):
from collections import defaultdict

S = defaultdict(int)

N=int(input())
for i in range(N):S[input()] += 1
N=int(input())
for i in range(N):S[input()] -= 1
    
ans = max(S.values())
if ans<0:ans=0
print(ans)

Solution (Python):
def makeDictionary(in_item, out_item):
    for item in in_item:
        if item in out_item.keys():
            out_item[item] += 1
        else:
            out_item[item] = 1

sResult = {}
tResult = {}

N = int(input())
s = makeDictionary([input() for i in range(N)], sResult)
M = int(input())
t = makeDictionary([input() for i in range(M)], tResult)

for item in tResult.keys():
    if item in sResult:
        sResult[item] -= tResult[item]

result = max(sResult.values())

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

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
pay=0
for si in s:
    aa=list(filter(lambda x: x==si, s))
    dd=list(filter(lambda x: x==si, t))
    tmp=len(aa)-len(dd)
    pay = tmp if pay<tmp else pay
print(pay)

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

s1 = list(set(s))
a = [0 for i in range(101)]
for i in range (len(s1)):
    for j in range (N):
        if s1[i] == s[j]:
            a[i]+=1
for i in range (len(s1)):
    for j in range (M):
        if s1[i] == t[j]:
            a[i]-=1
print(max(a))

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):
    ans_s=s.count(s[i])
    ans_t=t.count(s[i])
    if ans<ans_s-ans_t:
        ans=ans_s-ans_t

print(ans)

Solution (Python):
dic1 = {}
dic2 = {}
n = int(input())
for i in range(n):
    line = input()
    if line not in dic1:
        dic1[line] = 1
    else:
        dic1[line] += 1
m = int(input())
for i in range(m):
    line = input()
    if line not in dic2:
        dic2[line] = 1
    else:
        dic2[line] += 1
key1 = list(dic1.keys())
ls = [0]*len(dic1)
for i in range(len(dic1)):
    if key1[i] in dic2:
        ls[i] = dic1[key1[i]]-dic2[key1[i]]
    else:
        ls[i] = dic1[key1[i]]
print(max(ls) if max(ls)>0 else 0)

Solution (Python):
from collections import Counter
c = Counter([input() for i in range(int(input()))])
c -= Counter([input() for i in range(int(input()))])
print(c.most_common()[0][1] if c else 0)

Solution (Python):
from collections import Counter

N = int(input())
blue_list = [input() for _ in range(N)]
blue = Counter(blue_list)

M = int(input())
red_list = [input() for _ in range(M)]
red = Counter(red_list)

blue.subtract(red)
c = blue.most_common(1)[0][1]
if c < 0:
    print(0)
else:
    print(c)

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
cnt = 0
for i in s:
    if cnt < s.count(i)-t.count(i):
        cnt = s.count(i)-t.count(i)
print(cnt)

Solution (Python):
import collections

bluecard = []
redcard = []

n = int(input())
for i in range(n):
    bluecard.append(input())

m = int(input())
for i in range(m):
    redcard.append(input())

blue_count = collections.Counter(bluecard)
red_count = collections.Counter(redcard)
diff = blue_count - red_count
if len(diff.keys()) > 0:
    print(diff.most_common(1)[0][1])
else:
    print(0)

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

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

ans = 0
for key, value in s.items():
    ans = max(value - t.get(key, 0), ans)

print(ans)

Solution (Python):
n = int(input())
word_list = {}

for i in range(n):
    s = input()
    if s not in word_list :
        word_list[s] = 1
    else:
        word_list[s] += 1

m = int(input())

for j in range(m):
    s = input()
    if s not in word_list:
        word_list[s] = -1
    else:
        word_list[s] -= 1
if max(word_list.values()) < 0:
    print(0)
else:
    print(max(word_list.values()))