Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (s, t) = [e for e in lines[0].split(" ")]
    (a, b) = [int(e) for e in lines[1].split(" ")]
    u = lines[2]

    return (s, t, a, b, u)


def solve(s, t, a, b, u):
    
    a2 = a
    b2 = b
    if s == u:
        a2 = a2 - 1
    elif t == u:
        b2 = b2 - 1
    
    result = ' '.join([a2, b2])

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Fixed submission:
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (s, t) = [e for e in lines[0].split(" ")]
    (a, b) = [int(e) for e in lines[1].split(" ")]
    u = lines[2]

    return (s, t, a, b, u)


def solve(s, t, a, b, u):
    
    a2 = a
    b2 = b
    if s == u:
        a2 = a2 - 1
    elif t == u:
        b2 = b2 - 1
    
    result = ' '.join([str(a2), str(b2)])

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
Buggy python submission (verdict: Runtime Error):
import unittest
import math

from A04 import solve
from A04 import parse_input

class TestA04Solve(unittest.TestCase):


    def test_solve(self):

        lines_as_string = """
3
2 1 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 1)


        lines_as_string = """
3
2 2 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), -1)

        lines_as_string = """
10
3 1 4 1 5 9 2 6 5 3
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 7)

        lines_as_string = """
1
1
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 0)


if __name__ == '__main__':
    unittest.main()
                                         

Fixed submission:
# -*- coding: utf-8 -*-

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
#        for line in sys.stdin:
#            lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = [int(e) for e in lines[0].split(" ")][0]
    a = [int(e) for e in lines[1].split(" ")]

    return (n, a)

def solve(n, a):

    current_num = 1
    count = 0
    result = []
    for i in range(n):
        if a[i] != current_num:
            count = count + 1
        else:
            current_num = current_num + 1
            result.append(a[i])
    
    if debug:
        log("result=%s" % result)
        log("count=%s" % count)
    
    if result == []:
        count = -1

    for i in range(1, len(result) + 1):
        if result[i-1] != i:
            if debug:
                log("result[%d]=%s" % (i, result[i-1]))
            count = -1
            break


    return count

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    r = int(lines[0])

    return r


def solve(r):

    return r*r

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Fixed submission:
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    r = int(lines[0])

    return (r, )


def solve(r):

    return r*r

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
Buggy python submission (verdict: Runtime Error):
import unittest

from A01 import solve
from A01 import parse_input


class TestA01Solve(unittest.TestCase):

    def test_solve(self):

        lines_as_string = """
4
"""
        r = parse_input(lines_as_string)
        print(r)
        print("")
        self.assertEqual(solve(*r), 1)

        lines_as_string = """
999999
"""
        r = parse_input(lines_as_string)
        print(r)
        print("")
        self.assertEqual(solve(*r), 499999)


if __name__ == '__main__':
    unittest.main()

Fixed submission:
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])

    return (n, )

def solve(n):

    if n <= 2:
        return 0
    
    k = (n - 1 ) // 2  
    

    return int(k)
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
Buggy python submission (verdict: Runtime Error):
import unittest

from A02 import solve
from A02 import parse_input

class TestA02Solve(unittest.TestCase):


    def test_solve(self):
        lines_as_string = """
3
3 1 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 11)

        lines_as_string = """
7
5 0 7 8 3 3 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 312)

if __name__ == '__main__':
    unittest.main()
                                         

Fixed submission:
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = [int(e) for e in lines[0].split(" ")][0]
    d = [int(e) for e in lines[1].split(" ")]

    return (n, d)


def solve(n, d):

    s = 0
    for i in range(n-1):
        for j in range(i+1, n):
            s = s + d[i]*d[j]

    return s


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]    


    token = lines[0].split(" ")
    n = int(token[0])
    
    a = [int(e) for e in lines[1].split(" ")]
    
    return (n, a)


