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 = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i])))  for i in range(len(l)))

Submission status: Wrong Answer

Solution code:
N = int(input())
blue_cards = [input() for _ in range(N)]
M = int(input())
red_cards = [input() for _ in range(M)]
ans = 0

for i in blue_cards:
    a = blue_cards.count(i)
    b = red_cards.count(i)
    ans = a - b

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

Submission status: Wrong Answer

Solution code:
N = int(input())
C = {}
for _ in range(N):
    a = input().strip()
    if a not in C:
        C[a] = 0
    C[a] += 1
M = int(input())
for _ in range(M):
    a = input().strip()
    if a not in C:
        C[a] = 0
    C[a] -= 1
cmax = -100
for a in C:
    cmax = max(cmax,C[a])
print(cmax)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
g = [input() for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

b = int(input())
g2 = [input() for _ in range(b)]

g.sort()
g2.sort()

count=1
ans={}
ans2={}

for i in range(len(g)-1):
    if g[i+1]==g[i]:
        count+=1
    else:
        ans[g[i]]=count
        count=1

ans[g[-1]]=count
count=1
for i in range(len(g2)-1):
    if g2[i+1]==g2[i]:
        count+=1
    else:
        if g2[i] in ans.keys():
            ans[g2[i]]-=count
            count=1
        else:
            ans[g2[i]]=count

if g2[-1] in ans.keys():
    ans[g2[-1]]-=count
    count=1
else:
    ans[g2[-1]]=-count

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
g = [input() for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

b = int(input())
g2 = [input() for _ in range(b)]

g.sort()
g2.sort()

count=1
ans={}
ans2={}
if a!=0 and b!=0:
    for i in range(len(g)-1):
        if g[i+1]==g[i]:
            count+=1
        else:
            ans[g[i]]=count
            count=1

    ans[g[-1]]=count
    count=1
    for i in range(len(g2)-1):
        if g2[i+1]==g2[i]:
            count+=1
        else:
            if g2[i] in ans.keys():
                ans[g2[i]]-=count
                count=1
            else:
                ans[g2[i]]=count

    if g2[-1] in ans.keys():
        ans[g2[-1]]-=count
        count=1
    else:
        ans[g2[-1]]=count

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
g = [input() for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

b = int(input())
g2 = [input() for _ in range(b)]

g.sort()
g2.sort()

count=1
ans={}
ans2={}

for i in range(len(g)-1):
    if g[i+1]==g[i]:
        count+=1
    else:
        ans[g[i]]=count
        count=1

ans[g[-1]]=count
count=1
for i in range(len(g2)-1):
    if g2[i+1]==g2[i]:
        count+=1
    else:
        if g2[i] in ans.keys():
            ans[g2[i]]-=count
            count=1
        else:
            ans[g2[i]]=count

if g2[-1] in ans.keys():
    ans[g2[-1]]-=count
    count=1
else:
    ans[g2[-1]]=count

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
for i in range(int(input())):
  s = input()
for j in range(int(input())):
  t = input()
               
c = Counter(s)

for i in t:
  if i in c:
    c[i] -=1
    
print(max(0,c.most_common()[0][1]))

Submission status: Wrong Answer

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

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

st_dict = {}

for i in range(N):
    if s[i] not in st_dict.keys():
        st_dict[s[i]] = 1
    else:
        st_dict[s[i]] += 1
for i in range(M):
    if t[i] not in st_dict.keys():
        st_dict[t[i]] = -1
    else:
        st_dict[t[i]] -= 1

print(max(st_dict.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)]

T1 = [x+'*' for x in T]
arr = S + T1
list1 = []
list2 = []
for i in range(len(arr)):
  if arr[i] not in list2:
    s = arr.count(arr[i])
    t = arr.count(arr[i]+'*')
    a = s-t
    list1.append((arr[i], a))
    list2.append(arr[i])

for i in list1:
  
  if i[0].endswith('*'):
    list1.remove(i)
  print(list1)

ans1 = max(list1, key= lambda x:x[1])

if int(ans1[1]) <= 0:
  print(0)
else:
  print(ans1[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = [None] * n
for i in range(n):
    s[i] = input().rstrip()

m = int(input())
t = [None] * m
for i in range(m):
    t[i] = input().rstrip()

ctr = Counter(s) - Counter(t)
if ctr:
    print(ctr.most_common(1)[0][0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
blue_cards = [input() for _ in range(n)]
m = int(input())
red_cards = Counter([input() for _ in range(m)])

sources = set(blue_cards)
blue_cards = Counter(blue_cards)

result = -1
for x in sources:
  tmp = blue_cards[x]
  
  if x in red_cards:
    tmp -= red_cards[x]
  
  result = max(result, tmp)
  
print(0 if len(blue_cards) == len(red_cards) == 1 else 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)]

ans_list = []
for s in S:
  ans = 0
  ans += S.count(s)
  ans -= T.count(s)
  ans_list.append(ans)

print(max(ans_list))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict

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

d=defaultdict(int)
for x in s:
  d[x]+=1
for y in t:
  d[y]-=1

print(max(d.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())
from collections import Counter
s=Counter(s)
t=Counter(t)
ans=-1000000
for i in s:
  ans=max(ans,s[i]-t.get(i,0))
for i in t:
  ans=max(ans,-t[i]+s.get(i,0))


print(ans)

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

Submission status: Wrong Answer

Solution code:
n = int(input())


dic_blue = {}
for i in range(n):
    a = str(input())
    if a in dic_blue:
        dic_blue[a] += 1
    else:
        dic_blue[a] = 1

m = int(input())
dic_red = {}
for i in range(m):
    b = str(input())
    if b in dic_red:
        dic_red[b] += 1
    else:
        dic_red[b] = 1

total_list = []
for j in dic_blue.keys():
    total = 0
    if j in dic_red:
        total = dic_blue[j] - dic_red[j]
        total_list.append(total)
    else:
        total = dic_blue[j]
        total_list.append(total)

print(max(total_list))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as ddf
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]

dd=ddf(lambda:0)
for e in s: dd[e]+=1
for e in t: dd[e]-=1
print(max(dd.values()))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as ddf
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]

dd=ddf(lambda:0)
for e in s: dd[e]+=1
for e in t: dd[e]-=1
cnt=0
for v in dd.values():
  if v>0: cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
cards = {}
for _ in range(int(input())):
  s = input()
  cards[s] = cards.get(s,0)+1
for _ in range(int(input())):
  t = input()
  cards[t] = cards.get(s,0)-1
print(max(max(cards.values()),0))

Submission status: Wrong Answer

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

ans = 0
for w in set(blue_words):
  tmp = blue_words.count(w) - red_words.count(w)
  if tmp > ans:
    ans = tmp
      
if ans < 0:
  print(ans)
else:
  print('0')

Submission status: Wrong Answer

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

for k, j in t.items():
    if k in s:
        s[k] -= j

values, counts = zip(*s.most_common())
print(counts[0])

Submission status: Wrong Answer

Solution code:
N_1 = int(input())
A = [str(input()) for i in range(N_1)]
N_2 = int(input())
B = [str(input()) for i in range(N_2)]

C = A+B
D = list(set(C))
E=[]
for i in range(len(D)):
    NN = A.count(D[i]) - B.count(D[i])
    E.append(NN)
print(max(E))

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)]
S = list(set(s))
T = list(set(t))
print(S,T)
b = []
for x in range(len(S)):
  a = s.count(S[x]) - t.count(S[x])
  b.append(a)
ans = max(0, max(b))
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)]
S = list(set(s))
T = list(set(t))

for x in range(len(S)):
  a = s.count(S[x]) - t.count(S[x])
  ans = max(0, a)
print(ans)

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)]
dic_s = {}
for i in set(s):
    dic_s[i] = s.count(i) 
