Harryxun/stf_run huggingface dataset:
T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1

### FIXED CODE ###

T=str(input())
cnt=0
cc=[]
count=len(T)
for i in T:
    if i=='P':
        cnt=1
        cc.append('P')

    elif i=='D':
        cnt=0
        cc.append('D')
    else:
        if count == i:
            cc.append('D')

        elif cnt==1:
            cnt=0
            cc.append('D')
        else:
            cnt=1
            cc.append('?')

ccc=1
for i in cc:
    if i=='P':
        print('P',end='')
    elif i=='D':
        print('D',end='')
    else:
        if ccc==len(cc):
            print('D')
        elif cc[ccc]=='P':
            print('D',end='')
        else:
            print('P',end='')
    ccc+=1
X = int(input())

if (N >= 30):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

X = int(input())

if (X >= 30):
    print("Yes")
else:
    print("No")
A = int(input())
B = int(input())

a=A+B
b=A-B
c=A*B

if a>b and a>c:
    print(str(a))

elif b>c and b>a:
    print(str(b))

else:
    print(str(c))

### FIXED CODE ###

A,B = map(int, input().split())
print(max(A+B,A-B,A*B))
myArray = list()
for n in range(5):
    myArray.append(int(input()))
Jouyo  = 9

for i,j in enumerate(myArray):
    if 0 < j % 10 <= Jouyo:
        Jouyo = j % 10
        jouyoi = i

