Problem:


Score : 200 points

Problem Statement

You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y.
Here, we would like to maximize the number of different letters contained in both X and Y.
Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Constraints

2 \leq N \leq 100

|S| = N

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the largest possible number of different letters contained in both X and Y.

Sample Input 1

6
aabbca

Sample Output 1

2

If we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.
There will never be three or more different letters contained in both X and Y, so the answer is 2.

Sample Input 2

10
aaaaaaaaaa

Sample Output 2

1

However we divide S, only a will be contained in both X and Y.

Sample Input 3

45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir

Sample Output 3

9



Sample input:
6
aabbca


Sample output:
2

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = []
for i in range(1, n):
    a = set(s[0:i])
    b = set(s[i:n])
    ans.append(len(a.intersection(b)))
print(max(ans))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ansMax = 0

for i in range(N - 1):
    ansCnt = 0
    tmpX = "".join(set(S[0:i + 1]))
    tmpY = "".join(set(S[i + 1:]))

    for j in range(len(tmpX)):
        if tmpY.count(tmpX[j]) == 1:
            ansCnt += 1

    ansMax = max(ansMax, ansCnt)

print(ansMax)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(1, N):
  left = S[:i]
  right = S[i:]
  cnt = 0
  both = []
  for j in range(len(right)):
    if right[j] in left and not right[j] in both:
      cnt += 1
      both.append(right[j])
  ans = max(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
a=[]
for i in range(n):
  left=s[:i]
  right=s[i:]
  ps=set(left) & set(right)
  a.append(len(ps))
print(max(a))

Submission status: Accepted

Solution code:
a = int(input())
b = list(input())
c = 0
for i in range(a):
    d = {}
    e = {}
    for j in range(0, min(i+1, a)):
        if b[j] not in d:
            d[b[j]] = 1
    for j in range(i+1, a):
        if b[j] in d and b[j] not in e:
            e[b[j]] = 1

    c = max(c, len(e))
print(c)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print(max(a + b, a - b, a * b))
    return

#B
def B():
    n = II()
    s = S()
    ans = 0
    for i in range(n + 1):
        s1 = list(set(s[i:]))
        s2 = list(set(s[:i]))
        b = 0
        for si in s1:
            b += si in s2
        ans = max(ans, b)
    print(ans)
    return

#C
def C():
    n = II()
    s = S()
    dp = [0 for i in range(n)]
    for num,si in enumerate(s):
        if si == "E":
            dp[num] = dp[num-1]+1
        else:
            dp[num] = dp[num - 1]
    ans = float("INF")
    a = max(dp)
    for i in range(n):
        ans = min(ans,  a - dp[i] + i - dp[i] + (s[i] == "E"))
    
    print(ans)
    return

#D
def D():
    return



#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
r = []
for i in range(1,n):
  l,u = [], []
  for j in range(n):
    if j < i:
      l.append(s[j])
    else:
      u.append(s[j])
  c = 0
  for k in l:
    if k in u:
      u = [t for t in u if t != k]
      c += 1
  r.append(c)
print(max(r))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
S = list(input())
a1 = []
a2 = []
duplicate = []
max_num = 0

for i in range(1, N):
    a1 = S[0:i]
    a2 = S[i::]
    duplicate = [x for x in set(a1) if a2.count(x) >= 1]
    if len(duplicate) > max_num: 
        max_num = len(duplicate)
print(max_num)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()
l = []
for i in range(1, N):
    a = S[0:i]
    b = S[i:]
    a_set = set(a)
    b_set = set(b)
    # c = intersection(a_set, b_set)
    c = a_set & b_set
    l.append(len(c))
print(max(l))
    # a_l = len(Counter(a))
    # b_l = len(Counter(b))
    # print(a_l)
    # print(b_l)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
r = []
c = 0
for x in range(N):
  a = S[:x]
  b = S[x:]

  for y in set(a):
    if y in b:
      c += 1
  r.append(c)
  c = 0
print(max(r))

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
r = []
c = 0
for x in range(N):
  a = S[:x]
  b = S[x:]
  if len(a) >= 1 and len(b) >= 1:
    for y in set(a):
      if y in b:
        c += 1
    r.append(c)
  c = 0
print(max(r))

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
ans = [i * 0 for i in range(100)]
if n == 2:
    ans.clear()
    if s[0] == s[1]:
        ans.append(1)
    else:
        ans.append(0)
else:
    for i in range(0,n-1):
        tmp1 = list(set(s[:i]))
        tmp2 = list(set(s[i:]))
        for j in range(len(tmp1)):
            if tmp1[j] in tmp2:
                ans[i] += 1
print(max(ans))

Submission status: Accepted

Solution code:
a = int(input())
b = input()
ans = 0
for i in range(1, a-1):
    c = b[:i]
    d = b[i:]
    e = 0
    f = []
    for j in range(len(c)):
        for k in range(len(d)):
            if c[j] == d[k] and c[j] not in f:
                e += 1
                f.append(c[j])
                break
    ans = max(ans, e)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(1,N):
    A,B = S[:i],S[i:]
    A,B = set(A),set(B)
    ans = max(ans,len(A&B))
print(ans)

Submission status: Accepted

Solution code:
n,s = int(input()),input()
t=0
for i in range(1,n):
  t=max(t,(len(set(s[:i])&set(s[i:]))))
print(t)

Submission status: Accepted

Solution code:
n,s = int(input()),input()
tmp=[]
for i in range(1,n):
  tmp.append(len(list(set(s[:i])&set(s[i:]))))
print(max(tmp))

Submission status: Accepted

Solution code:
n,s = int(input()),input()
tmp=[]
for i in range(1,n):
  cnt = 0
  for j in list(set(s[:i])):
    if j in list(set(s[i:])):
      cnt += 1
  tmp.append(cnt)
print(max(tmp))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(N - 1):
    ans = max(ans, len(set(S[:i + 1]) & set(S[i + 1:])))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

ans = 0
for i in range(len(s)):
    ans = max(ans, len(set(s[:i+1]) & set(s[i+1:])))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
m = 0
for i in range(n):
  m = max(m,len(set(s[:i]) & set(s[i:])))
print(m)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(n):
    x = len(set(s[:i]) & set(s[i:]))
    if x > ans:
        ans = x
    if ans > n // 2:
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

pre={}
back={}

for i in range(len(S)):
    n = pre.get(S[i], 0)
    n = n+1
    pre[S[i]] = n

ans = 0
for i in range(len(S)):
    n = pre[S[i]]
    if(n > 1):
        pre[S[i]] = n-1
    else:
        pre.pop(S[i])
    back[S[i]] = back.get(S[i], 0) + 1
    c = [x for x in list(pre.keys()) if x in list(back.keys())]
    ans = max(ans,len(c))

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s = str(input())
ans=0
for i in range(n):
    s1=set(s[:i])
    s2=set(s[i:])
    tmp=len(s1&s2)
    if tmp>ans:ans=tmp
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
count = 0
for i in range(2, N-1):
    left = set(S[0:i])
    right = set(S[i:])
    num = len(left & right)
    if num > count:
        count = num
print(count)

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    S = list(_ for _ in input())
    max_S = 0
    for i in range(N):
        S1 = set(S[0:i])
        S2 = set(S[i:N])
        max_S = max(max_S,len(S1.intersection(S2)))
    print(max_S)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
S = input()
counters = []
for i in range(0, 26):
	counters.append(0)
for i in range(0, N):
	counters[ord(S[i])-97] += 1
R = counters
L = []
for i in range(0, 26):
	L.append(0)
max = 0
for i in range(0, N):
	R[ord(S[i])-97] -= 1
	L[ord(S[i])-97] += 1
	cnt = 0
	for j in range(0, 26):
		if R[j] != 0 and L[j] != 0:
			cnt += 1
	if max < cnt:
		max = cnt
print(max)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

largest_size_intersection = 0
for split in range(N):
    left = set(S[:split])
    right = set(S[split:])
    largest_size_intersection = max(largest_size_intersection, len(left.intersection(right)))
print(largest_size_intersection)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

answer = 0
for L in range(N):
  left = S[:L]
  right = S[L:]
  both = set(left) & set(right)
  answer = max(answer, len(both))

print(answer)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

ans = 0
for i in range(n-1):#iは左側の最大のindex
    tmp = []
    cnt = 0
    for j in range(i+1):
        if s[j] not in tmp:
            tmp.append(s[j])
    for j in range(i+1,n):
        if s[j] in tmp:
            cnt += 1
            tmp.remove(s[j])
    if ans < cnt:
        ans = cnt
print(ans)

Submission status: Accepted

Solution code:
#x, y = map(int,input().split())
#ls = list(map(int,input().split()))
n = int(input())
s = input()
#x, y = input().split()
ls = []
for i in range(n):
  ls.append([set(s[:i]),set(s[i:])])

n_ls = [len(i[0] & i[1]) for i in ls]
print(max(n_ls))

Submission status: Accepted

Solution code:
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    ans = max(ans, len(set(s[:i]) & set(s[i:])))

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

count = 0
for i in range(1, n):
    l = s[:i]
    r = s[i:]
    
    x = 0
    if len(set(l)) > len(set(r)):
        x = len(set(l)) - len(set(l) - set(r))
    else:
        x = len(set(r)) - len(set(r) - set(l))
    
    if count < x:
        count = x

print(count)

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    s = input()

    ans = -float("inf")
    for i in range(1, n):
        l = set(s[:i])
        r = set(s[i:])
        ans = max(ans, len(l.intersection(r)))

    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

result = []

for i in range(N):
    a = set(list(S[:i]))
    b = set(list(S[i:]))
    result.append(len(a.intersection(b)))

print(max(result))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
result=0
for i in range(1,n):
	result=max(result,len(set(s[:i])&set(s[i:])))
print(result)

Submission status: Accepted

Solution code:
n = int(input())

s = input()

ans = 0

# 分割
for i in range(1, n):
    # print(s[:i], s[i:])
    x = len(set(s[:i]).intersection(set(s[i:])))
    ans = max(ans, x)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

def char_count(a, b):
    if len(a) < len(b):
        s1 = a
        s2 = b
    else:
        s1 = b
        s2 = a
    result = 0
    d = {}
    for s in s1:
        if s in d:
            continue
        d[s] = True
        if s in s2:
            result += 1
    return result

ans = 0
for i in range(1, N-1):
    ans = max(ans, char_count(S[:i], S[i:]))

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
res = 0
for i in range(n):
    x = set(s[:i])
    y = set(s[i:])
    res = max(res, len(x&y))

print(res)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    #print(s[:i], " ", s[i:])
    l = set(s[:i])
    r = set(s[i:])
    ans = max(ans, len(l & r))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
#print(s)

ans=[]

for i in range(n):
    a=set(s[:i])
    b=set(s[i:])
    ans.append(len(a&b))
print(max(ans))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
l=0
for i in range(n-1):
  l=max(len(set(s[:i+1])&set(s[i+1:])),l)
print(l)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
list_ = []

for i in range(n):
    x = set(s[:i])
    y = set(s[i:])
    cnt = 0
    for j in x:
        if j in y:
            cnt += 1
    list_.append(cnt)

print(max(list_))

Submission status: Accepted

Solution code:
N = int(input())
S = input()

cnt = 0

for i in range(N-1):
    a = S[:i+1]
    b = S[i+1:]
    a = set(a)
    b = set(b)
    cnt = max(cnt, len(a & b))

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    lstx = list(s[:i])
    lsty = list(s[i:])
    lstxy = set(lstx) & set(lsty)
    if len(lstxy)>ans:
        ans=len(lstxy)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()

l=[]

for i in range(n-1):
    a = s[:i]
    b = s[i:]
    xy=set(a)&set(b)
    l.append(len(xy))
    

print(max(l))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
cnt = 0
for i in range(1,n+1):
    for c in set(s[0:i]):
        if c in set(s[i:]):
            cnt+=1
    ans = max(ans,cnt)
    cnt = 0
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
count=0
x=[]
for i in range(n-1):
    a=s[:i+1]
    b=s[i+1:]
    c=set(a)&set(b)
    x.append(len(c))
    
print(max(x))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
count=0
x=[]
for i in range(n-1):
    a=s[:i+1]
    b=s[i+1:]
    for j in range(97,123):
        if a.count(chr(j))!=0 and b.count(chr(j))!=0:
            count+=1
    x.append(count)
    count=0
print(max(x))

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())

