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

Solution (Python):
import sys
N = int(input())
array_plus = []
for I in range(N):
    array_plus.append(input())
M = int(input())
array_minus = []
for J in range(M):
    array_minus.append(input())

if not (1 <= N <= 100 and 1 <= M <= 100):
    sys.exit()
for K in range(len(array_plus)):
    if len(array_plus[K]) > 10:
        sys.exit()
    if not array_plus[K].islower():
        sys.exit()
for L in range(len(array_minus)):
    if len(array_minus[L]) > 10:
        sys.exit()
    if not array_minus[L].islower():
        sys.exit()

all = []
all = array_plus+array_minus
all_unique = set(all)
all_unique = list(all_unique)
result = 0
for I in range(len(all_unique)):
    tmp = array_plus.count(all_unique[I]) - array_minus.count(all_unique[I])
    if tmp > result:
        result = tmp
print(result)

Solution (Python):
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):
    t=input()
    if t in dic:
        dic[t]-=1
    
ans_list=sorted(dic.items(),key=lambda x:x[1],reverse=True)


if ans_list[0][1]<0:
    print(0)
else:
    print(ans_list[0][1])

Solution (Python):
from collections import defaultdict

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

dictS = defaultdict(int)
dictT = defaultdict(int)

for s in S:
    dictS[s] += 1
for t in T:
    dictT[t] += 1

res = 0
for key in dictS:
    res = max(res, dictS[key] - dictT[key])
print(res)

Solution (Python):
N = int(input())
S = []
for _ in range(N):
    S.append(input())
M = int(input())
T = []
for _ in range(M):
    T.append(input())

L = set(S + T)
ans = 0
for l in L:
    blue = S.count(l)
    red = T.count(l)
    ans = max(ans, blue-red)

print(ans)

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

s.sort()
t.sort()
for i in range(N-1):
    if s[i]!=s[i+1]:
        sf=s.count(s[i+1])
        tf=t.count(s[i+1])
        if sf>tf:
            temp=sf-tf
            if temp>ans:
                ans=temp
sf=s.count(s[0])
tf=t.count(s[0])
if sf>tf:
    temp=sf-tf
    if ans<temp:
        ans=temp
print(ans)

Solution (Python):
d = {}
n = int(input())
for _ in range(n):
  s = input()
  if s in d: d[s] += 1
  else: d[s] = 1

m = int(input())
for _ in range(m):
  t = input()
  if t in d: d[t] -= 1
    
maxNum = max(d.values())
if maxNum > 0: print(maxNum)
else: print(0)

Solution (Python):
def actual(N, S, M, T):
    points = [S.count(word) - T.count(word) for word in set(S)]

    return max(0, max(points))

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

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

print(actual(N, S, M, T))

Solution (Python):
blue={}
red={}
n=int(input())
for i in range(n):
    s=input()
    blue[s]=blue.get(s,0)+1
m=int(input())
for i in range(m):
    t=input()
    red[t]=red.get(t,0)+1

mx=0
for k,v in blue.items():
    mx=max(mx,blue[k]-red.get(k,0))
print(mx)

Solution (Python):
def actual(N, S, M, T):
    points = [S.count(word) - T.count(word) for word in set(S)]

    return max(0, max(points))

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

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

print(actual(N, S, M, T))

Solution (Python):
N = int(input())
blues=[]
for i in range(N):
  blues.append(input())
M = int(input())
reds=[]
for i in range(M):
  reds.append(input())

ma = 0

blueset = set(blues)

for S in blueset:
  ma = max(ma,blues.count(S)-reds.count(S))
print(ma)

Solution (Python):
def resolve():
    N = int(input())
    s = [input() for _ in range(N)]
    M = int(input())
    t = [input() for _ in range(M)]
    sdict = {k: 0 for k in set(s)}
    tdict = {k: 0 for k in set(t)}
    for w in s:
        sdict[w] += 1
    for w in t:
        tdict[w] += 1
    ks = set(s) | set(t)
    ans = 0
    for key in ks:
        ans = max(ans, sdict.get(key, 0) - tdict.get(key, 0))

    print(ans)

    return
resolve()

Solution (Python):
N = int(input())
words = {}

for _ in range(N):
    s = input()
    if s in words:
        words[s] += 1
    else:
        words[s] = 1

M = int(input())

for _ in range(M):
    t = input()
    if t in words:
        words[t] -= 1

