Problem:


Score: 400 points

Problem Statement

AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.

The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.

How many different PIN codes can he set this way?

Both the lucky number and the PIN code may begin with a 0.

Constraints

4 \leq N \leq 30000

S is a string of length N consisting of digits.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of different PIN codes Takahashi can set.

Sample Input 1

4
0224

Sample Output 1

3

Takahashi has the following options:

Erase the first digit of S and set 224.

Erase the second digit of S and set 024.

Erase the third digit of S and set 024.

Erase the fourth digit of S and set 022.

Thus, he can set three different PIN codes: 022, 024, and 224.

Sample Input 2

6
123123

Sample Output 2

17

Sample Input 3

19
3141592653589793238

Sample Output 3

329



Sample input:
4
0224


Sample output:
3

Submission status: Judge Not Available

Solution code:
ans = 1
N = int(input())
s = input()
ans = 0
for i in range(1000):
t = str(i).zfill(3)
t_index = 0 
for s_index in range(N):
    if s[s_index] == t[t_index]:
        t_index += 1
        if t_index == 3:
            break
if t_index == 3:
    ans += 1
print(ans)

Submission status: Runtime Error

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

# 3桁の番号を作るにあたり、文字列から抽出して作るのではなく、000〜999までの組み合わせが存在するかを確認する。
ans = 0
for i in range(10):
  a = s.find(str(i))
  for j in range(10):
    b = s.find(str(j), a+1) # aの取得位置の次から検索を行う
    for k in range(10):
      c = s.find(str(k), b+1)　# bの取得位置の次から検索を行う
      if a == -1 or b == -1 or c == -1: continue
      else: ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
a = {}
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      a.append(s[i] + s[j] + s[k])
print(len(s))

Submission status: Runtime Error

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 1
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
s = v()

s1,s2,s3 = set(),set(),set()
for x in S:
    for z in s2:
        s3.add(z+x)
    for y in s1:
        s2.add(y+x)
    s1.add(x)
print(len(s3))

Submission status: Runtime Error

Solution code:
N = input()
S = input()
ans = set()
num_count = [0]*10
i = 0
while i < len(S):
    s_num = int(S[i])
    if num_count[s_num] <= 3:
        num_count[s_num] += 1
        i += 1
    else:
        S.pop(i)
for i in range(len(S)-2):
    for j in range(i+1, len(S)-1):
        for k in range(j+1, len(S)):
            s = S[i]+S[j]+S[k]
            if s not in ans:
                ans.add(s)
print(len(ans))

Submission status: Runtime Error

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

ans = 0
tmp = [0 for _ in range(10)]
for i in range(len(S)):
    tmp[int(S[i])] += 1

for i in range(1000):
    flag = True

    if i < 10:
        dic = {"0": 2}
    elif i < 100:
        dic = {"0": 1}
    else:
        dic = {}
    for j in range(len(str(i))):
        if str(i)[j] in dic:
            dic[str(i)[j]] += 1
        else:
            dic[str(i)[j]] = 1

    for k, v in dic.items():
        if dic[k] > tmp[int(k)]:
            flag = False
            break

    if flag:
        t = 0
        for j in range(len(S)):
            if str(i)[t] == S[j]:
                t += 1
            if t == 3:
                ans += 1
                break

print(ans)

Submission status: Runtime Error

Solution code:
from itertools import combinations
def main():
    n=int(input())
    s=input()
    ss=[]
    p=""
    for i in s:
        if i != p:
            ss.append(i)
            p=i
    if len(ss) < 4:
        ss = s
    ans=set()
    for i,j,k in combinations(range(n),3):
        ans.add("".join([ss[i],ss[j],ss[k]]))
    print(len(ans))
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
count = 0
ALL_angou = [str(i)+str(k)+str(l) for i in range(0,10) for k in range(0,10) for l in range(0,10)]
def hantei(A, S):
    if len(S) == 0 or len(A) == 0:
        return False
    if S[0] == A[0]:
        if len(A) == 1:
            return True
        else:
            k = hantei(A[1:], S[1:])
    else:
        if len(S) == 1:
            return False
        k = hantei(A[0:], S[1:])
    return k