count = 0

for i in range(1, N + 1):
    set_a = set(S[:i])
    set_b = set(S[i:])
    set_c = set_a & set_b
    count = max(count, len(set_c))
    
print(count)

Submission status: Accepted

Solution code:
n = int(input())
b = input()
ans = 0
for i in range(n):
    pre = 0
    temp = b[:i]
    for k in range(i, n):
        flag = True
        for dub in range(i, k):
            if b[dub] == b[k]:
                flag = False
                break
        if flag:
            for com in temp:
                if b[k] == com:
                    pre += 1
                    break
    if pre > ans:
        ans = pre
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

res = []
for i in range(N):
    former = set(S[:i])
    latter = set(S[i:])
    res.append(len(former & latter))
print(max(res))

Submission status: Accepted

Solution code:
# ABC098B - Cut and Count
def main():
    n = int(input())
    s = input()
    cnt = 0
    for i in range(1, n):
        l, r = set(s[:i]), set(s[i:])
        cnt = max(cnt, len(l & r))
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
S = input()
count = 0
for i in range(1, N):
    X = list(S[:i])
    Y = list(S[i:])
    count = max(count, len(set(X) & set(Y)))
print(count)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
m = 0
for i in range(1,N):
    X = list(S[:i])
    Y = list(S[i:])
    m = max(m,len(set(X)&set(Y)))