val = sorted(words.values())

if val:
    if val[-1] < 0:
        print(0)
    else:
        print(val[-1])
else:
    print(0)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
dict={}

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

Solution (Python):
import collections

n = int(input())
blue = []
for i in range(n):
    blue.append(input())

red = []   
m = int(input())
for i in range(m):
    red.append(input())
    
b1 = collections.Counter(blue)
r1 = collections.Counter(red)

ans = 0

for key, value in b1.items():
    if key in r1:
        tmp = b1[key] - r1[key]
        ans = max(ans, tmp)
    else:
        ans = max(ans, b1[key])
        
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
B = Counter([input() for _ in range(N)])
M = int(input())
R = Counter([input() for _ in range(M)])
res = 0
for k, v in B.items():
    res = max(res, v - R[k])
print(res)

Solution (Python):
A = int(input())
X = [input() for _ in range(A)]
B = int(input())
Y = [input() for _ in range(B)]
t = 0
for x in X:
  if X.count(x)-Y.count(x)>t:
    t = X.count(x)-Y.count(x)
  else:
    pass
print(t)

Solution (Python):
n=int(input())
nlst=[input() for i in range(n)]
m=int(input())
mlst=[input() for i in range(m)]
ans=0
for i in nlst:
    plus=nlst.count(i)
    minus=mlst.count(i)
    ans=max(ans,plus-minus)
    
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
maxA = 0
for s in set(S):
    maxA = max(maxA, S.count(s) - T.count(s))
print(maxA)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = 0
for i in range(N):
    if S.count(S[i]) > T.count(S[i]):
        ans = max(ans, S.count(S[i]) - T.count(S[i]))
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
s = list(input() for i in range(N))
M = int(input())
t = list(input() for i in range(M))
count_p = Counter(s)
count_m = Counter(t)
counter = count_p - count_m
if (len(counter.values()) == 0):
    print (0)
else:
    print(max(counter.values()))

Solution (Python):
N = int(input())
S = [input() for n in range(N)]
M = int(input())
T = [input() for m in range(M)]
print(max(0,max([S.count(s)-T.count(s) for s in S])))

Solution (Python):
N = int(input())
S = [input() for n in range(N)]
M = int(input())
T = [input() for m in range(M)]
A = [0]

for s in S:
  A.append(S.count(s)-T.count(s))

print(max(A))

Solution (Python):
from collections import defaultdict

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

x=defaultdict(int)
for i in s:
  x[i]+=1
  
for i in t:
  x[i]-=1
  
ans=0
for y in x.keys():
  ans=max(ans, x[y])
  
print(ans)

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

ans=0
cnt=0
for i in range(n):
  for j in range(n):
    if s[i]==s[j]:
      cnt+=1
  for k in range(m):
    if s[i]==t[k]:
      cnt-=1
  ans=max(ans,cnt)
  cnt=0
print(ans)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

A = {}
for _ in range(N):
    a = input()
    A[a] = A.get(a, 0) + 1

M = int(input())
B = {}
for _ in range(M):
    b = input()
    B[b] = B.get(b, 0) + 1

ans = 0
for k, v in A.items():
    ans = max(ans, v - B.get(k, 0))

print(ans)

Solution (Python):
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 range(len(s)):
    if s.count(s[i])-t.count(s[i])>ans:
        ans=s.count(s[i])-t.count(s[i])
print(ans)

Solution (Python):



import sys
from collections import defaultdict


def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(blueCard, redCard):
    result = 0
    cardDict = defaultdict(int)
    for j in range(0, len(blueCard), +1):
        cardDict[blueCard[j]] += 1
    for j in range(0, len(redCard), +1):
        cardDict[redCard[j]] -= 1
    
    cardList = list(cardDict.keys())
    for j in range(0, len(cardList), +1):
        if result < cardDict[cardList[j]]:
            result = cardDict[cardList[j]]

    
    return result


if __name__ == "__main__":
    N = II()
    blueCard = list()
    for _ in range(0, N, +1):
        strings = sys.stdin.readline().strip('\n')
        blueCard.append(strings)
    M = II()
    redCard = list()
    for _ in range(0, M, +1):
        strings = sys.stdin.readline().strip('\n')
        redCard.append(strings)


    print("{}".format(solver(blueCard, redCard)))

Solution (Python):
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = defaultdict(int)
for i in range(n):
  s[input()]+=1
