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: Wrong Answer

Solution code:
n = int(input())
s = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 <= union:
    max1 = union
  else:
    break

max2 = 0
for i in range(1,half+1):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 <= union:
    max2 = union
  else:
    break
    
ans = max1 if max1>max2 else max2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 <= union:
    max1 = union
  else:
    break

max2 = 0
for i in range(half):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 <= union:
    max2 = union
  else:
    break
    
ans = max1 if max1>max2 else max2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 > union:
    break
  else:
    max1 = union

max2 = 0
for i in range(half):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 > union:
    break
  else:
    max2 = union
    
ans = max1 if max1>max2 else max2
print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(n):
    #複数のリストから共通する要素を抽出
    ans = max(ans, len(set(list(s[:i+1])) & set(list(s[i:]))))
    
print(ans)

Submission status: Wrong Answer

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

max_count = 0
for i in range(0, N-1):
  X = S[0:i+1]
  Y = S[i+1:]

  X_set = set(X)
  Y_set = set(Y)
  print(X,Y,X_set)

  count = len(X_set & Y_set)
  if max_count < count:
    max_count = count

print(max_count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
count = 0
for i in range(n-1):
  a=s[:i + 1]
  b=s[i+1:]
  temp = 0
  for j in range(26):
    if chr(96+j) in a and chr(96+j) in b:
      temp += 1
  count = max(temp, count)
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
dic="abcdefghijklmnopqrstuvwxyz"
maxcount = 0
for i in range(n):
  for j in range(26):
    count = 0
    if str(dic[j]) in a[:i] and str(dic[j]) in a[i:]:
      count+=1
  maxcount = max(count,maxcount)
print(maxcount)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
w = set(s)
t = 0
for i in w:
  if s.count(i) >= 2:
    t += 1
print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = 0
for i in range(n):
  if s.count(s[i]) >= 2:
    t += 1
print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
ans = 0
c = 0
fh = []
lh = s
for i in range(n):
  tmp = lh.pop(0)
  if tmp not in fh:
    if tmp in lh:
      c += 1
    else:
      c -= 1
  fh.append(tmp)
  ans = max(ans, c)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
ans = 0
c = 0
fh = []
lh = s
for i in range(n):
  tmp = lh.pop(0)
  if tmp not in fh:
    if tmp in lh:
      c += 1
    else:
      c -= 1
    fh.append(tmp)
  ans = max(ans, c)
print(ans)

Submission status: Wrong Answer

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

result =[]

for i in range(N):
    left = []
    right= []
    for l in range(0,i):
        if S[l] not in left:
            left.append(S[l])
        else:
            continue

    
     
    for r in range(i,N):
        if S[r] not in right:
             right.append(S[r])
        else:
            continue

    print(left)
    print(right)
    count =0
    for i in left:
        for  s in right:
            if i == s :
                count +=1
    result.append(count)
    
print(result)
print(max(result))

Submission status: Wrong Answer

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

result =[]

for i in range(N):
    left = []
    right= []
    for l in range(0,i+1):
        if S[l] not in left:
            left.append(S[l])
        else:
            continue

    
     
    for r in range(i,N):
        if S[r] not in right:
             right.append(S[r])
        else:
            continue

    count =0
    for i in left:
        for  s in right:
            if i == s :
                count +=1
    result.append(count)
    

print(max(result))

Submission status: Wrong Answer

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

result =[]

for i in range(N):
    left = []
    right= []
    for l in range(0,i):
        if S[l] not in left:
            left.append(S[l])
        else:
            continue
    for r in range(i,N):
        if S[r] not in right:
             right.append(S[r])
        else:
            continue

    if len(left)>=len(right):
        result.append(len(right))
    else:
        result.append(len(left))


print(max(result))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
answer = 0
for i in range(1,N-1):
  X = S[:i]
  Y = S[i:]
  Z = 0
  for c in 'abcdefghijklmnopqrstuvwxyz':
    if c in X and c not in Y or c in Y and c not in X:
      Z += 1
  answer = max(answer,Z)
print(answer)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
count=0
for i in range(n):
  str_1=s[0:i]
  str_2=s[i+1:n]
  if count<len(set(str_1)&set(str_2)):
    count=len(set(str_1)&set(str_2))
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
s=""
m=""
ss=[]
mm=[]
s1=set()
m1=set()
res = 0
for i in range(N):
  s=S[0:i]
  m=S[i+1:N]
  ss=list(s)
  mm=list(m)
  s1=set(ss)
  m1=set(mm)
  s_intersection = s1 & m1
  res= max(res,len(s_intersection))
print(res)

Submission status: Wrong Answer

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

for i in range(1, n):
    c = 0
    s1 = s[i:]
    s2 = s[:i]
    S = set(s1)

    for j in S:
        if j in s2:
            c += 1
    cnt = max(cnt, c)

print(cnt)

Submission status: Wrong Answer

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

for i in range(n):
    c = 0
    s1 = s[i:]
    s2 = s[:i]
    S = set(s1)

    for j in S:
        if j in s2:
            c += 1
    cnt = max(cnt, c)

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())

