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 = []
for i in range(N) :
    s.append(input())

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

s_uni = list(set(s))

count_p = []
count_m = []
_sum = []

for i in range(len(s_uni)) :
    count_p.append(0)
    for j in range(N) :
        if s_uni[i] == s[j] :
            count_p[i] += 1

for i in range(len(s_uni)) :
    count_m.append(0)
    for j in range(len(t)) :
        if s_uni[i] == t[j] :
            count_m[i] += 1

for i in range(len(s_uni)) :
    _sum.append(count_p[i] - count_m[i])

if max(_sum) >= 0 :
    print(max(_sum))
else :
    print(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_unique = list(set(s))
N_unique = len(s_unique)

ans = 0
for i in range(0,N_unique):
	string = s_unique[i]
	if ans < s.count(string)-t.count(string):
		ans = s.count(string)-t.count(string)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

Submission status: Accepted

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

m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
    else:
        s.update({t:-1})

print(0 if max(s.values()) < 0 else max(s.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.update({s:1})

m = int(input())
for j in range(m):
    t = input()
    if t in d:
        d[t] -= 1
    else:
        d.update({t:-1})
print("0" if max(d.values()) < 0 else max(d.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.update({s:1})

m = int(input())
for j in range(m):
    t = input()
    if t in d:
        d[t] -= 1
    else:
        d.update({t:-1})
print("0" if max(d.values()) < 0 else max(d.values()))

Submission status: Accepted

Solution code:
n = int(input())
s = list(input() for _ in range(n))

m = int(input())
t = list(input() for _ in range(m))

a = 0
d = 0
for i in s:
    a = s.count(i)-t.count(i)
    if d <= a:
        d = a
print(d)

Submission status: Accepted

Solution code:
aa=[]
a=int(input())
for i in range(0,a):
  aa.append(input())

bb=[]
b=int(input())
for j in range(0,b):
  bb.append(input())

score=0
max=0
for m in aa:
  score=(aa.count(m)-bb.count(m))
  if max<=score:
    max=score
      
print (str(max))

Submission status: Accepted

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

Submission status: Accepted

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

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

ans=0
for x in s.keys():
  if x in t.keys():
    if ans < s[x] - t[x]:
      ans=s[x] - t[x]
  else:
    if ans<s[x]:
      ans=s[x]
print(ans)

Submission status: Accepted

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

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

from collections import Counter

ans=0
for b in B:
    ans=max(ans,Counter(B)[b]-Counter(R).get(b,0))

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

    d = {}
    for v in s:
        if v in d:
            d[v] += 1
        else:
            d[v] = 1
    for v in t:
        if v in d:
            d[v] -= 1
        else:
            d[v] = -1

    max_v = max(d.values())
    max_v = max(max_v, 0)

    print(max_v)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# S = str(input())
# T = str(input())
total = {}
s = [0]*N
for i in range(N):
    s[i] = str(input())
    if not (s[i] in total):
        total[s[i]] = 1
    else:
        total[s[i]] += 1
M = int(input())
t = [0]*M
for i in range(M):
    t[i] = str(input())
    if not (t[i] in total):
        total[t[i]] = -1
    else:
        total[t[i]] -= 1

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

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())
t = collections.Counter(t)
s = collections.Counter(s)
s = s.most_common()

ans = 0
for i in range(len(s)):
    ans = max(s[i][1] - t[str(s[i][0])], ans)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s = []
for i in range(N):
    s.append(str(input()))
M = int(input())
t = []
for j in range(M):
    t.append(str(input()))
MAX = 0
for k in range(N):
    kari = s[k]
    ao = s.count(kari)
    aka = t.count(kari)
    kane = ao-aka
    if kane >= MAX:
        MAX = kane
print(MAX)

Submission status: Accepted

Solution code:
dic = {}
n = int(input())
for i in range(n):
  word = input()
  if (word not in dic):
    dic[word] = 1
  else:
    val = dic[word]
    val += 1
    dic.update([(word, val)])
m = int(input())
for i in range(m):
  word = input()
  if (word not in dic):
    dic[word] = -1
  else:
    val = dic[word]
    val -= 1
    dic.update([(word, val)])
ans = max(dic.values())
print(max(ans, 0))

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest091-B
#  TODO https://atcoder.jp/contests/abc091/tasks/abc091_b

def solveProblem(wordDic,blueCards,redCards):
	maxMoney = 0
	for eachWord in wordDic:
		getMoney = blueCards.count(eachWord)-redCards.count(eachWord)
		if maxMoney < getMoney:
 			maxMoney = getMoney
	answer = maxMoney
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	wordDic = []
	blueCards = []
	blueCardRange = range(0,N,+1)
	for _ in blueCardRange:
		eachWord = str(input().strip())
		blueCards.append(eachWord)
		if eachWord not in wordDic:
			wordDic.append(eachWord)
	M = int(input().strip())
	redCardRange = range(0,M,+1)
	redCards = []
	for _ in redCardRange:
		redCards.append(str(input().strip()))
	solution = solveProblem(wordDic,blueCards,redCards)
	print("{}".format(solution))

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
s = defaultdict(int)
for _ in range(n):
    s[input().rstrip()] += 1

m = int(input())
t = defaultdict(int)
for _ in range(m):
    t[input().rstrip()] += 1

ans = 0
for w in s.keys():
    tmp = s[w] - t[w]
    ans = max(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s = [0 for _ in range(N)]
words = []
for i in range(N):
    s[i] = input()
    if s[i] not in words:
        words.append(s[i])

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

ans = 0
for i in range(len(words)):
    x = s.count(words[i])
    y = t.count(words[i])
    result = x - y
    if result > ans:
        ans = result
print(ans)

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

Submission status: Accepted

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

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)]
d=set(s+t)
cnt=[0]
for k in d:
  score=0
  p=s.count(k)
  m=t.count(k)
  score=p-m
  if score>0:
    cnt.append(score)
print(max(cnt))

Submission status: Accepted

Solution code:
a = int(input())
b = [input() for _ in range(a)]
c = int(input())
d = [input() for _ in range(c)]
e = set(b)
f = set(d)
res = 0
for i in e:
    res = max(res,b.count(i)-d.count(i))
print(res)

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())
first = collections.Counter(s)
list1 = list(first.items())
second = collections.Counter(t)
list2 = list(second.items())
list3 = list(second.keys())
ans = 0
for i in list1:
  if i[0] in list3:
    tmp = i[1]-list2[list3.index(i[0])][1]
  else:
    tmp = i[1]
  if tmp > ans:
    ans = tmp
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
Blue = [input() for _ in range(N)]
M = int(input())
Red = [input() for _ in range(M)]
Blue_dic = {b: Blue.count(b) for b in Blue}
for k, v in Blue_dic.items():
  if(k in Red):
    Blue_dic[k] = v - Red.count(k)
print(max(max(Blue_dic.values()),0))

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N = ii()
s = {}
for _ in range(N):
    tmp = ii(str)
    try:
        s[tmp] += 1
    except KeyError:
        s[tmp] = 1

M = ii()
for _ in range(M):
    tmp = ii(str)
    try:
        s[tmp] -= 1
    except KeyError:
        s[tmp] = 0
print(max(max(s.values()), 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)]
c=[0]
for k in s:
    a = s.count(k)
    b = t.count(k)
    c.append(a-b)
print(max(c))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline

N = int(input())
lst_blue = [input() for _ in range(N)]
set_blue = set(lst_blue)
M = int(input())
lst_red = [input() for _ in range(M)]

ans = 0
for word in set_blue:
    cnt_blue = lst_blue.count(word)
    cnt_red = lst_red.count(word)
    ans = max(ans, cnt_blue - cnt_red)
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline

N = int(input())
lst_blue = [input() for _ in range(N)]
set_blue = set(lst_blue)
M = int(input())
lst_red = [input() for _ in range(M)]

ans = 0
for word in set_blue:
    cnt_blue = lst_blue.count(word)
    cnt_red = lst_red.count(word)
    cnt = cnt_blue - cnt_red
    if cnt >= ans:
        ans = cnt

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

Submission status: Accepted

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

s = sorted(s)
t = sorted(t)
c_list = []
for i in range(len(s)):
    c = 0
    for j in range(len(s)):
        if s[i] == s[j]:
            c += 1
    for j in range(len(t)):
        if s[i] == t[j]:
            c -= 1
    c_list.append(c)

for i in range(len(t)):
    c = 0
    for j in range(len(s)):
        if t[i] == s[j]:
            c += 1
    for j in range(len(t)):
        if t[i] == t[j]:
            c -= 1
    c_list.append(c)

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

Submission status: Accepted

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

M = int(input())
for j in range(M):
    B.append(input())
C = []
for k in A:
    le = A.count(k)
    num=B.count(k)
    C.append(le-num)
    num=0

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

Submission status: Accepted

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


def main():
    """Function."""
    n = int(input())
    plus, p_check = [], set()
    for _ in range(n):
        temp = str(input())
        plus.append(temp)
        p_check.add(temp)
    m = int(input())
    minus, m_check = [], set()
    for _ in range(m):
        temp = str(input())
        minus.append(temp)
        m_check.add(temp)

    diffs = []
    for dum in p_check:
        dif = plus.count(dum) - minus.count(dum)
        diffs.append(dif)

    maxdif = max(diffs)
    if maxdif < 0:
        print(0)
    else:
        print(maxdif)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
d = {}
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
M = int(input())
for i in range(M):
    t = input()
    if t in d.keys():
        d[t] -= 1
    else:
        d[t] = -1
print(max(max(d.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)]
d = {}
for c in s+t:
	d[c] = 0
for c in s:
	d[c] += 1
for c in t:
	d[c] -= 1
res = 0
for k in set(s+t):
	res = max(res, d[k])
print(res)

Submission status: Accepted

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

cs = Counter(S)
ct = Counter(T)
ans = 0
for k,v in cs.items():
    ans = max(ans, v - ct[k])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = {}
for i in range(n):
    inp = input()
    try:
        s[inp] += 1
    except:
        s[inp] = 1
m = int(input())
for i in range(m):
    inp = input()
    try:
        s[inp] -= 1
    except:
        s[inp] = -1
print(max(max(s.values()),0))

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    n = int(input())
    ss = Counter(input() for _ in range(n))
    m = int(input())
    ts = Counter(input() for _ in range(m))
    res = 0
    for k, v in ss.items():
        v -= ts[k]
        res = max(res, v)
    print(res)


if __name__ == '__main__':
    main()

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

d = {i: s.count(i)-t.count(i) for i in set(s)}
if max(d.values()) <-0:
    print(0)
else:
    print(max(d.values()))

Submission status: Accepted

Solution code:
import collections
N=int(input())
blue=[input() for i in range(N)]

b=collections.Counter(blue)

M=int(input())
for i in range(M):
    a=input()
    if a in b:
        b[a]-=1

ans=max(b.values())


if(ans<0):
    ans=0

print(ans)

Submission status: Accepted

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

max_get = 0
for bc in blue_card :
    gain = blue_card.count(bc)
    loss = red_card.count(bc)
    score = gain - loss
    if (max_get < score) :
        max_get = score

print(max_get)

Submission status: Accepted

Solution code:
N = int(input())
word_dict = {}
for _ in range(N):
    si = input()
    if si in word_dict:
        word_dict[si] += 1
    else:
        word_dict[si] = 1

M = int(input())
for _ in range(M):
    ti = input()
    if ti in word_dict:
        word_dict[ti] -= 1
    else:
        word_dict[ti] = -1
print(max([max(word_dict.values()), 0]))

Submission status: Accepted

Solution code:
import collections
N=int(input())
blue=[input() for _ in range(N)]
b = collections.Counter(blue)
M=int(input())
for i in range(M):
  a = input()
  if a in b:
    b[a] = b[a]-1
ans = max(b.values())
print(0 if ans<0 else ans)

Submission status: Accepted

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

blue_kinds = {b: blue.count(b) for b in blue}
red_kinds = {r: red.count(r) for r in red}

for s in blue_kinds:
    dif = 0

    if s in red_kinds:
        dif = blue_kinds[s] - red_kinds[s]
    else:
        dif = blue_kinds[s]
    
    if dif > r:
        r = dif

print(r)

Submission status: Accepted

Solution code:
n=int(input())
sl=list(input() for _ in range(n))
m=int(input())
tl=list(input() for _ in range(m))
sls=set(sl)
m=0
for s in sls:
    m = max(m,sl.count(s) - tl.count(s))
print(m)

Submission status: Accepted

Solution code:
N= int(input())
blue_list = []
for i in range(N):
  blue_list.append(input())
M = int(input())
red_list = []
for j in range(M):
  red_list.append(input())
ans_list =[]
for i in range(len(blue_list)):
  bl = blue_list.count(blue_list[i])
  rl = red_list.count(blue_list[i])
  ans_list.append(bl-rl)
if max(ans_list) >= 0:
  print(max(ans_list))
else:
  print(0)

Submission status: Accepted

Solution code:
N = int(input())

N_list = []
M_list = []
answer = 0

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

M = int(input())

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

for i in range(N):
	S = N_list[i]
	plus  = N_list.count(S)
	minus = M_list.count(S)
	if answer < (plus - minus):
		answer = (plus - minus)

print(answer)

Submission status: Accepted

Solution code:
blue = [input() for _ in range(int(input()))]
red = [input() for _ in range(int(input()))]

ans = 0
for s in blue:
    if blue.count(s) - red.count(s) > ans:
        ans = blue.count(s) - red.count(s)
print(ans)

Submission status: Accepted

Solution code:
blue = [input() for _ in range(int(input()))]
red = [input() for _ in range(int(input()))]

ans = 0
for s in blue[:]:
    if blue.count(s) - red.count(s) > ans:
        ans = blue.count(s) - red.count(s)
print(ans)

Submission status: Accepted

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

ans = 0
for s in blue[:]:
    if blue.count(s) - red.count(s) > ans:
        ans = blue.count(s) - red.count(s)
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())

sum = 0
for i in range(N):
    temp = 0
    sample = s[i]
    for j in range(N):
        if sample == s[j]:
            temp += 1
    for k in range(M):
        if sample == t[k]:
            temp -= 1
    if temp > sum:
        sum = temp
print(sum)

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())
x=0
for i in range(n):
    ben=s.count(s[i])-t.count(s[i])
    if ben>x:
        x=ben
print(x)

Submission status: Accepted

Solution code:
n=int(input())
s=[input()for i in range(n)]
m=int(input())
p=[input()for i in range(m)]
q=0
for i in range(n):
    d=s.count(s[i])-p.count(s[i])
    if d>q:
        q=d
print(q)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
S=[input() for i in range(n)]
S=dict(Counter(S).most_common())
m=int(input())
T=[input() for i in range(m)]
T=dict(Counter(T).most_common())

for i in S:
  for k in T:
    if i==k:
      S[i] -= T[k]

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

if S[0][1] < 0:
  print(0)
else:
  print(S[0][1])

Submission status: Accepted

Solution code:
# Two Colors Card Game
n = int(input())
s = []
for i in range(n):
    s.append(input())
m = int(input())
t = []
for i in range(m):
    t.append(input())
s_, t_ = set(s), set(t)
ans = 0
for x in s_:
    if s.count(x) - t.count(x) >= ans:
        ans = s.count(x) - t.count(x)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
B={}
for i in range(N):
    tmp=input()
    if tmp not in B:
        B.setdefault(tmp,1)
    else:
        B[tmp]+=1
M=int(input())
R={}
for i in range(M):
    tmp=input()
    if tmp not in R:
        R.setdefault(tmp,1)
    else:
        R[tmp]+=1
Ans=0
for i in B:
    if i in R:
        if B[i]-R[i]>Ans:
            Ans=B[i]-R[i]
    else:
        if B[i]>Ans:
            Ans=B[i]
print(Ans)

Submission status: Accepted

Solution code:
N = int(input())
ar = []
br = []
cr = []
for i in range(N):
    l = input()
    ar.append(l)
    cr.append(l)
M = int(input())
for i in range(M):
    l = input()
    br.append(l)
    cr.append(l)
dr = set(cr)
er = [0]
for d in dr:
    count = 0
    if d in ar:
        count += ar.count(d)
    if d in br:
        count -= br.count(d)
    er.append(count)
print(max(er))

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)]
count = 0

