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: Runtime Error

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

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

async=0
for i in range(1,n):
    a=set(s[:i])
    b=set(s[i:])
    c=a&b
    if len(c)>ans:
        ans=len(c)

print(ans)

Submission status: Runtime Error

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = ns()

ans = []

for i in range(1, n-1):
    set_x = set(s[:i])
    set_y = set(s[i:])
    ans.append(len(set_x & set_y))

print(max(ans))

Submission status: Runtime Error

Solution code:
import sys  
import numpy as np

input = sys.stdin.readline
N = int(input())
S = list(input())

S = S[:-1]

temp = []
for i in range(1,N-1):
    a = S[:i]
    b = S[i:]
    a = list(set(a))
    b = list(set(b))

    j = list(set(a+b))
    
    temp.append(len(a) + len(b) - len(j))
    

print(max(temp))

Submission status: Runtime Error

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

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

print(max)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
l = []
for i in range(1, len(s) - 1):
    f = s[:i]
    b = s[i:]
    fset = list(set(s[:i]))
    bset = list(set(s[i:]))
    cnt = 0
    for j in fset:
        if bset.count(j) != 0:
            cnt += 1
    l.append(cnt)
print(max(l))

Submission status: Runtime Error

Solution code:

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

ans = 0

for i in range(1, n):
    h = s[:i]
    t = s[i:]
    cnt = 0
    for j in range(26):
        c = chr(ord('a') + j)
        if c in head and c in tail:
            cnt += 1

    ans = max(ans, cnt)

print(ans)

Submission status: Runtime Error

Solution code:
***
「文字列」S を「文字列」X と 「文字列」Y に分割、X と Y 両方に含む文字種類数最大化

「文字列」S を 各位置 で 分割して、「集合」X と 「集合」Y に格納する。
「集合」X と 「集合」Y の 論理積(AND) の 要素数 を 最大化することで求めることができる。
「集合」X と 「集合」Y の 論理積(AND) は X & Y で求めることができる。
***

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

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

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0

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

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
ans=0
for i in range(1,n):
  s1=s[:i]
  s2=s[i:]
  li1=set([s1[j] for j in range(s1)])
  li2=set([s2[j] for j in range(s2)])
  ans = max(ans,len(li1 & li2))
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections

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

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

print(m)

Submission status: Runtime Error

Solution code:
a = input()
b = raw_input()
x = 0
for i in range(1,n):
    z = s[0:i]
    y = s[i:n]
    arr = []
    for l in y:
        for m in z:
            if l == m and l not in arr:
                arr.append(l)
    if len(arr) > x:
        x = len(arr)
print x

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
maxx=-
def got(a,al):
	for i in a:
    	if i==al:
      		return(True)
	return(False)
for i in range(n):
	a=s[:i]
  	b=s[i:]
  	cnt=0
  	alp="abcdefghijklmnopqrstuvwxyz"
  	for al in alp:
    	if got(a,al) and got(b,al):
      		cnt+=1
  	maxx=max(maxx,cnt)
print(maxx)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
\def main():
    n = int(input())
    s = input()
    ma = 0
    for i in range(1, n):
        x = s[:i]
        y = s[i:]
        ma = max(ma, count_same(x, y))
    print(ma)


def count_same(x, y):
    return len(set(x) & set(y))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
l = []
for i in range(2, n-1):
    head = set(s[:i])
    back = set(s[i:])
    l.append(len(head & back))
ans = max(l)
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
S = input()
array = []
for i in range(1,N-1):
    S1 = list(S[:i])
    S2 = list(S[i:])
    S1c = Counter(S1)
    S2c = Counter(S2)
    suma = 0
    for k in S1c:
        if k in S2c:
            suma += 1
    array.append(suma)
print(max(array))

Submission status: Runtime Error

Solution code:

    import collections

