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



Sample input:
3
apple
orange
apple
1
grape


Sample output:
2

Submission status: Accepted

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

S_set = {s:0 for s in S}
T_set = {t:0 for t in T}
for s in S:
  S_set[s] += 1
for t in T:
  T_set[t] += 1

  
ans = 0
for s in S_set.keys():
  if s in T_set.keys():
    pool = S_set[s] - T_set[s]
  else:
    pool = S_set[s]
  if pool > ans:
    ans = pool
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
red_counts = {}
for i in range(N):
    r = input()
    if r in red_counts:
        red_counts[r] += 1
    else:
        red_counts[r] = 1
M = int(input())
blue_counts = {}
for i in range(M):
    b = input()
    if b in blue_counts:
        blue_counts[b] += 1
    else:
        blue_counts[b] = 1
        
ans = 0
for k in red_counts.keys():
    if k in blue_counts:
        ans = max(ans, red_counts[k] - blue_counts[k])
    else:
        ans = max(ans, red_counts[k])
print(ans)

Submission status: Accepted

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

result = {}
for word in set(s):
  result[word] = s.count(word)
    
M = int(input())
for _ in range(M):
  w = input()
  if w in set(s):
    result[w]-=1

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

Submission status: Accepted

Solution code:
blue = []
red = []
n = int(input())
for i in range(n):
    blue.append(input())

m = int(input())
for j in range(m):
    red.append(input())

ans = 0
red_set = set(red)
blue_set = set(blue)
for b in blue_set:
 for r in red_set:
     ans = max(ans,blue.count(b)-red.count(b))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    s = list(input() for _ in range(n))
    m = int(input())
    t = list(input() for _ in range(m))
    words = set(s)
    ans = []
    for w in words:
        ans.append(s.count(w) - t.count(w))
    print(max(ans) if max(ans) > 0 else 0)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = list(input() for i in range(N))
M = int(input())
t = list(input() for i in range(M))

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

print(ans)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s = dict(collections.Counter(s).most_common())
t = dict(collections.Counter(t).most_common())
m_cnt = 0
for k, v in s.items():
    if k in t:
        if v > t[k]:
            if m_cnt < v - t[k]:
                m_cnt = v - t[k]
    else:
        if m_cnt < v:
            m_cnt = v
print(m_cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
dic={}
for _ in range(n):
  r=input()
  if r in dic:
    dic[r]+=1
  else:
    dic[r]=1

n=int(input())
for _ in range(n):
  r=input()
  if r in dic:
    dic[r]-=1
  else:
    dic[r]=-1

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

Submission status: Accepted

Solution code:

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

s_set = set(s)

ans = 0
for card in s_set:
    count = s.count(card) - t.count(card)
    ans = max(count, ans)

print(ans)

Submission status: Accepted

Solution code:
import collections

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

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

col = collections.Counter(s)

c = col.most_common()

ansl = []
for i in range(len(c)):
	ss = s.count(c[i][0])
	tt = t.count(c[i][0])
	ansl.append(ss - tt)
	
	
if max(ansl) < 0:
	ans = 0
else:
	ans = max(ansl)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
st = list(set(s+t))
cnt = []

for i in range(len(st)):
  cnt.append(0)

for i in range(len(st)):
  cnt[i] = s.count(st[i]) - t.count(st[i])

if max(cnt)>= 0 :
  print(max(cnt))
else:
  print(0)

Submission status: Accepted

Solution code:
nlst = [input() for _ in range(int(input()))]
mlst = [input() for _ in range(int(input()))]
point = max([nlst.count(i) - mlst.count(i) for i in set(nlst)])
print(point if point >= 0 else 0)

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
ss=tuple(s)
ans=0
for si in ss:
  ans=max(ans,s.count(si)-t.count(si))
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
s = []
t = []

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

M = int(input())

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

a = Counter(s)
b = Counter(t)

maxvalu = 0

for k,v in a.items():
    ans = a[k]
    if k in b:
        ans -= b[k]
    maxvalu = max(maxvalu,ans)

print(maxvalu)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    d = dict()
    for _ in range(N):
        s = input()
        d[s] = d.get(s, 0) + 1
    M = int(input())
    for _ in range(M):
        t = input()
        d[t] = d.get(t, 0) - 1

    max_v = 0
    for t in d:
        max_v = max(max_v, d[t])
    return max_v

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

Submission status: Accepted

Solution code:
n=int(input())
s=([(input() )for _ in range(n)])
m=int(input())
t=([(input()) for _ in range(m)])
#print(s,t)
a=0
max=0
for i in set(s):
    a=(s.count(i)-t.count(i))
    if a>max:
        max=a
print(max)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)