m = readInt()
t = defaultdict(int)
for i in range(m):
  t[input()]+=1

ans = 0
for i in s:
  ans = max(ans,s[i]-t[i])
print(ans)

Solution (Python):
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = [input() for i in range(n)]
m = readInt()
t = [input() for i in range(m)]

ans = 0
for i in s:
  ans = max(ans,s.count(i)-t.count(i))
print(ans)

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

Solution (Python):
def dict_update(val):
    s = input()
    if s not in v:
        v[s] = val
    else:
        v[s] += val


v = {}
n = int(input())
for i in range(n):
    dict_update(1)
m = int(input())
for j in range(m):
    dict_update(-1)
print(max(max(v.values()), 0))

Solution (Python):
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

Max = 0
for item in Blue.items():
    s = item[0]
    v = item[1]
    if s in Red:
        v -= Red[s]
    Max = max(Max, v)
print(Max)

Solution (Python):
N = int(input())
dic = {}

for _ in range(N):
    i = input()
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

M = int(input())

for _ in range(M):
    j = input()
    if j in dic:
        dic[j] -= 1
    else:
        dic[j] = -1

print(max(0, max(dic.values())))

Solution (Python):
n = int(input())
dic1 = {}
for i in range(n):
  temp = input()
  dic1.setdefault(temp, 0)
  dic1[temp] += 1
m = int(input())
for i in range(m):
  temp = input()
  dic1.setdefault(temp, 0)
  dic1[temp] -= 1
print(max(0, max(list(dic1.values()))))

Solution (Python):
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
ans=-10**9
for i in range(N):
  a=0
  for j in range(N):
    if s[i]==s[j]:
      a+=1
  for k in range(M):
    if s[i]==t[k]:
      a-=1
  ans=max(ans,a)
if ans<0:
  print(0)
else:
  print(ans)

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
x = collections.Counter(s)
for i in t:
    x[i] -= 1
print(max(max(x.values()),0))

Solution (Python):






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





ans = 0
for i in range(N):
    ans = max(ans, s.count(s[i]) - t.count(s[i]))
print(ans)

Solution (Python):

from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement




n = int(input())
blue = [input() for i in range(n)]
k = int(input())
red = [input() for i in range(k)]
T={}
for x in blue:
    if x not in T: T[x] = 1
    else: T[x]+=1
for x in red:
    if x not in T: T[x] = -1
    else: T[x]-=1
print(max(max(T.values()), 0))

Solution (Python):
from collections import Counter


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


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

    if max_cnt < cnt:
        max_cnt = cnt

print(max_cnt)

Solution (Python):
n = int(input())
S = [input() for _ in range(n)]
m = int(input())
T = [input() for _ in range(m)]
ans = 0
for i in S:
    p = S.count(i)
    m = T.count(i)
    ans = max(ans, p - m)
print(ans)

Solution (Python):
N = int(input())
s = [input() for s in range(N)]
M = int(input())
t = [input() for t in range(M)]
ans = 0
for i in range(N):
	tmp = s.count(s[i]) - t.count(s[i])
	ans = max(ans,tmp)
print(ans)

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
for i in s:
        ans = max(s.count(i) - t.count(i),ans)
print(ans)

Solution (Python):
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from collections import Counter

N = INT()
s = [input() for _ in range(N)]
M = INT()
t = [input() for _ in range(M)]

s = Counter(s)
t = Counter(t)
ans = 0

for k, v in s.items():
    ans = max(ans, v - t[k])
    
print(ans)

Solution (Python):
n = int(input())
s = []

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

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

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

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

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

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

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

print(max(max(counter.values()), 0))

Solution (Python):
N=int(input())
b=[]
for _ in range(N):
  b.append(input())
M=int(input())
r=[]
for _ in range(M):
  r.append(input())

from collections import Counter
red=Counter(r)
blue=Counter(b)
ans=0
for k, v in blue.items():
  ans=max(ans, v-red[k])
print(ans)

Solution (Python):
d = {"DUMMY": 0}
n = int(input())
for i in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1

n = int(input())
for i in range(n):
  s = input()
  d[s] = d.get(s, 0) - 1

print(max(d.values()))

Solution (Python):
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
used = []
for i in range(n):
    if s[i] not in used:
        used.append(str(s[i]))
for j in range(m):
    if t[j] not in used:
        used.append(str(t[j]))

