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())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
aa = list(set(a))
cnt = []
for i in aa:
  if b.count(i) >= 1:
    cnt.append(a.count(i)-b.count(i))
  else:
    cnt.append(a.count(i))
print(max(cnt))

Submission status: Wrong Answer

Solution code:
n = int(input())
si = [input() for i in range(n)]
m = int(input())
ti = [input() for i in range(m)]
sik = set(si) # 固有の値のみを抽出
tik =set(ti)
s=0
for i in sik:
    if si.count(i) > ti.count(i):
        s += si.count(i) - ti.count(i)
print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
si = [input() for i in range(n)]
m = int(input())
ti = [input() for i in range(m)]
sik = set(si) # 固有の値のみを抽出
tik =set(ti)
s=0
for i in sik:
    if si.count(i) > ti.count(i):
        s += 1
print(s)

Submission status: Wrong Answer

Solution code:
nblues = int(input())
profits = dict()
for _ in range(nblues):
    word = input().rstrip("\n")
    profits[word] = profits.get(word, 0) + 1

nreds = int(input())
for _ in range(nreds):
    word = input().rstrip("\n")
    profits[word] = profits.get(word, 0) - 1

print(max(profits.items(), key=lambda t: t[1])[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
blue = {}
for _ in range(n):
  s = input()
  if(s in blue):
    blue[s] += 1
  else:
    blue[s] = 1
m = int(input())
red = {}
for _ in range(m):
  t = input()
  if(t in red):
    red[t] += 1
  else:
    red[t] = 1
res = -100
for key, value in blue.items():
  tmp = 0
  if(key in red):
    tmp = blue[key] - red[key]
  else:
    tmp = blue[key]
  if(tmp > res):
    res = tmp
if(res >= 0):
  print(res)
else:
  print("kkanazaw")

Submission status: Wrong Answer

Solution code:
n = int(input())
blue = {}
for _ in range(n):
  s = input()
  if(s in blue):
    blue[s] += 1
  else:
    blue[s] = 1
m = int(input())
red = {}
for _ in range(m):
  t = input()
  if(t in red):
    red[t] += 1
  else:
    red[t] = 1
res = -100
for key, value in blue.items():
  tmp = 0
  if(key in red):
    tmp = blue[key] - red[key]
  else:
    tmp = blue[key]
  if(tmp > res):
    res = tmp
print(res)

Submission status: Wrong Answer

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

RedN = int(input())
RedList = []
for i in range(0,RedN):
  RedList.append(input())

stocker = 0

for i in set(BlueList):
  if BlueList.count(i) * 1 + RedList.count(i) * -1 >= stocker:
    stocker = BlueList.count(i)

print(stocker)

Submission status: Wrong Answer

Solution code:
l=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
n=set(l)
h=max([l.count(i)-m.count(i) for i in n])
print(h)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

a =defaultdict (int)

for i in range (int(input())):
  a[input()]+=1
for j in range(int(input())):
  a[input()]-=1

print(sorted(list(a.items()),key=lambda x: -x[1])[0][1])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

a =defaultdict (int)

for i in range (int(input())):
  a[input()]+=1
for j in range(int(input())):
  a[input()]-=1

print(sorted(list(a.items()),key=lambda x: -x[1])[0][0])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

a =defaultdict (int)

for i in range (int(input())):
  a[input()]+=1
for j in range(int(input())):
  a[input()]-=1

print(sorted(list(a.items()),key=lambda x: -x[1])[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for j in range(m)]
words = list(set(s + t))
if len(words) == 1:
    print(max([len(s)-len(t), 0]))
else:
    print(max(s.count(words[i]) - t.count(words[i]) for i in range(len(words))))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for j in range(m)]
words = list(set(s + t))
if len(words) == 1:
    print(max(len(s)-len(t), 0))
else:
    print(max(s.count(words[i]) - t.count(words[i]) for i in range(len(words))))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for j in range(m)]
words = list(set(s + t))
if len(words) == 1:
    print(0)
else:
    print(max(s.count(words[i]) - t.count(words[i]) for i in range(len(words))))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for j in range(m)]