Submission status: Accepted

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

uniq=list(set(ss+ts))

cost=[]
for u in uniq:
  cost.append(ss.count(u)-ts.count(u))

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

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    count_by_kw = Counter()
    n = int(input())
    for i in range(n):
        key = input()
        count_by_kw[key] += 1

    m = int(input())
    for i in range(m):
        key = input()
        count_by_kw[key] -= 1
    print(max(0, count_by_kw.most_common(1)[0][1]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

print(ans)

Submission status: Accepted

Solution code:
card = {}

for _ in range(int(input())):
    key = input()
    card[key] = card.get(key, 0) + 1

for _ in range(int(input())):
    key = input()
    card[key] = card.get(key, 0) - 1

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

print(max(sorted_card[0][1], 0))

Submission status: Accepted

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

dic={}
for i in s:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1

for i in t:
    if i in dic:
        dic[i]-=1
ma=max(dic.values())
print(max(ma , 0))

Submission status: Accepted

Solution code:
n = int(input())
s = {}
for _ in range(n):
    cur = input()
    val = s.get(cur,0) + 1
    s[cur] = val
m = int(input())
t = {}
for _ in range(m):
    cur = input()
    val = t.get(cur,0) + 1
    t[cur] = val
s = list(s.items())
s.sort(key=lambda x:x[1],reverse=True)

ans = 0
for key,point in s:
    cur = point
    if key in t.keys():
        cur -= t[key]
    if ans < cur:
        ans = cur

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for u in range(n)]
m = int(input())
t = [input() for k in range(m)]
list = [0]
for i in range(n):
    list.append(s.count(s[i])-t.count(s[i]))

print(max(list))

Submission status: Accepted

Solution code:
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))

print(max(0,max([n.count(l[i]) - m.count(l[i]) for i in range(len(l))])))

Submission status: Accepted

Solution code:
n = int(input())
s = [(input()) for i in range(n)]
m = int(input())
t = [(input()) for i in range(m)]
print(max([0]+[s.count(s[i])-t.count(s[i]) for i in range(n)]))

Submission status: Accepted

Solution code:
n = [input() for i in range(int(input()))]
m = [input() for i in range(int(input()))]
lst = []
for i in range(len(n)):
    lst.append(n.count(n[i])-m.count(n[i]))
print(max(max(lst),0))

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s in dic.keys():
    dic[s] += 1
  else:
    dic[s] = 1

m = int(input())
for i in range(m):
  t = input()
  if t in dic.keys():
    dic[t] -= 1
    
ans = 0
for key in dic.keys():
  ans = max(ans, dic[key])
  
print(max(ans, 0))

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
a=[]
for _ in range(n):
    a.append(input())
m=int(input())
b=[]
for _ in range(m):
    b.append(input())
a=Counter(a)
b=Counter(b)

ans=0
for k,v in a.items():
    tmp=v
    if k in b:
        tmp-=b[k]
    ans=max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]

l = list(set(s))

print(max(0, max(s.count(l[i]) - t.count(l[i]) for i in range(len(l)))))

Submission status: Accepted

Solution code:
N = int(input())
ss = [input() for _ in range(N)]

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

count = {}

for s in ss:
  if s in count:
    count[s] += 1
  else:
    count[s] = 1

for t in ts:
  if t in count:
    count[t] -= 1
  else:
    count[t] = -1
    
print(max(max(count.values()), 0))

Submission status: Accepted

Solution code:
num_red = int(input())
red = [0] * num_red

for i in range(num_red):
    red[i] = input()

num_blue = int(input())
blue = [0] * num_blue

for i in range(num_blue):
    blue[i] = input()

max = 0
count = 0

for i in range(num_red):
    if red.count(red[i]) > 0:
        count += red.count(red[i])

    for x in range(num_blue):
        if red[i] == blue[x]:
            count -= 1
    if count > max :
        max = count

    count = 0

print(max)

Submission status: Accepted

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
y = [s.count(c) - t.count(c) for c in set(s)]
print(max(0, max(y)))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[input() for _ in range(N)]
M=int(input())
B=[input() for _ in range(M)]

