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: Wrong Answer

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

counter = dict()
for i in s:
  counter[i] = counter.get(i, 0) + 1
for i in t:
  counter[i] = counter.get(i, 0) - 1

print(max(counter.values()))

Submission status: Wrong Answer

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

money = 0
money_list = []
word_list = list(set(s+t))
for i in range(len(word_list)):
    sum = s.count(word_list[i])
    sum -= t.count(word_list[i])
else:
    money_list.append(sum)

money_list.sort()
if money_list[0] < 0:
    print(0)
else:
    print(money_list[0])

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[input() for i in range(N)]
M=int(input())
l=[input() for i in range(M)]
list_str=list(dict.fromkeys(s+l))
s_l=[]
for i in range(len(list_str)):
  s_l.append(s.count(list_str[i])-l.count(list_str[i]))
if(all([i < 0 for i in s_l])):
  t='a'
  while(t==any(s_l)):
    t+='a'
  print(t)
else:print(max(s_l))

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[input() for i in range(N)]
M=int(input())
l=[input() for i in range(M)]
list_str=list(dict.fromkeys(s+l))
s_l=[]
for i in range(len(list_str)):
  s_l.append(s.count(list_str[i])-l.count(list_str[i]))
print(all([i < 0 for i in s_l]))
if(all([i < 0 for i in s_l])):
  t='a'
  while(t==any(s_l)):
    t+='a'
  print(t)
else:print(max(s_l))

Submission status: Wrong Answer

Solution code:
point = {}
for i in range(int(input())):
    name = input()
    if (name in point.keys()) == True:
        point[name] += 1
    else:
        point[name] = 1
for i in range(int(input())):
    name = input()
    if (name in point.keys()) == True:
        point[name] -= 1
    else:
        point[name] = -1
print(max(list(point.values())))

Submission status: Wrong Answer

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

memo = {}
for i in range(n):
  if s[i] not in memo:
    memo[s[i]] = 1
  else:
    memo[s[i]] +=1

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

    
print(max(memo[max(memo)],0))

Submission status: Wrong Answer

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

def solveProblem(wordDic,blueCards,redCards):
	print("wordDic:{}".format(wordDic))
	print("blueCards:{}".format(blueCards))
	print("redCards:{}".format(redCards))
	answer = wordDic
	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: Wrong Answer

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([i]) for i in range(len(l)))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(d.values()))

Submission status: Wrong Answer

Solution code:
N = int(input())

N_list = []
M_list = []
answer = -100

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: Wrong Answer

Solution code:
N = int(input())

N_list = []
M_list = []
answer = -100

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

M = int(input())

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

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: Wrong Answer

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())
if S[0][1] < 0:
  print(0)
else:
  print(S[0][1])

Submission status: Wrong Answer

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())
print(S[0][1])

Submission status: Wrong Answer

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[i]

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

Submission status: Wrong Answer

Solution code:
a=int(input())
b=[input() for i in range(a)]
c=int(input())
d=[input() for i in range(c)]
e=list(set(b))
l=list(set(d))
#print(e)
#print(l)
g={}
for i in range(len(e)):
	f=0
	for k in range(len(b)):
		if b[k]==e[i]:
			f=f+1
	g[e[i]]=f

h={}
for i in range(len(l)):
	f=0
	for k in range(len(d)):
		if d[k]==l[i]:
			f=f-1
	h[l[i]]=f

g=sorted(g.items())
h=sorted(h.items())
#print(g)
#print(h)

if len(g)==len(h)==1 and g[0][1] < abs(h[0][1]):
	print(0)
else:
	m=[]
	for k in range(len(g)):
		hantei0=False
		for i in range(len(h)):
			if g[k][0]==h[i][0]:
				l=g[k][1]+h[i][1]
				m.append(l)
				hantei0=True
		if hantei0==False:
			m.append(g[k][1])


	n=[]
	for k in range(len(h)):
		hantei1=False
		for i in range(len(g)):
			if h[k][0]==g[i][0]:
				o=h[k][1]+g[i][1]
				n.append(o)
				hantei1=True
		if hantei1==False:
			n.append(h[k][1])