words = list(set(s + t))
print(max(s.count(words[i]) - t.count(words[i]) for i in range(len(words))))

Submission status: Wrong Answer

Solution code:
a = int(input())
b = [input() for i in range(a)]
c = int(input())
d = [input() for j in range(c)]
g = [0]*a
t = 0
for k in b:
    e = b.count(k)
    f = d.count(k)
    g[t] = e - f
    t +=1
print(max(g))

Submission status: Wrong Answer

Solution code:
nN = int(input())
 
sListA = []
nListA = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
 
    
nN = int(input())
sListB = []
nListB = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] -= 1
 
nMax = max(nListA)

print(nMax)

Submission status: Wrong Answer

Solution code:
nN = int(input())
 
sListA = []
nListA = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
 
    
nN = int(input())
sListB = []
nListB = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListB[nTmp] -= 1
 
nMax = max(nListA)
print(nMax)

Submission status: Wrong Answer

Solution code:

nN = int(input())

sListA = []
nListA = [ 0 for i in range(nN)]

for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1

    
nN = int(input())
sListB = []
nListB = [ 0 for i in range(nN)]

for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListB[nTmp] -= 1

nMax =max(nListA)
print(nListA)

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)]
ansmx= -100
ans=0

strset =set(s+t)
strlist = list(strset)

for i in range(len(strlist)):
    str1=strlist[i]
    ans = s.count(str1)-t.count(str1)
    if ans>ansmx:
        ansmx = ans
if ans <0:
    print(0)
else:
    print(ansmx)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
words = []
for _ in range(N):
  words.append(('plus', input()))
M = int(input())
for _ in range(M):
  words.append(('minus', input()))
ans = 0
for i in range(N):
  point = 1
  for j in range(N+M):
    if words[i][1] == words[j][1]:
      if words[j][0] == 'plus':
        point += 1
      else:
        point -= 1
  ans = max(ans, 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)]
li=[]
for word in S:
  s=S.count(word)
  t=T.count(word)
  li.append(s-t)
print(max(li))

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 w in s:
    ans = max(ans, s.count(w) - 2 * t.count(w))

print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(input() for i in range(a))
c = int(input())
d = list(input() for i in range(c))
e = list()

for s in b:
  e.append(b.count(s)-d.count(s))
else:
  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 i in range(M)]

Scores = []
for s in S:
  score = len([s2 for s2 in S if s == s2])
  score -= len([s2 for s2 in T if s == s2])
  Scores.append(score)
print(max(Scores))

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

c1 = Counter(s)
c2 = Counter(t)
print(max(v - c2[i] for i, v in c1.most_common()))

Submission status: Wrong Answer

Solution code:
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()
  
p = {si: s.count(si) for si in set(s)}
for ti in t:
  if ti in p:
    p[ti] -= 1
print(max(p.values()))

Submission status: Wrong Answer

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

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

ans = 0

for i in range(min(n, m)):
    name = s[i]
    count = s.count(name) - t.count(name)
    if count > ans:
        ans = count

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
ls = []
for i in range(n):
    s = input()
    ls.append(s)
m = int(input())
lt = []
for i in range(m):
    t = input()
    lt.append(m)

ans = 0
for i in set(ls):
    sum = ls.count(i) - lt.count(i)
    if sum > ans:
        ans = sum
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]
 
from collections import defaultdict
 
d = defaultdict(int)
 
for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1
 