s = list(input())

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

s = list(input())

ans = 0

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

Submission status: Wrong Answer

Solution code:

N = int(input())
S = list(input()) #１文字ずつ

ans=0
for i in range(1,N):
    X = S[0:i]
    Y = S[i:N]
    #print('X.,Y:', X,Y)

    for k in range(len(X)):
        cnt=0
        already=[]
        for l in range(len(Y)):
            if X[k]==Y[l]:
                if X[k] not in already:
                    cnt+=1
                    already.append(X[k])
        ans=max(ans,cnt)

print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()
x = a - int(a / 2)
y = a - x
z = 0
X = b[0:x]
Y = b[x:a]
X = list(set(X))
Y = list(set(Y))
X.sort()
Y.sort()
if len(X) >= len(Y):
    for i in range(len(X) - len(Y)):
        Y.append("")
else:
    for i in range(len(Y) - len(X)):
        X.append("")

for i in range(len(X)):
    if X[i] in Y:
        z = z + 1
print(z)

Submission status: Wrong Answer

Solution code:
import math
def main():
  n = int(input())
  s = input()
  ans=0
  for i in range(0,int(n/2)+2):
    sum=0
    x=s[:i+1]
    y=s[i+1:]
    while len(x)>0:
      if x[0] in y :
        sum+=1
      x=x.replace(x[0],'')
    if sum>ans:
      ans=sum
  print(ans)
main()

Submission status: Wrong Answer

Solution code:
import math
def main():
  n = int(input())
  s = input()
  ans=0
  print(int(n/2)+1)
  for i in range(0,int(n/2)+2):
    sum=0
    x=s[:i+1]
    y=s[i+1:]
    while len(x)>0:
      if x[0] in y :
        sum+=1
      x=x.replace(x[0],'')
    if sum>ans:
      ans=sum
  print(ans)
main()

Submission status: Wrong Answer

Solution code:
import math
def main():
  n = int(input())
  s = input()
  ans=0
  for i in range(0,int(n/2)+1):
    sum=0
    x=s[:i+1]
    y=s[i+1:]
    while len(x)>0:
      if x[0] in y :
        sum+=1
      x=x.replace(x[0],'')
    if sum>ans:
      ans=sum
  print(ans)
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(str,input()))

ans = 0
for i in range(n):
    a = l[0:i]
    b = l[i:n-1]
    tmp = []
    for j in a:
        if j in b:
            tmp.append(j)
    tmp = set(tmp)
    ans = (max(ans,len(tmp)))

print(ans)

Submission status: Wrong Answer

Solution code:
N,S=int(input()),input()
ans=0
for i in range(N):
    a,b,c=S[:i+1],S[i:],0
    for j in range(26):
        if chr(97+j)in a and chr(97+j)in b:c+=1
    ans=max(ans,c)
print(ans)

Submission status: Wrong Answer

Solution code:
N,S,z=int(input()),input(),0
for i in range(N):a,b=S[:i+1],S[i:];z=max(z,len([0 for j in range(26) if chr(97+j) in a and chr(97+j) in b]))
print(z)

Submission status: Wrong Answer

Solution code:
N,S=int(input()),input()
ans=0
for i in range(N):
    a=S[:i+1];b=S[i:]
    c=0;l=[]
    for j in range(i+1):
        if a[j] in b and (not a[j] in l):c+=1;l.append(a[j])
    ans=max(ans,c)
print(ans)

Submission status: Wrong Answer

