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

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict


def solve():
    N = int(input())
    
    A = [input() for _ in range(N)]
    count_A = Counter(A)
    
    M = int(input())
    B = [input() for _ in range(M)]
    count_B = Counter(B)
    for k,v in count_B.items():
        if k in count_A:
            count_A[k] -= v
    
    print(count_A.most_common()[0][1])
    
solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

S_cnt = Counter(S)
S_key = S_cnt.keys()
T_cnt = Counter(T)

for key,v in T_cnt.items():
    if not key in S_key:
        continue
    S_cnt[key] -= v
print(max(S_cnt.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 = [s.count(si) - t.count(si) for si in set(s)]

print(max(ans))

Submission status: Wrong Answer

Solution code:
# blue card: N
N = int(input())
s = [''] * N
for i in range(N):
    s[i] = str(input())

# red card: M
M = int(input())
t = [''] * M
for i in range(M):
    t[i] = str(input())

# max(blueの要素xの重複数　- redの要素xの重複数), xがないときは0
scoreList1 = []
for i in range(N):
    win1 = 0
    lose1 = 0
    if s[i] in s:
        win1 += s.count(s[i])
    if s[i] in t:
        lose1 += t.count(s[i])
    scoreList1.append(win1 - lose1)

scoreList2 = []
for j in range(M):
    win2 = 0
    lose2 = 0
    if t[j] in s:
        win2 += s.count(t[j])
    if t[j] in t:
        lose2 += t.count(t[j])
    scoreList2.append(win2 - lose2)

scoreList = scoreList1 + scoreList2
print(max(scoreList))

Submission status: Wrong Answer

Solution code:
x=[]

n=int(input())
d1={}
for i in range(n):
  s=input()
  x.append(s)
  if s in d1:
    d1[s]+=1
  else:
    d1[s]=1
    
m=int(input())
d2={}
for i in range(m):
  t=input()
  x.append(t)
  if t in d2:
    d2[t]+=1
  else:
    d2[t]=1

ans=0
for s in x:
  cnt=0
  if s in d1:
    cnt+=d1[s]
  if s in d2:
    cnt+=d2[s]
  if ans<cnt:
    ans=cnt

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
s_cards = [input() for _ in range(N)]
M = int(input())
t_cards = [input() for _ in range(M)]

d = defaultdict(int)
for s in s_cards:
    if s not in t_cards:
        d[s] += 1

ans = sorted(d.items(), key=lambda x: -x[1])
if len(ans) > 0:
    print(ans[0][1])
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
n=[str(input()) for i in range(N)]
M=int(input())
m=[str(input()) for i in range(M)]
for i in range(N):
  print(max(0, n.count(n[i-1])-m.count(n[i-1])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

blue=int(input())
blueList = []

for i in range(blue):
  blueList.append(input())

red=int(input())
redList = []

for i in range(red):
  redList.append(input())

dict = defaultdict(int)

for b in blueList:
  dict[b] += 1

for r in redList:
  dict[r] -= 1

max = -10000

for s in dict:
  if dict[s] > max:
    max = dict[s]
  
print(max)

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)


ans = [0]
for key, cont in S.most_common():
  if cont > T[key]:
    ans.append(cont)
print(max(ans))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
s = []
for _ in range(N):
    s.append(input().rstrip())
M = int(input())
t = []
for _ in range(M):
    t.append(input().rstrip())
from collections import Counter
cs = Counter(s)
ct = Counter(t)
ans = {}
for i in cs.keys():
    ans[i] = cs[i] - ct[i]
print(max(ans.values()))

Submission status: Wrong Answer

Solution code:
ans={}
n=int(input())
for i in range(n):
    a = input()
    if a in ans:
        ans[a]+=1
    else:
        ans[a] = 1
m=int(input())
for i in range(m):
    a = input()
    if a in ans:
        ans[a]-=1
    else:
        ans[a] = -1
ans = sorted(ans.items(), key=lambda x: x[1], reverse=True)
print(ans[0][1])

Submission status: Wrong Answer

Solution code:
ans={}
n=int(input())
for i in range(n):
    a = input()
    if a in ans:
        ans[a]+=1
    else:
        ans[a] = 1
m=int(input())
for i in range(m):
    a = input()
    if a in ans:
        ans[a]-=1
    else:
        ans[a] = -1
ans = sorted(ans.items(), key=lambda x: x[1], reverse=True)
print(ans[0][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)]

n = []
for i in range(N):
  S = s.count(s[i])
  T = t.count(s[i])
  n.append(S - T)

if len(s) == 1 and t.count(s[0]) == M:
  print(0)
else:
  print(max(n))

Submission status: Wrong Answer

Solution code:
a = int(input())
A = [input() for _ in range(a)]
b = int(input())
B = [input() for _ in range(b)]
count = 0
for i in B:
  if i in A:
    pass
  else:
    count+= 1
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=[input() for i in range(n)]
m=int(input())
b=[input() for i in range(m)]
ca = Counter(a)
cb = Counter(b)
ans = []
for s,n in ca.items():
  ans.append(n-cb[s])
print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

ss = []
for _ in range(N):
    ss.append(input())

M = int(input())


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

ans = 1
for s in ss:
    ans = max(ans, ss.count(s) - ts.count(s))

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
blues = []
for i in range(n):
  blues.append(input())
m = int(input())
reds = []
for j in range(m):
  reds.append(input())
pairs = {}
count = 0
count_b = 0
count_r = 0
for k in blues:
  count_b = blues.count(k)
  for l in reds:
    count_r = reds.count(l)
    if k == l:
      count = count_b - count_r
    else:
      count = count_b
  pairs[count] = k
sorted_pairs = sorted(pairs.items(),key = lambda x:x[0],reverse = True)
answer = sorted_pairs[0][0]
if answer < 0:
  answer = 0
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
blues = []
for i in range(n):
  blues.append(input())
m = int(input())
reds = []
for j in range(m):
  reds.append(input())
pairs = {}
count = 0
count_b = 0
count_r = 0
for k in blues:
  count_b = blues.count(k)
  for l in reds:
    count_r = reds.count(l)
    if k == l:
      count = count_b - count_r
    else:
      count = count_b
  pairs[count] = k
sorted_pairs = sorted(pairs.items(),key = lambda x:x[0],reverse = True)
answer = sorted_pairs[0][0]
print(answer)

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

result=max(s.count(i)-t.count(i) for i in l)

print(result)

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

result=max(s.count(i)-t.count(i) for i in s)

print(result)

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

n_num = 0
m_num = 0
x = []
y = []

for i in range(N):
    n_num = s.count(s[i])
    m_num = t.count(s[i]) * -1
    x.append(n_num + m_num)


for j in range(M):
    n_num = s.count(t[j])
    m_num = t.count(t[j]) * -1
    y.append(n_num + m_num)

ans = x + y
print(max(ans))

Submission status: Wrong Answer

Solution code:
dict_ = dict()
[exec("dict_['{0}'] = dict_.get('{0}', 0) + 1".format(input())) for _ in range(int(input()))]
[exec("dict_['{0}'] = dict_.get('{0}', 0) - 1".format(input())) for _ in range(int(input()))]
print(max(dict_.values()))

Submission status: Wrong Answer

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

lst = []
lst.extend(nlst)
lst.extend(mlst)

lst = set(lst)

c = [nlst.count(i) - mlst.count(i) for i in lst]
print(max(c))

Submission status: Wrong Answer

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

ls_u =ls_s + ls_t
p = m + n 

ans = 0

for i in range(n):
    cnt = 0
    for j in range(p):
        if ls_u[i] == ls_u[j] and j < n - 1:
            cnt += 1
        elif ls_u[i] == ls_u[j] and n - 1 <= j:
            cnt += -1
    if cnt >= ans:
        ans = cnt

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s, t = [],[]
for _ in range(n):
    s.append(input())
s_dict = {s_:0 for s_ in s}
m = int(input())
for _ in range(m):
    t.append(input())
t_dict = {t_:0 for t_ in t}
for i in range(n):
    s_dict[s[i]] += 1
for i in range(m):
    t_dict[t[i]] += 1
    
for i in s_dict:
    if i in t_dict:
        s_dict[i] -= t_dict[i]
        
max(s_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 blue in s:
  if s.count(blue) > t.count(blue):
    ans = s.count(blue) - t.count(blue)
print(ans)

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)]
S.sort()
result=0

for i in range(N):
	if i<N-1 and S[i]!=S[i+1]:
		if S.count(S[i])-T.count(S[i])>result:
			result=S.count(S[i])-T.count(S[i])
	elif i==N-1 and S[i]!=S[i-1] and S.count(S[i])-T.count(S[i])>result:
		result=S.count(S[i])-T.count(S[i])
print(result)

Submission status: Wrong Answer

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

print(len(s-t))

Submission status: Wrong Answer

Solution code:
N = int(input())
dic = {}
for i in range(N):
  s = input()
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1
M = int(input())
for i in range(M):
  s = input()
  if s not in dic:
    dic[s] = -1
  else:
    dic[s] -= 1
print(max(list(dic.values())))

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)]
min = 0
for i in range(n):
    max = a.count(a[i])-b.count(a[i])
    if max >= min:
        min = max
    else:
        pass