print(max(d.values()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
d = dict()

def getv(a):
  M = int(input())
  for x in range(M):
    n = input()
    if d.get(n) is None:
      d[n] = 0
    d[n] += a

getv(1)
getv(-1)

print(d[sorted(d, key=lambda x:d[x], reverse=True)[0]])

Submission status: Wrong Answer

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

c = {}
for s in S:
    c[s] = c.get(s, 0) + 1
for t in T:
    c[t] = c.get(t, 0) - 1

print(max(c.values()))

Submission status: Wrong Answer

Solution code:
import collections

blue = int(input())
blue_string = [input() for i in range(blue)]
blue_type = set(blue_string)
red = int(input())
red_string = [input() for i in range(red)]
red_type = set(red_string)
blue_number = len(blue_type)
result = [0]

for i in range(blue_number):
    blue_sort = blue_string[i]
    bulue_sort_count = blue_string.count(blue_sort)
    red_sort_count = red_string.count(blue_sort)
    result.append(bulue_sort_count - red_sort_count )
print(max(result))

Submission status: Wrong Answer

Solution code:
import collections

blue = int(input())
blue_string = [input() for i in range(blue)]
blue_type = set(blue_string)
red = int(input())
red_string = [input() for i in range(red)]
red_type = set(red_string)
blue_number = len(blue_type)
result = []

for i in range(blue_number):
    blue_sort = blue_string[i]
    bulue_sort_count = blue_string.count(blue_sort)
    red_sort_count = red_string.count(blue_sort)
    result.append(bulue_sort_count - red_sort_count )
print(max(result))

Submission status: Wrong Answer

Solution code:
import collections

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

s_col = collections.Counter(s)
t_col = collections.Counter(t)

s_com = s_col.most_common()
t_com = t_col.most_common()

ans = []

for item in s:
    try:
        ans.append(s_col[item] - t_col[item])
    except:
        ans.append(s_col[item])

print(max(ans))

Submission status: Wrong Answer

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

for i in range(n):
    a.append(str(input()))
m=int(input())
for s in range(m):
    b.append(str(input()))
for k in range(n):
    c.append(a.count(a[k])-b.count(a[k]))
for l in range(m):
    c.append(a.count(b[l]) - b.count(b[l]))
print(max(c))

Submission status: Wrong Answer

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

for i in range(n):
    a.append(str(input()))
m=int(input())
for s in range(m):
    b.append(str(input()))
for k in range(n):
    c.append(a.count(a[k])-b.count(a[k]))
print(max(c))

Submission status: Wrong Answer

Solution code:
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 = {s: S.count(s) for s in S}
T = {t: T.count(t) for t in T}

ans = -float('inf')
for s in S:
    adv = S[s] - T.get(s, 0)
    ans = max(ans, adv)
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)]

print(max(map(lambda x: s.count(x) - t.count(x), set(s))))

Submission status: Wrong Answer

Solution code:
n=int(input())
s_list=[input() for i in range(n)]
m=int(input())
t_list=[input() for j in range(m)]

st_list=list(set(s_list)|set(t_list))
ans_list=[]
for k in range(len(st_list)):
    ans_list.append(s_list.count(st_list[k])-t_list.count(st_list[k]))

