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())
d = {}
for _ in range(n):
  s = input()
  if s not in d:
    d[s] = 0
  d[s] += 1
m  =int(input())
for _ in range(m):
  s = input()
  if s not in d:
    d[s] = 0
  d[s] -= 1
  
ans = 0
for key in d:
  ans += max(d[key], 0)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
blue = [input() for _ in range(n)]
n = int(input())
red = [input() for _ in range(n)]
blue_set = list(set(blue))
count = 0
for i in blue_set:
  if blue.count(i) >= red.count(i):
    count += blue.count(i) - red.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)]
max = 0
for ss in s:
  if s.count(ss) -t.count(ss) > 0:
    max = s.count(ss) - t.count(ss)
print(max)

Submission status: Wrong Answer

Solution code:
n = int(input())
B = [input() for _ in range(n)]
m = int(input())
R = [input() for _ in range(m)]
L = list(set(B) | set(R))
dict = {key:0 for key in L}
for b in B:
    dict[b] += 1
for r in R:
    dict[r] -=1
print(max(dict.values()))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
s = sorted([input() for _ in range(N)])
M = int(input())
t = sorted([input() for _ in range(M)])

print(Counter(s))
d = {}
for val,cnt in Counter(s).items():
    d[val] = cnt
print(Counter(t))

for val,cnt in Counter(t).items():
    if val in d:
        d[val] -= cnt
print(max(max(d.values()),0))

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))
l=list(set(s))
ans=(max(0,s.count(l[k])-t.count(l[k])) for k in range(len(l)))
print(ans)

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))
l=list(set(s))
ans=(max(0,s.count(l[k])-t.count(l[k])) for k in range(len(l)))

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

c = collections.Counter(s).most_common()
C = []
for i in range(len(c)):
    C.append([c[i][0], c[i][1]])

ans = []
for j in range(len(C)):
    if C[j][0] in t:
        C[j][1] -= t.count(C[j][0])
    ans.append(C[j][1])

print(max(ans))

Submission status: Wrong Answer

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

total = 0
for i in range(N):
  if not S[i] in T:
    total = total + 1

print(total)

Submission status: Wrong Answer

Solution code:
s_num=int(input())
s=[]
s=[input(x) for x in range(s_num)]
t=[]
t_num=int(input())
t=[input(x) for x in range(t_num)]
max_v=0
for i in range(s_num):
    if max_v < (s.count(s[i]) - t.count(s[i])):
        max_v = (s.count(s[i]) - t.count(s[i]))
print(max_v)

Submission status: Wrong Answer

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    s = [ns() for _ in range(n)]
    m = ni()
    t = [ns() for _ in range(m)]

    c1 = Counter(s)
    c2 = Counter(t)
    ans = []
    for key1, value1 in c1.items():
        if key1 in c2.keys():
            ans.append(value1 - c2[key1])
        else:
            ans.append(value1)
            
    print(max(ans))
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

N = int(input())
S = [input() for i in range(N)]

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

words_count = {}
for i in range(N):
    words_count[S[i]] = words_count.get(S[i], 0) + 1

for i in range(M):
    words_count[T[i]] = words_count.get(T[i], 0) - 1

print(max(words_count.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)]
a = list(set(s+t))
ans = {}
for i in a:
    ans[i] = 0
for i in s:
    ans[i] += 1
for i in t:
    ans[i] -= 1

print(max(ans.values()))

Submission status: Wrong Answer

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

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

# calc
d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 

for i in t:
    if i in d.keys():
        d[i] -= 1
    else:
        d[i] = -1

#import pdb; pdb.set_trace()
if len(d.keys()) != 1:
    print(max(d.values()))
else:
    print(max(list(d.values())[0], 0))

Submission status: Wrong Answer

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

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

# calc
d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 

for i in t:
    if i in d.keys():
        d[i] -= 1
    else:
        d[i] = -1

#import pdb; pdb.set_trace()
if len(d.keys()) != 1:
    print(max(d.values()))
else:
    print(max(list(d.values())[0], 0))

Submission status: Wrong Answer

Solution code:
a=int(input())
b,d,e=[],[],[]
for i in range(a):
    b.append(str(input()))
c=int(input())
up,down=0,0
for j in range(c):
    d.append(str(input()))
for k in set(b):
    up+=b.count(k)
    down+=d.count(k)
    e.append(up-down)
    up,down=0,0
print(max(e))

Submission status: Wrong Answer

