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)]
result=0
for i in range(N):
  r=S.count(S[i])-T.count(S[i])
  result = max(result,r)
print(result)

Submission status: Accepted

Solution code:
import collections

N = int(input())
s_list = [input() for _ in range(N)]
M = int(input())
t_list = [input() for _ in range(M)]

s_copy = s_list[:]
t_copy = t_list[:]
for i, s in enumerate(s_list):
  if s in t_copy:
    t_copy.remove(s)
    s_copy.remove(s)

if s_copy:
  c = collections.Counter(s_copy)
  print(c.most_common(1)[0][1])
else:
  print(0)

Submission status: Accepted

Solution code:
#ABC091 B - Two Colors Card Game
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N = ni()
S = [input() for i in range(N)]
M = ni()
T = [input() for i in range(M)]

ST_map = set(S)|set(T)
b = 0
r = 0

ans = -1000
for st_m in ST_map:
    b = 0
    r = 0
    for s in S:
        if st_m == s:
            b+=1
    for t in T:
        if st_m == t:
            r+=1
    ans = max(ans,b-r)

if ans<0:
    ans = 0
print(ans)

Submission status: Accepted

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

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)]
ans = 0
for x in a:
    ans = max(ans,a.count(x)-b.count(x))
print(ans)

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)]
ans=0
for x in a:
  ans = max(ans,a.count(x)-b.count(x))
print(ans)

Submission status: Accepted

Solution code:
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_money = 0

for word in set(s):
    money = s.count(word) - t.count(word)
    if money > max_money:
        max_money = money

print(max_money)

Submission status: Accepted

Solution code:
n=int(input())
a=[input() for _ in range(n)]
m=int(input())
b=[input() for _ in range(m)]
da={}
for word in a:
    da[word]=a.count(word)
for i in b:
    if i in da.keys():
        da[i]-=1
if max(da.values())>=0:
    print(max(da.values()))
else:
    print(0)

Submission status: Accepted

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

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

dic = {}
for item in s:
    if item not in dic.keys():
        dic[item] = 0
    dic[item] += 1

for item in t:
    if item not in dic.keys():
        dic[item] = 0
    dic[item] -= 1

ans = max(dic.values())

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

Submission status: Accepted

Solution code:
from collections import Counter

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

ans = 0
for key, num in S.items():
  if key in T: ans = max(num-T[key],ans)
  else: ans = max(ans, num)
print(ans)

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)]
x = list(set(s))
def counter(x,N,s,M,t):
    ans = [0]
    for i in range(len(x)):
        tmp = 0
        for j in range(N):
            if x[i] == s[j]:
                tmp += 1
        for k in range(M):
            if x[i] == t[k]:
                tmp += (-1)
        ans.append(tmp)
    return(ans)
print(max(counter(x,N,s,M,t)))

Submission status: Accepted

Solution code:
n = int(input())
s = []
t = []
for i in range(n):
    s.append(input())
for j in range(int(input())):
    t.append(input())
s_set = set(s)
ans = 0
for i in s_set:
    if ans <= s.count(i) - t.count(i):
        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)]

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

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

red = Counter(s)
blue = Counter(t)

point = 0
for r in red:
  point = max(point, red[r] - blue[r])
  
if point<0:
  point=0

print(point)

Submission status: Accepted

Solution code:
N = int(input())
cards = {}
for n in range(N):
    s = input()
    if s in cards:
        cards[s] += 1
    else:
        cards[s] = 1

M = int(input())
for m in range(M):
    s = input()
    if s in cards and cards[s] > 0:
        cards[s] -= 1
    else:
        cards[s] = 0

sorted_cards = list(reversed(sorted(cards.items(), key=lambda x:x[1])))
print(sorted_cards[0][1])

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 s in S:
  ans = max(ans, S.count(s)-T.count(s))
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)]
list = [s.count(i) - t.count(i) for i in set(s)]
print(max(0, *list))

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
s_counter = Counter([input() for _ in range(N)])
M = int(input())
t_counter = Counter([input() for _ in range(M)])
d = {}
for key, value in s_counter.items():
  d[key] = [value]
for key, value in t_counter.items():
  if key not in d:
    d[key] = [-value]
  else:
    d[key].append(-value)
result = 0
for value in d.values():
  if sum(value) > result:
    result = sum(value)
print(result)

Submission status: Accepted

Solution code:
N=int(input())
d={}
ans=0
for n in range(N):
    S=input()
    if S in d:
        d[S]+=1
    else:
        d[S]=1