Solution code:
N,S=int(input()),input()
ans=0
for i in range(N//2):
    a=S[:i+1];b=S[i:]
    c=0;l=[]
    for j in range(i+1):
        if a[j] in b and (not a[j] in l):c+=1;l.append(a[j])
    ans=max(ans,c)
print(ans)

Submission status: Wrong Answer

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

ans=1

for i in range(1,N):
    X=S[:i]
    Y=S[i:]
    setX=set(X)
    setY=set(Y)
    intersectionXY=setX & setY
    _temp=len(intersectionXY)
    if _temp>ans:
        ans=_temp
    else:
        pass
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
max(len(set(S[:i])&set(S[i:])) for i in range(N))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans=0
for i in range(N+1):
  bns=0
  dp=[0]*26
  bp=[0]*26
  a=S[:i]
  b=S[i:]
  a=sorted(a)
  b=sorted(b)
  for j in range(len(a)):
    dp[ord(a[j])-97]+=1
  for k in range(len(b)):
    bp[ord(b[k])-97]+=1
  for l in range(26):
    bns+=min(dp[l],bp[l])
  ans=max(ans,bns)
print(ans)

Submission status: Wrong Answer

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

for i in range(1,n):
  cnt=0
  x=list(set(s[:i]))
  y=list(set(s[i:]))
  for j in x:
    if x in y:
      cnt+=1
  if ans<cnt:
    ans=cnt
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = -1*float('inf')
for i in range(1, n-1):
  ans = max(ans, len(set(s[:i])&set(s[i:])))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = -1*float('inf')
for i in range(0, n-1):
  x = set(s[:i+1])
  y = set(s[i+1:])
  dif = max(x, y) - min(x, y)
  ans = max(ans, len(max(x, y) - dif))
print(ans)

Submission status: Wrong Answer

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

ans = 0
tmp = []
for i, v in enumerate(s):

    if v not in tmp:
        ans += (1 if s[i+1:].count(v) > 0 else 0)
        tmp.append(v)

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
s = input()
lmap = defaultdict(lambda:0)
rmap = set()
lmax = 0
for i in range(n):
  lmap[s[i]]+=1
i = n-1
while i>=0:
  lmap[s[i]]-=1
  rmap.add(s[i])
  if lmap[s[i]]==0:
    del lmap[s[i]]
  x = len(lmap)
  if x==len(rmap):
    #print(i,end=',')
    lmax = max(lmax,x)
  i-=1
print(lmax)

Submission status: Wrong Answer

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

ANS = []
for i in range(n):
  p = 0
  A = set(s[0:i])
  B = set(s[i-1:n+1])
  for j in A:
    if j in B:
      p += 1
  ANS.append(p)
  
  
print(max(ANS))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
maxCommon = 1
for i in range(1, N):
    # print(set(S[0:i]))
    # print(set(S[i:]))
    #print(set(S[0:i]) & set(S[i:]))

    commonNum = len(list(set(S[0:i]) & set(S[i:])))
    if commonNum > maxCommon:
        maxCommon = commonNum
print(maxCommon)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
maxCommon = 1
for i in range(1, N-1):
    commonNum = len(list(set(S[0:i]) & set(S[i:])))
    if commonNum > maxCommon:
        maxCommon = commonNum
print(maxCommon)

Submission status: Wrong Answer

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

import collections

ans = 0
for i in range(n):
    l = collections.Counter(s[:i])
    r = collections.Counter(s[i:])
    cnt = min(len(l), len(r))
    #print(s[:i], s[i:], cnt)
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
ans = 0
for i in range(N):
  A = S[:i]
  B = S[i:]
  C = list(set(A) & set(B))
  print(C)
  c = len(C)
  if c > ans:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans=0
for i in range(1,n-1):
    X=s[:i+1]
    Y=s[i:]
    c=0
    a=list(set(X))
    #print(a)
    for j in range(len(a)):
        if a[j] in Y:
            c+=1
    if c>ans:
        ans=c
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().strip()
cmax = 0
for n in range(1,N-1):
    X = S[:n]
    Y = S[n:]
    Cx = {}
    Cy = {}
    for i in range(n):
        a = X[i]
        if a not in Cx:
            Cx[a] = 0
        Cx[a] += 1
    for i in range(N-n):
        a = Y[i]
        if a not in Cy:
            Cy[a]=0
        Cy[a] += 1
    cnt = 0
    for a in Cx:
        if a in Cy:
            cnt += 1
    cmax = max(cmax,cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
ans = -1
for i in range(n-1):
    x = s[0:i+1]
    y = s[i:]
    temp = 0
    for j in range(26):
        c = chr(ord('a')+j)
        if c in x and c in y:
            temp += 1
    ans = max(ans, temp)
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    def calc_common_char_nums(a, b):
        set_a, set_b = set(list(a)), set(list(b))    # O(n)
        cnt = 0
        for char in string.ascii_lowercase:
            if char in set_a and char in set_b:
                cnt += 1
        return cnt



    n = ii()
    s = input()
    ans = -1
    for i in range(1, n-1):
        a, b = s[:i], s[i:]
        ans = max(ans, calc_common_char_nums(a, b))
    
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
x=""
y=""
saidai=0
for i in range(n):
    x=s[:i+1]
    y=s[i:]
    #print(x,y)
    x_y_and=set(x)&set(y)
    if len(x_y_and)>saidai:
        saidai=len(x_y_and)
    x=""
    y=""
    x_y_and=""
print(saidai)

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect

def solve(s):
    n = len(s)
    max_val = 0
    for i in range(1, n):
        s1 = set(list(s[0:i]))
        s2 = set(list(s[i:]))
        val = len(s1 ^ s2)
        max_val = max(max_val, val)
    return max_val

def main():
    n = int(input())
    s = input()
    print(solve(s))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
v = [0] * n
for c in range(ord('a'), ord('z') + 1):
  p = -1
  for i in range(n):
    if s[i] == c:
      if p >= 0:
        v[i] -= 1
        v[p] += 1
      p = i
ans = 0
vsum = 0
for i in v:
  vsum += i
  ans = max(ans, vsum)
print(ans)

Submission status: Wrong Answer

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


def read():
    N = int(input().strip())
    S = input().strip()
    return N, S


def solve(N, S):
    Z = 26
    cl = [[0 for j in range(Z)] for i in range(N)]  # [0, l)
    cr = [[0 for j in range(Z)] for i in range(N)]  # [l, N)
    for i in range(N):
        if i > 0:
            for j in range(Z):
                cl[i][j] = cl[i-1][j]
        s = ord(S[i]) - ord('a')
        cl[i][s] += 1
    for i in range(N-1, -1, -1):
        if i < N-1:
            for j in range(Z):
                cr[i][j] = cr[i+1][j]
        s = ord(S[i]) - ord('a')
        cr[i][s] += 1
    max_chars = 0
    for i in range(N):
        chars = 0
        for j in range(Z):
            if cl[i][j] > 0 and cr[i][j] > 0:
                chars += 1
        max_chars = max(max_chars, chars)
    return max_chars


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
a = []
ans = 0

for i in s:
    a.append(i)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
max_count = 0
for i in range(1,N-1): # N字目で切った場合
  count_list = np.zeros(26)
  for k in range(i):
#    print(i,k,S[k],S[i:len(S)])
    if S[k] in S[i:len(S)]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
  if max_count < len([1 for x in count_list if x>0]):
    max_count = len([1 for x in count_list if x>0])
  print(count_list)
print(max_count)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
max_count = 0
for i in range(1,N-1): # N字目で切った場合
  count_list = np.zeros(26)
  for k in range(i):
    if S[k] in S[i:len(S)-1]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
#  print(len([1 for x in count_list if x>0]))
  if max_count < len([1 for x in count_list if x>0]):
    max_count = len([1 for x in count_list if x>0])

print(max_count)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
count_list = np.zeros(26)
max_count = 0
for i in range(N-1): # N字目で切った場合
  for k in range(i):
    if S[k] in S[i:len(S)-1]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
  if max_count < len([1 for x in count_list if x>0]):
    max_count = len([1 for x in count_list if x>0])
print(max_count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
print(max(len(set[:i]&set[i:])) for i in range(N))

Submission status: Wrong Answer

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

for i in range(1, n):
    print(i)
    a,b = set(s[:i]), set(s[i:])
    if max(len(a),len(b))-max(len(a-b),len(b-a))>x:
        x = max(len(a),len(b))-max(len(a-b),len(b-a))

print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
diff = -1
ans = 0

for i in range(N):
  x = len(set(list(S[0:i])))
  y = len(set(list(S[i:len(S)])))
  if diff < x - y:
    diff = x - y
    ans = min(x, y)

print(ans)

Submission status: Wrong Answer

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

sp = N - 1
ans = 0
for i in range(1,(sp+1)//2+1):
    cnt = 0
    zenhan = list(set(S[:i]))
    kouhan = list(set(S[i:]))
    for j in zenhan:
        if kouhan.count(j) == 1:
            cnt += 1
    else:
        ans = max(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=str(input())
letters = "abcdefghijklmnopqrstuvwxyz"
max_num=0
for i in range(1,len(letters)):
  S1 = S[0:i]
  S2 = S[i:N]
  count = 0
  for k in range(26):
    n1 = len([1 for x in S1 if x==letters[k]])
    n2 = len([1 for x in S2 if x==letters[k]])
    if n1>0 and n2>0:
      count = count + 1
  if max_num < count:
    max_num = count
print(max_num)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
T=[]
for i in range(N):
    A=set(S[0:i+1])
    B=set(S[i:N+1])
    C=set(A&B)
    T.append(len(C))
print(max(T))

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input().strip()

print(max(len(set(S[i+1:]) & set(S[:i])) for i in range(n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max = 0
for i in range(n):
  max1 = s.count(s[i])
  if (max < max1):
    max = max1

print(max)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ch = []
for i in range(1, n):
    x = s[:i+1]
    y = s[i:len(s)]
    a = set(x)
    b = set(y)
    c = a.intersection(b)
    ch.append(len(c))
print(max(ch))

Submission status: Wrong Answer

Solution code:
#C - Attention
N = int(input())
S = input()
DP_w= []
DP_e = []
tmp = 0
tmpw = 0
tmpe = 0
ans = 0
# for i in range(N):
#     if S[i] == "W":
#         tmpw += 1
#         DP_w.append(tmpw)
#         DP_e.append(tmpe)
#     else:
#         tmpe += 1
#         DP_w.append(tmpw)
#         DP_e.append(tmpe)

for i in range(N):
    tmpw = S[:i].count('W')
    tmpe = S[i:].count('E')
    ans = max(ans,tmpw+tmpw)

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N = int(input())
s = list(input())
ans = -1
for i in range(1,N-1):
    lif = s[:i]
    lib = s[i:]
    cf= list(Counter(lif).keys())
    cb= list(Counter(lib).keys())
    k = len(cf) + len(cb) - len(set(cf+cb))
    ans = max(ans,k)
print(ans)

Submission status: Wrong Answer

Solution code:
def CutandCount(n , s):

    ans = 0

    for i in range(1 , n + 1):
        count = 0
        for w in range(ord('a'), ord('z') + 1):
            if s[:i] in chr(w) and s[i:] in chr(w):
                count += 1

        ans = max(ans , count)

    return ans

def main():
    n = int(input())
    s = str(input())
    print(CutandCount(n , s))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = []
ans.append(1)
for i in range(N):
    if i == 0:
        pass
    elif S[i] == S[i-1]:
        pass
    else:
        S_f = S[:i+1]
        S_b = S[i+1:]
        F = set(S_b)
        B = set(S_f)
        ans.append(len(F&B))
        
print(max(ans))

Submission status: Wrong Answer

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

ans = []
ans.append(len(set(S)))
for i in range(N):
    if i == 0:
        pass
    elif S[i] == S[i-1]:
        pass
    else:
        S_f = S[:i+1]
        S_b = S[i+1:]
        F = set(S_b)
        B = set(S_f)
        ans.append(len(F&B))
        
print(max(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
print(S)
ans = []
ans.append(len(set(S)))
for i in range(N):
    if i == 0:
        pass
    elif S[i] == S[i-1]:
        pass
    else:
        S_f = S[:i+1]
        S_b = S[i+1:]
        F = set(S_b)
        B = set(S_f)
        ans.append(len(F&B))
        
print(max(ans))

Submission status: Wrong Answer

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

ans = 0
for i in range(n-1):
  x = s[:i+1]
  y = s[i+1:]
  count = 0
  
  for j in range(len(x)):
    if x[j] in y:
      count += 1
  if ans <= count:
    ans = count
    
    
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1, n-1):
    a = set(s[:i])
    b = set(s[i:])

    print(a & b)
    
    if max < len(a & b):
        max = len(a & b)
print(max)

Submission status: Wrong Answer

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

max = 0

for i in range(1, n-1):
    a = set(s[:i])
    b = set(s[i:])

    print(a & b)
    
    if max < len(a & b):
        max = len(a & b)
print(max)

Submission status: Wrong Answer

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