for k in ALL_angou:
    if hantei(k, S):
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
count = 0
ALL_angou = [str(i)+str(k)+str(l) for i in range(0,10) for k in range(0,10) for l in range(0,10)]
def hantei(A, S):
    if len(S) == 0 or len(A) == 0:
        return False
    if S[0] == A[0]:
        if len(A) == 1:
            return True
        else:
            k = hantei(A[1:], S[1:])
    else:
        if len(S) == 1:
            return False
        k = hantei(A[0:], S[1:])
    return k
for k in ALL_angou:
    if hantei(k, str(S)):
        count += 1
print(count)

Submission status: Runtime Error

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

cnt = 0

for i in range(1000):
    if 0 <= i < 10:
        a = "00" + str(i)
    elif 10 <= i < 100:
        a = "0" + str(i)
    elif 100 <= i:
        a = str(i)
    
    idx = 0
    for j in range(N):
        if S[i] == a[idx]:
            idx += 1
            if idx == 3:
                cnt += 1
                break

print(cnt)

Submission status: Runtime Error

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

cnt = 0

for i in range(1000):
    if 0 <= i < 10:
        a = "00" + str(i)
    elif 10 <= i < 100:
        a = "0" + str(i)
    elif 100 <= i:
        a = str(i)
    
    idx = 0
    for j in range(S):
        if S[i] == a[idx]:
            idx += 1
            if idx == 3:
                cnt += 1
                break

print(cnt)

Submission status: Runtime Error

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

cnt = 0

for i in range(1000):
    if 0 <= i < 10:
        a = "00" + str(i)
    elif 10 <= i < 100:
        a = "0" + str(i)
    elif 100 <= i:
        a = str(i)
    
    idx = 0
    for j in range(S):
        if S[i] == a[idx]:
            idx += 1
            if idx == 3:
                cnt += 1
                break

Submission status: Runtime Error

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()
    S = input()
    # org = [i for i in set(S)]
    # ans_set = []
    # org.sort()
    # for c in org:
    #     for cc in org:
    #         for ccc in org:
    #             ans_set.append(c+cc+ccc)
    # b = [None] * len(S)
    # b[0] = set()
    # for i in range(1, len(S)):
    #     b[i] = set(S[i:])
    ans_set = []
    pset = [str(i) for i in range(10)]
    for p1 in pset:
        for p2 in pset:
            for p3 in pset:
                ans_set.append(p1+p2+p3)
    cnt = 0
    last = len(S)
    for ans in ans_set:
        f, s, t = ans[0], ans[1], ans[2]
        fidx, sidx, tidx = -1, -1, -1
        is_hit = False
        for i in range(last):
            if fidx < 0 and S[i] == f:
                fidx = i
                continue
            elif sidx < 0 and  if S[i] == s:
                sidx = i
                if i == last-1:
                    break
                continue
            elif tidx < 0 and  S[i] == t:
                is_hit = True
                break
        if is_hit:
            cnt += 1
    # 出力
    print(cnt)

Submission status: Runtime Error

Solution code:
ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      s='{}{}{}'.format(i,j,k)
      isOne=0
      isTen=0
      isHundred=0
      for i in range(N) :
        if S[i]==s[0] and isOne==0:
          isOne=1
        elif S[i]==s[1] and isOne==1 and isTen==0:
          isTen=1
        elif S[i]==s[2] and isOne==1 and isTen==1 and isHundred==0:
          isHundred=1
      if isHundred==1:
      ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
ans = 0
def count_match(first, second, third):
    cnt = 0
    for i in range(N):
        if S[i]==first:
            cnt += 1
            for j in range(i+1, N):
                if S[j]==second:
                    cnt += 1
                    for k in range(j+1, N):
                        if S[k]==third:
                            cnt += 1
                            return cnt
    return 0