def solve(n, a):


    current_max = -1
    result = "Yes"
    reduced_all = set()
    for i in range(n):

        if a[i] >= current_max:
            current_max = a[i]
        else:
            reduced_tmp = set()
            for j in range(i):
                if a[j] == current_max:
                    if j in reduced_all:
                        result = "No"
                        break
                    else:
                        reduced_tmp.add(j)

            if result == "No":
                break

            current_max = current_max - 1
            for j in reduced_tmp:
                reduced_all.add(j)
                a[j] = a[j] - 1
                if a[j] > a[i]:
                    result = "No"
                    break            

            if result == "No":
                break

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))


if __name__ == '__main__':

    main()


Fixed submission:
# -*- coding: utf-8 -*-

import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]    


    token = lines[0].split(" ")
    n = int(token[0])
    
    a = [int(e) for e in lines[1].split(" ")]
    
    return (n, a)


def solve(n, a):


    current_max = -1
    result = "Yes"
    reduced_all = set()
    last_j = 0
    for i in range(n):

        if a[i] >= current_max:
            current_max = a[i]
        else:
            reduced_tmp = set()
            for j in range(last_j, i):
                if a[j] == current_max:
                    if j in reduced_all:
                        result = "No"
                        break
                    else:
                        reduced_tmp.add(j)

            if result == "No":
                break

            current_max = current_max - 1
            for j in reduced_tmp:
                reduced_all.add(j)
                a[j] = a[j] - 1
                if a[j] > a[i]:
                    result = "No"
                    break
                else:
                    last_j = max(j, last_j)


            if result == "No":
                break

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))


if __name__ == '__main__':

    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def parse_input(lines_as_string = None):

    if lines_as_string is None:
        lines = [e for e in input()]
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    params = lines[0].split(" ")
    a = int(params[0])
    b = int(params[1])

    return (a, b)


def solve(a, b):

    result = 0
    if b % a == 0:
        result = a + b
    else:
        result = b - a

    return result

def main():
    # 出力

    a, b = parse_input()
    print("%d" % solve(a, b))

if __name__ == '__main__':

    main()


Fixed submission:
# -*- coding: utf-8 -*-

def solve(l1):

    l = [int(e) for e in l1.split(" ")]
    a = l[0]
    b = l[1]

    result = 0
    if b % a == 0:
        result = a + b
    else:
        result = b - a


    return str(result)

def main():
    # 出力
    params = []
    for i in range(0, 1):
        params.append(input())   
    print(solve(*params))

if __name__ == '__main__':

    main()

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def parse_input():
    line = [int(e) for e in input().split(" ")]
    a = line[0]
    b = line[1]

    returnr (a, b)


def solve(a, b):

    result = 0
    if b % a == 0:
        result = a + b
    else:
        result = b - a

    return str(result)

def main():
    # 出力

    a, b = parse_input()
    print(solve(a, b))

if __name__ == '__main__':

    main()


Fixed submission:
# -*- coding: utf-8 -*-

def solve(l1):

    l = [int(e) for e in l1.split(" ")]
    a = l[0]
    b = l[1]

    result = 0
    if b % a == 0:
        result = a + b
    else:
        result = b - a


    return str(result)

def main():
    # 出力
    params = []
    for i in range(0, 1):
        params.append(input())   
    print(solve(*params))

if __name__ == '__main__':

    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
import math

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    # 出力
    nm = lines[0].split(" ")
    n = int(nm[0])

    rows = []
    for i in range(1, 2):
        rows.append([int(e) for e in lines[i].split(" ")])

    return (n, rows[0])

def solve(n, monsters):

    g = monsters[0]
    for i in range(1, n):
        g = math.gcd(g, monsters[i])


    return g

def main():

    n, m, rows = parse_input()
    print("%d" % solve(n, m, rows))

if __name__ == '__main__':

    main()


Fixed submission:
# -*- coding: utf-8 -*-

import sys

def gcd(a, b):

    c = min(a, b)
    d = max(a, b)
    r = 0    
    while True:
        r = d % c
        if r == 0:
            break
        d = c
        c = r

    return c

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    # 出力
    nm = lines[0].split(" ")
    n = int(nm[0])

    rows = []
    for i in range(1, 2):
        rows.append([int(e) for e in lines[i].split(" ")])

    return (n, rows[0])

def solve(n, monsters):

    g = monsters[0]
    for i in range(1, n):
        g = gcd(g, monsters[i])


    return g