M=int(input())
for m in range(M):
    T=input()
    if T in d:
        d[T]-=1
    else:
        d[T]=1
for k in d:
    if d[k]>ans:
        ans=d[k]
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    s = [input() for i in range(N)]
    M = int(input())
    t = [input() for i in range(M)]
    from collections import Counter
    s_counted = Counter(s)
    t_counted = Counter(t)
    ans = 0
    for key, val in s_counted.items():
        ans = max(ans, val - t_counted[key])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

max_money = 0
for word in set(S):
  money = 0
  for s in S:
    if word == s:
      money += 1
  for t in T:
    if word == t:
      money -= 1
  if money > max_money:
    max_money = money

print(max(max_money, 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)]
dic = dict()
m = 0
for i in s:
    if i in dic:
        dic[i] = dic[i] + 1
    else:
        dic[i] = 1
for i in t:
    if i in dic:
        dic[i] = dic[i] - 1
    else:
        dic[i] = -1
for key in dic.keys():
    m = max(m,dic[key])
print(m)

Submission status: Accepted

Solution code:
N = int(input())
blues = {}
reds = {}
for i in range(N):
    s = input()
    if s in blues:
        blues[s] += 1
    else:
        blues[s] = 1
    reds[s] = 0
M = int(input())
for i in range(M):
    s = input()
    if s in reds:
        reds[s] += 1
    else:
        reds[s] = 1

res = 0
for s in blues:
    res = max(res, blues[s]-reds[s])

print(res)

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

ans=0
for i in range(N):
    ans=max(ans,S.count(S[i])-T.count(S[i]))

print(ans)

Submission status: Accepted

Solution code:
# 文字列の数（N）の分だけ、文字列を取得する
n=[input() for i in range(int(input()))]

# 文字列の数（M）の分だけ、文字列を取得する
m=[input() for i in range(int(input()))]

# 重複する文字列を削除するため、Nを集合にし、再度リスト化する
l = list(set(n))

# Lのリストの要素の文だけ繰り返す。
# Nのリストにおいて、任意の数番目のLのリストの要素の数から、
# Nのリストにおいて、任意の数番目のLのリストの要素の数を引く
# Lの要素の数だけ引き算を繰り返し、その中で最大のものを取り出す
# 取り出したものを0と比較し、大きい方を出力する
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())
dic={}
for i in range(n):
    s=input()
    dic[s]=dic.get(s,0)+1
m=int(input())
for i in range(m):
    t=input()
    dic[t]=dic.get(t,0)-1
print(max(max(dic.values()),0))

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)

def main():
    n = int(input())
    s = defaultdict(int)
    for _ in range(n):
        s[input()] += 1
    m = int(input())
    for _ in range(m):
        t = input()
        if t in s:
            s[t] -= 1
    print(max(max(s.values()), 0))

main()

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = Counter()
for i in range(N):
  s_i = input()
  S[s_i] += 1

M = int(input())
T = Counter()
for i in range(M):
  t_i = input()
  T[t_i] += 1

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

Submission status: Accepted

Solution code:
a=int(input())
b=[input() for i in range(a)]
x=int(input())
y=[input() for i in range(x)]
list=[b.count(i) - y.count(i) for i in set(b)]
print(max(0,*list))

Submission status: Accepted

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

Submission status: Accepted

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

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

import collections
v1 = collections.Counter(s)
v2 = collections.Counter(t)
c = 0
for s in v1.keys():
    _ = v1[s] - v2[s]
    if c < _:
        c = _
print(c)

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)]
list = {}
for i in s:
  if i in list:
    list[i]+=1
  else:
    list[i] = 1
for i in t:
  if i in list:
    list[i] -= 1
ans = max(list.values())
if ans > 0:
  print(ans)
else:
  print(0)

Submission status: Accepted

Solution code:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(s[i])
print(max(cnt))

Submission status: Accepted

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

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

I = list(set(n))
print(max(0,max(n.count(I[i]) - m.count(I[i]) for i in range(len(I)))))

Submission status: Accepted

Solution code:
n=int(input())
l=[str(input()) for i in range(n)]
m=int(input())
r=[str(input()) for i in range(m)]
l.sort();r.sort()
#print(l,r)
ans=0
for i in range(n):
    a=l[i]
    b=l.count(l[i])-r.count(l[i])
    if ans<=b:
        ans=b
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)]
Y = 0