dic_t = {}
for i in set(t):
    dic_t[i] = t.count(i)
ss=set(s)
ts=set(t)
if(ss & ts == set()):
    print(max(dic_s.values()))
else:
    dic_c = {}
    for i in ss&ts:
        dic_c[i] = dic_s[i] - dic_t[i]
    if(not ss & (ss^ts)):
        for i in ss & (ss^ts):
            dic_c[i] = dic_s[i]
    if(max(dic_c.values()) < 0):
        print(0)
    else:
        print(max(dic_c.values()))

Submission status: Wrong Answer

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)
smax = S.most_common()[0]
tmin = T.most_common()[::-1][0]
if smax[0] == tmin[0]:
    if len(S) != 1:
        print(1)
    else:
        print(0)
else:
    print(smax[1] - T[smax[0]])

Submission status: Wrong Answer

Solution code:
N = int(input())

p_names = []
p_count = []
for n in range(N):
    p_count.append(0)

for n in range(N):
    tmp = input()
    if tmp in p_names:
        index = p_names.index(tmp)
        p_count[index] += 1
    else:
        p_names.append(tmp)
        index = p_names.index(tmp)
        p_count[index] += 1
        
M = int(input())
for m in range(M):
    tmp = input()
    if tmp in p_names:
        index = p_names.index(tmp)
        p_count[index] -= 1
    else:
        continue

print(max(p_count))

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)]
dict={}

for i in s:
  if i not in dict.keys():
    dict[i]=1
  else:
    dict[i]+=1
for j in t:
  if j in s:
    dict[j]-=1
print(max(dict.values()))