N = int(input())
S = input()
A = ''
B = S
ans = 0
for i in range(N):
  A += B[0]
  B = B[1:]
  C = collections.Counter(A)
  D = 0
  for w in C:
    if w in B:
      D += 1
  if D > ans:
    ans = D
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    m = 0
    for i in range(1, n - 1):
        a = s[:i]
        b = s[i:]
        c = len(set(a) & set(b))
        if c >= m:
            m = c

    print(m)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
S =input()
def countchar(s1,s2):
  table=collections.defaultdict(int)
  for x in s1:
    table[x]+=1
  for x in s2:
    if x in table and table[x]>0:
      ret+=1
      table[x]=0
  return(ret)
ans=0
for i in range(1,N):
  X=S[:i]
  Y=S[i:]
  ans=max(ans,countchar(X,Y))
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
Alphabet = [q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m]
for j in range(1,n):
  r = 0
  StringL = s[0:j]
  StringR = s[j:n]
  for i in Alphabet:
    if StringL.count(i) == 0:
      pass
    else:
      if StringR.count(i) == 0:
        pass
      else: r = r + 1
print(r)

Submission status: Runtime Error

Solution code:
# 入力の受け取り
n = int(input())
list = list(input().split())

# 全種類用意しとく
alphabets_list = lsit("abcdefghijklmnopqrstuvwxyz".split())

# 判定
for i in range(1, n - 1):
    x = list[ :i]
    y = list[i: ]
    count = 0
    for alphabet in alphabets_list:
        if alphabet in x and alphabet in y:
            count += 1
        else:
            continue

print(continue)

Submission status: Runtime Error

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

Submission status: Runtime Error

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 - 1)])

Submission status: Runtime Error

Solution code:

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: Runtime Error

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

Submission status: Runtime Error

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

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