print(max)

Submission status: Wrong Answer

Solution code:
N = int(input())

card = {}
for i in range(N):
    tmp = input()
    if tmp in card:
        card[tmp] += 1
    else:
        card[tmp] = 1
        
M = int(input())
for i in range(M):
    tmp = input()
    if tmp in card:
        card[tmp] -= 1
 
print(max(card.values()))

Submission status: Wrong Answer

Solution code:
def examB():
    N = I(); s = [S() for _ in range(N)]
    M = I(); t = [S() for _ in range(M)]
    d = defaultdict(int)
    for l in s:
        d[l] +=1
    for l in t:
        d[l] -=1
    ans = max(d.values())
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [1]
for _ in range(n) :
    s += [input()]
m = int(input())
t = []
for _ in range(m) :
    t += [input()]
wordlist = list(set(s))
s_countdict = {word : s.count(word) for word in wordlist}
t_countdict = {word : t.count(word) for word in wordlist}
pointlist = [s_countdict[word] - t_countdict[word] for word in wordlist]
print(max(pointlist))

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

sCount = {}
for s in S:
    sCount[s] = S.count(s)

tCount = {}
for t in T:
    tCount[t] = T.count(t)

union = sCount.keys() & tCount.keys()
ans = sCount;
for i in union:
    ans[i] = sCount[i] - tCount[i]
    