ans=0
for w in set(A):
    ans=max(ans,A.count(w)-B.count(w))
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

Submission status: Accepted

Solution code:
dic = {}
for _ in range(int(input())):
    s = input()
    if s in dic:
        dic[s] +=1
    else:
        dic[s] = 1
for _ in range(int(input())):
    t = input()
    if t in dic and 1 < dic[t]:
        dic[t] -=1
    else:
        dic[t] = 0
print(max(dic.values()))

Submission status: Accepted

Solution code:
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 j in range(M):
  a = input()
  if a in d:
    d[a] -= 1
  else:
    d[a] = -1
li = d.values()
print(max(li) if max(li) >= 0 else 0)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
s = [ns() for _ in range(n)]
m = ni()
t = [ns() for _ in range(m)]
ans = 0
for word in set(s):
        point = s.count(word) - t.count(word)
        ans = max(point, ans)

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
n_list=[input() for _ in range(n)]

m=int(input())
m_list=[input() for _ in range(m)]

max_count=0
for word in set(n_list):
    count=n_list.count(word)-m_list.count(word)
    if max_count<count:
        max_count=count
print(max_count if max_count>0 else 0)

Submission status: Accepted

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

Submission status: Accepted

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

scores = []
for i in s:
    scores.append(s.count(i) - t.count(i))

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

Submission status: Accepted

Solution code:
N=int(input())
Blue=[ input() for i in range(N)]
M=int(input())
Red=[ input() for i in range(M)]
L=[0]
for b in set(Blue):
  L.append(Blue.count(b)-Red.count(b))
print(max(L))

Submission status: Accepted

Solution code:
N=int(input())
sN=[input() for _ in range(N)]
M=int(input())
tM=[input() for _ in range(M)]
Max=0
for s in list(set(sN)):
  Max = max(sN.count(s) - tM.count(s), Max)
print(max(Max, 0))

Submission status: Accepted

Solution code:
n=int(input())
sl=[input() for i in range(n)]

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

keyl=[]
bluedic={}
reddic={}
for st in sl :
  if st in bluedic.keys() :
    bluedic[st]=bluedic[st]+1
  else :
    bluedic[st]=1
for st in tl :
  if st in reddic.keys() :
    reddic[st]=reddic[st]+1
  else :
    reddic[st]=1
keyl=list(bluedic.keys())#+list(reddic.keys())
#keyl=list(set(keyl))
mx=0
for k in keyl :
  if not k in reddic.keys() :
    reddic[k]=0
  div=(bluedic[k]-reddic[k])
  if mx < div :
    mx=div
    
print(mx)

Submission status: Accepted

Solution code:
n=int(input())
c=0
dic={}
for i in range(n):
    x=input()
    if x not in dic:
        dic[x]=1
    else:
        dic[x]+=1
m=int(input())
for i in range(m):
    x=input()
    if x in dic:
        dic[x]-=1

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

Submission status: Accepted

Solution code:
n=[input() for i in range(int(input()))]
m=[input() for i in range(int(input()))]

l=list(set(n))

print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

Submission status: Accepted

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]

print(max(0, max(s.count(s[i]) - t.count(s[i]) for i in range(len(s)))))

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
x = [0]
for i in range(n):
  _ = s.count(s[i])-t.count(s[i])
  x.append(_)
print(max(x))

Submission status: Accepted

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

s_set = set(s)
t_set = set(t)
can = s_set | t_set

ans = 0
for c in can:
    num = s.count(c) - t.count(c)
    ans = max(ans, num)
print(ans)

Submission status: Accepted

Solution code:
s = list(input() for _ in range(int(input())))
t = list(input() for _ in range(int(input())))
print(max(0,max(s.count(S)-t.count(S) for S in set(s))))

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
cnt_dict = {}
for si in s:
    cnt_dict[si] = 0
for ti in t:
    cnt_dict[ti] = 0
for si in s:
  	cnt_dict[si] += 1
for ti in t:
    cnt_dict[ti] -= 1