ans = [0]*len(used)
for i in range(len(used)):
    for j in range(n):
        if s[j] == used[i]:
            ans[used.index(used[i])] += 1

for i in range(len(used)):
    for j in range(m):
        if t[j] == used[i]:
            ans[used.index(used[i])] -= 1
if max(ans) >= 0:
    print(max(ans))
else:
    print(0)

Solution (Python):
import heapq

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

l = list(set(s))
total = 0
for i in l:
    total = max(total, s.count(i) - t.count(i))

print(total)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
maxi = 0
for i in s:
    cnt = s.count(i) - t.count(i)
    maxi = max(maxi,cnt)
print(maxi)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
import collections

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

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

    ans = 0
    for key, value in s.items():
        if key in t:
            ans = max(ans, value-t[key])
        else:
            ans = max(ans, value)

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

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

Solution (Python):
N = int(input())
S = list((input() for _ in range(N)))
S_set = set(S)
M = int(input())
T = list((input() for _ in range(M)))
counters = []

for si in S_set:
    counter = 0
    for t in T:
        if t == si:
            counter += -1
    for s in S:
        if s == si:
            counter += 1
    counters.append(counter)
print(max(max(counters),0))

Solution (Python):

import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
count_S = Counter(S)
M = ir()
T = [sr() for _ in range(M)]
count_T = Counter(T)
answer = 0
for k, v in count_S.items():
    temp = v - count_T[k]
    if temp > answer:
        answer = temp

print(answer)

Solution (Python):
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    s = [input() for _ in range(N)]
    M = ii()
    t = [input() for _ in range(M)]
    dic = {}
    for v in s:
        if not v in dic:
            dic[v] = 0
        dic[v] += 1
    for v in t:
        if not v in dic:
            dic[v] = 0
        dic[v] -= 1

    print(max(0, max(dic.values())))

if __name__ == '__main__':
    main()

Solution (Python):
import collections

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

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

S = collections.Counter(s)
T = collections.Counter(t)

S.most_common()
T.most_common()

ans = S - T

try:
    print(ans.most_common()[0][1])
except:
    print('0')

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    ans_dict = {"aaaaaaaaaaa": 0}
    for _ in range(n):
        tmp_input = s_input()
        if tmp_input in ans_dict:
            ans_dict[tmp_input] += 1
        else:
            ans_dict[tmp_input] = 1

    m = i_input()
    for _ in range(m):
        tmp_input = s_input()
        if tmp_input in ans_dict:
            ans_dict[tmp_input] -= 1

    print(max(ans_dict.values()))

if __name__ == '__main__':
    main()

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

m = int(input())

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


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

if s[0][1] < 0:
  print(0)
else:
  print(s[0][1])

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

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

ans = 0
for k, v in cs.items():
    tmp = v
    if k in ct.keys():
        tmp -= ct[k]

    ans = max(ans, tmp)

print(ans)

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

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

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

arr=[]
cou=[0]*(n+m)
for i in s:
  if not (i in arr):
    arr.append(i)
  cou[arr.index(i)]+=1
for i in t:
  if not (i in arr):
    arr.append(i)
  cou[arr.index(i)]-=1
print(max(cou))

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
s.sort()
t.sort()
ans = 0
count = 1
count2 = 0
for i in range(len(s)):
    if i != len(s)-1:
        if s[i] == s[i+1]:
            count+=1
            continue
    for j in range(len(t)):
        if s[i] > t[j]:
            continue
        elif s[i] < t[j]:
            break
        else:
            count2+=1
    ans = max(count-count2,ans)
    count2 = 0
    count = 1
print(ans)

Solution (Python):
n = int(input())
s = list(input() for i in range(n))
m = int(input())
t = list(input() for i in range(m))
a = s + t
a = list(set(a))
p = 0

for i in range(len(a)):
    plus = s.count(a[i])
    minus = t.count(a[i])
    if plus - minus > p:
        p = plus - minus

print(p)

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

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

print(max(0,max(s.values())))

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

m = int(input())
for i in range(m):
    ti = input()
    s[ti] -= 1
ans = 0
for k,v in s.items():
    ans = max(ans, v)

print(ans)

Solution (Python):
N = int(input())
list_s = []
for i in range(N):
  list_s.append(input())
M = int(input())
list_t = []
for k in range(M):
  list_t.append(input())