print(m)

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
S = s()

max_common = 0
for i in range(1, N-1):
    X = set(S[:i])
    Y = set(S[i:])
    common = len(X.intersection(Y))
    if max_common < common:
        max_common = common
print(max_common)

Submission status: Accepted

Solution code:
n=int(input())
s=input()

maxcount=0
for i in range(n-1):
    left=s[:i+1]
    right=s[i+1:]
    
    leftset=set()
    for ss in left:
        leftset.add(ss)

    rightset=set()
    for ss in right:
        rightset.add(ss)

    maxcount=max(maxcount,len(leftset&rightset))
print(maxcount)

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
count = 0
ans = 0

for i in range(1,N):
    for a in alphabet:
        X = S[:i].count(a)
        Y = S[i:].count(a)
        if X > 0 and Y > 0:
            count += 1
    ans = max(ans, count)
    count = 0

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

al = [chr(i) for i in range(97, 97+26)]
ans = 0
for i in range(N):
    a = S[i:]
    b = S[:i]
    cnt = 0
    for j in al:
        if j in a and j in b:
            cnt+=1

    ans = max(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:

N = int(input())
S = input()

ans = 0

for i in range(N):

    if i != 0:

        now = 0
        
        dicA = {}
        dicB = {}

        A = S[:i]
        B = S[i:]

        for j in A:
            dicA[j] = 1

        for j in B:
            dicB[j] = 1

        for j in dicA:

            if j in dicB:

                now += 1

        ans = max(ans,now)

print (ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input().rstrip()
 
ans = 0
for i in range(1, len(s)):
  s1, s2 = s[0:i], s[i:]
  c = set(s1).intersection(set(s2))
  ans = max(ans, len(c))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(1,N):
    bef = list(set(S[:i]))
    aft = list(set(S[i:]))
    cnt = 0
    for j in bef:
        if j in aft:
            cnt += 1
    else:
        ans = max(cnt, ans)

print(ans)

Submission status: Accepted

Solution code:
def types(st1, st2):
    ret = 0
    for i in range(26):
        j = chr(i + 97)
        if j in st1 and j in st2:
            ret += 1
    return ret

n = int(input())
s = input()

ans = 0
for i in range(n-1):
    ans = max(ans, types(s[:i], s[i:]))
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = input()
mx = 0
for i in range(1,N):
    pre = Counter(S[:i])
    back = Counter(S[i:])
    tmp = 0
    for k in pre.keys():
        if k in back:
            tmp += 1
    mx = max(mx, tmp)
print(mx)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    #a = s[::]
    l,r = list(set(s[:i])),list(set(s[i:]))
    #print(l,r)
    tmp = 0
    if len(l)>len(r):
        for c in r:
            if c in l:  tmp += 1
        ans = max(ans,tmp)
    else:
        for c in l:
            if c in r:  tmp += 1
        ans = max(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
def abc():
    n = int(input())
    s = input().rstrip()
    max_dup = 0
    for i in range(1, n+1):
        s1 = set(s[0:i])
        s2 = set(s[i:])
        max_dup = max(max_dup, len(s1 & s2))
    print(max_dup)


abc()

Submission status: Accepted

Solution code:
def resolve():
    n=int(input())
    s=input()
    mx=0
    alp=list('abcdefghijklmnopqrstuvwxyz')
    l=[0 for i in alp]
    for i in range(n):
        lt=s[:i+1]
        lb=s[i+1:]
        fuku=0
        for j in alp:
            if j in lt and j in lb:
                fuku+=1
        mx=max(mx,fuku)
    print(mx)
resolve()

Submission status: Accepted

Solution code:
N = int(input())
S = input()
left = ""
right = ""
ans = []
for i in range(N):
    left = S[:i+1]
    right = S[i+1:]
    left_n = set(list(left))
    right_n = set(list(right))
    count = 0
    for l in left_n:
        if l in right_n:
            count += 1
    ans.append(count)
print(max(ans))

Submission status: Accepted

Solution code:
N = int(input())
S = input()

answer = 0
for L in range(N):
  left = S[:L]
  right = S[L:]
  both = set(left) & set(right)
  answer = max(answer, len(both))

print(answer)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
S = input()
ans = []
for i in range(N-1):
    c=0
    #print(S[0:i+1],S[i+1:])
    for j in list(set(S[0:i+1])):
        if j in list(set(S[i+1:])):
            c+=1
    ans.append(c)
print(max(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
s = input()
ans = 0
for i in range(len(s)):
    a = set(s[:i+1])
    b = set(s[i+1:])
    ab = a & b
    ans = max(ans, len(ab))

print(ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()

ans = 0
for i in range(N):
    a = set(Counter(S[:i]).keys())
    b = set(Counter(S[i:]).keys())
    ans = max(ans, len(a&b))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

ans = 0

for i in range(N):
  temp = len(set(S[:i])&set(S[i:]))
  ans = max(temp, ans)

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()

cnt=0
for i in range(n):
  temp=len(set(s[:i])&set(s[i:]))
  cnt=max(temp,cnt)
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

cnt = 0
for i in range(n):
  tmp = len(set(s[:i])&set(s[i:]))
  cnt = max(tmp,cnt)
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

cnt = 0
for i in range(n):
  tmp = len(set(s[:i]).intersection(s[i:]))
  cnt = max(tmp,cnt)
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
s = input()

cnt = 0
for i in range(1,n):
  tmp = 0
  for a in set(list(s[:i])):
    tmp += max(np.sign(s[i:].find(a)+0.5),0)
  cnt = max(cnt,tmp)
print(int(cnt))

Submission status: Accepted

Solution code:
n = int(input())
s = input()


def f(s1, s2):
    return len(set(s1).intersection(set(s2)))


print(max(map(lambda i: f(s[:i], s[i:]), range(1, n))))

Submission status: Accepted

Solution code:
N = int(input())
S = input()

ans = 0
for i in range(1, N):
    s1 = set(list(S[:i]))
    s2 = set(list(S[i:]))
    ans = max(ans, len(s1&s2))
print(ans)

Submission status: Accepted

Solution code:

n = int(input())
s = input()
ans = 0
for i in range(len(s)-1):
	s1 = list(set(s[i+1:]))
	s2 = list(set(s[:i+1]))

	tog = 0
	for i in s1:
		if i in s2:
			tog += 1

	ans = max(tog,ans)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    cnt = 0
    s_b = s[:i]
    s_a = s[i:]
    for j in set(s_b):
        if j in s_a:
            cnt+=1
    if cnt > ans:
        ans = cnt
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
S_set = list(set(S))
mx_ans = 0
for n in range(N):
  X = S[:n]
  Y = S[n:]
  ans = 0
  for i in range(len(S_set)):
    if (X.count(S_set[i])>0) and (Y.count(S_set[i])>0):
      ans += 1
  if mx_ans < ans:
    mx_ans = ans
print(mx_ans)

Submission status: Accepted

Solution code:
import sys


if __name__ == '__main__':
    N = int(input())
    S = str(input())

    S_list = list(S)

    answer = - sys.maxsize
    for i in range(1,len(S)):
        left_S = S_list[:i:]
        right_S = S_list[i::]
        cnt_both_S = len(set(left_S) & set(right_S))
        answer = max(answer, cnt_both_S)

    print(answer)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
ans=0
for i in range(n):
    t1=set(s[:i])
    t2=set(s[i:])
    ans=max(ans,len(t1&t2))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
st='abcdefghijklmnopqrstuvwxyz'
ans=0
for i in range(1,n-1):
    ll=[0]*26
    rl=[0]*26
    for j in range(i):
        ll[st.index(s[j])]+=1
    for j in range(i,n):
        rl[st.index(s[j])]+=1
    cnt=0
    for j in range(26):
        cnt+=1 if ll[j]>0 and rl[j]>0 else 0
    ans=max(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    chars = set([c for c in S[:i]]) & set([c for c in S[i:]])
    ans = max(ans, len(chars))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

max_size = 0
for i in range(1, n):
    former = s[:i]
    latter = s[i:]
    max_size = max(len(set(former) & set(latter)), max_size)
print(max_size)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

ans = 0

for i in range(1,N):
    left =  S[:i]
    right = S[i:]
    ans = max(ans, len(set(left)&set(right)))

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

cnt = 0

for i in range(n):
    li1 = s[:1+i]
    li2 = s[1+i:]
    ans = list(set(li1) & set(li2))
    cnt = max(cnt, len(ans))
    
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = int(input())
s = input()
ans = 0
for n in range(N):
    s_and = len(set(s[:n]) & set(s[n:]))
    ans = max(ans, s_and)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
max = 0
for i in range(1, N-1):
  X = set(S[0:i])
  Y = set(S[i:N])
  if max < len(X&Y):
    max = len(X&Y)
print(max)

Submission status: Accepted

Solution code:
n = int(input())
s = input()

res = 0
for i in range(1, n):
    cnt = 0
    sub_b, sub_a = set(s[:i]), set(s[i:])
    for j in sub_b:
        if j in sub_a:
            cnt += 1
    res = max(res, cnt)
    
print(res)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
ans = 0
for i in range(1,n-1):
    ans = max(ans, len(set(s[:i])) + len(set(s[i:])) - len(set(s)))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())

cnt = 0
for i in range(n+2):
    c = set(s[0:i]) & set(s[i:n+1])
    if len(c) >= cnt:
        cnt = len(c)
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
S = input()

ans = 0

for i in range(1,N-1):
    left = set(S[:i])
    right = set(S[i:])
    ans = max(ans,len(left&right))
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(n):
    x = s[:i+1]
    y = s[i+1:]
    ans = max(ans,len(set(x)&set(y)))

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(1,n) :
	cnt = 0
	l = s[:i]
	r = s[i:]
	for j in l :
		if j in r :
			cnt += 1
			r = r.replace(j, '')
	ans = max(cnt ,ans)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N, = map(int, input().split())
S = list(input().strip())

ans = 0
for i in range(1, N):
    x = set(S[0:i])
    y = set(S[i:])
    
    ans = max(ans, len(x & y))
    
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
moji=input()
ans=0
for i in range(1,n-1):
  left=set(list(moji[:i]))
  right=set(list(moji[i:]))
  if len(left&right)>ans:
    ans=len(left&right)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
count=[]
for i in range(n):
  count.append(len(set(s[:i])&set(s[i:])))
print(max(count))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
A=[]
B=[]
for i in range(len(s)):
    c=set(s[0:i])&set(s[i:len(s)])
    a=len(list(c))
    A.append(a)
print(max(A))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    X = {c for c in S[:i]}
    Y = {c for c in S[i:]}
    ans = max(ans, len(X & Y))
print(ans)

Submission status: Accepted

Solution code:
a=input()
n=input()
C=[]
dic={}
for i in n:
    if i not in dic:
        dic[i]=1
    else:
        dic[i]+=1
c=A=0;
for i in n:
    if dic[i]>1:
        dic[i]-=1
        if i not in C:
            C.append(i)
            c+=1
            if c>A:A=c
    else:
        if i in C:
            c-=1
print(A)

Submission status: Accepted

Solution code:
n=int(input())
l=input()

ans=[]
for i in range(n):
    l1=set(l[:i])
    l2=set(l[i:])
    ll=l1&l2
    ans.append(len(ll))
    
print(max(ans))

Submission status: Accepted

Solution code:
N=int(input())
L=list(input())
ans=[]
for i in range(N):
  a=set(L[:i+1])
  b=set(L[i+1:])
  ans.append(len(a & b))
print(max(ans))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
result = []
if len(set(s)) == 1:
  print(1)
else:
  for i in range(n):
    tmp = 0
    for k in set(s[:i]):
      if k in s[i:]:
        tmp += 1
    result.append(tmp)
  print(max(result))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
  n = int(input())
  s = list(input())
  ans = 0
  for i in range(0, len(s)):
    x = set(s[:i+1])
    y = set(s[i+1:])
    num = len(x & y)
    if ans <= num:
      ans = num
  print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
ans=0
for i in range(n):
    ans=max(ans,len(set(s[0:i+1])&set(s[i+1:n])))
print(ans)