for i in range(0,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()
print(max(l))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(1,n):
  s1 = set(s[:i])
  s2 = set(s[i:])
  w = lin(s1&s2)
  if w > c:
    c = w
    
print(c)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
s = list(str(input()))
w = ['a','b','c','d','e','f','g','h','i', 'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','z']
ans = []
x = []
y = []

for i in range(n):
    x = [s[0:i]]
    y = [s[i:n]]
    for j in range(len(w)):
        num = 0
        if w[j] in x and w[j] in y:
            num += 1
    else:
        ans.append(num)

print(max(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(input())
ans = [i * 0 for i in range(51)]
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: Runtime Error

Solution code:
n = int(input())
s = list(input())
ans = [i * 0 for i in range(51)]
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: Runtime Error

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

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

print(max(list_))

Submission status: Runtime Error

Solution code:
import collections

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

ans = 0
for i in range(1, N):
  l = S[:i]
  r = S[i:]
  lc = collections.Counter(l)
  rc = collections.Counter(r)
  ans = max(ans, lc, rc)

print(ans)

Submission status: Runtime Error

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

ans=0
for i in range(len(S)):
    a=set(S[:i])
    b=set(S[i:])
    if a&b>ans:
    	ans=a&b
print(ans)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc098/submissions/5418660
N = int(input())
S = input()
ans = 0
moji = 'abcdefghijklmnopqrstuvwxyz'
for i in range(1, N):
  l, r = S[:i], S[i:]
  cnt = 0
  for c in moji:
    if c in l an c in r:
      cnt += 1
  ans = max(ans, cnt)
  
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
L = []
for i in range(1, N-1):
    a = set()
    b = set()
    for j in S[:i]:
        a.add(j)
    for k in S[i:]:
        b.add(k)
    count = len(a & b)
    L.append(count)

print(max(L))

Submission status: Runtime Error

Solution code:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
string s;
int main(){
	int N; cin >> N;
	cin >> s;
	map<char,int> mpaf,mpbe;
	for(int i = 0; i < N; i++){
		mpaf[s[i]]++;
	}
	int be = 0, af = 0;
	int ans = 0;
	for(int i = 0; i < N; i++){
		mpbe[s[i]]++;
		mpaf[s[i]]--;
		int num = 0;
		for(char t = 'a'; t <= 'z'; t++){
			if(mpbe[t] > 0 && mpaf[t] > 0) num++;
		}
		ans = max(ans,num);
	}
	cout << ans << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(max(z))

Submission status: Runtime Error

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

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: Runtime Error

Solution code:
#include <stdio.h>
#include <string.h>

int main(){
    int N, ct, num, max;
    scanf("%d", &N);
    char S[N];
    scanf("%s", S);

    max = 0;
    for(int i=1;i<N;i++){
        ct = 0;
        char tmp_1[26] = {}, tmp_2[26] = {};
        for(int j = 0; j < i; j++){
            if(strchr(tmp_1, S[j]))
                continue;
            else
                tmp_1[ct++] = S[j];
        }
        ct = 0;
        for(int j = i; j < N; j++){
            if(strchr(tmp_2, S[j]))
                continue;
            else
                tmp_2[ct++] = S[j];
        }
        num = 0;
        for (int j = 0; j < ct; j++){
            if(strchr(tmp_1, tmp_2[j]))
                num += 1;
        }
        max = num>max ? num:max;
    }

    printf("%d", max);

    return 0;
}

Submission status: Runtime Error

Solution code:

Copy
Copy

    N = int(input())
    S = input()
    max_cnt = 0
    for i in range(N):
      li1 = [0]*26
      li2 = [0]*26
      cnt = 0
      for j in S[i:]:
        li[ord(j)-97]+=1
      for j in S[:i]:
        li[ord(j)-97]+=1
      for j in range(26):
        if(li1[j]>0 and li2[j]>0):
          cnt += 1
      max_cnt = max(max_cnt,cnt)
    print(max_cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
max_cnt = 0
for i in range(101):
  li1 = [0]*26
  li2 = [0]*26
  cnt = 0
  for j in S[i:]:
    li[ord(j)-97]+=1
  for j in S[:i]:
    li[ord(j)-97]+=1
  for j in range(26):
    if(li1[j]>0 and li2[j]>0):
      cnt += 1
  max_cnt = max(max_cnt,cnt)
print(max_cnt)

Submission status: Runtime Error

Solution code:
def cut_and_count(N: int, S: str) -> int:
    l, r = set([]), set([])
    for c in S:
        r.add(c)

    max_len = 0
    for c in S:
        l.add(c)
        r.discard(c)

        temp = len(l & r)
        max_len = max(max, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)

Submission status: Runtime Error

Solution code:
X=int(input())
i=2
L=[]
import math
while math.floor(X**(1/i))!=1:
    L.append(math.floor(X**(1/i))**2)
    i+=1
print(max(L))

Submission status: Runtime Error

Solution code:
N=int(input())
S=input()
L=[]
len_s=len(S)
for i in range(2,len_s-1):
  L1=list(S[1:i]);L2=list(S[i:len_s])
  L.append(len(list(set(L1)&set(L2))))
print(max(L))

Submission status: Runtime Error

Solution code:
N=int(input())
S=input()
L=[]
len_s=len(S)
for i in range(2,len_s):
  L1=list(S[1:i]);L2=list(S[i:len_s])
  L.append(len(list(set(L1)&set(L2))))
print(max(L))

Submission status: Runtime Error

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

for i in s:
    S.append(i)

ans = []

for j in range(1, n-1):
    count = 0
    l, r = set(S[:j]), set(S[j:])
    for k in l:
        if k in r:
            count += 1
    ans.append(count)

print(max(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
S = input().strip()
ans= []

for i in range(1, N-1):
    a = S[:i]
    b = S[i+1:]
    for j in a:
        num = 0
        if j in b:
            num += 1
        ans.append(num)
print(max(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count = []

for i in range(1,N-1):
    sum = 0
    sita = S[0:i]
    usiro = S[i:N]

    #print(sita,usiro)
    sita = list(set(sita))
    usiro = list(set(usiro))

    #print(sita,usiro)
    for x in range(len(sita)):
        if sita[x] in usiro:
            sum += 1

    count.append(sum)

print(max(count))

Submission status: Runtime Error

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

for i in range(1,n-1):
  
  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)

print(max(ls))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(a)

Submission status: Runtime Error

Solution code:
p=int(input())
a=input()
b=[]
for i in range(1,p-1):
    c=0
    t=list(set(a[:i]))
    k=a[i:]
    for j in range(len(t)):
        if t[j]in k:
            c+=1
    b.append(c)
print(max(b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(len(S)):
    a = []
    S_former = S[:i]
    S_latter = S[i:]
    for sub1 in S_former:
        if sub1 in S_latter:
           a.append(1)
           S_former.replace(sub1,"")
    b = sum(a)

print(max(b))

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>

using namespace std;

int main(){
	int N, ans = 0; cin >> N;
	string S; cin >> S;
	int left[26] = {}, right[26] = {};
	for(int i = 1; i < S.size(); ++i){
		int count = 0;
		string left_S = S.substr(0, i), right_S = S.substr(i, S.size());
		for(int i = 0; i < left_S.size(); ++i) left[left_S[i]-'a']++;
		for(int i = 0; i < right_S.size(); ++i) right[right_S[i]-'a']++;
		for(int i = 0; i < 26; ++i) if(left[i] > 0 && right[i] > 0) count++;
		ans = max(ans, count);
		fill(left, left + 26, 0);
		fill(right, right + 26, 0);
	}
	cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
for i in xrange(n):
  print(s[:i])
  print(s[i+1:])
  a = set(s[:i])
  b = set(s[i+1:])
  num = []
  num.append(len(a.intersection(b)))
print(max(num))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if n%2 == 0:
    s1 = set(s[:n//2:])
    s2 = set(s[n//2::])
    print(len(s1&s2))
else:
    s1 = set(s[:n//2:])
    s2 = set(s[n//2::])
    s3 = set(s[:(n//2)+1:])
    s4 = set(s[(n//2)+1::])
    print(max(len(s1&s2),len(s3,s4)))

Submission status: Runtime Error

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

if n%2 == 0:
    s1 = set(s[:n//2])
    s2 = set(s[n//2:])
    print(len(s1&s2))
else:
    s1 = set(s[:n//2])
    s2 = set(s[n//2:])
    s3 = set(s[:(n//2)+1])
    s4 = set(s[(n//2)+1:])
  print(max(len(s1&s2),len(s3,s4)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def count_same_car(s1, s2):
    same_car = 0
    for c in s1:
        if c in s2:
            same_car += 1
            s2 = s2.replace(c, "")
    return same_car

if n == 0:
    print(0)
    exit()

for i in range(1, n-1):
    s1 = s[:i]
    s2 = s[i:]
    same_list.append(count_same_car(s1, s2))

print(max(same_list))

Submission status: Runtime Error

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

def count_same_car(s1, s2):
    same_car = 0
    for c in s1:
        if c in s2:
            same_car += 1
            s2 = s2.replace(c, "")
    return same_car

for i in range(1, n-1):
    s1 = s[:i]
    s2 = s[i:]
    same_list.append(count_same_car(s1, s2))

print(max(same_list))

Submission status: Runtime Error

Solution code:
N, S = (input() for i in 'NS')
res = 0
for i in range(N):
    s, t = set(S[:i]), set(S[i:])
    res = max(res, len(s.intersection(t)))
print(res)

Submission status: Runtime Error

Solution code:
N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = s[:i+1]
    y = s[i+1:]
    x.sort()
    y.sort()
    x_str = []
    y_str = []
    count = 0
    for j in range(len(x)):
        if j == 0:
            x_str.append(x[0])
        else:
            if x[j-1] != x[j]:
                x_str.append(x[j])
    for j in range(len(y)):
        if j == 0:
            y_str.append(y[0])
        else:
            if y[j-1] != y[j]:
                y_str.append(y[j])
    for j in range(len(x_str)):
        if x_str[j] in y_str:
            count += 1
    types.append(count)
print(max(types))

Submission status: Runtime Error

Solution code:
N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = s[:i]
    y = s[i:]
    x.sort()
    y.sort()
    x_str = []
    y_str = []
    x_str.append(x[0])
    y_str.append(y[0])
    count = 0
    for j in range(len(x)):
        if j == 0:
            x_str.append(x[0])
        else:
            if x[j-1] != x[j]:
                x_str.append(x[j])
    for j in range(len(y)):
        if j == 0:
            y_str.append(y[0])
        else:
            if y[j-1] != y[j]:
                y_str.append(y[j])
    for j in range(len(x_str)):
        if x_str[j] in y_str:
            count += 1
    types.append(count)
print(max(types))

Submission status: Runtime Error

Solution code:
N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = s[:i]
    y = s[i:]
    x.sort()
    y.sort()
    x_str = []
    y_str = []
    x_str.append(x[0])
    y_str.append(y[0])
    count = 0
    for i in range(len(x)):
        if i == 0:
            x_str.append(x[0])
        else:
            if x[i-1] != x[i]:
                x_str.append(x[i])
    for i in range(len(y)):
        if i == 0:
            y_str.append(y[0])
        else:
            if y[i-1] != y[i]:
                y_str.append(y[i])
    for i in range(len(x_str)):
        if x_str[i] in y_str:
            count += 1
    types.append(count)
print(max(types))

Submission status: Runtime Error

Solution code:
N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = s[:i]
    y = s[i:]
    x.sort()
    y.sort()
    x_str = []
    y_str = []
    x_str.append(x[0])
    y_str.append(y[0])
    count = 0
    for i in range(1,len(x)):
        if x[i-1] != x[i]:
            x_str.append(x[i])
    for i in range(1,len(y)):
        if y[i-1] != y[i]:
            y_str.append(y[i])
    for i in range(len(x_str)):
        if x_str[i] in y_str:
            count += 1
    types.append(count)
print(max(types))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
array = []
for i in range(n):
  s1 = set(s[:i])
  s2 = set(s[i+1:])
  if s1 & s2:
    array.append(len(s1 & s2))
print(max(array))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

    both = left & right
    ans = max(len(both), ans)


print(ans)

Submission status: Runtime Error

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

l_dict = {}
r_dict = {}

for c in s:
	r_dict[c] = 0
	l_dict[c] = 0

for c in s:
	r_dict[c] += 1

ans = 0
for c in s:
	l_dict[c] += 1
	r_dict[c] -= 1

	count = 0
	for k, v in l_dict.items():
		if v > 0:
			if r_dict[k] > 0
				count += 1

	ans = max(ans, count)

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
S=str(input())
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        idx=i        
idx=idx+1
sub_X=S[:idx]
sub_Y=S[idx:]
import collections
count_list_X=list(collections.Counter(sub_X).keys())
count_list_Y=list(collections.Counter(sub_Y).keys())
max_count=0
count=0
for str1 in count_list_X:
    for str2 in count_list_Y:
        if str1==str2:
            count+=1
if count>max_count:
    max_count=count
print(max_count)

Submission status: Runtime Error

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

for i in range(len(S)-1):
    if S[i]==S[i+1]:
        idx=i        
idx=idx+1
sub_X=S[:idx]
sub_Y=S[idx:]
count=0
for str1 in sub_X:
    for str2 in sub_Y:
        if str1==str2:
            count+=1
            
print(int(count/2))

Submission status: Runtime Error

Solution code:
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        idx=i        
idx=idx+1
sub_X=S[:idx]
sub_Y=S[idx:]
count=0
for str1 in sub_X:
    for str2 in sub_Y:
        if str1==str2:
            count+=1
            
print(int(count/2))