for item in t_list:
    if item in s_list:
        s_list.remove(item)

for item in s_list:
    if count < s_list.count(item):
        count = s_list.count(item)

print(count)

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[0])
d = b.count(a[0])
ans = c-d
for i in range(n):
  if a.count(a[i]) - b.count(a[i]) > ans:
    ans = a.count(a[i]) - b.count(a[i])
if ans <= 0:
  print('0')
  exit()
print(ans)

Submission status: Accepted

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

#print(n)
#print(s)
#print(m)
#print(t)

ans=0

s1=list(set(s))
#print(s1)
t1=list(set(t))
#print(t1)
st1=s1+t1

for i in range(len(st1)):
    cnt=s.count(st1[i])-t.count(st1[i])
    if ans<cnt:
      ans=cnt
      
#print(cnt)
#print(st1)

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

from collections import Counter

sc = Counter(S)
tc = Counter(T)

result = max(0, max(sc[k] - tc[k] for k in sc))

print(result)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    dic = dict()

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

    m = int(input())

    for i in range(m):
        t = input()
        if t in dic:
            dic[t] -= 1

    max_v = 0
    for k, v in dic.items():
        if v > max_v:
            max_v = v

    print(max_v)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
dict = {}
for i in range(N):
    s = input()
    if not s in dict:
        dict[s] = 0
    dict[s] += 1
    
