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):
N = int(input())
S_list = []
for i in range(N):
    S_list.append(input())

M = int(input())
T_list = []
for i in range(M):
    T_list.append(input())

count_Max = 0
for l in S_list:
    count = 0
    for m in S_list:
        if m == l:
            count += 1
    for n in T_list:
        if n == l:
            count -= 1

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

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

A = list(set(s))
B = []

for k in range(len(A)):
    B.append(s.count(A[k])-t.count(A[k]))

C = max(B)

if C>0:
    print(C)
else:
    print("0")

Solution (Python):
from collections import Counter
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(input())
m=int(input())
for i in range(m):
    b.append(input())
an=Counter(a)
bn=Counter(b)

count=0
for i in an:
    c=an[i]-bn.get(i,0)
    if c>count:
        count=c
print(count)

Solution (Python):
words = {}

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

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

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

Solution (Python):
from collections import defaultdict

N = int(input())
s = []
for n in range(N):
    s.append(input())

M = int(input())
t = []
for m in range(M):
    t.append(input())

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

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

Solution (Python):
def main():
    n = int(input())
    ss = {}
    tt = {}
    for i in range(n):
        key = input()
        if not key in ss:
            ss[key] = 1
        else:
            ss[key] += 1
    m = int(input())
    for i in range(m):
        key = input()
        if not key in tt:
            tt[key] = 1
        else:
            tt[key] += 1
    ans = 0
    for k, v in ss.items():
        if k in tt:
            ans = max(ans, v - tt[k])
        else:
            ans = max(ans, v)
    print(ans)
main()

Solution (Python):
from collections import Counter

N = int(input())

list_s = []
for i in range(N):
    list_s += [input()]

list_t = []
M = int(input())
for i in range(M):
    list_t += [input()]

counter_s = Counter(list_s)
counter_t = Counter(list_t)

for key, count in counter_t.items():
    if key in counter_s:
        counter_s[key] -= count
    else:
        counter_s[key] = -1 * count

m = max(counter_s.values())

print(m if m > 0 else 0)

Solution (Python):
n = int(input())
s = {}
for i in range(n):
    word = input()
    if(word in s):
        s[word] += 1
    else:
        s[word] = 1
m = int(input())
t = {}
for i in range(m):
    word = input()
    if(word in s):
        s[word] -= 1
a = []
for x in s:
    a.append(s[x])
ans = max(a)
if(ans < 0):
    print(0)
else:
    print(ans)

Solution (Python):
N = int(input())
card = {}
for i in range(N):
    s = input()
    if s in card:
        card[s] += 1
    else:
        card[s] = 1
M = int(input())
for i in range(M):
    t = input()
    if t in card:
        card[t] -= 1
ans = 0
for i in card:
    ans = max(ans, card[i])
print(ans)

Solution (Python):
from collections import defaultdict as dd
from pprint import pprint as pp

rs = lambda: input()
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]

N = ri()
s = dd(int)
for _ in range(N):
    s[rs()] += 1
M = ri()
t = dd(int)
for _ in range(M):
    t[rs()] += 1

names = set(s.keys()) | set(t.keys()) | set([None])
result = max(s[name] - t[name] for name in names)
print(result)

Solution (Python):
from collections import Counter

N = int(input())
s = []
for i in range(N):
    s.append(input())
M = int(input())
t = []
for i in range(M):
    t.append(input())
N_count = Counter(s)
M_count = Counter(t)
ans = 0
for i in N_count.keys():
    temp = N_count[i] -M_count[i]
    if ans <= temp:
        ans = temp
print(ans)

Solution (Python):
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

from collections import Counter
def main():
  ss = Counter(input() for _ in range(GI()))
  ts = Counter(input() for _ in range(GI()))

  for k in ss:
    if k in ts:
      ss[k] -= ts[k]

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

main()

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
reward = [0]
for st in s:
    r = s.count(st) - t.count(st)
    reward.append(r)
print(max(reward))

Solution (Python):




def main():
    co=0
    n=input()
    n=int(n)
    l1=[]
    l2=[]
    for i in range(n):
        l1.append(input())
    m=input()
    m=int(m)
    for j in range(m):
        l2.append(input())

    for l in l1:
        co=max(co,l1.count(l)-l2.count(l))


    print(co)


if __name__ == '__main__':
    main()

Solution (Python):
import collections

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

n_dict = collections.Counter(n_array)

m = int(input())
m_array = []
for i in range(m):
    m_array.append(input())
m_dict = collections.Counter(m_array)

res = 0
for i, j in n_dict.items():
    if j - m_array.count(i) > res:
        res = j - m_array.count(i)

print(res)

Solution (Python):
N = int(input())
red = {}
for i in range(N):
    s = input()
    if s in red:
        red[s] += 1
    else:
        red[s] = 1
M = int(input())
for i in range(M):
    s = input()
    if s in red:
        red[s] -= 1
    else:
        red[s] = -1

if max(red.values()) <= 0:
    print(0)
else:
    print(max(red.values()))

Solution (Python):
count = dict([])
n = int(input().strip())
for _ in range(n):
    key = input()
    if key in count:
        count[key] += 1
    else:
        count[key] = 1
m = int(input().strip())
for _ in range(m):
    key = input()
    if key in count:
        count[key] -= 1
    else:
        count[key] = -1
num = 0
for k, v in count.items():
    if num < v:
        num = v
print(num)

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

score = 0
for word in s:
	n = s.count(word)
	m = t.count(word)
	if n > m:
		score = max(score, n-m)

print(score)