list_s_new = list(set(list_s))
cnt_list = []
for l in list_s_new:
  cntplus = list_s.count(l)
  cntminus = list_t.count(l)
  cnt_list.append(cntplus-cntminus)
if max(cnt_list) > 0:
  print(max(cnt_list))
else:
  print(0)

Solution (Python):
n=int(input())
a=[input() for i in range(n)]
m=int(input())
b=[input() for i in range(m)]
ans=0
for s in set(a):
    score=a.count(s)-b.count(s)
    if ans<score:
        ans=score
print(ans)

Solution (Python):
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 range(n):
    tmp = s.count(s[i])-t.count(s[i])
    ans=max(ans,tmp)
print(ans)

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

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

Solution (Python):
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]
u=set(s)
ans=0
for i in u:
  temp=s.count(i)-t.count(i)
  ans=max(ans,temp)
print(ans)

Solution (Python):



import sys
from collections import defaultdict


def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


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


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

Solution (Python):
from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
m = int(input())
t = Counter([input() for i in range(m)])
ans = 0
for i in s.most_common():
    ans = max(ans, i[1] - t[i[0]])
print(ans)

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

Solution (Python):
n=int(input())

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

m=int(input())
for i in range(m):
    s=input()
    if s in dic:
        dic[s]-=1
    else:
        dic[s]=-1
        
print(max(0,max(dic.values())))

Solution (Python):
from collections import Counter
N = int(input())
blue = Counter()
for _ in range(N):
    blue[input()] += 1

M = int(input())
red = Counter()
for _ in range(M):
    red[input()] += 1


res = 0
for k in blue.keys():
    res = max(blue[k]-red[k], res)

print(res)

Solution (Python):
from collections import Counter





N = int(input())
ARR = []

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

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

for j in range(M):
    BRR.append(input())


def calculate(a, b):
    result = {}

    for i in a:
        if result.get(i) == None:
            result.__setitem__(i, 1)
        else:
            result.__setitem__(i, result.get(i) + 1)

    for i in b:
        if result.get(i) == None:
            result.__setitem__(i, -1)
        else:
            result.__setitem__(i, result.get(i) - 1)

    print(max(0,max(result.values())))


calculate(ARR, BRR)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    list1=[]
    for i in range(n):
        a =input()
        list1.append(a)

    m = int(input())
    list2=[]
    for i in range(m):
        a =input()
        list2.append(a)

    max= 0
    set1 = set(list1) | set(list2)

    for i in set1:
        count= list1.count(i)-list2.count(i)

        if count > max:
            max=count
    print(max)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
d = {}
for ss in s:
    if ss not in d.keys():
        d[ss] = 1
    else:
        d[ss] += 1
for tt in t:
    if tt not in d.keys():
        d[tt] = -1
    else:
        d[tt] -= 1
max = 0
for dd in d.values():
    if max < dd:
        max = dd
print(max)

Solution (Python):
n=[input() for i in range(int(input()))]
m=[input() for i in range(int(input()))]
l=list(set(n))
x=0
for i in l:
    y=max(0,n.count(i)-m.count(i))
    if y > x:
        x=y
print(x)

Solution (Python):
n = int(input())
ds = {}
for _ in range(n):
    s = input()
    if s not in ds.keys():
        ds[s] = 1
    else:
        ds[s] += 1

m = int(input())
dt = {}
for _ in range(m):
    s = input()
    if s not in dt.keys():
        dt[s] = 1
    else:
        dt[s] += 1

ans = 0
for k in ds.keys():
    if k in dt.keys():
        tmp = ds[k] - dt[k]
    else:
        tmp = ds[k]

    if ans < tmp:
        ans = tmp

print (ans)

Solution (Python):
n=int(input())
plus=[]
for i in range(n):
    plus.append(input())
    
m=int(input())
minus=[]
for j in range(m):
    minus.append(input())
    
x=plus+minus

l=[]
x=set(x)
x=list(x)

for i in range(len(x)):
    l.append(plus.count(x[i])-minus.count(x[i]))
    
if max(l)<0:
    print(0)
else:
    print(max(l))

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
s_set = set(s)
m = int(input())
t = [input() for i in range(m)]
ans = 0
for i in s_set:
    ans = max(ans, s.count(i) - t.count(i))
print(ans)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
d = {}
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for j in t:
    if j in d:
        d[j] -= 1

sd = sorted(d.items(), key=lambda x:x[1], reverse=True)
print(max(0, sd[0][1]))