print(max(ans.values()))

Submission status: Wrong Answer

Solution code:
b = [input() for i in range(int(input()))]
r = [input() for i in range(int(input()))]
o = 0
for w in list(set(b)):
  o = max(0, b.count(w) - r.count(w))
  
print(o)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
result=0
for i in range(n):
    result=max(0,s.count(s[i])-t.count(s[i]))
print(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)]
result=0
for i in range(n):
    result=s.count(s[i])-t.count(s[i])
    result=max(0,result)
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = {}
ans = -1000
for _ in range(N):
  s = input()
  if s in l:
    l[s] = l[s] + 1
  else:
    l[s] = 1
M = int(input())
for _ in range(M):
  s = input()
  if s in l:
    l[s] = l[s] - 1
for v in l.values():
  ans = max(ans, v)
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)]

d = {}
for i in s:
    d[i] = d.get(i, 0)+1
for i in t:
    d[i] = d.get(i, 0)-1
ans = sum([i for i in d.values() if i>0])
print(ans)

Submission status: Wrong Answer

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-06 22:04:18(JST)
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        a.update({s: a.get(s, 0) - c})

    ma = max(max(a.values()), 0)
    print(ma)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Wrong Answer

Solution code:
blue_list = []
red_list = []


n = int(input())
for i in range(n):
    a = input()
    blue_list.append(a)

m = int(input())
for i in range(m):
    b = input()
    red_list.append(b)

if red_list[0] == red_list[-1] and blue_list[0] ==  blue_list[-1] and blue_list[0] == red_list[0] and len(blue_list) <= len(red_list):
    print(0)
    exit()

blue_list.sort()
red_list.sort()

count = 0
score = 1
while count != n-1:
    for i in range(n-1):
        blue_count = 1
        if blue_list[i] == blue_list[i+1]:
            blue_count += 1
        else:
            for j in range(m):
                if blue_list[i] == red_list[j]:
                    blue_count -= 1
        if blue_count >= score:
            score = blue_count
        count += 1

print(score)

