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 = 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))

Submission status: Wrong Answer

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

cnt = [0]
L = []
for i in range(N):
    if S[i] not in L:
        L.append(S[i])
        t = cnt[-1] + 1
        cnt.append(t)

print(cnt[int(len(cnt)/2)])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from functools import reduce
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    def func(n, i, initializer=0):
        a = set(S[:i])
        b = set(S[i:])
        return max( n, len(a & b) )

    N = int(lines.pop(0))
    S = lines.pop(0)

    print( reduce( func, range(1,N) ) )

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:


n = int(input())

s = input()

alphabet = 'abcdefghigklmnopqrstuvxwyz'
A = [0] * len(alphabet)
B = A.copy()


for c in s:
    pos = alphabet.find(c)
    A[pos]+=1

#print(A)
#print(B)

ans = 0
for c in s:
    pos = alphabet.find(c)
    A[pos] -= 1
    B[pos] += 1
    
    #print(A)
    #print(B)

    t = sum(1 if ae>0 and be > 0 else 0 for ae, be in zip(A,B) )

    ans = max(t,ans)

    

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
a=[]
l=[]
for i in range(n):
  kind=0
  l=s.pop(0)
  for j in list(set(l)):
    if j in list(set(s)):
      kind+=1
  a.append(kind)
print(max(a))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
a=[]
l=[]
for i in s:
  kind=0
  l.append(i)
  for j in list(set(l)):
    if j in list(set(s)):
      kind+=1
  a.append(kind)