#print(m)
#print(n)

	if max(m)>max(n):
		print(max(m))
	else:
		print(max(n))

Submission status: Wrong Answer

Solution code:
a=int(input())
b=[input() for i in range(a)]
c=int(input())
d=[input() for i in range(c)]
e=list(set(b))
l=list(set(d))
#print(e)
#print(l)
g={}
for i in range(len(e)):
	f=0
	for k in range(len(b)):
		if b[k]==e[i]:
			f=f+1
	g[e[i]]=f

h={}
for i in range(len(l)):
	f=0
	for k in range(len(d)):
		if d[k]==l[i]:
			f=f-1
	h[l[i]]=f

g=sorted(g.items())
h=sorted(h.items())
#print(g)
#print(h)

if len(g)==len(h)==1:
	print(0)
else:
	m=[]
	for k in range(len(g)):
		hantei0=False
		for i in range(len(h)):
			if g[k][0]==h[i][0]:
				l=g[k][1]+h[i][1]
				m.append(l)
				hantei0=True
		if hantei0==False:
			m.append(g[k][1])


	n=[]
	for k in range(len(h)):
		hantei1=False
		for i in range(len(g)):
			if h[k][0]==g[i][0]:
				o=h[k][1]+g[i][1]
				n.append(o)
				hantei1=True
		if hantei1==False:
			n.append(h[k][1])

#print(m)
#print(n)

	if max(m)>max(n):
		print(max(m))
	else:
		print(max(n))

Submission status: Wrong Answer

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[i]) - t.count(s[i])
  
  if( judge < money):
    judge = money
    
  else:
    continue
    
print(judge)

Submission status: Wrong Answer

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[i]) - t.count(s[i])
  
  if( judge < money):
    judge = money
    
print('judge')

Submission status: Wrong Answer

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(rewards.values()))

Submission status: Wrong Answer

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 = out_data.count(n)
  if tmp > max_count:
    max_count = tmp
    
print(max_count)

Submission status: Wrong Answer

Solution code:
N = int(input())
L1 = []
for i in range(N) :
    L1.append(input())
M = int(input())
L2 = []
for i in range(M) :
    L2.append(input())
ans = -10**8
L3 = list(set(L1))
for i in range(len(L3)) :
    p = L1.count(L3[i])
    q = L2.count(L3[i])
    if ans < p-q :
        ans = p-q
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s_list = []
for i in range(N):
  s_list.append(input())
M = int(input())
t_list = []
for i in range(M):
  t_list.append(input())
dict_index = set(s_list + t_list)
s_count = [s_list.count(i) for i in dict_index]
t_count = [t_list.count(i) for i in dict_index]
dict_count = [i - n for i, n in zip(s_count, t_count)]
print(max(dict_count))

Submission status: Wrong Answer

Solution code:
dict = {}

n = int(input())

for i in range(n):
	s = input()
	try:
		dict[s] += 1
	except:
		dict[s] = 1

m = int(input())

for i in range(m):
	s = input()
	try:
		dict[s] -= 1
	except:
		dict[s] = -1

ans = sorted(dict.items(), key=lambda x: -x[1])

print(ans[0][1])

Submission status: Wrong Answer

Solution code:
a=[]
b=[]
m=0

for _ in [0]*int(input()):
  a += input()
for _ in [0]*int(input()):
  b += input()

for s in a:
  m = max(m, a.count(s)-b.count(s))
print(m)

Submission status: Wrong Answer

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 l in s:
    if s.count(l)-t.count(l)>0:
        ans=s.count(l)-t.count(l)
print(ans)

Submission status: Wrong Answer

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

s_set = list(set(s_list))
result = []
for s in s_set:
    r = 0
    for i in s_list:
        if i == s:
            r += 1
    for j in t_list:
        if j == s:
            r -= 1
    result.append(r)
print(max(result))

Submission status: Wrong Answer

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

for i in range(M):
    for j in range(t.count(t[i])):
        if t[i] in s:
            s.remove(t[i])
        else:
            break

for i in range(len(s)):
    if sum < s.count(s[i]):
        sum = s.count(s[i])