times = 0
for i,j in enumerate(myArray):
    if i != jouyoi:
        if j % 10 != 0:
            times += ((j // 10) + 1) * 10
        else:
            times += j
    else:
        times += j
print(times)

### FIXED CODE ###

myArray = list()
for n in range(5):
    myArray.append(int(input()))
Jouyo  = 9
jouyoi = 0

for i,j in enumerate(myArray):
    if 0 < j % 10 <= Jouyo:
        Jouyo = j % 10
        jouyoi = i
times = 0
for i,j in enumerate(myArray):
    if i != jouyoi:
        if j % 10 != 0:
            times += ((j // 10) + 1) * 10
        else:
            times += j
    else:
        times += j
print(times)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def walk_on_multiplication_table(n):

    ans = 10**13
    yaku = make_divisors(n)
    yaku.sort()
    count = len(yaku)

    for i in range(int(count//2)):
        ans = min(ans, (yaku[i]+yaku[count-i-1]-2))

    if count % 2 == 0:
        return ans

    return min(ans, (yaku[int((count+1)**2)]-2))

def main():
    n = int(input())
    print(walk_on_multiplication_table(n))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def walk_on_multiplication_table(n):

    ans = 10**13
    yaku = make_divisors(n)
    yaku.sort()
    count = len(yaku)
    for i in range(int(count//2)):
        ans = min(ans, (yaku[i]+yaku[count-i-1]-2))

    if count % 2 == 0:
        return ans
    return min(ans, (yaku[int(count//2)]*2)-2)

def main():
    n = int(input())
    print(walk_on_multiplication_table(n))

if __name__ == '__main__':
    main()
def main(inputs):
	x=int(inputs[0][0])
	n=x//500
	x-=n*500
	n1=x//5
	print(n*1000+n1*5)


if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)


### FIXED CODE ###


def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs

def main(inputs):
	x=int(inputs[0][0])
	n=x//500
	x-=n*500
	n1=x//5
	print(n*1000+n1*5)


if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)
import math
t = 1
for tc in range(t):
    N = 1000005
    div = [0] * N
    for i in range(1,N):
        for j in range(i,N,i):
            div[j] += 1
    n = int(input())
    ans = 0
    for i in range(1,n):
        ans += div[n-c]
    print(ans)
        

    
    


### FIXED CODE ###

import math
t = 1
for tc in range(t):
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        j = 1
        ans += (n-1) // i
        # while i*j + 1 <= n:
        #     ans += 1
        #     j += 1
    print(ans)
li=list(map(int,input().split()))

if (li[0] or li[1])>0:
  if (li[2] or li[3])>0:
    x=min(li[0],li[1]+1)
    y=max(li[2],li[3]+1)
    print(x*y)
  else:
    x=max(li[0],li[1]+1)
    y=max(li[2],li[3]+1)
    print(x*y)
else:
  if (li[2] or li[3])>0:
    x=mix(li[0],li[1]+1)
    y=man(li[2],li[3]+1)
    print(x*y)
  else:
    x=min(li[0],li[1]+1)
    y=min(li[2],li[3]+1)
    print(x*y)

### FIXED CODE ###

li=list(map(int,input().split()))
ans=[]
a=li[0]*li[2]
b=li[0]*li[3]
c=li[1]*li[2]
d=li[1]*li[3]
ans.append(a)
ans.append(b)
ans.append(c)
ans.append(d)

print(max(ans))
N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * M
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

for i in M:
    print(ans[i])

### FIXED CODE ###

N, M = map(int, input().split())
cnt = [0 for i in range(N + 1)] 
check = []
ans = []

for i in range(M):
    p, y = map(int, input().split())
    check.append((y, p, i))

check.sort()

for y, p, i in check:
    cnt[p] += 1
    ans.append((i,str(p).zfill(6)+str(cnt[p]).zfill(6)))

ans.sort()

for aa, bb in ans:
    print(bb)
n = int(input())
v = list(map(int,input().split()))

a = [v[2*i] for i in range(int(n/2))]
b = [v[2*i+1] for i in range(int(n/2))]

from collections import Counter

x = Counter(a)
y = Counter(b)
x = list(x.items())
y = list(y.items())
x.sort(reverse=1,key=lambda p: p[1])
y.sort(reverse=1,key=lambda p: p[1])

if x[0][0] != y[0][0]:
    print(n-x[0][1]-y[0][1])
else:
    if x[0][0] == y[0][0]:
        print(n-max(x[0][1]+y[1][1],y[0][1]+x[1][1]))
    

### FIXED CODE ###

n = int(input())
v = list(map(int,input().split()))

a = [v[2*i] for i in range(int(n/2))]
b = [v[2*i+1] for i in range(int(n/2))]

from collections import Counter

x = Counter(a)
y = Counter(b)
x = list(x.items())
y = list(y.items())
x.sort(reverse=1,key=lambda p: p[1])
y.sort(reverse=1,key=lambda p: p[1])

if x[0][0] != y[0][0]:
    print(n-x[0][1]-y[0][1])
else:
    if x[0][0] == y[0][0]:
        if min(len(x),len(y))>=2:
            print(n-max(x[0][1]+y[1][1],y[0][1]+x[1][1]))
        elif len(x)==2:
            print(n-x[1][1]-y[0][1])
        elif len(y)==2:
            print(n-y[1][1]-x[0][1])
        else:
            print(int(n/2))
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1; ;) {
    if (h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i = G.size() - 1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);
  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--) {
    printf("%d", G[i]);
    if (i) printf(" ");
  }

  printf("\n");
  printf("%lld\n", cnt);
  for (int i = 0; i < n; i++) printf("%d\n", A[i]);

  return 0;
}



### FIXED CODE ###

def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            cnt += 1
            j -= g
        A[j+g] = v

    return A, cnt


def shell_sort(A, n):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A


n = int(input().rstrip())
A = []
for _ in range(n):
    A.append(int(input().rstrip()))

m, G, cnt, A = shell_sort(A, n)

print(m)
print(' '.join(list(map(str, G))))
print(cnt)
print('\n'.join(list(map(str, A))))
import sys

for line in sys.stdin:
    A=line.split()
    B=map(int,A)
    if B[0]<B[1]:
        p=B[1]
        B[1]=B[0]
        B[0]=p
    e=1

    while e != 0:
        e=B[0]%B[1]
        C=B[1]
        B[1]=e
        B[0]=C

    print B[0]

### FIXED CODE ###

A=map(int,raw_input().split())
A.sort()

while A[1]%A[0]!=0:
    temp=A[0]
    A[0]=A[1]%A[0]
    A[1]=temp

print A[0]
a=int(input())
b=0
while b=<a
    b+=1000
print(b-a)

### FIXED CODE ###

a=int(input())
b=0
while b<a:
    b+=1000
print(b-a)
# -*- using:utf-8 -*-
class main:
  def function(x, k, d):
    for i in range(k):
      if abs(x + d) >= abs(x - d):
        x = x - d
      if abs(x + d) < abs(x - d):
        x = x + d
    print(x)

if __name__ == "__main__":
  x, k, d = map(int, input().split())
  main.function(x,k,d)

### FIXED CODE ###

# -*- using:utf-8 -*-

if __name__ == "__main__":
  s = list(input())
  sum = 0
  for i in range(3):
    if s[i] == 'R':
      sum = 1
  if s[0] == 'R' and s[1] =='R':
    sum += 1
  if s[1] == 'R' and s[2] == 'R':
    sum += 1
  print(sum)
import fractions

def lcm(n, m):
    return int(n * m / fractions.gcd(n, m))


n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
t_sorted = sorted(t)

time = 0
for i in range(0, n):
    if i == 0:
        time = t_sorted[0]
    else:
        time = lcm(int(time), t_sorted[i])

print(int(time))

### FIXED CODE ###

def gcd(n, m):
    if min(n, m) == 0:
        return max(n,m)
    else:
        return gcd(min(n,m), max(n,m) % min(n,m))

def lcm(n, m):
    return n * m // gcd(n, m)


n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
t_sorted = sorted(t)

time = 0
for i in range(0, n):
    if i == 0:
        time = t_sorted[0]
    else:
        time = lcm(time, t_sorted[i])

print(int(time))
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue

            else:
                # 3角形の成立条件
                if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                    ans += 1
print(ans)


### FIXED CODE ###

s = list(input())
c = s.count("R")
if c == 3:
    print(3)
elif c == 2 and s[1] != "S":
    print(2)
elif c == 0:
    print(0)
else:
    print(1)
N_s = input()
N = int(N_s)
ans = 0
for i in range(1, len(N_s))
	if i % 2 == 1:
    	ans += (10**i - 10**(i - 1))
if len(N_s) % 2 == 1:
  	ans += (1 - 10**(len(N_s)) + N)
print(ans)

### FIXED CODE ###

n = int(input())
cnt = 0
for i in range(1, n + 1):
  if len(str(i)) % 2 == 1:
    cnt +=1
print(cnt)
List = list(map,input().split())
List2 = sorted(List)
print('Yes' if List2[0] + List2[1] == List2[3] else 'No') 

### FIXED CODE ###

List = sorted(list(map(int,input().split())))
print('Yes' if List[0] + List[1] == List[2] else 'No')
N, X, M = map(int, input().split())
if X <= 1:
    print(X*N)
    exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
    A = (A**2)%M
    if check[A] != 0:
        last_count = sum(check)
        target_value = A
        break
    check[A] += 1
A2 = X
first_count = 0
while True:
    first_count += 1
    A2 = (A2**2)%M
    if A2 == target_value:
        break

roop_count = last_count-first_count

A3 = target_value
mass = A3
for i in range(roop_count-1):
    A3 = (A3**2)%M
    mass += A3

ans = X
A = X
for i in range(min(N,first_count)-1):
    A = (A**2)%M
    ans += A
if N > first_count:
    ans += ((N-first_count)//roop_count)*mass
    A4 = target_value
    if (N-first_count)%roop_count >= 1:
        ans += A4
    for i in range(((N-first_count)%roop_count)-1):
        A4 = (A4**2)%M
        ans += A4
print(ans)

### FIXED CODE ###

N, X, M = map(int, input().split())
if X <= 1:
    print(X*N)
    exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
    A = (A**2)%M
    if check[A] != 0:
        last_count = sum(check)
        target_value = A
        break
    check[A] += 1
A2 = X
first_count = 0
while A2 != target_value:
    first_count += 1
    A2 = (A2**2)%M

roop_count = last_count-first_count

A3 = target_value
mass = A3
for i in range(roop_count-1):
    A3 = (A3**2)%M
    mass += A3
if roop_count == 0:
    print(N*X)
    exit()
if first_count != 0:
    ans = X
    A = X
    for i in range(min(N,first_count)-1):
        A = (A**2)%M
        ans += A
else:
    ans = 0
if N > first_count:
    ans += ((N-first_count)//roop_count)*mass
    A4 = target_value
    if (N-first_count)%roop_count >= 1:
        ans += A4
    for i in range(((N-first_count)%roop_count)-1):
        A4 = (A4**2)%M
        ans += A4
print(ans)
s = input()
if s=="SAT":
  ans=1
if s=="FRI":
  ans=2
if s=="THU":
  ans=3
if s=="WED":
  ans=4
if s=="THU":
  ans=5
if s=="MON":
  ans=6
if s=="SUN":
  ans=7
  
print(ans)


### FIXED CODE ###

s = input()
if s=="SAT":
  ans=1
if s=="FRI":
  ans=2
if s=="THU":
  ans=3
if s=="WED":
  ans=4
if s=="TUE":
  ans=5
if s=="MON":
  ans=6
if s=="SUN":
  ans=7
  
print(ans)
import re
s=str(input())
t=str(input())
t2=t.replace(s,"",1)
if re.match([a-z]):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import re
s=str(input())
t=str(input())
for i in range(len(s)):
 if s[i]!=t[i]:
  print("No")
  exit()
 else:
  pass
if re.sub(r"[a-z]","",t)=="":
  print("Yes")
else:
  print("No")
from collections import Counter as c
from math import factorial as fac
from functools import reduce

def f(n):
  d=c()
  for i in range(2,1+int(n**0.5)):
    while n%i==0:
      d[i]+=1
      n/=i
  return d.values()

def comb(n,r):
  return fac(n)//fac(r)//fac(n-r)%mod

n,m=map(int,input().split())
mod=10**9+7
g=lambda x:comb(x+n-1,x)
h=lambda x,y:x*y%mod
print(reduce(h,map(g,f(m)))%mod)

### FIXED CODE ###

from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod,v=10**9+7,1
for x in f(m):
  v*=comb(x+n-1,x,exact=True)%mod
print(v%mod)
# -*- coding: utf-8 -*-
import sys
from collections import deque
from numba import njit
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

@njit(cache=True)
def solve(N,M,P):
    d=[0]*M
    for i in range(N):
        for j in range(N):
            d[i*N+j]=min(min(i,N-1-i),min(j,N-1-j))
    used=[1]*M
    dx=(-1,1,-N,N)
    ans=0
    que=[]
    for p in P:
        ans+=d[p]
        used[p]=0
        que.append(p)
        while que:
            x=que.pop()
            for ddx in dx:
                nx=x+ddx
                if 0<=nx<M:
                    if used[x]==0 and d[nx]-d[x]>=1:
                        d[nx]-=1
                        que.append(nx)
                    elif used[x]==1 and d[nx]-d[x]>=2:
                        d[nx]-=1
                        que.append(nx)
    return ans

def main():
    N=int(input())
    M=N**2
    P=tuple(map(int1,input().split()))
    ans=solve(N,M,P)
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
M=N**2
P=tuple(map(int1,input().split()))
d=[0]*M
for i in range(N):
    for j in range(N):
        d[i*N+j]=min(min(i,N-1-i),min(j,N-1-j))
used=[1]*M
ans=0
que=[]
for p in P:
    ans+=d[p]
    used[p]=0
    que.append(p)
    while que:
        x=que.pop()
        for ddx in (-1,1,-N,N):
            nx=x+ddx
            if 0<=nx<M:
                if used[x]==0 and d[nx]-d[x]>=1:
                    d[nx]-=1
                    que.append(nx)
                elif used[x]==1 and d[nx]-d[x]>=2:
                    d[nx]-=1
                    que.append(nx)
print(ans)
import math

x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  x = max(x_minA, x_minB)
  while (x * 8 / 100 - A >= 1) or (x / 10 - B >= 1):
    print(x, x * 8 / 100, x / 10)
    x += 1
  print(x)

### FIXED CODE ###

import math
 
A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  for x in range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1):
    if int(x * 8 / 100) == A and int(x / 10)==B:
      print(x)
      break
  else:
    print(-1)
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_diff = [x[i]-x[i-1] for i in range(1,m)]
x_diff.sort(reverse == True)
if n >= m:
  print(0)
else:
  del x_diff[:n-1]
  print(sum(x_diff))

### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_diff = [x[i]-x[i-1] for i in range(1,m)]
x_diff.sort(reverse = True)
if n >= m:
  print(0)
else:
  del x_diff[:n-1]
  print(sum(x_diff))
a,b = map(int,input().split)

def solve(a,b):
  if a<=9 and b<=9:
    return a * b
  else:
    return -1
  
print(solve(a,b))

### FIXED CODE ###

a,b = map(int,input().split())
     
def solve(a,b):
  if a<=9 and b<=9:
    return a * b
  else:
    return -1
  
print(solve(a,b))
cnt = 0
def dfs(g , start,N):
    global cnt
    visited = [False for i in range(N)]
    stack =[]
    stack.append(start)

    while stack:
        v = stack.pop()
        visited[v] = True


        for i in range(N):
            if g[v][i] == 1 and visited[i] ==False:
                stack.append(i)

    for i in range(N):
        if visited[i] == False:
            cnt += 1
            break


N,M = map(int,input().split())
g = [ [0 for i in range(N)] for j in range(N)]
a,b = [0] * N,[0] * N

for i in range(M):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

for i in range(M):

    g[a[i]][b[i]] -= 1
    g[b[i]][a[i]] -= 1

    dfs(g,0,N)

    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

print(cnt)


### FIXED CODE ###


cnt = 0
def dfs(g , start,N):
    global cnt
    visited = [False for i in range(N)]
    stack =[]
    stack.append(start)

    while stack:
        v = stack.pop()
        visited[v] = True

        for i in range(N):
            if g[v][i] == 1 and visited[i] ==False:
                stack.append(i)

    for i in range(N):
        if visited[i] == False:
            cnt += 1
            break


N,M = map(int,input().split())
g = [ [0 for i in range(N)] for j in range(N)]
a,b = [0] * M,[0] * M

for i in range(M):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

for i in range(M):

    g[a[i]][b[i]] -= 1
    g[b[i]][a[i]] -= 1

    dfs(g,0,N)

    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

print(cnt)
k, n = map(int,input().split())
length = list(map(int,input.split())
distance =[]
for i in range(n-1):
  diatance.append(lenght[i+1]-lenght[i])
distance.append(k-length[n-1])
print(k-max(distance))

### FIXED CODE ###

k, n = map(int,input().split())
length = list(map(int,input().split()))
length.append(k+length[0])
distance =[]
for i in range(n):
  distance.append(length[i+1]-length[i])
print(k-max(distance))
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)

### FIXED 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)
x=int(input())
y=x//2
z=x-y
print(z/y)

### FIXED CODE ###

x=int(input())
y=x//2
z=x-y
print(z/x)
n = int(input())
n_lst = []
for i in range(n):
    n_lst.append(i+1)
    
##共通
kosu = n // 15
 
##3の倍数
a3 = n // 3
lst3 = []
for i in range(a3):
    n3 = 3 * (i+1)
    lst3.append(n3)
 
##5の倍数
a5 = n // 5
lst5 = []
for i in range(a5):
    n5 = 5 * (i+1)
    lst5.append(n5)
 
kosu2 = a5 - kosu
    
###リストから取り除く.strip
for i in range(a3):
    n_lst.remove(lst3[i])
for i in range(kosu2):
    n_lst.remove(lst5[i])
    
goke = sum(n_lst)
print(goke)

### FIXED CODE ###

import math
from functools import reduce
 
k = int(input())
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
kotae = 0
for i in range(k):
    a = i + 1
    for j in range(k):
        b = j + 1
        for l in range(k):
            c = l + 1
            koyakusu = gcd(a, b, c)
            kotae += koyakusu
print(kotae)
# coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
    order,data =input().split() 
    if order == "insert":
        output.append(int(data))
    elif order == "deleteFirst":
        output.pop()
    elif order == "deleteLast":
        output.popleft()
    elif order == "delete":
        try:
            output.remove(int(data))
        except:
            pass
#output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output)))

### FIXED CODE ###

import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
 
Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))
n = input()
 
INFTY = float('inf')
 
color = [0 for i in range(n)]
m = [[INFTY for i in range(n)] for j in range(n)]
d = [INFTY for i in range(n)]
k = [-1 for i in range(n)]

for i in range(n):
    G = map(int, raw_input().split())
    for j in range(n):
    if G[j] != -1:
        m[i][j] = G[j]

d[0] = 0
 
while 1:
    cost = INFTY
for i in range(n):
    if color[i] != 2 and d[i] < cost:
        cost = d[i]
        u = i

if cost == INFTY:
    break
    
color[u] = 2
 
for v in range(n):
    if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]:
        d[v] = m[u][v]
        k[v] = u
        color[v] = 1
sum = 0
for i in range(n):
    if p[i] != -1:
        sum += m[i][k[i]]
print sum

### FIXED CODE ###

n = int(raw_input())
 
INFTY = float('inf')
 
color = [0 for i in range(n)]
M = [[INFTY for i in range(n)] for j in range(n)]
d = [INFTY for i in range(n)]
p = [-1 for i in range(n)]
 
def MST():
  d[0] = 0
 
  while True:
    cost = INFTY
    for i in range(n):
      if color[i] != 2 and d[i] < cost:
        cost = d[i]
        u = i
 
    if cost == INFTY:
      break
     
    color[u] = 2
 
    for v in range(n):
      if color[v] != 2 and M[u][v] != INFTY and M[u][v] < d[v]:
        d[v] = M[u][v]
        p[v] = u
        color[v] = 1
 
  sum = 0
  for i in range(n):
    if p[i] != -1:
      sum += M[i][p[i]]
  return sum
 
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(n):
   if G[j] != -1:
     M[i][j] = G[j]
 
print MST()