Solution code:
N = int(input())
li1 = [input() for _ in range(N)]
li1.sort()
M = int(input())
li2 = [input() for _ in range(M)]
li2.sort()
temp = 0
for i in li1:
    for j in li2:
        if i == j:
            temp -=1
        elif i!=j:
            temp +=1
ans = 0
print(max(ans,temp))

Submission status: Wrong Answer

Solution code:
dic = dict()
for a in range(int(input())):
    i = input()
    if not i in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1
for b in range(int(input())):
    i = input()
    if not i in dic:
        dic[i] = -1
    else:
        dic[i] = dic[i]-1
print(max(max([a for a in dic.values()]), 1))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
count1 = Counter(s)
count2 = Counter(t)
ans = -1 * M
for key in count1.keys():
    ans = max(ans, count1[key] - count2[key])
print(ans)

Submission status: Wrong Answer

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

ans = 0
for ss in s:
    score = s.count(ss) - t.count(s)
    if ans < score:
        ans = score
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)]

dicts = {}
small = 0
for i in s:
    if i not in dicts.values():
        dicts[i] = 1
    else:
        dicts[i] += 1
    
for i in t:
    if i not in dicts.values():
        dicts[i] = -1
    else:
        dicts[i] -= 1

tmp = max(dicts.values())
print(max(tmp, small))

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]
m=[]
while N>0:
    a=input()
    l.append(a)
    N-=1
M=int(input())
while M>0:
    b=input()
    m.append(b)
    M-=1
print(sorted(l))
print(sorted(m))

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
a = 0
for i in range(0,N):
        for j in range(0,M):
            if a < (s.count(s[i]) - t.count(t[j])):
                a = s.count(s[i]) - t.count(t[j])
            else:
             	break
print(a)

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
for i in range(0,N):
        for j in range(0,M):
            if a < (s.count(s[i]) - t.count(t[j])):
                a = s.count(s[i]) - t.count(t[j])
print(a)

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
for i in range(0,N):
    if s.count(i) > 0:
        for j in range(0,M):
            if a < (s.count(s[i]) - t.count(t[j])):
                a = s.count(s[i]) - t.count(t[j])
print(a)

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
for i in range(0,N):
    if s.count(i) > 0:
        for j in range(0,M):
            if a < (s.count(s[i]) - t.count(t[j])):
                a = s.count(s[i]) - t.count(t[j])
            else:
                continue
print(a)

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
for i in range(0,N):
    for j in range(0,M):
        if a <= (s.count(s[i]) - t.count(t[j])):
            a = s.count(s[i]) - t.count(t[j])
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in range(0,N):
    for j in range(0,M):
        if a <= (s.count(s[i]) - t.count(t[j])):
            a = s.count(s[i]) - t.count(t[j])
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in range(N):
    for j in range(M):
        if a <= (s.count(s[i]) - t.count(t[j])):
            a = s.count(s[i]) - t.count(t[j])
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in range(N):
    for j in range(M):
        if a < s.count(s[i])-t.count(t[j]):
            a = s.count(s[i])-t.count(t[j])
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in range(N):
    for j in range(M):
        if a < s.count(s[i])-t.count(j):
            a = s.count(s[i])-t.count(j)
print(a)

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)]
a = set(blue)
ans = []
for i in a:
  b = 0
  for j in range(n):
    if blue[j] == i:
      b += 1
  for j in range(m):
    if red[j] == i:
      b -= 1
  ans.append(b)
