Problem p03338 (python)

Fixed submission:
N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = list(s[:i+1])
    y = list(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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))

Buggy submission (verdict: Runtime Error):
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))