print(max(max(cnt_dict.values()), 0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [str(input()) for _ in range(n)]
m = int(input())
b = [str(input()) for _ in range(m)]
l = set(a + b)
result = [0]
for i in l:
    result.append(a.count(i) - b.count(i))
print(max(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
sn = [input() for _ in range(n)]
m = int(input())
tm = [input() for _ in range(m)]
print(max([sn.count(x)-tm.count(x) for x in sn]+[0]))

Submission status: Accepted

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

Submission status: Accepted

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

res = 0
s = set(S)
for x in s:
    v = S.count(x)-T.count(x)
    if v >= res:
        res = v
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

sl=set(s)
tl=set(t)
c=sl|tl
cl=[]
for item in c:
    cl.append(max(0,s.count(item)-t.count(item)))
print(max(cl))

Submission status: Accepted

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

s_set = set(s)

points = []
for s_set_i in s_set:
    points.append(max(0, s.count(s_set_i) - t.count(s_set_i)))

print(max(points))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
l=set(s)
M=[]
for i in l:
  M.append(s.count(i)-t.count(i))
print(max(0, max(M)))

Submission status: Accepted

Solution code:
blue_list = []
red_list = []
diff_list = []

N = int(input())
for _ in range(N):
  blue_list.append(input())
M = int(input())
for _ in range(M):
  red_list.append(input())
  
for word in set(blue_list):
    diff_list.append(blue_list.count(word)-red_list.count(word))
    
print(max(0,max(diff_list)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
for i in range(M):
    if t[i] in s:
        s.remove(t[i])
if s ==list():
    print(0)
else:
    print(s.count(collections.Counter(s).most_common()[0][0]))

Submission status: Accepted

Solution code:
n = int(input())
n_list = [str(input()) for i in range(n)]

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

List = list(set(n_list))
print(max(0, max(n_list.count(List[i]) - m_list.count(List[i]) for i in range(len(List)))))

Submission status: Accepted

Solution code:
# B - Two Colors Card Game
from collections import Counter
n = int(input())
n_dict = {}
for _ in range(n):
    ns = str(input().split())
    if ns not in n_dict.keys():
        n_dict[ns] = 1
    else:
        n_dict[ns] += 1

m = int(input())
m_dict = {}
for _ in range(m):
    ms = str(input().split())
    if ms not in m_dict.keys():
        m_dict[ms] = 1
    else:
        m_dict[ms] += 1

delta = dict(Counter(n_dict) - Counter(m_dict))
if len(delta)>0:
  ans = max(delta.values())
else:
  ans = 0
print(ans)

Submission status: Accepted

Solution code:
N=[input() for i in range(int(input()))]
M=[input() for i in range(int(input()))]
point={}

for i in N:
    if i not in point:
        point[i]=1
    else:point[i] +=1

for i in M:
    try:
        point[i] -=1
    except:continue

ans=max(point.values())
print(ans if ans>0 else 0)

Submission status: Accepted

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
ls = list(set(s))
temp=0
for l in ls:
    ans=s.count(l) - t.count(l)
    temp = max(temp, ans)
print(temp)

Submission status: Accepted

Solution code:
n = int(input())
nlist = [input() for i in range(n)]
m = int(input())
mlist = [input() for j in range(m)]
r = 0
for nn in nlist:
    if nlist.count(nn) > mlist.count(nn) and r < nlist.count(nn) - mlist.count(nn):
        r = nlist.count(nn) - mlist.count(nn)
print(r)

Submission status: Accepted

Solution code:
import collections

def main():
    N = int(input())

    S = collections.defaultdict(int)
    for i in range(N):
        s = input()
        S[s] += 1
    
    M = int(input())
    for j in range(M):
        t = input()
        S[t] -= 1
    
    if max(S.values()) > 0:
        print(max(S.values()))
    else:
        print(0)

main()

Submission status: Accepted

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
L = list(set(s))
ans = []

for i in L:
    ans.append(s.count(i) - t.count(i))

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

Submission status: Accepted

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

L = set(S)

ans = 0
for i in L:
    ans = max(ans, S.count(i)-T.count(i))

print(ans)

Submission status: Accepted

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

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

sdict = {k:s.count(k) for k in set(s)}
tdict = {k:t.count(k) for k in set(t)}

stkeys = set( list(sdict.keys()) + list(tdict.keys()) )

maxV = 0
for st in stkeys:
    sv = sdict[st] if st in sdict else 0
    tv = tdict[st] if st in tdict else 0
    maxV = max(maxV, sv-tv)

print(maxV)

Submission status: Accepted

Solution code:
d={}
for i in range(int(input())):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
        
for j in range(int(input())):
    t = input()
    if t in d:
        d[t] -= 1
    else:
        d[t] = -1

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

Submission status: Accepted

Solution code:

n = int(input())
S = [input() for _ in range(n)]
m = int(input())
T = [input() for _ in range(m)]

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

print(count)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]

db, dr = [Counter(x) for x in (b, r)]
print(max(*[v-dr[k] for k, v in db.items()]+[0]))

Submission status: Accepted

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

from collections import Counter
sc = Counter(s)
tc = Counter(t)

print(max(0, max([sc[i] - tc[i] for i in sc])))

Submission status: Accepted

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

s_dict = {}

for s_word in s:
    if s_word in s_dict:
        s_dict[s_word] += 1
    else:
        s_dict[s_word] = 1
        if s_word in t:
            s_dict[s_word] -= t.count(s_word)

max_count = max(s_dict.values())
if max_count < 0:
    max_count = 0
print(max_count)

Submission status: Accepted

Solution code:
n=int(input())
blue=[input() for i in range(n)]
m=int(input())
red=[input() for i in range(m)]
print(max(max([blue.count(blue[i])-red.count(blue[i]) for i in range(n)]),0))

Submission status: Accepted

Solution code:
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))
a = max(n.count(l[i]) - m.count(l[i]) for i in range(len(l)))
print(a if a > 0 else 0)

Submission status: Accepted

Solution code:
s, t = [], []
d = {}

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

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

for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for i in t:
    if i in d:
        d[i] -= 1
    else:
        d[i] = -1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

n = int(input())
aol = [input() for i in range(n)]
m = int(input())
akal = [input() for j in range(m)]

aod = collections.Counter(aol)
akad = collections.Counter(akal)

l = [0]
for key in aod:
    if (key in akad) == True:
        sa = aod[key] - akad[key]
        l.append(sa)
    else:
        l.append(aod[key])

print(max(l))

Submission status: Accepted

Solution code:
n = int(input())
sL = [input() for i in range(n)]
m = int(input())
tL = [input() for i in range(m)]
L = list(set(sL))
maxnum = 0
for i in range(len(L)):
    num = max(0, sL.count(L[i])-tL.count(L[i]))
    if num > maxnum:
        maxnum = num
print(maxnum)

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)

N = int(input())
a = list(input() for i in range(N))
M = int(input())
b = list(input() for i in range(M))

for i in range(N):
  d[str(a[i])] += 1

for i in range(M):
  d[b[i]] -= 1
print(max(d.values()) if max(d.values()) > 0 else 0)

Submission status: Accepted

Solution code:
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
aa = list(set(a))
cnt = [0]
for i in aa:
  if b.count(i) >= 1:
    cnt.append(a.count(i)-b.count(i))
  else:
    cnt.append(a.count(i))
print(max(cnt))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input()); s = [ input() for _ in range(N)]
M = int(input()); t = [ input() for _ in range(M)]
cnt_s = Counter(s)
cnt_n = Counter(t)
cnt_s.subtract(cnt_n)
print(max(0, max(cnt_s.values())))

Submission status: Accepted

Solution code:
N=int(input())
SN=[input() for _ in range(N)]
M=int(input())
TM=[input() for _ in range(M)]

SNdict={}
TMdict={}

for name in SN:
    if name in SNdict.keys():
        SNdict[name]+=1
    else:
        SNdict[name]=1
for name in TM:
    if name in TMdict.keys():
        TMdict[name]+=1
    else:
        TMdict[name]=1
       
ret=0
for name in SNdict:
    tmp=0
    if name in TMdict.keys():
        tmp=TMdict[name]
    tmp=SNdict[name]-tmp
    ret=max(ret,tmp)
print(ret)

Submission status: Accepted

Solution code:
from collections import defaultdict


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

m = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
si = [input() for i in range(n)]
m = int(input())
ti = [input() for i in range(m)]
sik = set(si) # 固有の値のみを抽出
tik =set(ti)
s=0
ma = 0
for i in sik:
    if si.count(i) - ti.count(i) > ma:  #もしもsにある数の方が多ければ特するのでgo!!
        ma = si.count(i) -ti.count(i)
print(ma)

Submission status: Accepted

Solution code:
from collections import Counter

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

A = Counter(S)
B = Counter(T)

ans = 0
for k, v in A.items():
    if k in B.keys():
        v -= B[k]
    ans = max(v, ans)
print(ans)