print(max(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
ls1 = []
ls2 = []
ls3 = []
ans = []
for i in range(N):
    s = input()
    ls1.append(s)
    ls3.append(s)
M = int(input())
for j in range(M):
    t = input()
    ls2.append(t)
    ls3.append(t)
k = set(ls3)
p = list(k)
for i in range(len(p)):
    ans.append(ls1.count(p[i])-ls2.count(p[i]))
print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
crs = list(cr.most_common())
cb = collections.Counter(blue)
cbs = list(cb.most_common())

result =[]

for i in range(len(crs)):
  for j in range(len(cbs)):
    if crs[i][0]==cbs[j][0]:
      result.append(crs[i][1]-cbs[j][1])
    else:
      result.append(crs[i][1])

if max(result)>0:
  print(max(result))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
red_name = cr.most_common()[0][0]
red_count = cr.most_common()[0][1]
cb = collections.Counter(blue)
blue_name = cb.most_common()[0][0]
blue_count = cb.most_common()[0][1]

if blue_name == red_name:
  if red_count - blue_count < 0:
    if len(red)==1:
      print(0)
  else:
    print(red_count - blue_count)
else:
  print(red_count)

Submission status: Wrong Answer

Solution code:

import math
#import itertools
#import statistics
#import numpy as np
import collections
n = int(input())
#a = list(map(int, input().split()))
#a = list(map(int, input().split()))
s = []
for i in range(n):
    s.append(input())
m = int(input())
t = []
for j in range(m):
    t.append(input())

s2 = collections.Counter(s)
t2 = collections.Counter(t)
point = 0
ans  = 0
#print(s2)
#print(t2)
for i in s2.keys():
    for j in t2.keys():
        if i==j:
            point = s2.get(i)-t2.get(j)
            print(i+j+""+str(point))
            break
        else:
            point = s2.get(i)
    #print(point)
    if ans < point:
        ans = point

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = {}
for _ in range(N):
    s = input()
    if s not in D: D[s]=0
    D[s] += 1

M = int(input())
for _ in range(M):
    t = input()
    if t not in D: D[t]=0
    D[t] -= 1

print(max(D.values()))

Submission status: Wrong Answer

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

from collections import Counter
sc = Counter(s)
tc = Counter(t)
s_keys, s_values = zip(*sc.most_common())
t_keys, t_values = zip(*tc.most_common())
ans = 0
for i in range(len(s_values)):
  for j in range(len(t_values)):
    minus = 0
    if s_keys[i] == t_keys[j]:
      minus = t_values[j]
      ans = max(ans, s_values[i] - minus)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    point = dict()
    for _ in range(N):
        s = input().strip("\n")
        if s in point: point[s] += 1
        else: point[s] = 1
    M = int(input())
    for _ in range(M):
        s = input().strip("\n")
        if s in point: point[s] -= 1
        else: point[s] = -1
    
    Ans = -1 * 10 ** 20
    for key in point:
        Ans = max(Ans, point[key])
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()

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=n
for i in range(m):
    if t[i] in s:
        ans-=1
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)]
ans=n-len(list(set(s)&set(t)))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = {}
for _ in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1
m = int(input())
for _ in range(m):
    s = input()
    if s in a:
        a[s] -= 1
    else:
        a[s] = -1
ans = -10**9
for i in a:
    ans = max(ans,a[i])
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

sDic = {}
tDic = {}
for i in s:
    if i not in sDic:
        sDic.setdefault(i, 1)
    else:
        sDic[i] += 1

for i in t:
    if i not in tDic:
        tDic.setdefault(i, 1)
    else:
        tDic[i] += 1

# print(sDic)
# print(tDic)

maxCount = 0
for i in sDic.keys():
    if i in tDic:
        maxCount = max(maxCount, sDic[i] - tDic[i])
    else:
        maxCount = max(maxCount,sDic[i])

for i in tDic.keys():
    if i not in sDic:
        maxCount = max(maxCount, tDic[i])

print(maxCount)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
d["DEFAULT"]=0

n=int(input())
for _ in range(n):
  d[input()]+=1

n=int(input())
for _ in range(n):
  d[input()]-=1
  
print(d[max(d)])

Submission status: Wrong Answer

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

n=int(input())
for _ in range(n):
  d[input()]+=1

n=int(input())
for _ in range(n):
  d[input()]-=1
  
print(d[max(d)])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = Counter([input() for _ in range(int(input()))])
M = Counter([input() for _ in range(int(input()))])
print(max(N[key]-M[key] for key in N.keys()))

Submission status: Wrong Answer

Solution code:
#abc091 b
n=int(input())
card=dict()
for i in range(n):
    s=input()
    if s not in card:
        card[s]=1
    else:
        card[s]+=1
m=int(input())
for i in range(m):
    t=input()
    if t not in card:
        card[t]=-1
    else:
        card[t]-=1
ans=-m

for i in card.values():
    ans=max(ans,i)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=[]
for i in range(N):
    s+=[input()]
M=int(input())
t=[]
for i in range(M):
    t+=[input()]
ans1=0
for i in range(len(set(s))):
    ans=s.count(s[i])-t.count(s[i])
    ans1=max(ans1,ans)
if ans1<0:
    print(0)
    exit()