print(sum)

Submission status: Wrong Answer

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

for i in range(M):
    while t[i] in s:
        s.remove(t[i])

for i in range(len(s)):
    if sum < s.count(s[i]):
        sum = s.count(s[i])
print(sum)

Submission status: Wrong Answer

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

s2 = s
for i in range(M):
    while t[i] in s:
        s2.remove(t[i])

for i in range(len(s2)):
    if sum < s.count(s2[i]):
        sum = s.count(s2[i])
print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
t = []
sum = 1

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

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

for i in range(M):
    while t[i] in s:
        s.remove(t[i])

for i in range(len(s)):
    if sum < s.count(s[i]):
        sum = s.count(s[i])
print(sum)

Submission status: Wrong Answer

Solution code:
h={};
for i in[1,-1]:
    for _ in range(int(input())):
        s=input()
        if s in h:h[s]+=i
        else:h[s]=i
print(max(h.values()))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for j in range(n)]
m=int(input())
t=[input() for k in range(m)]
set_s = list(set(s))
set_t = list(set(t))
list_s = [s.count(set_s[i]) for i in range(len(set_s))]
list_t = [t.count(set_s[j]) for j in range(len(set_s))]
list_x = [list_s[i] - list_t[i] for i in range(len(list_s))]
print(max(list_x) if set_s != set_t else 0)

Submission status: Wrong Answer

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

print(max([s.count(text)-t.count(text) for text in set(s) | set(t)]))

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
blue = [list(input().split()) for i in range(N)]
M = int(input())
red = [list(input().split()) for i in range(M)]
sum =0
for i in blue:
    score = blue.count(i) - red.count(i)
    if score>sum:
        result = sum
print(sum)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

def countDic(str_list):
    ret = {}
    for s in str_list:
        if s in ret.keys():
            ret[s] += 1
        else:
            ret[s] = 1
    return ret

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

s_c = countDic(s)
t_c = countDic(t)
a = []
for k in s_c.keys():
    if k in t_c.keys():
        a.append(s_c[k] - t_c[k])
    else:
        a.append(s_c[k])