ans_list.sort()
print(ans_list[-1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main(s, t):
    s_c = sorted(Counter(s).items(), key=lambda x: -x[1])
    t_c = Counter(t)
    for i, (k, v) in enumerate(s_c):
        benefit = v - t_c[k] if k in t_c.keys() else v
        if i + 1 == len(s_c):
            print(max(benefit, 0))
            break
        if s_c[i + 1][1] <= benefit:
            print(max(benefit, 0))
            break

if __name__ == '__main__':
    N = int(input().strip())
    s = [input().strip() for _ in range(N)]
    M = int(input().strip())
    t = [input().strip() for _ in range(M)]
    main(s, t)

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main(s, t):
    s_c = sorted(Counter(s).items(), key=lambda x: -x[1])
    t_c = Counter(t)
    for i, (k, v) in enumerate(s_c):
        benefit = v - t_c[k]
        if i + 1 == len(s_c):
            print(max(benefit, 0))
            break
        if s_c[i + 1][1] <= benefit:
            print(max(benefit, 0))
            break

if __name__ == '__main__':
    N = int(input().strip())
    s = [input().strip() for _ in range(N)]
    M = int(input().strip())
    t = [input().strip() for _ in range(M)]
    main(s, t)

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main(s, t):
    s_c = sorted(Counter(s).items(), key=lambda x: -x[1])
    t_c = Counter(t)
    for i, (k, v) in enumerate(s_c):
        benefit = v - t_c[k]
        if i + 1 == len(s_c):
            print(benefit)
            break
        if s_c[i + 1][1] <= benefit:
            print(benefit)
            break

if __name__ == '__main__':
    N = int(input().strip())
    s = [input().strip() for _ in range(N)]
    M = int(input().strip())
    t = [input().strip() for _ in range(M)]
    main(s, t)

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=len(s)

for i in range(n):
  for j in range(m):
    if s[i] == t[j]:
      ans-=1
if ans < 0:
  print(0)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
d = {}
n = int(input())
for _ in range(n):
    e = input()
    if e not in d:
        d[e] = 1
    else:
        d[e] += 1
m = int(input())
for _ in range(m):
    e = input()
    if e not in d:
        d[e] = -1
    else:
        d[e] -= 1

print(max(d.values()))

Submission status: Wrong Answer

Solution code:
d = {}
n = int(input())
for _ in range(n):
    e = input()
    if e not in d:
        d[e] = 1
    else:
        d[e] += 1
m = int(input())
for _ in range(m):
    e = input()
    if e not in d:
        d[e] = -1
    else:
        d[e] -= 1

print(max(d, key=d.get))

Submission status: Wrong Answer

Solution code:
n=int(input())
b=[input()for _ in range(n)]
m=int(input())
r=[input()for _ in range(m)]
c=[b.count(l)-r.count(l)for l in set(b)]
print(max(c))

Submission status: Wrong Answer

Solution code:
N = int(input())

b = {}
for i in range(N):
  s = str(input())
  if b.get(s) is None:
    b[s] = 1
  else:
    b[s] += 1
    
r = {}
M = int(input())
for i in range(M):
  s = str(input())
  if r.get(s) is None:
    r[s] = 1
  else:
    r[s] += 1

ans = -999999
for st in b:
  if r.get(st) is None:
    ans = max(ans, b[st])
  else:
    ans = max(ans, b[st] - r[st])
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=list( set(s) )
maxbox=[]
for i in range( len(l) ):
    maxbox.append( int( s.count(l[i])-t.count(l[i]) ) ) 
print(max(maxbox),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)]
l=list( set(s) )
maxbox=[]
for i in range( len(l) ):
    maxbox.append( int( s.count(l[i])-t.count(l[i]) ) ) 
print(max(maxbox))

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 = set(s+t)
ans = -10000

for i in st:
    count = 0
    for j in s:
        if i == j:
            count += 1
    for j in t:
        if i == j:
            count -= 1
    ans = max(ans, count)

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

for i in s:
  if i in t:
    s.remove(i)

print(max([0] + [s.count(i) for i in set(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)]

ans = 0
for word in set(s):
    given = s.count(word) - t.count(word)
    ans = max(ans, given)

Submission status: Wrong Answer

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

ln=s+t
ans=[]
for i in range(len(ln)):
    ctr=0
    test=ln[i]
    for k in range(n):
        if s[k]==test:
            ctr+=1
    for j in range(m):
        if t[j]==test:
            ctr-=1
    ans.append(ctr)

print(max(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)]
#print(set(s),set(t))
if len(set(s))>=len(set(t)):
    ans=[0]+[s.count(i)-t.count(i) for i in set(s)]
    print(max(ans))
else:
    ans=[0]+[s.count(i)-t.count(i) for i in set(t)]
    print(max(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)]
#print(set(s),set(t))
if len(set(s))>=len(set(t)):
    ans=[s.count(i)-t.count(i) for i in set(s)]
    #print(ans)
else:
    ans=[s.count(i)-t.count(i) for i in set(t)]
    #print(ans)
if max(ans)<0:
    print(0)
else:
    print(max(ans))

Submission status: Wrong Answer

Solution code:
a=[]
for i in range(int(input())):
  a+=input()
b=[]
for i in range(int(input())):
  b+=input()
ans=0
for i in range(len(a)):
  ans=max(ans,a.count(a[i])-b.count(a[i]))
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
m = int(input())
t = []
for _ in range(m):
    t.append(input())
s_ = collections.Counter(s)
t_ = collections.Counter(t)
a = []
for key in s_.keys():
    num = s_[key] - t_[key]
    a.append(num)
print(max(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
blue = []
red = []
score_list = []
for i in range(n):
    blue.append(input())
m = int(input())
for j in range(m):
    red.append(input())
for value in blue:
    score = 0
    for s in blue:
        if value == s:
            score += 1
    for t in red:
        if value == t:
            score -= 1
    if score not in score_list:
        score_list.append(score)
print(max(score_list))

Submission status: Wrong Answer

Solution code:
def solve(string):
    count = dict([])
    n, *rest = string.split()
    n = int(n)
    blues = rest[:n]
    m = rest[n]
    reds = rest[n + 1:]
    print(blues)
    for key in blues:
        if key in count:
            count[key] += 1
        else:
            count[key] = 1
    for key in reds:
        if key in count:
            count[key] -= 1
        else:
            count[key] = -1
    num = 0
    for k, v in count.items():
        if num < v:
            num = v
    return str(num)


if __name__ == '__main__':
    n = int(input())
    ins = '{}\n'.format(n) + '\n'.join([input() for _ in range(n)])
    m = int(input())
    print(solve(ins + '\n{}\n'.format(m) + '\n'.join([input() for _ in range(m)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    count = dict([])
    n, *rest = string.split()
    n = int(n)
    blues = rest[:n]
    m = rest[n]
    reds = rest[n + 1:]
    for key in blues:
        if key in count:
            count[key] += 1
        else:
            count[key] = 1
    for key in reds:
        if key in count:
            count[key] -= 1
        else:
            count[key] = -1
    num = 0
    for k, v in count.items():
        if num < v:
            num = v
    return str(num)


if __name__ == '__main__':
    n = int(input())
    ins = '{}\n'.format(n) + '\n'.join([input() for _ in range(n)])
    m = int(input())
    print(solve(ins + '{}\n'.format(m) + '\n'.join([input() for _ in range(m)])))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
for i in range(n):
  k=input()
  s.append(k)
m=int(input())
t=[]
for i in range(m):
  k=input()
  t.append(k)
check=[]
ans=[]
for i in s:
  if i in check:
    continue
  ans.append(s.count(i)-t.count(i))
  check.append(i)
print(max(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
for i in range(n):
  k=input()
  s.append(k)
m=int(input())
t=[]
for i in range(m):
  k=input()
  t.append(k)
check=[]
ans=0
for i in s:
  if i in check:
    continue
  if s.count(i)>=t.count(i):
    ans+=s.count(i)-t.count(i)
  check.append(i)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = np.int(input())
slist = [input() for _ in range(N)]
M = np.int(input())
tlist = [input() for _ in range(M)]
sslist = np.array(list(set(slist)))
sslist
number = np.zeros(len(sslist))
for i in range(len(sslist)):
    number[i] = np.sum(slist.count(sslist[i])) - np.sum(tlist.count(sslist[i]))
answer = np.int(np.max(number))  
print(np.max(answer, 0))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = np.int(input())
slist = [input() for _ in range(N)]
M = np.int(input())
tlist = [input() for _ in range(M)]
sslist = np.array(list(set(slist)))
sslist
number = np.zeros(len(sslist))
for i in range(len(sslist)):
    number[i] = np.sum(slist.count(sslist[i])) - np.sum(tlist.count(sslist[i]))
print(np.int(np.max(number)))

Submission status: Wrong Answer

Solution code:
import collections
l = collections.Counter()
n = int(input())
for i in range(n):
    k = input()
    l[k] += 1
n = int(input())
for i in range(n):
    k = input()
    l[k] -= 1
l = l.most_common()
print(l[0][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=[]
for i in range(n):
  hoge.append(input())
m=int(input())
huga=[]
for i in range(m):
  huga.append(input())
ans=0
while 1:
  blue=hoge.count(hoge[0])
  red=huga.count(hoge[0])
  if(blue>red):
    ans+=blue-red
  hoge.remove(hoge[0])
  if(len(hoge)==0):
    break
    
print(ans)

Submission status: Wrong Answer

Solution code:
def two_color_card_games(N: int, S: list, M: int, T: list) -> int:
    d = {}
    for s in S:
        d.setdefault(s, 0)
        d[s] += 1

    for t in T:
        d.setdefault(t, 0)
        d[t] -= 1


    return max(d.values())


if __name__ == "__main__":
    N = int(input())
    S = [input() for _ in range(N)]
    M = int(input())
    T = [input() for _ in range(M)]
    ans = two_color_card_games(N, S, M, T)
    print(ans)

Submission status: Wrong Answer

Solution code:
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)
    return result
  
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

result = list_difference(s,t)
if len(result) == 0 and len(s) > 0:
  print("0")
else:
  result.sort()
  print(result.count(result[0]))

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
Ss= [input() for i in range(N)]
M = int(input())
Mm = [input() for i in range(M)]
Scounter = collections.Counter(Ss)
Mcounter = collections.Counter(Mm)
Ansdic = {}
for s,value in Scounter.items():
    if s not in Ansdic:
        Ansdic[s]=value
    else:
        Ansdic[s]+=value
for m,value in Mcounter.items():
    if m not in Ansdic:
        Ansdic[m]=-value
    else:
        Ansdic[m]-=value
print(max(Ansdic.values()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = {}
for _ in range(n):
  temp = input()
  if temp in lst:
    lst[temp] = lst[temp]+1
  else:
    lst[temp] = 1
m = int(input())
for _ in range(m):
  temp = input()
  if temp in lst:
    lst[temp] = lst[temp] - 1
print(max(0,lst[max(lst)]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

B = int(input())
Lb = [input() for _ in range(B)]
R = int(input())
Lr = [input() for _ in range(R)]

Cb = Counter(Lb)
Cr = Counter(Lr)

cand = []
for i, v in Cb.items():
    cand.append(v-Cr[i])
ans = max(cand)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

B = int(input())
Lb = [input() for _ in range(B)]
R = int(input())
Lr = [input() for _ in range(R)]

Cb = Counter(Lb)
Cr = Counter(Lr)

cand = []
for i, v in Cb.items():
    cand.append(v-Cr[i])
ans = sum(list(filter(lambda x: x > 0, cand)))
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
a = int(input())
d = defaultdict(int)
for i in range(a):
    k = input()
    d[k] += 1
b = int(input())
for i in range(b):
    k = input()
    d[k] -= 1
c = d[0]
for i in range(len(d)):
    c = max(c, d[i])
print(c)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
a = int(input())
d = defaultdict(int)
for i in range(a):
    k = input()
    d[k] += 1
b = int(input())
for i in range(b):
    k = input()
    d[k] -= 1
c = d[0]
for i in range(len(d)):
    c = max(c, d[k])
print(c)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
a = int(input())
d = defaultdict(int)
for i in range(a):
    k = input()
    d[k] += 1
b = int(input())
for i in range(b):
    d[k] -= 1

c = d[0]
for i in range(len(d)):
    c = max(c, d[k])
print(c)

Submission status: Wrong Answer

Solution code:
s=open(0).readlines();print(max(0,*[s.count(i)-s[int(s[0])+1:].count(i)*2for i in s]))

Submission status: Wrong Answer

Solution code:
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();print(max(s.count(i)-t.count(i)for i in set(s)))

Submission status: Wrong Answer

Solution code:
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();c=0
for i in set(t):a=t.count(i)-s.count(i);c+=a*(a>0)
print(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)]
cnt = {}
for word in s:
    if word in cnt: cnt[word] += 1
    else:cnt[word] = 1
for word2 in t:
    if word2 in cnt:cnt[word] -= 1
ls = [v for k,v in cnt.items()]
print(max(ls))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for _ in [0]*N:
    s.append(input().rstrip())
M = int(input())
t = []
for _ in [0]*M:
    t.append(input().rstrip())

u = set(s+t)
if len(u) == 1 and N <= M:
    print(0)
else:
    ans = -1000
    for i in set(s+t):
        ans = max(ans, s.count(i) - t.count(i))

    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for _ in [0]*N:
    s.append(input().rstrip())
M = int(input())
t = []
for _ in [0]*M:
    t.append(input().rstrip())

u = set(s+t)
if len(u) == 1 and N <= M:
    print(0)
else:
    ans = -100
    for i in set(s+t):
        ans = max(ans, s.count(i) - t.count(i))

    print(ans)