def main():

    print("%d" % solve(*parse_input()))

if __name__ == '__main__':

    main()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = [int(i) for i in input().rstrip().split()]
A = np.array(A)
sum = 0

for i in range(N):
  for j in range(N-1-i):
    sum += A[i]*A[j+1+i]


ans = sum % (10**9+7)
print(ans) 

Fixed submission:
from itertools import accumulate
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
Ac = list(accumulate(A))

ans = 0
for i in range(N):
  ans += A[i]*(Ac[-1]-Ac[i])
  ans = ans%MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().rstrip().split()]

sum = 0

for i in range(N):
  for j in range(N-1-i):
    sum += A[i]*A[j+1+i]


ans = sum % (10**9+7)
print(ans) 

Fixed submission:
from itertools import accumulate
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
Ac = list(accumulate(A))

ans = 0
for i in range(N):
  ans += A[i]*(Ac[-1]-Ac[i])
  ans = ans%MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from math import gcd
from functools import reduce

PC = True
SC = True

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)


for i in range(N):
  for j in range(N-1, i, -1):
    if A[i] < np.sqrt(A[j]):
      break
    if gcd(A[i],A[j]) != 1:
      PC = False
      break
        
p = reduce(gcd, A)
if p != 1:
  SC = False
      
if PC == True:
  print('pairwise coprime')
else:
  if SC == True:
    print('setwise coprime')
  else:
    print('not coprime')

Fixed submission:
from math import gcd
from functools import reduce
import numpy as np

PC = True

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)

MAX = A[0]+1
mp = [0]*MAX

for i in A:
  mp[i] += 1

for i in range(2,MAX):
  if sum(mp[i::i])>1:
    PC = False
    break

if PC:
  print('pairwise coprime')
else:
  if reduce(gcd, A) == 1:
    print('setwise coprime')
  else:
    print('not coprime')
Buggy python submission (verdict: Runtime Error):
line = [int(i) for i in input().rstrip().split()]
N = line[0]
X = line[1]
T = line[2]