print(max(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [i for i in input()]
ans = 0

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

print(ans)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
S=input()
m=0
for i in range(1,n):
    x=S[:i]
    y=S[i:]
    x1=list(x)
    x2=set(x1)
    y1=list(y)
    y2=set(y1)
    y1=list(y2)
    for i in x2:
        m=max(y1.count(i),m)
    x=""
    y=""
    x1=[]
    x2=[]
    y1=[]
    y2=[]
print(m)

Submission status: Wrong Answer

Solution code:
def ToSet(S):
    set_S = set()
    for s in S:
        set_S.add(s)
    return set_S

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

    m = 1
    for i in range(1, n):
        set1 = ToSet(s[0:i])
        set2 = ToSet(s[i:n])
        l = len(set1 & set2)
        if m < l: 
            m = l
    print(m)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

intger2 = 0
c = []

for i in range(N):
  intger1 = 0
  str1 = list(set(S[i:]))
  str2 = list(set(S[:i + 1]))
  l = len(str2)
  
  for j in range(l):
    if( str2[j] in str1):
      intger1 += 1
      
    else:
      continue
  
  if( intger2 <= intger1):
    intger2 = intger1
    c.append(intger2)
    
  else:
    continue

print(max(c))

Submission status: Wrong Answer

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

intger2 = 0

for i in range(N):
  intger1 = 0
  str1 = list(set(S[i:]))
  str2 = list(set(S[:i + 1]))
  l = len(str2)
  
  for j in range(l):
    if( str2[j] in str1):
      intger1 += 1
      
    else:
      continue
  
  if( intger2 <= intger1):
    intger2 = intger1
    
  else:
    continue
    
print(intger2)

Submission status: Wrong Answer

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

intger2 = 0

for i in range(N):
  intger1 = 0
  str1 = list(set(S[i:]))
  str2 = list(set(S[:i + 1]))
  #print(str1)
  #print(str2)
  l = len(str2)
  #print(l)
  
  for j in range(l):
    if( str2[j] in str1):
      intger1 += 1
      
    else:
      continue
  
  if( intger2 <= intger1):
    intger2 = intger1
    
  else:
    continue
    
print(intger2)

Submission status: Wrong Answer

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

result = 0
for i in range(N):
	x = S[:i]
	y = S[i:]
	print(x,y)
	x_set,y_set = set(),set()
	for ii in x:
		x_set.add(ii)
	for ii in y:
		y_set.add(ii)
	result = max(len(x_set & y_set),result)
print(result)

Submission status: Wrong Answer

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

s1 = []
s2 = []

for i in range(n):
  s1.append([])
  s2.append([])

for i in range(n):
  for j in range(n):
    if j < i:
      s1[i].append(s[i])
    else:
      s2[i].append(s[i])

count = 0
com = []
slv = []
      
for i in range(n):
  for j in range(i):
    if s1[i][j] in s2[i] and s1[i][j] not in com:
      count += 1
      com.append(s1[i][j])
  slv.append(count)
  count = 0
  com = []
  
print(max(slv))

Submission status: Wrong Answer

Solution code:
N = 6
S= "aabbca"

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
a = {}
b = {}
c = []
for i in range(n//2):
  a = set(s[:i+1])
  b = set(s[i+1:])
  c.append(len((a&b)))
  a.clear()
  b.clear()
print(max(c))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
m = 0
for i in range(1,n):
  count = 0
  for j in "abcdefghijiklmnopqrstuvwxyz":
    if j in s[0:i] and j in s[i:n]:
      count += 1
  if count > m:
    m = count
print(m)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

INF = float('inf')


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

ans = -INF
for i in range(1, N - 1):
    str_list = []
    score = 0

    for x in S[:i]:
        if x not in str_list: str_list.append(x)

    for xi in str_list:
        if xi in S[i:]: score += 1

    ans = max(ans, score)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = 0
if n % 2:
    r = n//2 + 2
else:
    r = n//2 + 1
for i in range(1,r):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    count = 0
    for j in range(len(x)):
        if x[j] in y:
            count += 1
    ans = max(ans, count)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count=0
maxim=0
for i in S:
  for j in S:
    if i == j:
      count+=1
  maxim=max(maxim,count)
  count=0
print(int(maxim))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count=0
maxim=0
for i in S:
  for j in S:
    if i == j:
      count+=1
  maxim=max(maxim,count)
  count=0
print(maxim)

Submission status: Wrong Answer

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

for i in range(1,n):
    left=set()
    right=set()
    for j in range (1,i):
        left.add(s[j])

    for j in range (i,n):
        right.add(s[j])
    
    both=right&left
    ans=max(ans,len(both))
    

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a=list(input())
#print(a)
#print(b)
#del a[0],a[1]
#print(a)
x=[]
b=[]
for i in range(n//2):
	b.append(a[0])
	del a[0]
	#print(b)
	#print(a)
	c=list(set(a) & set(b))
	#print(c)
	#print(len(c))
	x.append(len(c))
r=max(x)

p=[]
d=[]
for k in range(n//2):
	d.append(a[-1])
	del a[-1]
	e=list(set(a) & set(b))
	p.append(len(e))
f=max(p)

print(max([r,f]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a=list(input())
#print(a)
#print(b)
#del a[0],a[1]
#print(a)
x=[]
b=[]
for l in range(n//2):
	b.append(a[0])
	del a[0]
	#print(b)
	#print(a)
	c=list(set(a) & set(b))
	#print(len(c))
	x.append(len(c))
r=max(x)

p=[]
d=[]
for k in range(n//2):
	d.append(a[-1])
	del a[-1]
	e=list(set(a) & set(b))
	p.append(len(e))
f=max(p)

print(max([r,f]))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
for i in range(1, 33):
    if n == i*i:
        print(i*i)
        break
    elif n < i*i:
        print((i-1)*(i-1))
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
c = 0
list_s = [sorted(list(set(s[:i]))) for i in range(1,n)]
list_l = [sorted(list(set(s[i:]))) for i in range(0,n)]
print(max([sum([1 if list_s[j][i] in list_l[j] else 0 for i in range(len(list_s[j]))]) for j in range(n-1)]))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
c = 0
list_s = [sorted(list(set(s[:i]))) for i in range(1,n)]
list_l = [sorted(list(set(s[i:]))) for i in range(0,n-1)]
print(max([sum([1 if list_s[j][i] in list_l[j] else 0 for i in range(len(list_s[j]))]) for j in range(n-1)]))

Submission status: Wrong Answer

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

for i in range(1, N):
    tmp_ans = len(set(S[0:i]) and set(S[i:]))
    if(tmp_ans > ans):
        ans = tmp_ans

print(ans)

Submission status: Wrong Answer

Solution code:
#標準入力
N = int(input())
S = input()

Max_count = 0
#処理
for i in range(1, N):
  temporary_count = len(set(S[i:]) and set(S[:i]))
  if temporary_count > Max_count:
    Max_count = temporary_count
    
print(Max_count)

Submission status: Wrong Answer

Solution code:
#標準入力
N = int(input())
S = input()

Max_count = 0
#処理
for i in range(1, N):
  temporary_count = len(set(S[i:]) and (S[:i]))
  if temporary_count > Max_count:
    Max_count = temporary_count
    
print(Max_count)

Submission status: Wrong Answer

Solution code:
#標準入力
N = int(input())
S = input()

Max_count = 0
#処理
for i in range(0, N):
  temporary_count = len(set(S[i:]) and (S[:i]))
  if temporary_count > Max_count:
    Max_count = temporary_count
    
print(Max_count)

Submission status: Wrong Answer

Solution code:

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = len(s)
x = s[0:n]
y = s[n:l]
ans = 0
for i in x :
    if i in x and i in y :
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
st = input()
b = 0
for i in range(1,n):
    k = list(set(st[:i]))
    u = 0
    for j in range(len(k)):
        if st[j] in st[i:]:
            u += 1
    if u > b:
        b = u
print(str(b))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count_max=0
for i in range(1,N):
    X=S[:i]
    Y=S[i:]
    count=0
    for character in X:
        if character in Y:
            count+=1
    count_max=max(count, count_max)
print(count_max)

Submission status: Wrong Answer

Solution code:
def same_count(str_list):
    standard_str = min(str_list, key=lambda x: len(x))
    return [all([c in str_ for str_ in str_list]) for c in standard_str].count(True)

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

print(max([same_count([s[:i], s[i:]]) for i in range(n)]))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count_M=0
for i in range(N):
	SR=S[(i+1):]
	SL=S[:(i+1)]
	count = 0
	for j in SL:
		for k in SR:
			if(j == k):
				count+=1
				break
	if(count_M < count):
		count_M=count

print(count_M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N=int(raw_input())
S=raw_input()

st2 = Counter(S)
st1 = Counter()
best = 0
for i in range(N-1):
  st1.update(S[i])
  cnt = 0
  for k,v in st1.items():
    if st2[v]-v > 0:
      cnt += 1
  best = max(best, cnt)
print best

Submission status: Wrong Answer

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

ans = 0
for i in range(N+1):
  left = S[:i]
  right = S[i:]

  k=0
  for j in range(ord('a'),ord('z')):
    if left.count(chr(j))>0 and right.count(chr(j))>0:
      k += 1

  if ans<k:
    ans = k

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
  left = S[:i]
  right = S[i:]

  k=0
  for j in range(ord('a'),ord('z')):
    if left.count(chr(j))>0 and right.count(chr(j))>0:
      k += 1

  if ans<k:
    ans = k

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = 0
 
for i in range(n):
    a = s[:i]
    b = s[i:]
    print(a)
    print(b)
    tes = 0
    c = []
    for cha in a:
        if cha in b:
            if cha not in c:
                c.append(cha)
                tes += 1
    ans = max(tes,ans)
    print(tes)
    
print(ans)

Submission status: Wrong Answer

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

for i in range(n):
    a = s[:i]
    b = s[i+1:]
    tes = 0
    c = []
    for cha in a:
        if cha in b:
            if cha not in c:
                c.append(cha)
                tes += 1
    ans = max(tes,ans)
    
print(ans)

Submission status: Wrong Answer

Solution code:
ini = [input() for i in range(2) ]
counts = []
count=0
for i in range(int(ini[0])):
    for k in ini[1][:i]:
        if k in ini[1][i:]:
            count+=1
    print(count)
    counts.append(count)
print(max(counts))

Submission status: Wrong Answer

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

max_n = 0

for i in range(1,n):
    x = set()
    y = set()
    for j in range(0,i):
        x.add(s[j])
    for j in range(i,n):
        y.add(s[j])

    if len(x|y) > max_n:
        max_n = len(x|y)

print(max_n)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
n1 = []
for i in range(n):
    s1 = set()
    for j in range(i):
        for k in range(i+1, n):
            # print(i, j, k, s[j], s[k])
            if s[j] == s[k] and set(s[j]).issubset(s1) is False:
                s1.add(s[j])
            # print('len', len(s1))
    n1.append(len(s1))
print(max(n1))

Submission status: Wrong Answer

Solution code:
num = int(input())
li = list(input())
ans = 0
for i in range(num):
  fi = set(li[:i])
  se = set(li[i:])
  hoge = len(list(fi & se))
  print(hoge)
  if hoge > ans:
    ans = hoge
 
print(ans)

Submission status: Wrong Answer

Solution code:
num = int(input())
li = list(input())
ans = 0
for i in range(num):
  fi = set(li[:i])
  se = set(li[i:])
  hoge = len(list(fi & se))
  print(hoge)
  if hoge > ans:
    ans = hoge
 
print(hoge)

Submission status: Wrong Answer

Solution code:
num = int(input())
li = list(input())
i = int(num/2)
while(i>num/2):
  fi = set(li[:i])
  se = set(li[i:])
  ans = len(list(fi & se))
  if i < ans:
    i = ans
  else:
    i = i+1    
 
print(i)

Submission status: Wrong Answer

Solution code:
num = int(input())
li = list(input())
i = int(num/2)
while(i>num):
  fi = set(li[:i])
  se = set(li[i:])
  ans = len(list(fi & se))
  if i < ans:
    i = ans
  else:
    i = i+1    

print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
temp=0
for i in range(N-1):
    S1=S[0:i+1]
    S2=S[i+1:N]
#    print(S1 + " " + S2)
    kaburi=[]
    for s in S1:
        if s in S2 and s not in kaburi:
            kaburi.append(s)
    print (kaburi)
    if len(kaburi)>temp:
        temp = len(kaburi)
print(temp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
temp=0
for i in range(N-1):
    S1=S[0:i+1]
    S2=S[i+1:N]

    kaburi = [s for s in S1 if s in S2]

    if len(kaburi)>temp:
        temp = len(kaburi)
print(temp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
X = S[:N//2]
Y = S[N//2:]
MAX = max(len(X),len(Y))
cnt = 0
for i in range(MAX):
  if Y[i] in X:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
for i in range(1, N+1):
    A = [ ]
    B = [ ]
    C = [ ]
    F = [ ]
    E = S[0:i]
    for m in E:
        if m not in A:
            A.append(m)
        elif m not in B:
            B.append(m)
        else:
            C.append(m)
        na = len(B)
        F.append(na)
g = max(F)
print(g)

Submission status: Wrong Answer

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

posDevide = 1
maxMatchWordNum = 0

while posDevide < N:
        arrayNum = 1
        matchWordNum = 0
        while arrayNum <=  posDevide:
                matchWordNum = matchWordNum + 1 if  bool( S.count( S[ arrayNum - 1 ], posDevide, N-1 )) else matchWordNum
                arrayNum += 1

        maxMatchWordNum = matchWordNum if matchWordNum > maxMatchWordNum else maxMatchWordNum
        posDevide += 1

print(maxMatchWordNum)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = input()
    used = []
    max = 0;
    for i in range(1, N):
        k = S[i]
        if (k in used): del used[used.index(k)]
        for ii in range(i + 1, N):
            if (k == S[ii] and k not in used):
                used.append(k)
        if len(used) > max: max = len(used)
    print(max)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = input()
    used = []
    max = 0;
    for i in range(1, N):
        k = S[i]
        if (k in used): del used[used.index(k)]
        for ii in range(i + 1, N):
            if (k == S[ii] and k not in used):
                used.append(k)
                if len(used) > max: max = len(used)
    print(max)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
print(S)
a = len(S)//2
X = S[:a]
Y = S[a:]
print(len(set(X) & set(Y)))

Submission status: Wrong Answer

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

ans = list()

for i in range((len(s) // 2) + 1):
    cnt = 0
    x = sorted(set(s[:i]), key=s.index)
    y = sorted(set(s[i:]), key=s.index)
    for j in x:
        if j in y:
            cnt += 1
    ans.append(cnt)

print(max(ans))

Submission status: Wrong Answer

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

ans = list()

for i in range((len(s) // 2) + 1):
    cnt = 0
    x = sorted(set(s[:i]), key=s.index)
    y = sorted(set(s[i:]), key=s.index)
    for j in x:
        if y.count(j) > 0:
            cnt += 1
    ans.append(cnt)

print(max(ans))

Submission status: Wrong Answer

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

ans = list()

for i in range(1, len(s) // 2 + 1):
    cnt = 0
    x = sorted(set(s[:i]), key=s.index)
    y = sorted(set(s[i:]), key=s.index)
    for j in x:
        if y.count(j) > 0:
            cnt += 1
    ans.append(cnt)

print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def charToInt(c):
    return ord(c) - ord("a")

def stringToFlags(s):
    t = [False for i in range(26)]
    for i in range(len(s)):
        t[charToInt(s[i])] = True
    return t

def B(n, s):
    max = 0
    for i in range(1, n):
        print(s[0:i], s[i:n])
        xflags = stringToFlags(s[0:i])
        yflags = stringToFlags(s[i:n])
        
        count = 0
        for i in range(26):
            if xflags[i] and yflags[i]:
                count += 1
                if count > max:
                    max = count
    return max

n = int(input())
s = input()
print(B(n, s))

Submission status: Wrong Answer

Solution code:
def charToInt(c):
    return ord(c) - ord("a")

def stringToFlags(s):
    t = [False for i in range(26)]
    for i in range(len(s)):
        t[charToInt(s[i])] = True
    return t

def B(n, s):
    max = 0
    for i in range(1, n):
        print(s[0:i], s[i:n])
        xflags = stringToFlags(s[0:i])
        yflags = stringToFlags(s[i:n])
        
        count = 0
        for i in range(26):
            if xflags[i] and yflags[i]:
                count += 1
                if count > max:
                    max = count
    return max

def em_input(s):
    n = int(s.split("\n")[0])
    s = s.split("\n")[1]
    return B(n, s)

print(input())

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
x,y,ans = [[s[0]]],[[s[-1]]],0
for i in range(1,n):
	if s[i] in x[-1]: x.append(x[-1])
	else: x.append(x[-1]+[s[i]])
s = s[::-1]
for i in range(1,n):
	if s[i] in y[-1]: y.append(y[-1])
	else: y.append(y[-1]+[s[i]])
y = y[::-1]
for i in range(n): ans = max(ans,len(x[i])+len(y[i])-len(set(x[i]+y[i])))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(str,input()))
print(S)
icchi=[]
num=[]
for i in range(0,N-1):
	p_list=[]
	q_list=[]
	for p in range(0,i+1):
		p_list.append(S[p])
	for q in range(i+1,N):
		q_list.append(S[q])
	for x in range(0,len(p_list)):
		for y in range(0,len(q_list)):
			if(p_list[x]==q_list[y]):
				icchi.append(p_list[x])
				break
	num.append(len(set(icchi)))
print(max(num))

Submission status: Wrong Answer

Solution code:
data = input().strip()
result = 0
for i in range(1, len(data)):
    left = list(set(data[0:i]))
    right = data[i:]

    count = 0
    for c in left:
        if right.count(c) > 0:
            count = count + 1
    if count > result:
        result = count

print(result)

Submission status: Wrong Answer

Solution code:
#length of string
N = int(input())

#string
S = input()

count = []

for i in range(N) :
	count.append(0)

temp = 0
k = 0

for i in range(N) :
	for k in range(i) :
		for j in range(i, N) :
			if S[k] == S[j] :
				count[i] += 1
				break	

	if temp < count[i] :
		temp = count[i]		

print(temp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
mati = list()
maxi = 0
count = 0
for i in range(N):
  X = S[:i+1]
  Y = S[i+1:]
 
  for j in range(len(X)):
    for k in range(len(Y)): 
     
      if X[j] == Y[k]:
        if len(mati) == 0:
          mati.append(X[j])
        elif mati[len(mati)-1] == X[j]:
          mati.append(X[j])
        break
  if len(mati) >= maxi:
    maxi = len(mati)
    mati.clear()

print(maxi)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(str,input()))

icchi=[]
num=[]
for i in range(0,N-1):
	p_list=[]
	q_list=[]
	for p in range(0,i+1):
		p_list.append(S[p])
	for q in range(i+1,N-i):
		q_list.append(S[q])
	for x in p_list:
		for y in q_list:
			if(x==y):
				icchi.append(x)
				break
	num.append(len(set(icchi)))
print(max(num))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(str,input()))

icchi=[]
num=[]
for i in range(0,N-1):
	p_list=[]
	q_list=[]
	for p in range(0,i+1):
		p_list.append(S[p])
	for q in range(i+1,N-i):
		q_list.append(S[q])
	for x in range(0,len(p_list)):
		for y in range(0,len(q_list)):
			if(p_list[x]==q_list[y]):
				icchi.append(p_list[x])
				break
	num.append(len(set(icchi)))
print(max(num))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(str,input()))

icchi=[]
num=[]
for i in range(0,N):
	p_list=[]
	q_list=[]
	for p in range(0,i+1):
		p_list.append(S[p])
	for q in range(i+1,N-i):
		q_list.append(S[q])
	for x in range(0,len(p_list)):
		for y in range(0,len(q_list)):
			if(p_list[x]==q_list[y]):
				icchi.append(p_list[x])
				break
	num.append(len(set(icchi)))
print(max(num))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(str,input()))

p_list=[]
q_list=[]
icchi=[]
num=[]
for i in range(0,N):
	p_list=[]
	q_list=[]
	for p in range(0,i+1):
		p_list.append(S[p])
	for q in range(i+1,N-i):
		q_list.append(S[q])
	for x in range(0,len(p_list)):
		for y in range(0,len(q_list)):
			if(p_list[x]==q_list[y]):
				icchi.append(p_list[x])
				break
	num.append(len(set(icchi)))
print(max(num))

Submission status: Wrong Answer

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

num = set()
count = []
for i in range(a-1) :
    s1 = s[:i]
    s2 = s[i+1:]

    num.add(len(set(list(s1)) & set(list(s2)) ) )
    count.append(i)

num = list(num)
print(count[num.index(max(num))])

Submission status: Wrong Answer

Solution code:
a = 6
s = 'aabbca'
x=[]
y=[]
count=[0]*a
z=0
for i in range (a):
    for j in range (i):
        x.insert(j,s[j])
    for k in range (a-i):
        y.insert(k,s[i+k])
    for l in range (i):
        for m in range (1):
            for n in range(l+1):
                if (l==0 and  x[l] == y[m]) or (x[l]!=x[n] and x[l] == y[m]):
                    count[i]+=1
                    
print(max(count))

Submission status: Wrong Answer

Solution code:
a = int(input())
s = input()
x=[]
y=[]
count=[0]*a
z=0
for i in range (a):
    for j in range (i):
        x.insert(j,s[j])
    for k in range (a-i):
        y.insert(k,s[i+k])
    for l in range (i):
        for m in range (1):
            for n in range(l+1):
                if (l==0 and  x[l] == y[m]) or (x[l]!=x[n] and x[l] == y[m]):
                    count[i]+=1
                    
print(count)

Submission status: Wrong Answer

Solution code:
_ = input()
s = input()
maximum = 0

check = lambda x, y: x in y
count = lambda x, y: y.count(x) >= 2

for i in range(len(s) - 1):  # character level
    # (s[0:i+1], s[i:])
    # aab, bac
    tmp = 0

    char_dict = {}
    for ii in range(len(s[0: i + 1])):  # part level
        # s[0:i+1], s[0:i+1][ii]
        # aab, a

        # s[0:i+1][ii], s[i:]
        # a, bac


        if count(s[0: i + 1][ii], s[0: i + 1]):  # left check
            if not s[0: i + 1][ii] in char_dict.keys():
                char_dict.update({s[0: i + 1][ii]: True})
                if check(s[0: i + 1][ii], s[i:]):
                    tmp += 1
                    continue
        elif check(s[0: i + 1][ii], s[i:]):
            tmp += 1
    char_dict.clear()

    if tmp > maximum:
        maximum = tmp

print(tmp)

Submission status: Wrong Answer

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

num = set()
count = []
for i in range(a-1) :
    s1 = s[:i]
    s2 = s[i+1:]

    num.add(len(set(list(s1)) & set(list(s2)) ) )
    count.append(i)

num = list(num)
print(count[num.index(num[-1])])

Submission status: Wrong Answer

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

M = 0
for n in range(1,N) :
    set1 = set([])
    set2 = set([])
    I = set([])
    for c in (S[:n]) :
        set1.add(c)
    for d in (S[n+1:]) :
        set2.add(d)
    I = set1 & set2
    if(len(I)>M) :
        M = len(I)
print(M)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=input()
s=list(x)
list=[]
 
for i in range(n):
    a=0
    moji=[]
    for j in range(i+1):
        for k in range(n-i):
            if s[j]==s[k+i-1]:
                if s[j] not in moji:
                    a+=1
                    moji.append(s[j])
    list.append(a)
 
f=max(list)
print(f)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=input()
s=list(x)
list=[]
 
for i in range(n):
    a=0
    moji=[]
    for j in range(i):
        for k in range(n-i):
            if s[j]==s[k+i-1]:
                if s[j] not in moji:
                    a+=1
                    moji.append(s[j])
    list.append(a)
 
f=max(list)
print(f)

Submission status: Wrong Answer

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

for i in range(n-1):
    a=0
    moji=[]
    for j in range(i):
        for k in range(n-i):
            if s[j]==s[k+i-1]:
                if s[j] not in moji:
                    a+=1
                    moji.append(s[j])
    list.append(a)

f=max(list)
print(f)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=input()
s=list(x)
list=[]
 
for i in range(n-1):
    a=0;
    for j in range(i+1):
        for k in range(n-i):
            if s[j]==s[k+i]:
                a+=1
    list.append(a)
 
f=max(list)
print(f)

Submission status: Wrong Answer

Solution code:
def counter(chr_list, half_set):
    chr_set = set(chr_list[:])
    count = 1
    for c in chr_set:
        if c in half_set:
            count += 1
    return count

if __name__ == '__main__':
    length = int(input().strip())
    strings = input()
    count_r = -1
    count_l = -1
    length_half = length // 2
    i = 0
    while True:
        now = counter(strings[length_half+i:], set(strings[:length_half+i]))
        i += 1
        if count_r > now:
            count_r = now
            break
        count_r = now
    i = 0
    while True:
        now = counter(strings[length_half-i:], set(strings[:length_half-i]))
        i += 1
        if count_l > now:
            count_l = now
            break
        count_l = now
    print(max(count_l, count_r))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=input()
s=list(x)
list=[]
 
for i in range(n):
    a=0;
    for j in range(i):
        for k in range(n-i):
            if s[j]==s[k+i]:
                a+=1
    list.append(a)
 
f=max(list)
print(f)

Submission status: Wrong Answer

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

for i in range(n):
    a=0;
    for j in range(i):
        for k in range(n-i):
            if s[j]==s[k+i-1]:
                a+=1
    list.append(a)

f=max(list)
print(f)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
mx = 0
for i in range(int(n/2)):
    fw = set(s[:i+1])
    df = set(s[i+1:])
    if mx < len(fw&df):
        mx = len(fw&df)
print(mx)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, N//2+1):
    X = set(S[:i])
    Y = set(S[i:])

    ans = max(ans, len(X&Y))

print(ans)