for i in set(s):
    Y = max(Y,s.count(i) - t.count(i))
print(Y)

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 i in range(m):
  s=input()
  if s in d:
    d[s]-=1
  else:
    d[s]=-1
print(max(int(max(d.values())),0))

Submission status: Accepted

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

Submission status: Accepted

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

c = [0]
for i in s:
  c.append(s.count(i) - t.count(i))
  
print(max(c))

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 s in set(S):
    p = S.count(s)
    m = T.count(s)
    if p > m:
        ans = max(ans, p-m)

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    from collections import defaultdict
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[input()] += 1
    M = int(input())
    for _ in range(M):
        d[input()] -= 1
    res = 0
    for _,v in d.items():
        if v > res:
            res = v
    print(res)
resolve()

Submission status: Accepted

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

Words = list(set(B)) + list(set(R))

ans = 0
for w in Words:
	ans = max(ans, B.count(w) - R.count(w))

print(ans)

Submission status: Accepted

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

List = []
for i in range(len(list(set(sn)))):
    List.append(sn.count(list(set(sn))[i]) - sm.count(list(set(sn))[i]))
    
print(max(max(List), 0))

Submission status: Accepted

Solution code:
word=[]
max_score=0

n=int(input())
for i in range(n):
    s=input()
    word.append([s,1])
m=int(input())
for i in range(m):
    s=input()
    word.append([s,-1])
word2=sorted(word)

now=word2[0][0]
score=0
for i in range(n+m):
    if now==word2[i][0]:
        score+=word2[i][1]
    else:
        if score>max_score:
            max_score=score
        score=0
        score+=word2[i][1]
        now=word2[i][0]
print(max(score,max_score))

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

counter_s = collections.Counter(s)
ans = 0
for k, v in counter_s.items():
    ans = max(ans, v - t.count(k))
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)]

ans_list = []
for i in range(N):
    say_word = s[i]
    ans_list.append(s.count(say_word) - t.count(say_word))

print(max(max(ans_list),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)]
output = 0

s_count, t_count = Counter(s), Counter(t)

for i in s_count:
    tmp_s = s_count[i]
    tmp_t = 0
    if i in t_count:
        tmp_t = t_count[i]

    if output < tmp_s - tmp_t:
        output = tmp_s - tmp_t

print(output)

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 range(len(s)):
    ans = max(ans, s.count(s[i])-t.count(s[i]))
print(ans)

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)]
l_list=list(set(s_list))
a=max(0,max(s_list.count(l_list[i-1])-t_list.count(l_list[i-1]) for i in range(len(l_list))))
print(a)

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    r = collections.Counter([str(input().rstrip('\n')) for _ in range(n)])
    m = int(input().rstrip('\n'))
    b = collections.Counter([str(input().rstrip('\n')) for _ in range(m)])
    mt = 0
    for k, v in r.items():
        if k in b:
            if v > b[k]:
                mt = max(mt, v - b[k])
        else:
            mt = max(mt, v)
    print(mt)


if __name__ == '__main__':
    slove()

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)]
sc=collections.Counter(s)
tc=collections.Counter(t)
ans=sc-tc
print(max(ans[i] for i in ans) if len(ans)>0 else 0)

Submission status: Accepted

Solution code:
import collections
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
u=set(s)
ans=0
for i in u:
    p=s.count(i)-t.count(i)
    ans=max(ans,p)
print(ans)

Submission status: Accepted

Solution code:
import collections
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cs=collections.Counter(s)
ct=collections.Counter(t)
ans=0
for k,v in cs.items():
    mp=0
    if k in ct:
        mp=ct[k]
    ans=max(ans, v-mp)
print(ans)

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

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
table.append(0)
print(max(table))

Submission status: Accepted

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

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

print(max_v)

Submission status: Accepted

Solution code:
N = int(input())
S = [input().strip() for _ in range(N)]
M = int(input())
T = [input().strip() for _ in range(M)]
cntmax = 0
for s in S:
    cnt = S.count(s)
    for t in T:
        if t==s:
            cnt -= 1
    cntmax = max(cntmax,cnt)
print(cntmax)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
S=[]
T=[]
for n in range(N):
    s=input()
    S.append(s)
M=int(input())
for m in range(M):
    t=input()
    T.append(t)
d_s=Counter(S)
d_t=Counter(T)
if len(d_s-d_t)==0:
    print(0)