print(max(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
s,t = list(),list()

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

m = int(input())

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

s.sort()
t.sort()

s_ = set(s)
t_ = set(t)

s_,t_ = list(s_),list(t_)
st_ = s_ + t_
st = set(st_)

res_list = list(st)
lo = len(res_list)
res_co = [0]*lo

for i in range(lo):
    res_co[i] += s.count(res_list[i])
    res_co[i] -= t.count(res_list[i])

#point = res_co.index(max(res_co))
#print(res_list)
#print(res_co)
print(max(res_co))

Submission status: Wrong Answer

Solution code:
n = int(input())
s,t = list(),list()

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

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

s.sort()
t.sort()

s_ = set(s)
t_ = set(t)

s_,t_ = list(s_),list(t_)
st_ = s_ + t_
st = set(st_)

res_list = list(st)
lo = len(res_list)
res_co = [0]*lo

for i in range(lo):
    res_co[i] += s.count(res_list[i])
    res_co[i] -= t.count(res_list[i])

point = res_co.index(max(res_co))

print(point)

Submission status: Wrong Answer

Solution code:
n = int(input())
s,t = list(),list()

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

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

s.sort()
t.sort()

s_ = set(s)
t_ = set(t)

"""
ls = len(s_)
lt = len(t_)

co_s = [0]*ls
co_t = [0]*ls

for i in range(ls):
    co_s[i] +=s.count(s_[i])

for i in range(lt):
    co_t[i] -=t.count(t_[i])

for i in range(s_):
    for j in range(t_):
        if s_[i] == t_[j]:
"""
s_,t_ = list(s_),list(t_)
st_ = s_ + t_
st = set(st_)

res_list = list(st)
lo = len(res_list)
res_co = [0]*lo

for i in range(lo):
    res_co[i] += s.count(res_list[i])
    res_co[i] -= t.count(res_list[i])

point = res_co.index(max(res_co))
#print(res_list)
#print(res_co)
print(point)
#print(res_list[point])

Submission status: Wrong Answer

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

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

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

print max

Submission status: Wrong Answer

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

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

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

print max

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
from itertools import groupby

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from itertools import groupby

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

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


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

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


counter_max = 0

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

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

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

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

counter_max = 0

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

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

Submission status: Wrong Answer

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())
cnt,ans=1,0
for i in range(n):
    temp=s[i]
    for j in range(i+1,n):
        if s[j]=="": continue
        if temp==s[j]:
            cnt+=1
            s[j]=""
    for j in range(m):
        if temp == t[j]:
            cnt-=1
    ans = max(ans,cnt)
    cnt=1
print(ans)

Submission status: Wrong Answer

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
l = []
for thisKey in d:
  l.append(d[thisKey])
print(max(l))

Submission status: Wrong Answer

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

str_s = ""
str_t = ""
for word in s:
    str_s += word
    str_s += ","
for word in t:
    str_t += word
    str_t += ","


import re
max_s = 0
max_t = 0
get = 0

for word in s:
    max_s = len(re.findall(word, str_s))
    max_t = len(re.findall(word, str_t))
    if(get < abs(max_s) - abs(max_t)):
        get = abs(max_s) - abs(max_t)

print(get)

Submission status: Wrong Answer

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

str_s = ""
str_t = ""
for word in s:
    str_s += word
    str_s += ","
for word in t:
    str_t += word
    str_t += ","


import re
max_s = 0
max_t = 0
get = 0

for word in s:
    max_s = len(re.findall(word, str_s))
    max_t = len(re.findall(word, str_t))
    if(get < max_s - max_t):
        get = max_s - max_t

print(get)

Submission status: Wrong Answer

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

str_s = ""
str_t = ""
for word in s:
    str_s += word
for word in t:
    str_t += word

import re
max_s = 0
max_t = 0
get = 0

for word in s:
    max_s = len(re.findall(word, str_s))
    max_t = len(re.findall(word, str_t))
    if(get < max_s - max_t):
        get = max_s - max_t

print(get)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for j in range(M)]
print(s)
print(t)
newlist =s + t
print(newlist)
count = 0
for k in (newlist):
    if k == s:
        print(k)
        count +=1
    if k == t:
        count += -1
    print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

words = []

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

M = int(input())

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

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

print(max_money)

Submission status: Wrong Answer

Solution code:
N = int(input())

words = []

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

M = int(input())

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

print(blue_cards)
print(red_cards)

max_money = -100
for word in words:
  get_money, lose_money = 0, 0
  if word in blue_cards:
    get_money = blue_cards[word]
  if word in red_cards:
    lose_money = red_cards[word]
  print("{} {}".format(get_money, lose_money))
  max_money = max(max_money, get_money - lose_money)

print(max_money)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 s:
    if s.count(i) > t.count(i):
        cnt = s.count(i)-t.count(i)
print(cnt)

Submission status: Wrong Answer

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())
    
cnt = {}

for S in s:
    if S not in cnt.keys():
        cnt[S] = 1
    else:
        cnt[S] += 1

for T in t:
    if T not in cnt.keys():
        cnt[T] = -1
    else:
        cnt[T] -= 1
        
print(max(cnt.values()))

Submission status: Wrong Answer

Solution code:
N = input()
n = []
for i in range(N):
    n.append(raw_input())
M = input()
m = []
for i in range(M):
    m.append(raw_input())

result = [n.count(a) - m.count(a) for a in n]
print(max(result))

Submission status: Wrong Answer

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

max_count = -1
flag = -1
for i in range(len(s)):

    #print(s[i],s.count(s[i]),t.count(s[i]))

    if s.count(s[i]) > t.count(s[i]):
        if s.count(s[i]) > max_count:
            max_count = s.count(s[i])
            flag = 1
if flag == -1:
    print(max_count)
else:
    print(0)

Submission status: Wrong Answer

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

max_count = 0
for i in range(len(s)):
    if s.count(s[i]) >= t.count(s[i]):
        if s.count(s[i]) > max_count:
            max_count = s.count(s[i])

print(max_count)