print(ans1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N=int(input())
A=[input() for _ in range(N)]

M=int(input())
B=[input() for _ in range(M)]

a=Counter(A)
b=Counter(B)

ans=0
for p in A:
    print(p)
    ans=max(ans,a[p]-b[p])
    
print(ans)

Submission status: Wrong Answer

Solution code:

import collections

def uzai():
            n = int(input())
            s = []
            for i in range(n):
                        s_i = input()
                        s.append(s_i)
            count_dict_s = collections.Counter(s)
            return n, s, count_dict_s

n,s,count_dict_s = uzai()
m,t,count_dict_t = uzai()

print("count_dict_s",count_dict_s)
print("count_dict_t",count_dict_t)

s_count_l=[]
for s_name, s_count in count_dict_s.items():
            for t_name, t_count in count_dict_t.items():
                    if s_name==t_name:
                                 s_count_l.append(s_count-t_count)
                    elif s_name not in count_dict_t:
                                 s_count_l.append(s_count)
                                 print(s_name,s_count_l)
if max(s_count_l)<=0:
            print('0')
else:
             print(max(s_count_l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
n=int(input())
a=[] ; b=[]
for _ in range(n):
    a.append(input())
m=int(input())
for _ in range(m):
    b.append(input())
from collections import Counter
a=Counter(a)
b=Counter(b)
for i in b:
    if i in a:
        a[i]-=b[i]
print(max(a.values()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res=0
for S in set(s):
    res=max(0,s.count(S)-t.count(S))
print(res)

Submission status: Wrong Answer

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

res=0
for S in set(s):
    res+=max(0,s.count(S)-t.count(S))
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
blue=[input() for _ in range(n)]
bset = set(blue)

m=int(input())
red=[input() for _ in range(m)]

print(max([min(0, blue.count(b) - red.count(b)) for b in bset]))

Submission status: Wrong Answer

Solution code:
n=int(input())
blue=[input() for _ in range(n)]
bset = set(blue)

m=int(input())
red=[input() for _ in range(m)]

print(max([blue.count(b) - red.count(b) for b in bset]))

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)]
cnt = Counter(s)
ans = 0
for k, v in cnt.items():
    if k in t:
        pass
    else:
        ans = max(ans, v)
print(ans)

Submission status: Wrong Answer

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

for i in range(K):
  s=input()
  if s in A==1:
    A.remove(s)
B=set(A)
ans=0
for i in B:
  if A.count(i)>ans:
    ans=A.count(i)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s not in d.keys():
        d[s] = 0
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    if s in d.keys():
        d[s] -= 1
d = sorted(d.items(), key=lambda x:x[1])
if d[-1][1] == - (m - 1): print(0)
else: print(d[-1][1])

Submission status: Wrong Answer

Solution code:
lst_blue = []
lst_red = []
dic = {}

N = int(input())
for i in range(0,N):
  lst_blue.append(input())
M = int(input())
for i in range(0,M):
  lst_red.append(input())
  
for i in list(set(lst_blue)):
  dic[i] = int(lst_blue.count(i))

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

Submission status: Wrong Answer

Solution code:
lst_blue = []
lst_red = []
dic = {}

N = int(input())
for i in range(0,N):
  lst_blue.append(input())
M = int(input())
for i in range(0,M):
  lst_red.append(input())
  
for i in list(set(lst_blue)):
  dic[i] = int(lst_blue.count(i))

for i in list(set(lst_red)):
  if i in dic:
    dic[i] -= 1

print(max(dic.values()))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
for _ in range(int(input())):
    d[input()] -= 1
print(max(d.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
buf=0
s.sort()
t.sort()
for i in range(n):
    buf=0
    for j in range(i,n):
        if s[i]==s[j]:
            buf+=1
        elif s[i]>s[j]:
            break
    for j in range(m):
        if s[i]==t[j]:
            buf-=1
        elif s[i]>t[j]:
            break
    if buf>ans:
        ans=buf
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)]
d={}
for i in range(n):
  d[s[i]] = d.get(s[i],0) + 1
for j in range(m):
  d[t[j]] = d.get(t[j],0) - 1
print(max(d.values()))

Submission status: Wrong Answer

Solution code:
def get_info(diff):
    length = int(input())
    strings = {}
    for _ in range(length):
        tmp = input()
        if tmp in strings:
            strings[tmp] += diff
        else:
            strings[tmp] = diff
    return length, strings


def main():
    blue_card, blue_card_str = get_info(1)
    red_card, red_card_str = get_info(-1)
    answer = 0
    common_keys = blue_card_str.keys() & red_card_str.keys()
    for common_key in common_keys:
        diff = blue_card_str[common_key] + red_card_str[common_key]
        answer = max(answer, diff)
    if len(common_keys) == 0 or answer <= 0:
        diff_key = blue_card_str.keys() - red_card_str.keys()
        for d in diff_key:
            answer = max(answer, blue_card_str[d])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

dict = {}
for i in s_lst:
    dict[i] = 0
for i in t_lst:
    dict[i] = 0
for i in s_lst:
    dict[i] += 1
for i in t_lst:
    dict[i] -= 1
infinity = float('inf')
max = -infinity
for i in dict.values():
    if max < i:
        max = i
print(max)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
s=[]
for _ in range(n):
	s.append(input())
c=collections.Counter(s)
m=int(input())
for _ in range(m):
	t=input()
	c[t] -= 1
print(max(c.values()))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

b = defaultdict(int)
r = defaultdict(int)

n = int(input())
for i in range(n):
    b[input()] += 1
m = int(input())
for i in range(m):
    r[input()] += 1
print(b)
print(b.items())

ans = 0
for k, v in b.items():
    ans = max(ans, v - r[k])
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
L01=collections.defaultdict(dict)
N=int(input())
L1=list(input() for _ in range(N))
M=int(input())
L2=list(input() for _ in range(M))
for i in set(L1):
    L01[i]=L1.count(i)
for i in set(L2):
    L01[i]=-L2.count(i)
print(max(L01.values()) if max(L01.values())>=0 else 0)

Submission status: Wrong Answer

Solution code:
import collections
L01=collections.defaultdict(dict)
N=int(input())
L1=list(input() for _ in range(N))
M=int(input())
L2=list(input() for _ in range(M))
for i in set(L1):
    L01[i]=L1.count(i)
for i in set(L2):
    L01[i]=-L2.count(i)
print(L01[max(L01)] if int(L01[max(L01)])>=0 else 0)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = {}
for i in range(N):
    s = input()
    if s not in S:
        S[s] = 1
        continue
    S[s] +=1
    

M = int(input())
T = {}
for i in range(M):
    t = input()
    if t not in T:
        T[t] = 1
        continue
    T[t] += 1

ans = 0
for key in S.keys():
    if key not in T:
        ans = S[key]
        continue
    ans = max(ans, S[key] - T[key])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = {}
for i in range(N):
    s = input()
    if s not in S:
        S[s] = 1
        continue
    S[s] +=1
    

M = int(input())
T = {}
for i in range(M):
    t = input()
    if t not in T:
        T[t] = 1
        continue
    T[t] += 1

ans = 0
for key in S.keys():
    if key not in T:
        continue
    ans = max(ans, S[key] - T[key])
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)]
ans_1=0
ans=""
for S in s:
    ans_1=s.count(S)
    if s.count(S)>=ans_1:
        ans_1=s.count(S)
        ans=S

if ans_1>t.count(ans):
    print(ans_1-t.count(ans))
else :
    print("0")

Submission status: Wrong Answer

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

n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(m):
    d[input()] -= 1
print(max(d.values()))

Submission status: Wrong Answer

Solution code:

N = int(input())
st = set()
s = []

for i in range(N):
    tmp = input()
    st.add(tmp)
    s.append(tmp)

M = int(input())
t = []

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

ans = -100
tmp = 0

for x in st:
    print(x)
    tmp = s.count(x)
    tmp -= t.count(x)
    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
st = set()
s = []

for i in range(N):
    tmp = input()
    st.add(tmp)
    s.append(tmp)

M = int(input())
t = []

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

ans = -100
tmp = 0

for x in st:
    print(x)
    tmp = s.count(x)
    tmp -= t.count(x)
    ans = max(ans, tmp)

print(ans if 0 <= ans else 0)

Submission status: Wrong Answer

Solution code:
import sys

nn=int(input())
s_list=[]
for i in range(nn):
	s_list.append(str(input()))
mm=int(input())
t_list=[]
for j in range(mm):
	t_list.append(str(input()))

count_list=[]
for k in range(nn):
	name = s_list[k]
	count=0
	for l in range(nn):
		if name==s_list[l]:
			count+=1
	for m in range(mm):
		if name==t_list[m]:
			count-=1
	count_list.append(count)

for n in range(mm):
	name = t_list[n]
	count=0
	for o in range(nn):
		if name==s_list[o]:
			count+=1
	for p in range(mm):
		if name==t_list[p]:
			count-=1
	count_list.append(count)
print(max(count_list))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
s = Counter([input() for _ in range(N)])

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

point = [get - t[word] for word, get in s.items()]
print(max(point))

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