Solution (Python):
n = int(input())
x = [input() for i in range(n)]
m = int(input())
y = [input() for i in range(m)]
z,answer = set(x+y),0
for j in z:
	num = x.count(j)-y.count(j)
	if num > answer:
		answer = num
print(answer)

Solution (Python):

from collections import Counter

n = int(input())
N = [input() for i in range(n)]
m = int(input())
M = [input() for i in range(m)]

nc = Counter(N)
mc = Counter(M)

a = set(list(nc.keys())+list(mc.keys()))
ans = 0

for i in a:
    b = nc[i]-mc[i]
    if ans < b:
        ans = b
        
print(ans)

Solution (Python):
import collections
c=collections.Counter()
n=int(input())
for _ in range(n):
    c[input()] +=1
m=int(input())
for _ in range(m):
    c[input()] -=1
print(max(0,c.most_common(1)[0][1]))

Solution (Python):
N = int(input())
ss = []
for i in range(N):
    ss.append(input())
M = int(input())
ts = []
for i in range(M):
    ts.append(input())
ans = 0
for s in ss:
    tmp = ss.count(s) - ts.count(s)
    if tmp > ans:
        ans = tmp
print(ans)

Solution (Python):
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())
sc=Counter(s)-Counter(t)
ans=0

for ss in sc.values():
    ans=max(ans,ss)
print(ans)

Solution (Python):

"""
B - Two Colors Card Game
https://beta.atcoder.jp/contests/abc091/tasks/abc091_b

"""
import sys
from sys import stdin
from collections import defaultdict
input = stdin.readline


def main(args):
    words = defaultdict(int)

    N = int(input())
    for _ in range(N):
        w = input().strip()
        words[w] += 1
    M = int(input())
    for _ in range(M):
        w = input().strip()
        words[w] -= 1

    ans = 0
    for k, v in words.items():
        ans = max(ans, v)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
N = int(input())
S = []

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

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

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

U = list(set([''] + S + T))

R = []

for u in U:
    R.append(sum([s == u for s in S]) - sum([t == u for t in T]))

print(max(R))

Solution (Python):
d = {}
n = int(raw_input())
for i in range(n):
	s = raw_input()
	if d.get(s) == None:
		d[s] = 1;
	else:
		d[s] += 1;
m = int(raw_input())
for i in range(m):
	s = raw_input()
	if d.get(s) == None:
		d[s] = -1;
	else:
		d[s] -= 1;
ans = -10000000000
for i in d:
	if d[i] > ans:
		ans = d[i];

print max(ans,0);

Solution (Python):
from collections import defaultdict
n = int(input())
rec = defaultdict(int)
for i in range(n):
    a = input()
    rec[a] += 1
m = int(input())
for i in range(m):
    a = input()
    rec[a] -= 1

q = -100000
for k, v in rec.items():
    if q <= v:
        q = v

print(max(q, 0))

Solution (Python):
N = int(input())
A = {}
for i in range(N):
    tmp = input()
    if tmp not in A:
        A[tmp] = 1
    else:
        A[tmp] +=1
M = int(input())
B = {}
for j in range(M):
    tmp = input()
    if tmp not in B:
        B[tmp] = 1
    else:
        B[tmp] +=1
maxV = 0
for k,v in A.items():
    if k in B:
        maxV = max(maxV,v-B[k])
    else:
        maxV = max(maxV,v)
print(maxV)

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

cards = defaultdict(int)
for i in s:
    cards[i] += 1
for j in t:
    cards[j] -= 1

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

Solution (Python):
N = int(input())
s = [input() for n in range(N)]
M = int(input())
t = [input() for m in range(M)]
max_coin = 0
for word in s:
    coin = s.count(word) - t.count(word) 
    max_coin = coin if coin > max_coin else max_coin
print(max_coin)

Solution (Python):
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(input())
    m = int(input())
    B = []
    for _ in range(m):
        B.append(input())
    
    ans = 0
    A_set = list(set(A))
    for i in range(len(A_set)):
        tmp = 0
        for j in range(len(A)):
            if(A_set[i] == A[j]):
                tmp += 1
        for j in range(len(B)): 
            if(A_set[i] == B[j]):
                tmp -= 1
        ans = max(ans, tmp)
    print(ans)

    
if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):
a=int(input())
x=[]
for i in range(a):
	s=str(input())
	x.append(s)
b=int(input())
y=[]
for i in range(b):
	s=str(input())
	y.append(s)
m=0
for i in range(a):
	a=x.count(x[i])-y.count(x[i])
	if(a>m):
		m=a
print(m)

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

m = int(input())
t = []
for i in range(m):
    t.append(input())
sset = set(s)
money = 0
for i in sset:
    money = max(money,s.count(i)-t.count(i))
print(money)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
temp = set(s)
for i in temp:
  if s.count(i) - t.count(i) > ans:
    ans = s.count(i) - t.count(i)

print(ans)

Solution (Python):
import math

n = int(input(""))
blue = []
red = []
for i in range(0,n):
    blue.append(input(""))
m = int(input(""))
for i in range(0,m):
    red.append(input(""))
ans = 0
for i in range(0,n):
    temp = 0
    for str in blue:
        temp += 1 if blue[i] == str else 0
    for str in red:
        temp -= 1 if blue[i] == str else 0
    ans = max(ans,temp)
print(ans)

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

result = 0
for s in S:
    score = S.count(s) - T.count(s)
    if result < score:
        result = score
print(result)

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 s in S:
    ans = max(ans, S.count(s) - T.count(s))
print(ans)