Submission status: Wrong Answer

Solution code:
blue_list = []
red_list = []


n = int(input())
for i in range(n):
    a = input()
    blue_list.append(a)

m = int(input())
for i in range(m):
    b = input()
    red_list.append(b)

if red_list[0] == red_list[-1] and blue_list[0] ==  blue_list[-1] and blue_list[0] == red_list[0]:
    print(0)
    exit()

blue_list.sort()
red_list.sort()

count = 0
score = 1
while count != n-1:
    for i in range(n-1):
        blue_count = 1
        if blue_list[i] == blue_list[i+1]:
            blue_count += 1
        else:
            for j in range(m):
                if blue_list[i] == red_list[j]:
                    blue_count -= 1
        if blue_count >= score:
            score = blue_count
        count += 1

print(score)

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

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

    if output > tmp_s - tmp_t:
        output = tmp_s - tmp_t

print(output)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(max(bd.values()))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [input(_) for _ in range(n)]
m = int(input())
t = [input(_) for _ in range(m)]
l = set(s) - set(t)
print(len(l))

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 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)]
l =[0]*n
for j in range(n):
  a = s.count(s[j])
  b = s.count(s[j])
  l[j] = a-b
print(max(max(l),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)]
l =[0]*n
for j in range(n):
  a = s.count(s[j])
  b = s.count(s[j])
  l[j] = a-b
print(max(l))

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

Submission status: Wrong Answer

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

for i in range(len(s)):
    cnt.append(s.count(s[i]) - t.count(s[i]))
print(max(cnt))

Submission status: Wrong Answer

Solution code:
import numpy as np

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 = np.unique(s, return_counts=True)
#t = np.unique(t, return_counts=True)

ans = 0
#for i,ch_s in enumerate(s[0]):
#  ans_tmp = s[1][i]
#  for j,ch_t in enumerate(t[0]):
#    if ch_s == ch_t:
#      ans_tmp -= t[1][j]
#  if ans_tmp > ans:
#    ans = ans_tmp
print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
blues = [input() for _ in range(n)]
m = int(input())
reds = [input() for _ in range(m)]
words = set(blues)
_max = 0
for w in words:
    score = 0
    score += blues.count(w)
    score -= reds.count(w)
    print(w, score)
    if _max < score:
        _max = score
print(_max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
print(max(scores))

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)]
point = 0
lst = list(set(s))

for i in range(len(lst)):
  tmp = s.count(lst[i]) - t.count(lst[i])
  if tmp > point:
    point = tmp

print(tmp)

Submission status: Wrong Answer

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

point = 0
for i in range(len(set(s))):
    tmp = s.count(s[i]) - t.count(s[i])
    if tmp > point:
        point = tmp
        ans = i
print(point)

Submission status: Wrong Answer

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

set_s = list(set(s))
print( max(s.count(set_s[i])-t.count(set_s[i]) for i in range(len(set_s))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

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

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

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)]
c=[a.count(a[i])-b.count(a[i]) for i in range(n)]
print(max(c))

Submission status: Wrong Answer

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

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_dict = {}
for si in s:
    cnt_dict[si] = 0
for ti in t:
    cnt_dict[ti] = 0
for si in s:
  	cnt_dict[si] += 1
for ti in t:
    cnt_dict[ti] -= 1
print(max(cnt_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)]
cnt_dict = {}
for si in s:
    cnt_dict[si] = 0
for ti in t:
    cnt_dict[ti] = 0
for si in s:
  	cnt_dict[si] += 1
for ti in t:
    cnt_dict[ti] -= 1
score = 0
for cnt in cnt_dict.values():
    if cnt > 0:
        score += cnt
print(score)

Submission status: Wrong Answer

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

Submission status: 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 i in s:
    ans = max(ans, s.count(i) - t.count(s))
print(ans)

Submission status: Wrong Answer

Solution code:
blue_list = []
red_list = []
cnt = 0

N = int(input())
for _ in range(N):
  blue_list.append(input())
M = int(input())
for _ in range(M):
  red_list.append(input())
  
for word in blue_list:
  if word in red_list:
    pass
  else:
    cnt+=1
    
print(cnt)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

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

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

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

print(max(l))

Submission status: Wrong Answer

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

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

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

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