else:
    u=sorted((d_s-d_t).items(), key=lambda x:x[1], reverse=True)
    #print(u)
    print(u[0][1])
    #print("s-t:{}\tmax:{}".format(d_s-d_t, max(d_s-d_t)))
    #print((d_s-d_t)[max(d_s-d_t)])

Submission status: Accepted

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

get_money = []

for word in n_list:
    plus = [i for i, j in enumerate(n_list) if j == word]
    plus = len(plus)
    minus = [i for i, j in enumerate(m_list) if j == word]
    minus = len(minus)
    price = 1*plus - 1*minus
    get_money.append(price)

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

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
count1 = 0
count2 = 0
for i in range(N):
  for j in range(N):
    if S[i] == S[j]:
      count1 += 1
  for k in range(M):
    if S[i] == T[k]:
      count2 += 1
  ans = max(ans,count1-count2)
  count1 = 0
  count2 = 0
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
bd = defaultdict(lambda: 0)
for i in range(N):
  bd[input()] += 1
N = int(input())
for i in range(N):
  bd[input()] -= 1

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

Submission status: Accepted

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

l = n.copy()
l.extend(m)
l = set(l)

prize = [n.count(cand_i) - m.count(cand_i) for cand_i in l]
print(max(0, max(prize)))

Submission status: Accepted

Solution code:
S = [input() for _ in range(int(input()))]
T = [input() for _ in range(int(input()))]
ans = 0
for s in set(S):
    score = S.count(s) - T.count(s)
    if score > ans:
        ans = score
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
r = [input() for _ in range(N)]
r1 = Counter(r)
M = int(input())
b = [input() for _ in range(M)]
b1= Counter(b)
#print(r1)
#print(b1)
ans = 0
for i in r1.keys():
  if i in b1:
    ans = max(ans,r1[i]-b1[i])
  else:
    ans = max(ans,r1[i])
print(ans)

Submission status: Accepted

Solution code:
#2019/09/29
# open(0)で再チャレンジ
input_line = open(0).readlines()
N = int(input_line[0])
s = [i.rstrip("\n") for i in input_line[1:1+N]]
M = int(input_line[1+N])
t = [i.rstrip("\n") for i in input_line[2+N:2+N+M]]

s_set = set(s)
cnt_list = []
for i in range(len(s_set)):
    ele_cnt = max(s.count(list(s_set)[i])-t.count(list(s_set)[i]), 0)
    cnt_list.append(ele_cnt)

print(max(cnt_list))

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)
m = int(input())
t = []
for i in range(m):
    a = input()
    t.append(a)
c = []
k = 0
for i in s:
    for j in s:
        if i == j:
            k += 1
    for j in t:
        if i == j:
            k -= 1
    c.append(k)
    k = 0
if max(c) < 0:
    print(0)
else:
    print(max(c))

Submission status: Accepted

Solution code:
w_map = {}

for i in range(0, int(input())):
    s = input()
    if s in w_map:
        w_map[s] += 1
    else:
        w_map[s] = 1

for i in range(0, int(input())):
    t = input()
    if t in w_map:
        w_map[t] -= 1
    else:
        w_map[t] = -1

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

Submission status: Accepted

Solution code:
s_list = []
t_list = []

for i in range(0, int(input())):
    s_list.append(input())

for i in range(0, int(input())):
    t_list.append(input())

w_map = {}
for s in s_list:
    if s in w_map:
        w_map[s] += 1
    else:
        w_map[s] = 1

for t in t_list:
    if t in w_map:
        w_map[t] -= 1
    else:
        w_map[t] = -1