M = int(input())
for i in range(M):
    t = input()
    if not t in dict:
        dict[t] = 0
    dict[t] -= 1
    
print(max(list(dict.values())+[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())
x = 0
for i in range(n):
    ben = s.count(s[i]) - t.count(s[i])
    if ben > x:
        x = ben
print(x)

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

judge = 0
for l in range(N):
  money = s.count(s[l]) - t.count(s[l])
  
  if( judge < money):
    judge = money
  
  else:
    continue
    
print(judge)

Submission status: Accepted

Solution code:
N = int( input())
s = list()

for i in range(N):
  S = input()
  s.append(S)
  
M = int( input())
t = list()

for j in range(M):
  T = input()
  t.append(T)

  judge = 0
for l in range(N):
  money = s.count(s[l]) - t.count(s[l])
  
  if( judge < money):
    judge = money
  else:
    continue
    
print(judge)

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

cards = Counter()
for s in S:
    cards[s] += 1
for t in T:
    cards[t] -= 1
print(max(cards.most_common()[0][1], 0))

Submission status: Accepted

Solution code:
N = int(input())
options = set()
blues = []
for i in range(N):
    card = input()
    blues.append(card)
    options.add(card)

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

max_p = 0
for card in options:
    p = 0
    for blue in blues:
        if card == blue:
            p += 1
    for red in reds:
        if card == red:
            p -= 1
    max_p = max(p, max_p)

print(max_p)

Submission status: Accepted

Solution code:
import sys
def 解():
    input = sys.stdin.readline
    iN = int(input())
    dS = {}
    for i in range(iN):
        s = input().rstrip()
        if s in dS:
            dS[s] += 1
        else:
            dS[s] = 1
    iM = int(input())
    dT = {}
    for i in range(iM):
        s = input().rstrip()
        if s in dT:
            dT[s] += 1
        else:
            dT[s] = 1
    iMax = 0
    for s in dS.keys():
        iMax = max(iMax, dS[s] - dT.get(s,0))
    print(iMax)
解()

Submission status: Accepted

Solution code:
# coding: utf-8
blue = []
red = []
point = 0
N = int(input())
for i in range(N):
    blue.append(input())
M = int(input())
for i in range(M):
    red.append(input())
for str in blue:
    a_point = 0
    for b_str in blue:
        if str == b_str:
            a_point += 1
    for r_str in red:
        if str == r_str:
            a_point -= 1
    if a_point > point:
        point = a_point
print(point)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
https://beta.atcoder.jp/contests/abc091/tasks/abc091_b
"""

from collections import defaultdict

rewards = defaultdict(lambda: 0)

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

M = int(input())
for j in range(M):
    rewards[input()] -= 1

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

Submission status: Accepted

Solution code:
N = input()
dic = {}
for i in range(N):
	s = raw_input()
	if s not in dic.keys():
		dic[s] = 0
	dic[s] += 1
	

M = input()
for i in range(M):
	t = raw_input()
	if t not in dic.keys():
		dic[t] = 0
	dic[t] -= 1
print max(0, max(dic.values()))

Submission status: Accepted

Solution code:
import collections
n_co = collections.Counter()
m_co = collections.Counter()

n = int(input())

for i in range(n):
	ni = input()
	n_co[ni] += 1

m = int(input())

for j in range(m):
	mi = input()
	m_co[mi] += 1

ans = (n_co - m_co)

if len(ans) == 0:
	print(0)
else:
	ans = ans.most_common(1)
	print(ans[0][1])

Submission status: Accepted

Solution code:
in_num = input()
in_data=[]
for i in range(0,int(in_num)):
  in_data.append(input())
  
out_num = input()

out_data = []

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

max_count=0
for n in in_data:
  tmp = in_data.count(n) - out_data.count(n)
  if tmp > max_count:
    max_count = tmp
    
print(max_count)

Submission status: Accepted

Solution code:
blue = [input() for _ in range(int(input()))]
red = [input() for _ in range(int(input()))]

from collections import Counter

bc = Counter(blue)
rc = Counter(red)
c = (bc - rc)
print(max([x[1] for x in filter(lambda x: x[1] > 0, c.items())] or [0]))

Submission status: Accepted

Solution code:
n = int(input())
nLis = []
for i in range(n):
    nLis.append(input())
m = int(input())
mLis = []
for i in range(m):
    mLis.append(input())
cnt = 0
sLis = set(nLis)
for j in sLis:
    tmp = nLis.count(j) - mLis.count(j)
    cnt = max(cnt,tmp)
print(max(cnt,0))

Submission status: Accepted

Solution code:
bl=int(input())
bldict={}
for i in range(bl):
    s=input()
    if(s in bldict):
        bldict[s]+=1
    else:
        bldict[s]=1

red=int(input())
reddict={}
for i in range(red):
    s=input()
    if(s in reddict):
        reddict[s]+=1
    else:
        reddict[s]=1

ans=[0]
bllist=bldict.items()
for youso in bllist:
    try:
        ans.append(youso[1] - reddict[youso[0]])
    except:
        ans.append(youso[1])
print(max(ans))

Submission status: Accepted

Solution code:
"""
B - Two Colors Card Game
"""
n = int(input())
n_i = {}
for i in range(n):
    _str = input()
    if _str in n_i:
        n_i[_str] += 1
    else:
        n_i[_str] = 1
#print(n_i)

m = int(input())
m_i = {}
for i in range(m):
    _str = input()
    if _str in m_i:
        m_i[_str] += 1
    else:
        m_i[_str] = 1
#print(m_i)

for n in n_i.keys():
    # 同じ文字列がいたら引く
    if n in m_i.keys():
        #print("%s %d - %d" % (n, n_i[n], m_i[n]))
        n_i[n] -= m_i[n]

#print(n_i)

if max(n_i.values()) > 0:
    print(max(n_i.values()))
else:
    print(0)

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

cs = collections.Counter(s)
ct = collections.Counter(t)
#print(cs)
#l = max(n, m)
count = []
count.append(0)
for i in range(n):
    count.append(cs[s[i]] - ct[s[i]])

for j in range(m):
    count.append(cs[t[j]] - ct[t[j]])

print(max(count))
"""from statistics import mode

tmp_list = [1, 1, 1, 1, 0, 1, 1]
print(mode(tmp_list))
u = max(s)"""

Submission status: Accepted

Solution code:
blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]
c = 0
for i in blue:
  a=blue.count(i)-red.count(i)
  if a>0 and a>c:
    c=a
print(c)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
blue = Counter(input() for _ in range(n))
m = int(input())
red = Counter(input() for _ in range(m))
c = (blue - red).most_common(1)

if c:
  print(max(c[0][1], 0))
else:
  print(0)