if __name__ == '__main__':
    N = int(input())
    S = list(map(int, list(input())))
    f = S[0]
    s = S[1]
    t = s[2]
    fst = (f, s, t) 
    for n in range(0, 999+1):
        first = n//100
        if first not in fst:
            continue
        second = n//10-(first*10)
        third = n%10
        cnt = count_match(first, second, third)
        if cnt==3:
            ans += 1
    
    print(ans)

Submission status: Runtime Error

Solution code:
ans = 0
def count_match(first, second, third):
    cnt = 0
    for i in range(N):
        if S[i]==first:
            cnt += 1
            for j in range(i+1, N):
                if S[j]==second:
                    cnt += 1
                    for k in range(j+1, N):
                        if S[k]==third:
                            cnt += 1
                            return cnt
    return 0



if __name__ == '__main__':
    N = int(input())
    S = list(map(int, list(input())))
    f = S[0]
    s = S[1]
    t = s[2]
    fst = (f, s, t) 
    for n in range(0, 999+1):
        first = n//100
        if first not in fst:
            continue
        second = n//10-(first*10)
        third = n%10
        cnt = count_match(first, second, third)
        if cnt==3:
            ans += 1
    
    print(ans

Submission status: Runtime Error

Solution code:
N=int(input())
S=input()
ans=0
for i in range(10):
  str_i = str(i)
  i_index==S.find(str_i)
  if i_index==-1:
    continue
  for j in range(10):
    str_j=str(j)
    j_index=S.find(str_j, i_index+1)
    if j_index==-1:
      continue
    for k in range(10):
      str_k=str(k)
      k_index=S.find(str_k, j_index+1) 
      if k_index!=-1:
        ans+=1
print(ans)

Submission status: Runtime Error

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

S = set()
for c in combinations(range(N), N-3):
    i0 = 0; x = ''
    for i in c:
        x += s[i0:i]
        i0 = i+1
    x += s[i0:]
    S.add(x)                                  
print(len(S))   #; print(S)

Submission status: Runtime Error

Solution code:
n=list(input())
ans=0
for i in range(0,10):
  for x in range(len(n)):
    if s[x]==str(i):
      for j in range(0,10):
        for y in range(len(n)):
          if s[y]==str(j):
            for k in range(0,10):
              for z in range(len(n)):
                if s[z]==str(k):
                  ans+=1
                  
print(ans)

Submission status: Runtime Error

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

lst = []
lst2 = []
lst3 = []
for i in range(n):
  pin = ''
  if numbers[i] not in lst:
    pin += numbers[i]
    lst.append(pin)
    for j in range(i+1, n):
      pin += numbers[j]
      if pin not in lst2:
        lst2.append(pin)
        for k in range(j+1, n):
          pin += numbers[k]
          if pin not in lst3:
            lst3.append(pin)
          pin = pin[0] + pin[1]
      pin = pin[0]
    if ('0' in lst) and ('1' in lst) and ('2' in lst) and ('3' in lst) and ('4' in lst) and ('5' in lst) and ('6' in lst) and ('7' in lst) and ('8' in lst) and ('9' in lst):
      break
print(lst2[:][1])
print(len(lst3))

Submission status: Runtime Error

Solution code:
import math
import sys
import collections
import bisect
import sympy
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    s = readline()
    cnt = 0
    for i in range(1000):
        x = str(i).zfill(3)
        a = s[:-1].find(x[0])
        if a != -1:
            b = s[a + 1: -1].find(x[1])
            if b != -1:
                c = s[a + b + 2:].find(x[2])
                if c != -1:
                    cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import sys
import collections
import bisect
import sympy
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    s = readline().rstrip()
    cnt = 0
    for i in range(1000):
        x = str(i).zfill(3)
        a = s[:-1].find(x[0])
        if a != -1:
            b = s[a + 1: -1].find(x[1])
            if b != -1:
                c = s[a + b + 2:].find(x[2])
                if c != -1:
                    cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import sys
import collections
import bisect
import sympy
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    s = readline().rstrip()
    cnt = 0
    for i in range(1000):
        x = str(i).zfill(3)
        a = s.find(x[0])
        b = s[a+1:].find(x[1])
        c = s[a+b+2:].find(x[2])
        if -1 not in (a, b, c):
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools

N=int(input())
S=input

print(len(list(itertools.combinations_with_replacement(S, 3)))

Submission status: Runtime Error

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

# dp = [[[False for _ in range(1001)] for __ in range(4)] for ___ in range(30001)]
# dp = [[[False]  * 1001]*4]*30001
dp = [[[False]*30009]*4]*1009
dp[0][0][0] = True

for ix in range(N):
    for jx in range(4):
        for kx in range(1000):
            if dp[ix][jx][kx] == False:
                continue
            dp[ix+1][jx][kx] = True
            if jx <= 2:
                dp[ix+1][jx+1][kx*10+(ord(S[ix])-ord('0'))] = True

ans = 0
for p in range(1000):
    if dp[N][3][p] == True:
        ans += 1
# print(dp)
print(ans)

Submission status: Runtime Error

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

# dp = [[[False for _ in range(1001)] for __ in range(4)] for ___ in range(30001)]
# dp = [[[False]  * 1001]*4]*30001
dp = [[[False]*30001]*4]*1001
dp[0][0][0] = True

for ix in range(N):
    for jx in range(4):
        for kx in range(1000):
            if dp[ix][jx][kx] == False:
                continue
            dp[ix+1][jx][kx] = True
            if jx <= 2:
                dp[ix+1][jx+1][kx*10+(ord(S[ix])-ord('0'))] = True

ans = 0
for p in range(1000):
    if dp[N][3][p] == True:
        ans += 1
# print(dp)
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
a=[]
b=[]
for i in range(n):
  d=s[i]+s[j]
  if d in b:continue
  else:b.append(d)
  for j in range(i+1,n):
    for k in range(j+1,n):
      c=s[i]+s[j]+s[k]
      if c not in a:
        a.append(c)
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import math

H, W = list(map(int, input().split()))

if H == 1 or W == 0:
    print(1)
else:
    result = math.ceil(int(H * W) / 2)
    print(result)

Submission status: Runtime Error

Solution code:
import collections

n = int(input())
s_list = list(input())

ans = 0
for i in range(1000):
    key = str(i).zfill(3)
    k = 0
    t = key[k]
    for s in s_list:
        if t == s[j]:
            k += 1
            if k == 3:
                ans += 1
                break
            t = key[k]
print(ans)

Submission status: Runtime Error

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

ans = 0
for p in range(1000):
  s = '{:03}'.format(p)
  i = 0
  for j in range(N):
    if i < 3 and S[j] == s[i]:
      i += 1
  	if i== 3:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
for i in range(1000):
  i = "{0:03d}".format(i)
  a,b,c = i[0],i[1],i[2]
  bit = 0
  for j in range(n):
    if bit==1:
      break
    if s[j]==a:
      for k in range(j+1,n):
        if bit==1:
          break
        if s[k]==b:
          for m in range(k+1,n):
            if s[m]==c:
              cou.append(i)
              bit = 1
              break
              
print(len(set(cou)))

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
import itertools
state = itertools.product(list(range(10)),repeat = 3)
#print(list(state))
def lucky_pin(i):
    spot = -1
    for j in i:
        
        if str(j) in s[spot +1 : ]:
            spot = s[spot +1 : ].find(str(j)) +spot +1
            
        else:
            return 0
    return 1
print(lucky_pin(i))        
counter = 0
for i in state:
    if 1 ==  lucky_pin(i):
        
        counter +=1
print(counter)

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,S = read().decode('utf-8').split()
print(N,S)
count = 0
for i in range(1000):
  s = str(i).zfill(3)
  index_all = 0
  for j in range(3):
    index = S[index_all:].find(s[j])
    if index == -1:
      break
    index_all += index+1
    if j ==2:
      count += 1
print(count)import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,S = read().decode('utf-8').split()
count = 0
for i in range(1000):
  s = str(i).zfill(3)
  index_all = 0
  for j in range(3):
    index = S[index_all:].find(s[j])
    if index == -1:
      break
    index_all += index+1
    if j ==2:
      count += 1
print(count)

Submission status: Runtime Error

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

S_set = set(S)
ans = 0
for num in range(0, 1000):
    n0, n1, n2 = list(str(num).zfill(3))
    if n0 in S_set and n1 in S_set and n2 in S_set:
        idx0 = S.idx(n0)
        idx2 = N - S[::-1].idx(n2) - 1
        if idx0 < idx2:
            if n1 in S[idx0 + 1: idx2]:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys

n = int(sys.stdin.readline().rstrip("\n"))
s = sys.stdin.readline().rstrip("\n")
pass_set = set([])

while True:
    for j in range(1, n):
        for k in range(j+1, n):
            pass_set.add(s[0] + s[j] + s[k])
    if s == s[-3:]:
      break
    s = s[1:]
    
print(len(pass_set))

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
cnt = 0
for i in range(10):
    a = s.find(i)
    if a == -1:
        continue
    for j in range(10):
        b = s.find(j,a+1)
        if b == -1:
            continue        
        for k in range(10):
            if str(k) in s[b+1::]:
                cnt += 1
print(cnt

Submission status: Runtime Error

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

ans = 0

for i in range(1000):
    t = str(i).zfill(3)
    t_index = 0
    for s_index in range(N):
        if S[s_index] == t[t_index]:
            t_index += 1
            if t_index == 3:
                break
        if t_index == 3:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
numlist = [str(i) for i in range(10)]
numlist *= 3

numcombi = list(itertools.combinations(numlist, 3))

print(numcombi)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            num.append(f"{i}{j}{k}")

ans = 0
for n in num:
    i = 0
    j = 0
    while j < N:
        # print(i, j)
        if n[i] == S[j]:
            i += 1
            j += 1
        else:
            j += 1
        if i == 3:
            ans += 1
            break
print(ans)

Submission status: Runtime Error

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

num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            num.append(f"{i}{j}{k}")

ans = 0
for n in num:
    i = 0
    j = 0
    while j < N:
        # print(i, j)
        if n[i] == S[j]:
            i += 1
            j += 1
        else:
            j += 1
        if i == 3:
            ans += 1
            break
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(input())
pin_li = []
for i in range(len(s)):
    if len(set(pin_li)) >1000:
        break
    for j in range(i+1,len(s)):
        for k in range(j+1,len(s)):
            pin_li.append(s[i]+s[j]+s[k])
            if len(set(pin_li)) > 1000:
                break
print(len(set(pin_li

Submission status: Runtime Error

Solution code:

def search(S):
    List = []
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                word = S[i]+S[j]+S[k]
                if not word in List:
                    List.append(word)
                    ans += 1
        if ans == 999:
            break
    return ans


ans = search(S)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
res = 0
for i in range(10):
    if str(i) in S:
        T = S[S.index(str(i))+1:]
        for j in range(10):
        if str(j) in T:
            U = T[T.index(str(j))+1:]
            for k in range(10):
                if str(k) in U:
                res += 1         
print(res)

Submission status: Runtime Error

Solution code:

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

S = [int(s) for s in S]


res = 0
for q in product(range(10), repeat=3):
    i = 0
    for s in S:
        if s==q[i]:
            if i==2:
                res += 1
                break
            else:
                i+=1
print (res)

Submission status: Runtime Error

Solution code:
N = int(input())
S = [s for s in input()]
ans = 0
for i in range(1000):
    v = str(i).zfill(3)
    idx = 0
    for j, s in enumerate(S):
        if v[idx] == s:
            idx += 1
            if v[idx] not in S[j+1:]:
                break
        if idx == 3:
            ans += 1
            break
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  a = [i//100,(i//10)%10,i%10]
  f=0
  for j in range(n):
    if((s[j])==a[f]): f+=1
    if(f==3): break
 　if(f==3): cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  c = [i/100,(i/10)%10,i%10]
  f=0
  for j in range(n):
    if(s[j]=='0'+c[f]): f++
        if(f==3):break
  if(f==3): cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  c = [i/100,(i/10)%10,i%10]
  f=0
  for j in range(n):
    if(s[j]==c[f]): f++
        if(f==3):break
  if(f==3): cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  c = [i/100,(i/10)%10,i%10]
  f=0
  for j in range(n):
    if(s[j]==c[f]): f++
    if(f==3):break
  if(f==3): cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  c = [i/100,(i/10)%10,i%10]
  f=0
  for j in range(n):
    if(s[j]=='0'+c[f]): f++
    if(f==3):break
  if(f==3): cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  List = [i/100,(i/10)%10,i%10]
  f=0
  for j in range(n):
    if(s[j]=='0'+List[f]):
      f++
    if(f==3):
      break
  if(f==3): cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  List = [i/100,(i/10)%10,i%10]
  f=0
  for j in range(n):
    if(s[j]=='0'+f):
      f++
    if(f==3):
      break
  if(f==3):cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
fun main(args: Array<String>) {
    sumitb2019d()
}

fun sumitb2019d() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val topArray = HashMap<Char, MutableSet<Char>>()
    val candidate = mutableSetOf<String>()
    for (c in s) {
        for (p in topArray) {
            for (e in p.value) {
                candidate.add("${p.key}$e$c")
            }
            p.value.add(c)
        }
        if (c !in topArray) topArray[c] = mutableSetOf()
    }
    println(candidate.size)
}

Submission status: Runtime Error

Solution code:
import ita
import numpy as np
val1=input()
s=input()
n=int(val1)

data=ita.array.make1d(1000)

for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            data[int(s[i]+s[j]+s[k])]+=1
1000-data.count(0)

Submission status: Runtime Error

Solution code:
import ita
import numpy as np
val1=input()
val2=input()
n=int(val1)
s=int(val2)
data=ita.array.make1d(1000)
ss=str(s)
for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            data[int(ss[i]+ss[j]+ss[k])]+=1
1000-data.count(0)

Submission status: Runtime Error

Solution code:
import ita
import numpy as np
val1=input()
val2=input()
n=int(val1)
s=int(val2)
data=ita.array.make3d(10,10,10)
ss=str(s)
for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            data[int(ss[i])][int(ss[j])][int(ss[k])]+=1
np.count_nonzero(data)

Submission status: Runtime Error

Solution code:


# 000から９９９まで決め打ちで全探索。計算量はO(1000*N)程度
def solution1():

    # 入力
    n = int(input())
    s = [int(i) for i in input()]
    cnt = 0
    for c in range(1000):
        candidate = [c/100, (c/10)%10, c%10]
        f = 0
        for j in range(n):
            if s[j] == ("0" + candidate[f]):
                f += 1
            if f == 2:
                break
        if f == 2:
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    solution1()

Submission status: Runtime Error

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

for i in range(1000):
    one = str(i//100)
    two = str(i%100//10)
    three = str(i%10)
    
    flg1 = False 
    flg2 = False
    flg3 = False
    
    ptr = 0
    
    for j in range(ptr,n-2):
        if str(s)[j] == one:
            flg1 = True
            ptr = j + 1
            break
    for j in range(ptr,n-1):
        if str(s)[j] == two:
            flg2 = True
            ptr = j + 1
            break
    for j in range(ptr,n):
        if str(s)[j] == three:
            flg3 = True
            ptr = j + 1
            break
    if (flg1 and flg2 and flg3):
        res +=1
        
print(res)