print(max(max(w_map.values()), 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 = set(s)
b = 0
for i in ss:
    a = 0
    for l in s:
        if l == i:
            a += 1
    for l in t:
        if l == i:
            a -= 1
    if a > b:
        b = a
print(b)

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_x = list(set(s))
ans =0
for b in s_x:
  ans = max(ans, s.count(b)-t.count(b))
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

def bb091():
    n = int(input())
    sn = Counter()
    sn['0'] = 0
    for i in range(0,n):
        sn[input()] += 1

    m = int(input())
    tm = Counter()
    for i in range(0,m):
        tm[input()] += 1

    for k,v in tm.items():
        sn[k] -= v

    ma = 0
    for k,v in sn.items():
        if v > ma:
            ma = v

    print(ma)

bb091()

Submission status: Accepted

Solution code:
N = int(input())
red = dict()
blue = dict()

for n in range(N):
  r = input()
  if r in red:
    red[r] += 1
  else:
    red[r] = 1

M = int(input())

for m in range(M):
  b = input()
  if b in blue:
    blue[b] += 1
  else:
    blue[b] = 1

ret = [0]
for k in red.keys():
  cnt = red[k] - (blue[k] if k in blue else 0)
  ret.append(cnt)

print(max(ret))

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:
N = int(input())
dic = {}
for _ in range(N):
    s = input()
    if s in dic: 
        dic[s] += 1
    else:
        dic[s] = 1

M = int(input())
for _ in range(M):
    t = input()
    if t in dic: 
        dic[t] -= 1
ans = max(dic.values())
if ans<0:
    print(0)
else:
    print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
dic=defaultdict(int)
n=int(input())
for i in range(n):
    s=input()
    dic[s]+=1
m=int(input())
for i in range(m):
    s=input()
    dic[s]-=1

ans=float('-inf')
for i in dic.values():
    ans=max(ans,i)
print(max(ans,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
count=0
for i in range(N):
  count=s.count(s[i])
  count-=t.count(s[i])
  ans=max(ans,count)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
S = defaultdict(int)
S_item = []
for _ in range(N):
    s = input()
    S[s] += 1
    S_item += [s]
M = int(input())
T = defaultdict(int)
T_item = []
for _ in range(M):
    t = input()
    T[t] += 1
    T_item += [t]
ans = 0
for item in S_item:
    if item not in T_item:
        ans = max(ans, S[item])
    else:
        ans = max(ans, S[item]-T[item])
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)]
res = 0
for s in set(S):
    score = S.count(s) - T.count(s)
    if score > res:
        res = score
print(res)

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())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
point = 0
s.sort() #logN
t.sort() #logM
l = list(set(s))
for i in l:
    tmp = s.count(i) - t.count(i) #N+M
    point = max(point,tmp)
#N(N+M)<=10**5
print(point)

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 = collections.Counter(s)
t = collections.Counter(t)
ans = 0
for k in s:
    ans = max(ans, s[k] - t[k])
print(ans)

Submission status: Accepted

Solution code:
blue_num = int(input())
blue_list = []
[blue_list.append(input()) for i in range(blue_num)]
red_num = int(input())
red_list = []
[red_list.append(input()) for n in range(red_num)]

count_list = []
for i in blue_list:
    count = 0
    count += blue_list.count(i)
    for j in red_list:
        if i == j:
            count -= 1
        else:
            pass
    count_list.append(count)


if max(count_list) <= 0:
    print(0)
else:
    print(max(count_list))

Submission status: Accepted

Solution code:
n = int(input())

sarr = []

for i in range(n):
    sarr.append(input())

m = int(input())

tarr = []

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

dic = {}

sset = list(set(sarr))
tset = list(set(tarr))

for i in range(len(sset)):
    dic[sset[i]] = sarr.count(sset[i]) - tarr.count((sset[i]))

ans = max(dic.values())

if ans < 0:
    ans = 0

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)]
l=[0]
for i in range(n):
    k=s.count(s[i])-t.count(s[i])
    l.append(k)
print(max(l))

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
M = int(input())
T = []
for i in range(M):
    T.append(input())
    
dic = {}
for i in range(N):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
for i in range(M):
    if T[i] in dic:
        dic[T[i]] -= 1
    
ans = 0
for key in dic:
    if ans < dic[key]:
        ans = dic[key]
        
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)]
num = [0]
for i in set(s):
  num.append(s.count(i)-t.count(i))
print(max(num))

Submission status: Accepted

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

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(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)]
red = set(S)
ans = [S.count(s) - T.count(s) for s in red]
print( max(max(ans), 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)]
income = 0
for i in range(N):
    income = max(income,S.count(S[i])-T.count(S[i]))
print(income)

Submission status: Accepted

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

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

ans = []

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

for i in range(len(cs)):
        ans.append(cs.most_common()[i][1] - t.count(cs.most_common()[i][0]))
print(max(max(ans), 0))

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(input())
m = int(input())
t = []
for i in range(m):
  t.append(input())
  
out = 0

s_uniq = set(s)
for i in s_uniq:
  c = len([x for x in s if x == i]) - len([x for x in t if x == i])
  if out < c:
    out = c

print(out)

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(i)-t.count(i) for i in set(s)])))

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 _ in range(N)]
M=int(input())
T=[input() for _ in range(M)]

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