print((N//X+1)*T)line = [int(i) for i in input().rstrip().split()]
N = line[0]
X = line[1]
T = line[2]

if N%X == 0:
	print((N//X)*T)
else:
    print((N//X+1)*T)
    

Fixed submission:
line = [int(i) for i in input().rstrip().split()]
N = line[0]
X = line[1]
T = line[2]
 
if N%X == 0:
	print((N//X)*T)
else:
    print((N//X+1)*T)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for _ in range(Q):
  B, C = map(int, input().split())
  count = A.count(B)
  if count >0:
    for _ in range(count):
      A.remove(B)
    A.extend([C]*count)
  print(sum(A))
  #print(A)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
cnt = [0]*(10**5+1)

s = sum(A)
for i in A:
  cnt[i] += 1

for _ in range(Q):
  B, C = map(int, input().split())
  s += (C-B)*cnt[B]
  print(s)
  cnt[C] += cnt[B]
  cnt[B] = 0

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for _ in range(Q):
  B, C = map(int, input().split())
  for i in range(N):
    if A[i] == B:
      A[i] = C
  print(sum(A))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
cnt = [0]*(10**5+1)

s = sum(A)
for i in A:
  cnt[i] += 1

for _ in range(Q):
  B, C = map(int, input().split())
  s += (C-B)*cnt[B]
  print(s)
  cnt[C] += cnt[B]
  cnt[B] = 0
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
cnt = [0]*(10**6+1)

for i in A:
  cnt[i] += 1
  
for i in range(N):
  for j in range(N):
    if i != j:
      if A[j] % A[i] == 0 and cnt[A[j]] != 0:
        cnt[A[j]] -= 1

print(sum(cnt))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
MAX = 10**6+1
cnt = [0]*MAX

for x in A:
  if cnt[x] != 0:
  	cnt[x] = 2
  else:
    for i in range(x, MAX, x):
      cnt[i] += 1
  
ans = 0
for x in A:
  # 2回以上通った数字 (cnt[x]>1) は，その数字より小さい約数が存在する (割り切れる他の数が存在する)。
  if cnt[x] == 1:  
    ans += 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
for i in range(N-1):
  ans *= A[i+1]
if ans > 10**18:
  print('-1')
else:
  print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
if A.count(0)>0:
  print(0)
else:
  ans = A[0]
  for i in range(N-1):
    ans *= A[i+1]
    if ans > 10**18:
      print('-1')
      exit()
  print(ans)
Buggy python submission (verdict: Runtime Error):
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f**2 <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

count = 0

N = int(input())
c = collections.Counter(prime_factorize(N))

K = [sum(range(1,i)) for i in range(2,10)]
#print(K)
 
for i in c:
  for j in range(len(K)):
    if c[i] < K[j]:
      count += j
      break
      
print(count)

Fixed submission:
line = input().split()
a = int(line[0])
b = round(float(line[1])*100)

print(a*b//100)

Buggy python submission (verdict: Runtime Error):
1000000000000000 9.99

Fixed submission:
line = input().split()
a = int(line[0])
b = round(float(line[1])*100)

print(a*b//100)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int,input(),split()))
a = sum(A)

if N >= a:
  print(int(N-a))
if N < a:
  print(-1)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int,input().split()))
a = sum(A)
 
if N >= a:
  print(int(N-a))
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

A = [0]*1000 
ans = 0

for i in range(1000):
  if i < 10:
    s = '00' + str(i)
  elif i < 100:
    s = '0' + str(i)
  else:
    s = str(i)
    
  for j in range(N):
    if S[j] == s[0]:
      for k in range(j+1,N):
        if S[k] == s[1]:
          for l in range(k+1,N):
            if S[l] == s[2]:
              A[i] = 1
              break
          break
      break

print(A.count(1))

Fixed submission:
N = int(input())
S = input()

A = [0]*1000 
ans = 0

for i in range(1000):
  if i < 10:
    s = '00' + str(i)
  elif i < 100:
    s = '0' + str(i)
  else:
    s = str(i)
    
  for j in range(N):
    if S[j] == s[0]:
      for k in range(j+1,N):
        if S[k] == s[1]:
          for l in range(k+1,N):
            if S[l] == s[2]:
              A[i] = 1
              break
          break
      break

print(A.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

A = [0]*1000 
ans = 0

for i in range(1000):
  if i < 10:
    s = '00' + str(i)
  elif i < 100:
    s = '0' + str(i)
  else:
    s = str(i)
    
  for j in range(N):
    if S[j] == s[0]:
      for k in range(j+1,N):
        if S[k] == s[1]:
          for l in range(k+1,N):
            if S[l] == s[2]:
              A[i] = 1
              break
        elif A[i] == 1:
          break
    elif A[i] == 1:
      break

print(A.count(1))

Fixed submission:
N = int(input())
S = input()

A = [0]*1000 
ans = 0

for i in range(1000):
  if i < 10:
    s = '00' + str(i)
  elif i < 100:
    s = '0' + str(i)
  else:
    s = str(i)
    
  for j in range(N):
    if S[j] == s[0]:
      for k in range(j+1,N):
        if S[k] == s[1]:
          for l in range(k+1,N):
            if S[l] == s[2]:
              A[i] = 1
              break
          break
      break

print(A.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

A = [0]*1000 
ans = 0

for i in range(1000):
  if i < 10:
    s = '00' + str(i)
  elif i < 100:
    s = '0' + str(i)
  else:
    s = str(i)
    
  for j in range(N):
    if S[j] == s[0]:
      for k in range(j+1,N):
        if S[k] == s[1]:
          for l in range(k+1,N):
            if S[l] == s[2]:
              A[i] = 1
              break
print(A.count(1))

Fixed submission:
N = int(input())
S = input()

A = [0]*1000 
ans = 0

for i in range(1000):
  if i < 10:
    s = '00' + str(i)
  elif i < 100:
    s = '0' + str(i)
  else:
    s = str(i)
    
  for j in range(N):
    if S[j] == s[0]:
      for k in range(j+1,N):
        if S[k] == s[1]:
          for l in range(k+1,N):
            if S[l] == s[2]:
              A[i] = 1
              break
          break
      break

print(A.count(1))