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:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def check(s, idx):
    s1 = set(s[:idx])
    s2 = set(s[idx:])
    return len(s1 & s2)

def main():
    n = int(input())
    s = input()[:-1]

    ma = -1 * 10**9
    
    for i in range(1, n-1):
        if check(s, i) > ma:
            ma = check(s,i)

    print(ma)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

a = set(s[:(n//2)])

for i in a:
    if(s.rfind(i) >= (n//2)-2):
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys

n=int(input())
s=str(input())
list=[]
for i in range(1,n):
	a=s[0:i]
	b=s[i:]
	print(a)
	print(b)
	count=0
	for j in range(97,97+26):
		if (chr(j) in a)and(chr(j) in b):
			count+=1
	list.append(count)
print(max(list))

Submission status: Wrong Answer

Solution code:
import collections

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

m = 0
index = 0
for i in range(N):
    a = set(S[:i])
    b = set(S[i:])
    #print(a)
    #print(b)
    d = 0
    for c in a:
        if c in b:
            d += 1
    if d > m:
        m = d
        index = i
print(index - 1)

Submission status: Wrong Answer

Solution code:
import collections

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

m = 0
index = 0
for i in range(1, N):
    a = set(S[:i])
    b = set(S[i:])
    #print(a)
    #print(b)
    d = 0
    for c in a:
        if c in b:
            d += 1
    if d > m:
        m = d
        index = i
print(index - 1)

Submission status: Wrong Answer

Solution code:
import collections

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

m = 0
index = 0
for i in range(1, int(N*0.5)+1):
    a = set(S[:i])
    b = set(S[i:])
    #print(a)
    #print(b)
    d = 0
    for c in a:
        if c in b:
            d += 1
    if d > m:
        m = d
        index = i
print(index - 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(input())
ans = 0
for i in range(n):
  l1 = l[i:]
  count = 0
  for j in range(i+1):
    if l[j] in l1:
      count += 1
  ans = max(ans,count)
  
print(ans)

Submission status: Wrong Answer

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

m = 0

l = [max(m, len(set(S[:S.index(s)])&(set(S[S.index(s):])))) for s in S]
print(max(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans=0
for i in range(N-1):
  A=set(S[:i+1])
  B=S[i:]
  cnt=0
  for j in A:
    if (j in B):
      cnt+=1
  ans=max(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
ans=0
for i in range(N-1):
  A=set(S[:i+1])
  B=set(S[i:])
  cnt=0
  for j in A:
    if (j in B):
      cnt+=1
  ans=max(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
x = int(input())
seen = [0] * 1001
ans = 1
for i in range(x):
    if(seen[i]): pass
    cur = i
    if(i > 1):
        while (cur <= x):
            cur *= i
            if(cur <= x): ans = max(ans, cur)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n = int(input())
s = list(input())
x = []
y = []
ans = []

for i in range(1,n):
    x = s[0:i]
    y = s[i:n]
    print(x)
    print(y)

    for j in range(len(x)):
        a = 0
        if y.count(x[j]) >= 1:
            a += 1
    ans.append(a)
    print(ans)

print(max(ans))

Submission status: Wrong Answer

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

num=0
for i in range(n):
    x=set(s[:n])
    y=set(s[n:])
    if len(x&y)>num:
        num=len(x&y)

print(num)

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
  cnt = 0
  X = S[:i]
  Y = S[i + 1:]
  for j in range(i):
    if X[j] in Y:
      cnt += 1
  ans = max(cnt,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ls = list("abcdefghijklmnopqrstuvwxyz")
ans = [0]*n
for i in range(1,n):
  for j in ls:
    if j in s[:i] and j in s[i+1:]:
      ans[i]+=1
print(max(ans))

Submission status: Wrong Answer

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


def solve(N: int, S: str):
    ans = 0
    for i in range(N):
        Z = set(S[:i+1]) & set(S[i:])
        ans = max(len(set(Z)), ans)
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, S: str):
    ans = 1
    for i in range(N):
        X = set(S[:i+1])
        Y = set(S[i:])
        Z = X & Y
#        print(set(Z))
        ans = max(len(set(Z)), ans)
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, S: str):
    ans = 1
    if N == 2:
        print(ans)
        return
    for i in range(N):
        X = set(S[:i+1])
        Y = set(S[i:])
        Z = X & Y
#        print(set(Z))
        ans = max(len(set(Z)), ans)
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, S: str):
    ans = 1
    if N == 2:
        print(ans)
        return
    for i in range(N - 1):
        X = set(S[:i+1])
        Y = set(S[i:])
        Z = X & Y
#        print(set(Z))
        ans = max(len(set(Z)), ans)
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=str(input())
uniq=len(set(S))
S_a=''
S_b=''
#count_a=[]
#count_b=[]
count=0
ans=[]
for i in range(1,N):
  S_a=S[:i]
  S_b=S[i:]
  count_a=list(set(S_a))
  count_b=list(set(S_b))
  if len(count_a)<=len(count_b):
    for j in range(len(count_a)):
      if count_a[j] in count_b:
        count+=1
  else:
    for j in range(len(count_b)):
      if count_a[j] in count_b:
        count+=1
  ans.append(count)
  count=0
print(max(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=str(input())
uniq=len(set(S))
S_a=''
S_b=''
#count_a=[]
#count_b=[]
count=0
ans=[]
for i in range(1,N):
  S_a=S[:i]
  S_b=S[i:]
  count_a=list(set(S_a))
  count_b=list(set(S_b))
  if len(count_a)<len(count_b):
    for j in range(len(count_a)):
      if count_a[j] in count_b:
        count+=1
  else:
    for j in range(len(count_b)):
      if count_a[j] in count_b:
        count+=1
  ans.append(count)
  count=0
print(max(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
m = 1
for i in range(n):
  t = len(set(s[:i]) & set(s[i:]))
  if t > m:
    m = t
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
m = 1
for i in range(1,n-1):
  t = len(set(s[:i]) & set(s[i:]))
  if t > m:
    m = t
print(m)

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
S=one_str()

maxs=-1
for i in range(1,N-1):
    temp = len(set(S[:i]) & set(S[i:]))
    if maxs < temp:
        maxs = temp

print(maxs)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ret = input()
count_max = 0
for i in range(1, len(ret)):#全ての場所での分割を試す
  count = 0
  for k in range(97, 123):#それぞれのアルファベットがそれぞれの部分に含まれるか検証(アスキーコードを用いる）
    if ((chr(k) in ret[:i]) and (chr(k) in ret[i:])):
      count += 1
  if count > count_max:
    count_max = count
print(count_max)

Submission status: Wrong Answer

Solution code:
ret = input()
count_max = 0
for i in range(1, len(ret)):#全ての場所での分割を試す
  count = 0
  for k in range(97, 123):#それぞれのアルファベットがそれぞれの部分に含まれるか検証(アスキーコードを用いる）
    if ((chr(k) in ret[:i]) & (chr(k) in ret[i:])):
      count += 1
  if count > count_max:
    count_max = count
print(count_max)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().strip()
cmax = 0
for i in range(1,N//2+1):
    A = set(list(S[:i]))
    B = set(list(S[i:]))
    C = A&B
    cmax = max(cmax,len(C))
print(cmax)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
a = set(S[:1])
b = set(S[1:])
M = a & b

for i in range(2,N):
  a = set(S[:i])
  b = set(S[i:])
  if (a & b) > M:
    M = (a & b)
  else:
    print(M)
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
letters = list("abcdefghijklmnopqrstuvwxyz")
max([len([x for x in letters if (x in S[:i]) & (x in S[i:])]) for i in range(1, n)])

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
l = [] 
for i in range(len(s)):
    x = s[:i]
    y = s[i:]
    for j in x:
        if x.count(j) >= 2:
            while True:
                if x.count(j) == 1:
                    break
                else:
                    x.remove(j) 
    t = 0
    for j in x:
        if j in y:
            t += 1
    l.append(t)
print(max(l))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
l = [] 
for i in range(len(s)):
    x = s[:i]
    y = s[i:]
    for j in x:
        if x.count(j) >= 2:
            while True:
                if j not in x:
                    break
                else:
                    x.remove(j) 
    t = 0
    for j in x:
        if j in y:
            t += 1
    l.append(t)
print(max(l))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
l = []
for i in range(len(s)):
    x = s[:i]
    y = s[i:]
    t = 0
    for j in x:
        if j in y:
            t += 1
            if x.count(j) >= 2:
                while True:
                    if j not in x:
                        break
                    else:
                        x.remove(j)  
    l.append(t)
print(max(l))

Submission status: Wrong Answer

Solution code:
S = input()
p = list(S)
wordcount ={}
for i in p :
  if i not in wordcount:
    wordcount[i] = 1
  else:
    wordcount[i] +=1
result = 0
for key,value in wordcount.items():
  if value >=2:
    result += 1
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
l = []
for i in range(len(s)):
    x = s[:i]
    y = s[i:]
    t = 0
    for j in x:
        if j in y:
            t += 1
    for j in x:
        if x.count(j) >= 2:
            t -= (x.count(j) - 1)
    l.append(t)
print(max(l))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
l = []
for i in range(len(s)):
    x = s[:i]
    y = s[i:]
    t = 0
    for j in x:
        if j in y:
            t += 1
            if x.count(j) >= 2:
                t -= (x.count(j) - 1)
    l.append(t)
print(max(l))

Submission status: Wrong Answer

Solution code:
s = "abdcfmekdssldjglle"
l = []
for i in range(len(s)):
    x = s[:i]
    y = s[i:]
    t = 0
    for j in x:
        if j in y:
            t += 1
    l.append(t)
print(max(l))

Submission status: Wrong Answer

Solution code:
S = 'asjdfuvurasodfmaskdvhrefasdfcnusofjwafdsvfb'
p = list(S)
wordcount ={}
for i in p :
  if i not in wordcount:
    wordcount[i] = 1
  else:
    wordcount[i] +=1
result = 0
for key,value in wordcount.items():
  if value >=2:
    result+=1
print(result)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ss = [0]*N

for i in range(1, N):
  X = "".join(set(S[:i]))
  Y = "".join(set(S[i:]))
  for j in range(len(X)):
    if X[j] in Y:
      ss[i] += 1

ss = max(ss)

if ss == 0:
  print(1)

else:
  print(ss)

Submission status: Wrong Answer

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

maxi = 0
for i in range(1, n):
  x = 0
  for c in s[:i]:
    if c in s[i:]:
      x += 1
  maxi = max(maxi, x)
print(maxi)

Submission status: Wrong Answer

Solution code:
# ABC098 B - Cut and Count
n = int(input())
s = input()

ans=0
for i in range(1,n-1):
    start = s[0:i]
    end = s[i+1:n]
    start = ''.join(set(start))
    c = 0
    for ss in start:
        if ss in end:
            c += 1
            ans = max(ans,c)
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC098 B - Cut and Count
n = int(input())
s = input()

s1 = set()
l = []

for i in range(1,n-1):
    start = s[0:i]
    end = s[i+1:n]
    for ss in start:
        if ss in end:
            s1.add(ss)
    l.append(len(s1))
    s1.clear()
    for sss in end:
        if sss in start:
            s1.add(sss)
    l.append(len(s1))
    s1.clear()
if len(l)==0:
    print(0)
else:
    print(max(l))

Submission status: Wrong Answer

Solution code:
# ABC098 B - Cut and Count
n = int(input())
s = input()

ans = 101
s1 = set()
l = []

for i in range(1,n-1):
    start = s[0:i]
    end = s[i+1:n]
    for ss in start:
        if ss in end:
            s1.add(ss)
            l.append(len(s1))
    s1.clear()

if len(l)==0:
    print(0)
else:
    print(max(l))

Submission status: Wrong Answer

Solution code:
# ABC098 B - Cut and Count
n = int(input())
s = input()

ans = 101
s1 = set()
l = []

for i in range(1,n):
    start = s[0:i]
    end = s[i+1:n]
    for ss in start:
        if ss in end:
            s1.add(ss)
            l.append(len(s1))
    s1.clear()

if len(l)==0:
    print(0)
else:
    print(max(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
c = 0
m = 0
for i in range(N):
  S1 = S[:i]
  S2 = S[i:]
  c = 0
  for s1 in S1:
    if s1 in S2:
      c += 1
  m = max(c,m)
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


def main():

    N = int(input())
    S = input()
    count = 0

    for i in range(N//2+1):
        attributeNum = len(set(S[0:i]) & set(S[i:]))
        
        if attributeNum > count:
            count = attributeNum

    print(count)


if __name__== "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    m_cnt = 0
    for i in range(n):
        t_s = s[:i + 1]
        t_t = s[i:]
        import collections
        t_s = collections.Counter(t_s)
        t_t = collections.Counter(t_t)
        cnt = 0
        for k, v in t_s.items():
            if k in t_t.keys():
                cnt += 1
        m_cnt = max(m_cnt, cnt)
    print(m_cnt)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(str(input()))
ans=[]
for i in range(N-1):
  num=0
  l=[]
  s1=S[0:i+1]
  s2=S[i:N]
  if len(s1)<=len(s2):
    s1,s2=s1,s2
  else:
    s1,s2=s2,s1
  for j in range(len(s1)):
    if s1[j] not in l:
      l.append(s1[j])
  for j in range(len(l)):
    if (l[j] in s2)==True:
      num+=1
  ans.append(num)
print(max(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import collections

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

max_count = 1

for i in range(N):
    a = S[:i]
    b = S[i:]

    a_2 = collections.Counter(a)
    b_2 = collections.Counter(b)

    dst = {}

    for k,v in b_2.items():
        if k in a_2:
            dst[k] = v

    max_count = max(max_count,len(dst))

print(max_count)

Submission status: Wrong Answer

Solution code:
import collections

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

max_count = 1

for i in range(N-1):
    a = S[:i+1]
    b = S[i+1:]

    a_2 = collections.Counter(a)
    b_2 = collections.Counter(b)

    dst = {}

    for k,v in b_2.items():
        if k in a_2:
            dst[k] = v

    max_count = max(max_count,len(dst))

print(max_count)

Submission status: Wrong Answer

Solution code:
import collections

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

max_count = 0

for i in range(N-1):
    a = S[:i+1]
    b = S[i+1:]

    a_2 = collections.Counter(a)
    b_2 = collections.Counter(b)

    dst = {}

    for k,v in b_2.items():
        if k not in a_2:
            dst[k] = v

    max_count = max(max_count,len(dst))
print(max_count)

Submission status: Wrong Answer

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

m = 0
for i in range(1,len(s)):
    x = s[0:i]
    y = s[i:len(s)]
    a = []
    count = 0
    for j in range(0,i-1):
        if x[j] in y and not(x[j] in a):
            a.append(x[j])
            count += 1
    m = max(m,count)
print(m)

Submission status: Wrong Answer

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

ans = 0
a = 0

for i in range(1,N):
    X = S[:i]
    Y = S[i:]
    lis = list(set(X))
    for j in range(len(lis)):
        if Y.count(X[j]) != 0:
            a += 1

    if a > ans:
        ans = a
    a = 0

print(ans)

Submission status: Wrong Answer

Solution code:
# N, S = map(int, input().split())  # 入力
N = int(input())
S = input()
S = [c for c in S]

# print(N, S)
ans = 0
for i in range(N - 1):
    first = set(S[0:i+1])
    second = set(S[i+1:])
    # print(S[0:i+1], S[i+1:])
    # print(first, second)
    tmpans = 0
    for index, n in enumerate(range(min(len(first), len(second)))):
        if list(first)[index] in list(second):
            tmpans += 1
            ans = max(ans, tmpans)


print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(n+1):
    str1 = list(set(s[:i]))
    str2 = list(set(s[i:]))
    minimam = min(len(str1), len(str2))
    if ans < minimam :
        ans = minimam
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
mx = 0
for i in range(n-1):
  a = [ord(aa) for aa in s[:i+1]]
  b = [ord(bb) for bb in s[i+1:]]
  counter = 0
  for c in range(ord('a'), ord('z')):
    if c in a and c in b:
      counter += 1
  if mx < counter:
    mx = counter

print(counter)

Submission status: Wrong Answer

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+2]))
        tmp2 = list(set(s[i+1:]))
        for j in range(len(tmp1)):
            if tmp1[j] in tmp2:
                ans[i] += 1
print(max(ans))

Submission status: Wrong Answer

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(n-1):
        tmp1 = list(set(s[:i+1]))
        tmp2 = list(set(s[i:]))
        for j in range(len(tmp1)):
            if tmp1[j] in tmp2:
                ans[i] += 1
print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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,122):
        if a.count(chr(j))!=0 and b.count(chr(j))!=0:
            count+=1
    x.append(count)
    count=0
print(max(x))

Submission status: Wrong Answer

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))
  for ch in c:
    ans = max(ans, min(s1.count(ch), s2.count(ch)))
print(ans)

Submission status: Wrong Answer

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+1:]))
print(ans)

Submission status: Wrong Answer

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]) == Y.count(S_set[i]):
      ans += 1
  if mx_ans < ans:
    mx_ans = ans
print(mx_ans)

Submission status: Wrong Answer

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])
  print(X)
  if max < len(X&Y):
    max = len(X&Y)
print(max)

Submission status: Wrong Answer

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(a & b)
print(len(max(ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
num = []
for i in range(1,n):
    former = set(s[:i])
    latter = set(s[i:])
    comm = len(former.intersection(latter))
    print(s[:i], s[i:])
    num.append(comm)

print(max(num))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
num = []
for i in range(1,n):
    former = set(s[:i])
    latter = set(s[i:])
    comm = len(former and latter)
    #print(s[:i], s[i:])
    num.append(comm)

print(max(num))

Submission status: Wrong Answer

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

dicX={s[0]:1}
dicY={}
for i in range(1,N):
    if s[i] in dicY: dicY[s[i]]+=1
    else: dicY[s[i]]=1

ans=(s[0] in dicY)

for i in range(1,N-1):
    if not s[i] in dicX: dicX[s[i]]=1
    
    if dicY[s[i]]>1: dicY[s[i]]-=1
    else: dicY.pop(s[i])
    
    tmp=0
    for j in dicX:
         if j in dicY: tmp+=1
    ans=max(tmp,ans)

print(ans)

Submission status: Wrong Answer

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

dicX={s[0]:1}
dicY={}
for i in range(1,N):
    if s[i] in dicY: dicY[s[i]]+=1
    else: dicY[s[i]]=1

ans=0
for i in range(1,N-1):
    if s[i] in dicX: dicY[s[i]]+=1
    else: dicX[s[i]]=1
    
    if dicY[s[i]]>1: dicY[s[i]]-=1
    else: dicY.pop(s[i])
    
    tmp=0
    for j in dicX:
         if j in dicY: tmp+=1
    ans=max(tmp,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
alpha = [chr(i) for i in range(97,97 + 26)]

def Count(s,t):
	ret = 0
	for i in alpha:
		if i in s and i in t:ret+=1
	return ret

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    count = 0
    max_ = 0

    for i in range(N):
        x = set(S[:i])
        y = set(S[:i])

        max_ = max(len(x&y), max_)

    print(max_)


if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

z = []
for i in range(1,N):
  x = S[:i]
  y = S[i:]
  print(x,y)
  print(set(x) & set(y))
  if set(x) & set(y):
    z.append(len(set(x)&set(y)))
  else:
    continue

print(max(z) if len(z) != 0 else 0)

Submission status: Wrong Answer

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

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

print(z)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,n-1):
    a = set(s[:i])
    b = set(s[i:])
    cnt = len(a) + len(b) - len(s)
    c = max(c,cnt)

print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
import string
abcs = string.ascii_lowercase

ans = 0
for sakaime in range(N):
    cnt = 0
    left = S[:sakaime]
    right = S[sakaime:]
    for alpha in abcs:
        if alpha in left and alpha in right:
            cnt += 1
    ans = max(ans, cnt)

Submission status: Wrong Answer

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

ans = 0
for sakaime in range(N):
    left = S[:sakaime]
    right = S[sakaime:]
    cnt = 0
    for c in left:
        if c in right:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    x = set(S[:i+1])
    y = set(S[i:])
    cnt = 0
    for j in x:
        if j in y:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

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

s1 = s[:int(len(s)/2)]
s2 = s[int(len(s)/2):]

ans = 0
ansarray = []

for i in range(len(s1)):
    for j in range(len(s2)):
        if s1[i] == s2[j]:
            ansarray.append(s1[i])

ansarray = set(ansarray)
ansarray = list(ansarray)
print(len(ansarray))

Submission status: Wrong Answer

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

c = 0
p = n
for l in range(n):
    for i in range(n):
        if i < l and a[i] == 'W':
            c += 1
        elif i == l:
            pass
        elif i > l and a[i] == 'E':
            c += 1
        elif c > p:
            break
    if p > c:
        p = c
    c = 0
print(p)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
  cnt = 0
  l = list(set(S[:i+1]))
  r = list(set(S[i:]))
  for ls in l:
    if(ls in r):
      cnt += 1
  ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
result=0
for i in range(n):
    x=s[0:i+1]
    y=s[i:]
    kind=0
    for j in range(len(x)):
        if x[j] in y:
            if x[j] in x[0:j]:
                pass
            else:
                kind+=1
    if kind>result:
        result=kind
print(result)

Submission status: Wrong Answer

Solution code:
#ABC098B
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    s1 = list(set(s[:i]))
    s2 = list(set(s[i:]))
    cnt = [s2.count(x) for x in s1]
    count=0
    for c in cnt:
        count+=c
    ans=max(ans,count)
print()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,n):
  if i != n:
    dic_f = {}
    dic_l = {}
    former = s[:i]
    latter = s[i+1:]
    counter = 0
  
    for j in range(len(former)):
      if former[j] not in dic_f.keys():
        dic_f[former[j]] = 1
      
    for j in range(len(latter)):
      if latter[j] not in dic_l.keys():
        dic_l[latter[j]] = 1
      
    for j in dic_f.keys():
      if j in dic_l.keys():
        counter += 1
    ls.append(counter)
else:
  former = s[:i-1]
  latter = s[-1]
  counter = 0
  for j in range(len(former)):
    if former[j] not in dic_f.keys():
      dic_f[former[j]] = 1
      
  for j in range(len(latter)):
    if latter[j] not in dic_l.keys():
      dic_l[latter[j]] = 1
      
  for j in dic_f.keys():
    if j in dic_l.keys():
      counter += 1
  ls.append(counter)
  
print(max(ls))