Submission status: Wrong Answer

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

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

max_count = 0
for i in range(len(s)):

    print(s[i],s.count(s[i]),t.count(s[i]))

    if s.count(s[i]) >= t.count(s[i]):
        if s.count(s[i]) > max_count:
            max_count = s.count(s[i])

Submission status: Wrong Answer

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

    if i == 0:
        lst.append([S, 1])
    else:
        for j in range(len(lst)):
            if lst[j][0] == S:
                lst[j][1] += 1
            else:
                lst.append([S, 1])

M = int(input())
for i in range(M):
    S = input()

    if i == 0:
        lst.append([S, -1])
    else:
        for j in range(len(lst)):
            if lst[j][0] == S:
                lst[j][1] -= 1
            else:
                lst.append([S, -1])

ans = -9999
for i in range(len(lst)):
    ans = max(ans, lst[i][1])

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

Submission status: Wrong Answer

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

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

str_list = set(s + t)

X = 0

for i in str_list:
  tmp = 0
  for j in s:
    if i == j:
      X += 1
  for j in t:
    if i == j:
      X -= 1
  if tmp > X:
    X = tmp

print(X)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [input() for i in range(N)]
M = int(input())
b = [input() for i in range(M)]
 
k = []
 
for x in a:
  temp = a.count(x)-b.count(x)
  k.append(temp)
for y in b:
  temp = a.count(y)-b.count(y)
  k.append(temp)
print(max(k))

Submission status: Wrong Answer

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

k = []

for x in a:
  temp = a.count(x)-b.count(x)
  k.append(temp)
print(max(k))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = input()
    s = {}
    for i in range(n):
        a = raw_input()
        if a not in s.keys():
            s[a] = 1
        else:
            s[a] += 1
    m = input()
    t = {}
    for i in range(m):
        a = raw_input()
        if a not in t.keys():
            t[a] = 1
        else:
            t[a] += 1
    m = -10000000
    for a in s.keys():
        if a in t.keys():
            m = max(m, s[a] - t[a])
        else:
            m = max(m, s[a])
    for a in t.keys():
        if a in s.keys():
            m = max(m, s[a] - t[a])
        else:
            m = max(m, -t[a])
    print m

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = input()
    s = {}
    for i in range(n):
        a = raw_input()
        if a not in s.keys():
            s[a] = 1
        else:
            s[a] += 1
    m = input()
    t = {}
    for i in range(m):
        a = raw_input()
        if a not in t.keys():
            t[a] = 1
        else:
            t[a] += 1
    m = -10000000
    for a in s.keys():
        if a in t.keys():
            m = max(m, s[a] - t[a])
        else:
            m = max(m, s[a])
    print m

Submission status: Wrong Answer

Solution code:
n = int(input())
arr1 = [input() for _ in range(n)]
m = int(input())
arr2 = [input() for _ in range(m)]
for _, j in zip(arr1, arr2):
    try:
        arr1.remove(j)
    except:
        pass
d = {i: arr1.count(i) for i in set(arr1)}
print(0) if not d else print(max(d.items(), key=lambda x: x[1])[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
arr1 = [input() for _ in range(n)]
m = int(input())
arr2 = [input() for _ in range(m)]
# print(arr1, arr2)
for i, j in zip(arr1, arr2):
    try:
        arr1.remove(j)
    except:
        pass
# print(arr1, arr2)
d = {i: arr1.count(i) for i in set(arr1)}
# for i in set(arr1):
#     d[i] = arr1.count(i)
try:
    print(max(d.items(), key=lambda x:x[1])[1])
except:
    print("0")

Submission status: Wrong Answer

Solution code:
n = int(input())

arr1 = [input() for _ in range(n)]

m = int(input())

arr2 = [input() for _ in range(m)]
# print(arr1, arr2)

for i, j in zip(arr1, arr2):
    try:
        arr1.remove(j)
    except:
        pass
# print(arr1, arr2)

d = {}
for i in set(arr1):
    d[i] = arr1.count(i)
try:
    print(max(d.items(), key=lambda x:x[1])[1])
except:
    print("0")