Submission status: Wrong Answer

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(N):
    if S.count(S[i]) >= T.count(S[i]):
        ans = S.count(S[i]) - T.count(S[i])
print(ans)

Submission status: Wrong Answer

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

print(sum([1 for x in s if not x in t]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
from sys import maxsize

# input
N = int(input())
S = Counter([input() for i in range(N)])
M = int(input())
T = Counter([input() for j in range(M)])

# check
max_cnt = -maxsize
for s in S.keys():
    cnt = S[s]
    if s in T.keys():
        cnt -= T[s]

    if max_cnt < cnt:
        max_cnt = cnt

print(max_cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from sys import maxsize

# input
N = int(input())
S = Counter([input() for i in range(N)])
M = int(input())
T = Counter([input() for j in range(M)])

# check
max_cnt = -maxsize
for s in S.keys():
    cnt = S[s]
    if s in T.keys():
        cnt -= T[s]

    if max_cnt < cnt:
        max_cnt = cnt

print(max)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = dict()
for _ in range(n):
  temp = input()
  try:
    s[temp] += 1
  except:
    s[temp] = 1

m = int(input())

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


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

print(s[0][1])

Submission status: Wrong Answer

Solution code:
N=int(input())
plus=[input() for i in range(N)]
M=int(input())
minus=[input() for i in range(M)]
S=list(set(plus+minus))
ans=[]
for i in S:
    point=0
    point=plus.count(i)-minus.count(i)
    ans.append(point)
print(max(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
plus=[input() for i in range(N)]
M=int(input())
minus=[input() for i in range(M)]
S=list(set(plus+minus))
ans={}
for i in S:
    point=0
    point=plus.count(i)-minus.count(i)
    ans[point]=i
print(max(ans.keys()))

Submission status: Wrong Answer

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

m = int(input())
for i in range(m):
    ti = input()
    s[ti] -= 1

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

Submission status: Wrong Answer

Solution code:
# Problem: https://atcoder.jp/contests/abc091/tasks/abc091_b
# Python 1st Try

import sys
from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(plusCardNum, plusCards, minusCardNum, minusCards):
    result = 0
    selectString = defaultdict(int)
    for j in range(plusCardNum):
        print("{}".format(plusCards[j]))
        selectString[plusCards[j]] = selectString[plusCards[j]] + 1
    for j in range(minusCardNum):
        selectString[minusCards[j]] = selectString[minusCards[j]] - 1
    keyList = list(selectString.keys())
    for j in range(0, len(keyList)):
        if result < selectString.get(keyList[j]):
            result = selectString.get(keyList[j])
    return result


if __name__ == "__main__":
    N = II()
    NList = []
    for _ in range(0, N, +1):
        NList.append(input())
    M = II()
    MList = []
    for _ in range(0, M, +1):
        MList.append(input())
    print("{}".format(solver(N, NList, M, MList)))

Submission status: Wrong Answer

Solution code:
# Problem: https://atcoder.jp/contests/abc091/tasks/abc091_b
# Python 1st Try

import sys
from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(plusCardNum, plusCards, minusCardNum, minusCards):
    result = 0
    selectString = defaultdict(int)
    for j in range(plusCardNum):
        print("{}".format(plusCards[j]))
        selectString[plusCards[j]] = selectString[plusCards[j]] + 1
#    print("{}".format(selectString))
    for j in range(minusCardNum):
        selectString[minusCards[j]] = selectString[minusCards[j]] - 1
    # algorithm
#    print("{}".format(selectString))
    keyList = list(selectString.keys())
#    valueList = list(selectString.values())
    for j in range(0, len(keyList)):
        if result < selectString.get(keyList[j]):
            result = selectString.get(keyList[j])
    #  for j in range(0,len(selectString):
    #    point = selectString[0]

    return result


if __name__ == "__main__":
    N = II()
    NList = []
    for _ in range(0, N, +1):
        NList.append(input())
    M = II()
    MList = []
    for _ in range(0, M, +1):
        MList.append(input())
    print("{}".format(solver(N, NList, M, MList)))

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

ANS = []
for i in range(len(S)):
  p = 0
  q = 0
  for j in range(len(S)):
    if S[i]== S[j]:
      p += 1
  for k in range(len(T)):
    if S[i] == T[k]:
      q += -1
  ANS.append(p+q)

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

ANS = []
for i in range(len(S)):
  p = 0
  q = 0
  for j in range(len(S)):
    if S[i]== S[j]:
      p += 1
  for k in range(len(T)):
    if S[i] == T[k]:
      q += -1
  ANS.append(p+q)

print(S)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
A = []
B = []
for s in S:
    if s not in A:
        B.append(S.count(s)-T.count(s))
        A.append(s)
print(max(B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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():
    tmp = 0
    tmp += v
    for k2, v2 in T.items():
        if k2 == k:
            tmp -= v2
        ans = max(ans, tmp)
            
print(ans)

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=[]
for i in set(s):
    ans.append(s.count(i)-t.count(i))
print(max(ans))

Submission status: Wrong Answer

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

S=list(set((s)))
T=list(set((t)))
n=len(S)
ans=0
for i in range(n):
  if s.count(s[i])-t.count(s[i])>ans:
    ans=s.count(s[i])-t.count(s[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
b=[]
ans=0

for i in range(n):
    a.append(input())
m=int(input())
for i in range(m):
    b.append(input())
for i in a:
    if i not in b:
        ans=max(ans,a.count(i))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
worddict = {}
for i in range(N):
  s = input()
  if s in worddict:
    worddict[s] += 1
  else:
    worddict[s] = 1
    
M = int(input())
for i in range(M):
  t = input()
  if t in worddict:
    worddict[t] -= 1
    
maxyen = 0
for i in worddict:
  maxyen = max(maxyen, worddict[i])

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)]
ss=set(s)
ans = [1]
for i in ss:
  ans.append(s.count(i)-t.count(i))
print(max(ans))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
b=[input() for i in range(n)]
m=int(input())
r=[input() for i in range(m)]
ans=[]
for i in set(b):
    ans.append(b.count(i)-r.count(i))
print(max(ans))

Submission status: Wrong Answer

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

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

t = list()
m = int(input())

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

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(counter.values()))

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
def resolve():
    N,=pin()
    S=[input() for i in range(N)]
    S.sort()
    M,=pin()
    T=[input() for j in range(N)]
    T.sort()
    for t in T:
        try:S.remove(t)
        except:pass
    n=len(S)
    #print(S)
    if n<2:print(n);return
    else:
        temp=1
        ans=1
        for i in range(1,n):
            if S[i]==S[i-1]:temp+=1
            else:ans=max(temp,ans);temp=1
        print(ans)
                
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
def resolve():
    N,=pin()
    S=[input() for i in range(N)]
    S.sort()
    M,=pin()
    T=[input() for j in range(N)]
    T.sort()
    for t in T:
        try:S.remove(t)
        except:pass
    temp=1
    ans=1
    if len(S)==0:ans=0
    for k in range(1,len(S)):
        try:
            if S[k]==S[k-1]:
                temp+=1
            else:
                ans=max(ans,temp)
                temp=1
        except :pass
    print(ans)
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter
    n = int(input())
    s = [input() for _ in range(n)]
    cs = Counter(s)
    m = int(input())
    t = [input() for _ in range(m)]
    print(max(0,cs.most_common()[0][1] - t.count(cs.most_common()[0][0])))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter
    n = int(input())
    s = [input() for _ in range(n)]
    cs = Counter(s)
    m = int(input())
    t = [input() for _ in range(m)]
    print(cs.most_common()[0][1] - t.count(cs.most_common()[0][0]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

C = []  
for i in range(N):
  count = 0
  for j in range(N):
    if S[i] == S[j]:
      count = count + 1
  for k in range(M):
    if S[i] == T[k]:
      count = count -1
  C.append(count)

print(max(C))

Submission status: Wrong Answer

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

S = list(set(S))
T = list(set(T))
count = 0
for i in range(len(S)):
  for j in range(len(T)):
    if S[i] != T[j]:
      count = count + 1
      
print(count)

Submission status: Wrong Answer

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

sc = Counter(s)
tc = Counter(t)
ns = len(sc)
ans = 0
print(ns)
for i in range(ns):
  key = sc.most_common()[i][0]
  print(key,sc[key],tc[key])
  if key in tc:
    ans = max(sc[key] - tc[key],ans)
  else:
    ans = max(sc[key],ans)
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)]
l=list(set(s))
print(l)
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))

Submission status: Wrong Answer

Solution code:
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
N = len(list(set(n)))
M = len(list(set(m)))
print(abs(N-M))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)
###################################################

def main():
    n=int(input())
    dic=defaultdict(int)
    for a in range(n):
        dic[input()]+=1
    m=int(input())
    for a in range(m):
        dic[input()]-=1
    mmax=-inf
    for a in dic.values():
        mmax=max(mmax,a)
    print(mmax)
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter as cnt
b = cnt([input() for _ in range(int(input()))])
r = cnt([input() for _ in range(int(input()))])
a = -10**3
for l in b.keys(): a = max(a,b[l]-r[l])
for l in r.keys(): a = max(a,b[l]-r[l])
print(a)

Submission status: Wrong Answer

Solution code:
from collections import Counter as cnt
b = cnt([input() for _ in range(int(input()))])
r = cnt([input() for _ in range(int(input()))])
a = -10**3
for l in b.keys(): a = max(a,b[l]-r[l])
print(a)