ZhenlongDai/ACPR huggingface dataset:
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()

c = 0
for i in range(10):
        for j in range(10):
            for k in range(10):
                count = 0
                for l in s:
                    if count == 3:
                        c += 1
                        break
                    if l == str(k) and count == 2:
                        count += 1
                    if l == str(j) and count == 1:
                        count += 1
                    if l == str(i) and count == 0:
                        count += 1

print(c)


Failing test case input:
19
5064181902262262894

Expected output:
261


Actual output:
216


Fixed submission (verdict: Accepted):
n = int(input())
s = list(map(int,input()))

def nc(n,s,i,j,k):
    c1 = -1
    for l in range(n):
        if s[l] == i:
            c1 = l
            break
    if c1 == -1:
        return 0
    c2 = -1
    for l in range(c1+1,n):
        if s[l] == j:
            c2 = l
            break
    if c2 == -1:
        return 0
    c3 = -1
    for l in range(c2+1,n):
        if s[l] == k:
            c3 = l
            break
    if c3 == -1:
        return 0
    return 1

c = 0
for i in range(10):
        for j in range(10):
            for k in range(10):
                c += nc(n,s,i,j,k)



print(c)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input()) 
s = str(input()) 
cnt = 0 
 
for a in range(9): 
  for b in range(9): 
    for c in range(9): 
      for i in range(n-3):
        if str(a) == s[i]:
          tmp_i = i + 1
          for j in range(tmp_i,n-2):
            if str(b) == s[j]:
              tmp_i = j + 1
              for k in range(tmp_i,n-1):
                if str(c) == s[k]:
                  cnt = cnt + 1
print(cnt)

Failing test case input:
19
2428657595278740475

Expected output:
283


Actual output:
680


Fixed submission (verdict: Accepted):
n = int(input()) 
s = str(input()) 
cnt = 0 

for a in range(10): 
  for b in range(10): 
    for c in range(10): 
      flg = False
      check_a = s.find(str(a))
      if check_a != -1:
        tmp_s = s[check_a + 1:]
        check_b = tmp_s.find(str(b))
        if check_b != -1:
          tmp_t = tmp_s[check_b + 1:]
          check_c = tmp_t.find(str(c))
          if check_c != -1:
            cnt = cnt + 1            
print(cnt)

Problem: p02844
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
ans = 0
for i in range(10):
  a = s.find(str(i))
  for j in range(10):
    b = s.find(str(j), a+1)
    for k in range(10):
      c = s.find(str(k), b+1)
    if a == -1 or b == -1 or c == -1:
      continue
    else:
      ans += 1
print(ans)

Failing test case input:
19
3472014646073257965

Expected output:
380


Actual output:
55


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
ans=0
for i in range(10):
  idx1=s.find(str(i))
  for j in range(10):
    idx2=s.find(str(j),idx1+1,n)
    for k in range(10):
      idx3=s.find(str(k),idx2+1,n)
      if idx1==-1 or idx2==-1 or idx3==-1:
        continue
      else:
        ans+=1
print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
S = input()

result = 0
for i in range(10):
  if str(i) in S:
    T = S[S.index(str(i)):]

    for j in range(10):
      if str(j) in T:
        U = T[T.index(str(j)):]

        for k in range(10):
          if str(k) in U:
            result += 1

print(result)



Failing test case input:
19
3616863455241776042

Expected output:
322


Actual output:
375


Fixed submission (verdict: Accepted):
n = int(input())
S = input()

result = 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:
            result += 1

print(result)

Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

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

count = 0

ls_si = []
for i in range(n-2):
    print("i={}".format(i))
    if s[i] in ls_si:
        pass
    else:
        ls_si.append(s[i])
        ls_sj = []
        for j in range(i+1,n-1):
            if s[j] in ls_sj:
                pass
            else:
                ls_sj.append(s[j])
                
                
                
                
                
                
                count += len(set(list(s[j+1:-1])))



print(count)

Failing test case input:
19
7444371886993568623

Expected output:
256


Actual output:
i=0
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10
i=11
i=12
i=13
i=14
i=15
i=16
256


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

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

count = 0

ls_si = []
for i in range(n-2):
    
    if s[i] in ls_si:
        pass
    else:
        ls_si.append(s[i])
        ls_sj = []
        for j in range(i+1,n-1):
            if s[j] in ls_sj:
                pass
            else:
                ls_sj.append(s[j])
                
                
                
                
                
                
                count += len(set(list(s[j+1:-1])))



print(count)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



N = int(input())
S = input()
count = 0
for i in range(0, 999):
    j = 0
    a = str(i).zfill(3)
    for k in range(0, len(S)):
        if (a[j] == S[k]):
            j += 1
        if (j == 3):
            count += 1
            break
            
print(count)

Failing test case input:
19
6045650728996405239

Expected output:
392


Actual output:
391


Fixed submission (verdict: Accepted):



N = int(input())
S = input()
count = 0
for i in range(0, 1000):
    j = 0
    a = str(i).zfill(3)
    b = S.find(a[0])
    if b == -1:
        continue
    c = S[b+1:].find(a[1])
    if c == -1:
        continue
    d= S[b+c+2:].find(a[2])
    if d != -1:
        count += 1
    
            
print(count)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
L = list(S)
first = [L.index(str(i)) if str(i) in S else None for i in range(10)]
con = 0

for i in range(10):
  if str(i) in first:
    p = first[i]
    for j in range(10):
      if str(j) in S[p + 1]:
        q = S[p + 1].index(j)
        for k in range(10):
          if str(k) in S[q + 1]:
            con += 1

print(con)


Failing test case input:
19
6497226819164496691

Expected output:
193


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
con = 0

for i in range(10):
  if str(i) in S:
    p = S.index(str(i))
    S2 = S[p + 1:]
    for j in range(10):
      if str(j) in S2:
        q = S2.index(str(j))
        S3 = S2[q + 1:]
        for k in range(10):
          if str(k) in S3:
            con += 1

print(con)

Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()

ans = 0
for i in range(1, 1000):
    num = str(i).zfill(3)
    flag2 = True
    start = 0
    for j in range(3):
        flag = False
        for k in range(start, N):
            if(num[j] == S[k]):
                flag = True
                start = k+1
                break
        if flag == False:
            flag2 = False
            break
    if flag2:
        ans += 1

print(ans)

Failing test case input:
19
6202201021086487753

Expected output:
207


Actual output:
206


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

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    flag2 = True
    start = 0
    for j in range(3):
        flag = False
        for k in range(start, N):
            if(num[j] == S[k]):
                flag = True
                start = k+1
                break
        if flag == False:
            flag2 = False
            break
    if flag2:
        ans += 1

print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1001):
        pw = str(i).zfill(3)
        pw_ind = 0
        for s in S:
            if s == pw[pw_ind]:
                pw_ind += 1
                if pw_ind == 3:
                    break
        if pw_ind == 3:
            ans += 1

    return print(ans)

if __name__ == "__main__":
    resolve()

Failing test case input:
19
1036710694297327965

Expected output:
364


Actual output:
365


Fixed submission (verdict: Accepted):
def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1000):
        pw = str(i).zfill(3)
        pw_ind = 0
        for s in S:
            if s == pw[pw_ind]:
                pw_ind += 1
                if pw_ind == 3:
                    break
        if pw_ind == 3:
            ans += 1

    return print(ans)

if __name__ == "__main__":
    resolve()

Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(0,100)]
cnt =0
for k in kouho:
    ok = True
    S_temp = S
    for l in k:
        if l in S_temp:
            basho = S_temp.index(l)
            S_temp = S_temp[basho+1:]
        else:
            ok = False
            break
    if ok == True:
        cnt += 1
print(cnt)

Failing test case input:
6
123123

Expected output:
17

Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(0,1000)]
cnt =0
for k in kouho:
    ok = True
    S_temp = S
    for l in k:
        if l in S_temp:
            basho = S_temp.index(l)
            S_temp = S_temp[basho+1:]
        else:
            ok = False
            break
    if ok == True:
        cnt += 1
print(cnt)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def ok(target, S):
    pos = 0
    for t in target:
        if t in S[pos:]:
            pos = S[pos:].index(t)
        else:
            return False
    return True


N = int(input())
S = input()
ans = 0

for i in range(0, 999+1):
    target = str(i).zfill(3)
    ans += ok(target, S)

print(ans)


Failing test case input:
19
5064181902262262894

Expected output:
261


Actual output:
367


Fixed submission (verdict: Accepted):
def ok(target, S):
    for t in target:
        if t in S:
            S = S[S.index(t)+1:]
        else:
            return False
    return True


N = int(input())
S = input()
ans = 0

for i in range(0, 999+1):
    target = str(i).zfill(3)
    ans += ok(target, S)

print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def ok(target, S):
    for t in target:
        if t in S:
            S = S[S.index(t)+1:]
        else:
            return False
    print(target)
    return True


N = int(input())
S = input()
ans = 0

for i in range(0, 999+1):
    target = str(i).zfill(3)
    ans += ok(target, S)

print(ans)


Failing test case input:
19
3307844521537959020

Expected output:
351


Actual output:
000
002
010
012
013
015
017
019
020
021
022
023
025
027
029
030
032
035
037
039
040
041
042
043
044
045
047
049
050
051
052
053
055
057
059
070
071
072
073
074
075
077
078
079
080
081
082
083
084
085
087
089
090
092
095
099
100
102
120
130
132
135
137
139
150
152
153
155
157
159
170
172
175
179
190
192
195
199
200
202
210
212
213
215
217
219
220
230
232
235
237
239
250
252
253
255
257
259
270
272
275
279
290
292
295
299
300
301
302
303
304
305
307
308
309
310
312
313
315
317
319
320
321
322
323
325
327
329
330
331
332
333
334
335
337
338
339
340
341
342
343
344
345
347
349
350
351
352
353
355
357
359
370
371
372
373
374
375
377
378
379
380
381
382
383
384
385
387
389
390
392
395
399
400
402
410
412
413
415
417
419
420
421
422
423
425
427
429
430
432
435
437
439
440
441
442
443
445
447
449
450
451
452
453
455
457
459
470
472
475
479
490
492
495
499
500
502
510
512
513
515
517
519
520
521
522
523
525
527
529
530
532
535
537
539
550
552
553
555
557
559
570
572
575
579
590
592
595
599
700
702
710
712
713
715
717
719
720
721
722
723
725
727
729
730
732
735
737
739
740
741
742
743
744
745
747
749
750
751
752
753
755
757
759
770
772
775
779
780
781
782
783
784
785
787
789
790
792
795
799
800
802
810
812
813
815
817
819
820
821
822
823
825
827
829
830
832
835
837
839
840
841
842
843
844
845
847
849
850
851
852
853
855
857
859
870
872
875
879
890
892
895
899
900
902
920
950
952
959
990
992
351


Fixed submission (verdict: Accepted):
def ok(target, S):
    for t in target:
        if t in S:
            S = S[S.index(t)+1:]
        else:
            return False
    return True


N = int(input())
S = input()
ans = 0

for i in range(0, 999+1):
    target = str(i).zfill(3)
    ans += ok(target, S)

print(ans)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
  f1=fi(s,i)
  if f1==-1:
    continue
  s1=s[f1+1:]
  for j in range(10):
    f2=fi(s1,j)
    if f2==-1:
      continue
    s2=s1[f2+1:]
    for k in range(10):
      f3=fi(s1,k)
      if f3>0:
        ans+=1
print(ans)

Failing test case input:
19
6497226819164496691

Expected output:
193


Actual output:
210


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
  f1=fi(s,i)
  if f1==-1:
    continue
  s1=s[f1+1:]
  for j in range(10):
    f2=fi(s1,j)
    if f2==-1:
      continue
    s2=s1[f2+1:]
    for k in range(10):
      f3=fi(s2,k)
      if f3>=0:
        ans+=1
print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=int(input())

l_S=list(str(S))

count=0
for i in range(0,1000):
    i_1=int(i/100)
    i_2=int(i/10)-i_1*10
    i_3=i%10
    if str(i_1) in l_S[:-2]:
        idx_1=l_S[:-2].index(str(i_1))
        if str(i_2) in l_S[idx_1+1:-1]:
            idx_2=l_S[idx_1+1:-1].index(str(i_2))+idx_1+1
            if str(i_3) in l_S[idx_2+1:]:
                count+=1
print(count)

Failing test case input:
4
0224

Expected output:
3

Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
S=str(input())

l_S=list(S)

count=0
for i in range(0,1000):
    i_1=int(i/100)
    i_2=int(i/10)-i_1*10
    i_3=i%10
    if str(i_1) in l_S[:-2]:
        idx_1=l_S[:-2].index(str(i_1))
        if str(i_2) in l_S[idx_1+1:-1]:
            idx_2=l_S[idx_1+1:-1].index(str(i_2))+idx_1+1
            if str(i_3) in l_S[idx_2+1:]:
                count+=1
print(count)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
code = input()
f = 0
total = 0
for i in range(100,1000):
  s = str(i)
  idx = -1
  for dig in range(3):
    idx = code.find(s[dig], idx+1) 
    if idx == -1:
      break
  if idx != -1:
    total += 1
print(total)
        
      
  

Failing test case input:
19
3452770094764755131

Expected output:
307


Actual output:
271


Fixed submission (verdict: Accepted):
n = int(input())
code = input()
f = 0
total = 0
for i in range(0,1000):
  s = str(i)
  if i< 10:
    s = '00' + s
  elif i < 100:
    s = '0' + s
  idx = -1
  for dig in range(3):
    idx = code.find(s[dig], idx+1) 
    if idx == -1:
      break
  if idx != -1:
    total += 1
print(total)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=list(input())
L=[str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
n=0
I=N
J=N
for l in L:
  for i in range(N):
    if S[i]==l[0]:
      I=i
      break
    else:
      I=N
  for j in range(I+1,N):
    if S[j]==l[1]:
      J=j
      break
    else:
      J=N
  for k in range(J+1,N):
    if S[k]==l[2]:
      n+=1
      break
print(n)

Failing test case input:
19
3690627262944922638

Expected output:
230


Actual output:
390


Fixed submission (verdict: Accepted):
N=int(input())
S=list(input())
L=[str(i)+str(j) for i in range(10) for j in range(10)]
n=0
for l in L:
  I=N
  for i in range(N):
    if S[i]==l[0]:
      I=i
      break
  J=N
  for j in range(I+1,N):
    if S[j]==l[1]:
      J=j
      break
  n+=len(list(set(S[J+1:N])))
print(n)
Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()

ans = 0

for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j),a+1)
        for k in range(10):
            if b == -1:
                continue
            c = S.find(str(k),b+1)
            if c > b :
                ans +=1
                print(i,j,k)
print(ans)

Failing test case input:
19
4000293803763350759

Expected output:
274


Actual output:
0 0 0
0 0 2
0 0 3
0 0 5
0 0 6
0 0 7
0 0 8
0 0 9
0 2 0
0 2 3
0 2 5
0 2 6
0 2 7
0 2 8
0 2 9
0 3 0
0 3 3
0 3 5
0 3 6
0 3 7
0 3 8
0 3 9
0 5 0
0 5 5
0 5 7
0 5 9
0 6 0
0 6 3
0 6 5
0 6 7
0 6 9
0 7 0
0 7 3
0 7 5
0 7 6
0 7 7
0 7 9
0 8 0
0 8 3
0 8 5
0 8 6
0 8 7
0 8 9
0 9 0
0 9 3
0 9 5
0 9 6
0 9 7
0 9 8
0 9 9
2 0 0
2 0 3
2 0 5
2 0 6
2 0 7
2 0 9
2 3 0
2 3 3
2 3 5
2 3 6
2 3 7
2 3 8
2 3 9
2 5 0
2 5 5
2 5 7
2 5 9
2 6 0
2 6 3
2 6 5
2 6 7
2 6 9
2 7 0
2 7 3
2 7 5
2 7 6
2 7 7
2 7 9
2 8 0
2 8 3
2 8 5
2 8 6
2 8 7
2 8 9
2 9 0
2 9 3
2 9 5
2 9 6
2 9 7
2 9 8
2 9 9
3 0 0
3 0 3
3 0 5
3 0 6
3 0 7
3 0 9
3 3 0
3 3 3
3 3 5
3 3 6
3 3 7
3 3 9
3 5 0
3 5 5
3 5 7
3 5 9
3 6 0
3 6 3
3 6 5
3 6 7
3 6 9
3 7 0
3 7 3
3 7 5
3 7 6
3 7 7
3 7 9
3 8 0
3 8 3
3 8 5
3 8 6
3 8 7
3 8 9
4 0 0
4 0 2
4 0 3
4 0 5
4 0 6
4 0 7
4 0 8
4 0 9
4 2 0
4 2 3
4 2 5
4 2 6
4 2 7
4 2 8
4 2 9
4 3 0
4 3 3
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 5 0
4 5 5
4 5 7
4 5 9
4 6 0
4 6 3
4 6 5
4 6 7
4 6 9
4 7 0
4 7 3
4 7 5
4 7 6
4 7 7
4 7 9
4 8 0
4 8 3
4 8 5
4 8 6
4 8 7
4 8 9
4 9 0
4 9 3
4 9 5
4 9 6
4 9 7
4 9 8
4 9 9
5 0 5
5 0 7
5 0 9
5 5 9
5 7 5
5 7 9
6 0 5
6 0 7
6 0 9
6 3 0
6 3 3
6 3 5
6 3 7
6 3 9
6 5 0
6 5 5
6 5 7
6 5 9
6 7 5
6 7 9
7 0 5
7 0 7
7 0 9
7 3 0
7 3 3
7 3 5
7 3 7
7 3 9
7 5 0
7 5 5
7 5 7
7 5 9
7 6 0
7 6 3
7 6 5
7 6 7
7 6 9
7 7 5
7 7 9
8 0 0
8 0 3
8 0 5
8 0 6
8 0 7
8 0 9
8 3 0
8 3 3
8 3 5
8 3 6
8 3 7
8 3 9
8 5 0
8 5 5
8 5 7
8 5 9
8 6 0
8 6 3
8 6 5
8 6 7
8 6 9
8 7 0
8 7 3
8 7 5
8 7 6
8 7 7
8 7 9
9 0 0
9 0 3
9 0 5
9 0 6
9 0 7
9 0 9
9 3 0
9 3 3
9 3 5
9 3 6
9 3 7
9 3 8
9 3 9
9 5 0
9 5 5
9 5 7
9 5 9
9 6 0
9 6 3
9 6 5
9 6 7
9 6 9
9 7 0
9 7 3
9 7 5
9 7 6
9 7 7
9 7 9
9 8 0
9 8 3
9 8 5
9 8 6
9 8 7
9 8 9
274


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

ans = 0

for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j),a+1)
        for k in range(10):
            if b == -1:
                continue
            c = S.find(str(k),b+1)
            if c > b :
                ans +=1
print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def f():
    n = int(input())
    s = input()
    leftMemo = [None]*10
    rightMemo = [None]*10
    for i in range(10):
        char = str(i)
        for j in range(n):
            if s[j] == char:
                leftMemo[i] = j
                break
        for k in range(n-1,-1,-1):
            if s[k] == char:
                rightMemo[i] = k
                break
    ans = 0
    for leftNum in range(10):
        if leftMemo[leftNum] is None:
            continue
        start = leftMemo[leftNum]+1
        for rightNum in range(10):
            if rightMemo[rightNum] is None:
                continue
            end = rightMemo[rightNum]
            ans += len(set(s[start:end]))
    print(ans)

Failing test case input:
19
9352460586099976652

Expected output:
327


Actual output:

Fixed submission (verdict: Accepted):
def f():
    n = int(input())
    s = input()
    leftMemo = [None]*10
    rightMemo = [None]*10
    for i in range(10):
        char = str(i)
        for j in range(n):
            if s[j] == char:
                leftMemo[i] = j
                break
        for k in range(n-1,-1,-1):
            if s[k] == char:
                rightMemo[i] = k
                break
    ans = 0
    for leftNum in range(10):
        if leftMemo[leftNum] is None:
            continue
        start = leftMemo[leftNum]+1
        for rightNum in range(10):
            if rightMemo[rightNum] is None:
                continue
            end = rightMemo[rightNum]
            ans += len(set(s[start:end]))
    print(ans)


f()
Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = list(map(int, input()))
print(s)
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            preindex = 0
            flag1 = 0
            flag2 = 0
            flag3 = 0 
            while preindex < n:
                if s[preindex] == i:
                    preindex += 1
                    flag1 = 1
                    break
                preindex += 1

            while preindex < n:
                if s[preindex] == j:
                    preindex += 1
                    flag2 = 1
                    break
                preindex += 1

            while preindex < n:
                if s[preindex] == k:
                    flag3 = 1
                    break
                preindex += 1
            if flag1 and flag2 and flag3:
                ans += 1
print(ans)
             



Failing test case input:
19
1718854681289667852

Expected output:
300


Actual output:
[1, 7, 1, 8, 8, 5, 4, 6, 8, 1, 2, 8, 9, 6, 6, 7, 8, 5, 2]
300


Fixed submission (verdict: Accepted):
n = int(input())
s = list(map(int, input()))
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            preindex = 0
            flag1 = 0
            flag2 = 0
            flag3 = 0 
            while preindex < n:
                if s[preindex] == i:
                    preindex += 1
                    flag1 = 1
                    break
                preindex += 1

            while preindex < n:
                if s[preindex] == j:
                    preindex += 1
                    flag2 = 1
                    break
                preindex += 1

            while preindex < n:
                if s[preindex] == k:
                    flag3 = 1
                    break
                preindex += 1
            if flag1 and flag2 and flag3:
                ans += 1
print(ans)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            fi = S.find(str(i))
            fj = S.find(str(j))
            fk = S.find(str(k))
            if fi >= 0 and fj >= 0 and fk >= 0 and fi < fj and fj < fk:
                ans += 1

print(ans)


Failing test case input:
19
4424307180593597450

Expected output:
360


Actual output:
84


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

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            fi = S.find(str(i))
            if fi < 0:
                continue
            fj = S[fi+1:].find(str(j))
            if fj < 0:
                continue
            fk = S[fi+fj+2:].find(str(k))
            if fk < 0:
                continue
            ans += 1

print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(map(int,input()))

def nc(n,s,i,j,k):
    c1 = -1
    for l in range(n):
        if s[l] == i:
            c1 = l
            break
    if c1 == -1:
        return 0
    c2 = -1
    for l in range(c1+1,n):
        if s[l] == j:
            c2 = l
            break
    if c2 == -1:
        return 0
    c3 = -1
    for l in range(c2+1,n):
        if s[l] == k:
            c3 = l
            break
    if c3 == -1:
        return 0
    print(i,j,k)
    return 1

c = 0
for i in range(10):
        for j in range(10):
            for k in range(10):
                c += nc(n,s,i,j,k)



print(c)


Failing test case input:
19
1881640749761814188

Expected output:
220


Actual output:
0 1 1
0 1 4
0 1 8
0 4 1
0 4 4
0 4 6
0 4 7
0 4 8
0 4 9
0 6 1
0 6 4
0 6 8
0 7 1
0 7 4
0 7 6
0 7 7
0 7 8
0 7 9
0 8 1
0 8 4
0 8 8
0 9 1
0 9 4
0 9 6
0 9 7
0 9 8
1 0 1
1 0 4
1 0 6
1 0 7
1 0 8
1 0 9
1 1 0
1 1 1
1 1 4
1 1 6
1 1 7
1 1 8
1 1 9
1 4 0
1 4 1
1 4 4
1 4 6
1 4 7
1 4 8
1 4 9
1 6 0
1 6 1
1 6 4
1 6 6
1 6 7
1 6 8
1 6 9
1 7 1
1 7 4
1 7 6
1 7 7
1 7 8
1 7 9
1 8 0
1 8 1
1 8 4
1 8 6
1 8 7
1 8 8
1 8 9
1 9 1
1 9 4
1 9 6
1 9 7
1 9 8
4 0 1
4 0 4
4 0 6
4 0 7
4 0 8
4 0 9
4 1 1
4 1 4
4 1 8
4 4 1
4 4 4
4 4 6
4 4 7
4 4 8
4 4 9
4 6 1
4 6 4
4 6 8
4 7 1
4 7 4
4 7 6
4 7 7
4 7 8
4 7 9
4 8 1
4 8 4
4 8 8
4 9 1
4 9 4
4 9 6
4 9 7
4 9 8
6 0 1
6 0 4
6 0 6
6 0 7
6 0 8
6 0 9
6 1 1
6 1 4
6 1 8
6 4 0
6 4 1
6 4 4
6 4 6
6 4 7
6 4 8
6 4 9
6 6 1
6 6 4
6 6 8
6 7 1
6 7 4
6 7 6
6 7 7
6 7 8
6 7 9
6 8 1
6 8 4
6 8 8
6 9 1
6 9 4
6 9 6
6 9 7
6 9 8
7 1 1
7 1 4
7 1 8
7 4 1
7 4 4
7 4 6
7 4 7
7 4 8
7 4 9
7 6 1
7 6 4
7 6 8
7 7 1
7 7 4
7 7 6
7 7 8
7 8 1
7 8 4
7 8 8
7 9 1
7 9 4
7 9 6
7 9 7
7 9 8
8 0 1
8 0 4
8 0 6
8 0 7
8 0 8
8 0 9
8 1 0
8 1 1
8 1 4
8 1 6
8 1 7
8 1 8
8 1 9
8 4 0
8 4 1
8 4 4
8 4 6
8 4 7
8 4 8
8 4 9
8 6 0
8 6 1
8 6 4
8 6 6
8 6 7
8 6 8
8 6 9
8 7 1
8 7 4
8 7 6
8 7 7
8 7 8
8 7 9
8 8 0
8 8 1
8 8 4
8 8 6
8 8 7
8 8 8
8 8 9
8 9 1
8 9 4
8 9 6
8 9 7
8 9 8
9 1 1
9 1 4
9 1 8
9 4 1
9 4 8
9 6 1
9 6 4
9 6 8
9 7 1
9 7 4
9 7 6
9 7 8
9 8 1
9 8 4
9 8 8
220


Fixed submission (verdict: Accepted):
n = int(input())
s = list(map(int,input()))

def nc(n,s,i,j,k):
    c1 = -1
    for l in range(n):
        if s[l] == i:
            c1 = l
            break
    if c1 == -1:
        return 0
    c2 = -1
    for l in range(c1+1,n):
        if s[l] == j:
            c2 = l
            break
    if c2 == -1:
        return 0
    c3 = -1
    for l in range(c2+1,n):
        if s[l] == k:
            c3 = l
            break
    if c3 == -1:
        return 0
    return 1

c = 0
for i in range(10):
        for j in range(10):
            for k in range(10):
                c += nc(n,s,i,j,k)



print(c)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
length = int(input())
string = input()

possible_pins = list()
for pin in [str(num) for num in range(1, 1000)]:
    if len(pin) == 1:
        pin = "00" + pin
    elif len(pin) == 2:
        pin = "0" + pin
    possible_pins.append(pin)


count = 0
for pin in possible_pins:
    start = 0
    for letter in pin:
        try:
            index = string.index(letter, start)
            start = index + 1
        except ValueError:
            break
    else:
        count += 1
print(count)


Failing test case input:
19
6472474502231700356

Expected output:
279


Actual output:
278


Fixed submission (verdict: Accepted):
length = int(input())
string = input()

possible_pins = list()
for pin in [str(num) for num in range(0, 1000)]:
    if len(pin) == 1:
        pin = "00" + pin
    elif len(pin) == 2:
        pin = "0" + pin
    possible_pins.append(pin)


count = 0
for pin in possible_pins:
    start = 0
    for letter in pin:
        try:
            index = string.index(letter, start)
            start = index + 1
        except ValueError:
            break
    else:
        count += 1
print(count)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


n=int(input())
s=str(input())
ans = 0
for i in range (0,10):
    for j in range (0,10):
        for k in range (0,10):
            check_i = (s.find(str(i)))
            check_j = (s.find(str(j),check_i))
            check_k = (s.rfind(str(k),check_j))
            if(check_i > 0 and check_j > 0 and check_k >0):
                ans += 1
print(ans)

Failing test case input:
19
3263967186908363560

Expected output:
304


Actual output:
303


Fixed submission (verdict: Accepted):


n=int(input())
s=str(input())
ans = 0
for i in range (10):
    for j in range (10):
        for k in range (10):
            check_i = (s.find(str(i)))
            check_j = (s.find(str(j),check_i+1))
            check_k = (s.find(str(k),check_j+1))
            if(check_i >= 0 and check_j >= 0 and check_k >= 0):
                ans += 1
print(ans)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
ans = 0

for i in range(1000):
    i = str(i).zfill(3)

    first = s.find(i[0])
    second = s.find(i[1])
    third = s.find(i[2])

    if first != -1 and second != -1 and third != -1:
        ans += 1

print(ans)

Failing test case input:
19
5064181902262262894

Expected output:
261


Actual output:
512


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
ans = 0

for i in range(1000):
    i = str(i).zfill(3)

    first = s.find(i[0])
    if first == -1:
        continue

    second = s.find(i[1], first+1)
    if second == -1:
        continue

    third = s.find(i[2], second+1)

    if third != -1:
        ans += 1

print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from string import digits

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

cnt = 0
for i in digits:
    x = s.find(i)
    if x == -1:
        continue
    for j in digits:
        y = s.find(j, x + 1)
        if y == -1:
            continue
        for k in digits:
            z = s.find(k, y + 1)
            if z == -1:
                continue
            cnt += 1

    print(cnt)

Failing test case input:
19
7230040539071200180

Expected output:
292


Actual output:
47
56
106
153
191
219
275
275
292


Fixed submission (verdict: Accepted):
from string import digits

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

cnt = 0
for i in digits:
    x = s.find(i)
    if x == -1:
        continue
    for j in digits:
        y = s.find(j, x + 1)
        if y == -1:
            continue
        for k in digits:
            z = s.find(k, y + 1)
            if z == -1:
                continue
            cnt += 1

print(cnt)

Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()

dp = [[0]*10 for _ in range(10)]

count = [0]*10

result = []

for i in range(n-2):
    if count[int(s[i])]==0:
        for j in range(i+1,n-1):
            if dp[int(s[i])][int(s[j])]==0:
                tem = "".join(set(s[j+1:]))
                for k in range(len(tem)):
                    result.append(s[i]+s[j]+tem[k])
                dp[int(s[i])][int(s[j])]=1
        count[int(s[i])]=1

Failing test case input:
19
2785343766571511696

Expected output:
239


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
s = input()

dp = [[0]*10 for _ in range(10)]

count = [0]*10

result = []

for i in range(n-2):
    if count[int(s[i])]==0:
        for j in range(i+1,n-1):
            if dp[int(s[i])][int(s[j])]==0:
                tem = "".join(set(s[j+1:]))
                for k in range(len(tem)):
                    result.append(s[i]+s[j]+tem[k])
                dp[int(s[i])][int(s[j])]=1
        count[int(s[i])]=1

ans = set(result)
print(len(ans))

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()


count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
      for k in range(p2+1,N):
        if n3==int(S[k]):
          count+=1
          break
      
              
print(count)


Failing test case input:
19
9012072135615388585

Expected output:
242


Actual output:
322


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


count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       
       if str(n3) in S[p2+1:]:
        
        count+=1
        cond=0
      
              
print(count)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
print(s)
cnt = 0
for s1 in range(10):
    s1_ind = s.find(str(s1))
    if s1_ind == -1 or s1_ind >= len(s)-2 : continue
    for s2 in range(10):
        s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
        if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
        for s3 in range(10):
            s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
            if s3_ind > s2_ind: 
                cnt+=1

print(cnt)



Failing test case input:
19
4424307180593597450

Expected output:
360


Actual output:
4424307180593597450
360


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
cnt = 0
for s1 in range(10):
    s1_ind = s.find(str(s1))
    if s1_ind == -1 or s1_ind >= len(s)-2 : continue
    for s2 in range(10):
        s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
        if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
        for s3 in range(10):
            s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
            if s3_ind > s2_ind: 
                cnt+=1

print(cnt)

Problem: p02844
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    S=list(input())

    ans = 0
    for i in range(1,1000):
        pin = str(i)
        if len(pin) == 1:
            pin = "00"+pin
        elif len(pin) == 2:
            pin = "0"+pin
        
        waiti = 0
        for j in range(N):
            if S[j] == pin[waiti]:
                waiti += 1
                if waiti == 3:
                    break
                    
        if waiti == 3:
            ans += 1

    print(ans)
            
            





if __name__ == "__main__":
    main()

Failing test case input:
19
4412007830174088444

Expected output:
204


Actual output:
203


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    S=list(input())

    ans = 0
    for i in range(1000):
        pin = str(i)
        if len(pin) == 1:
            pin = "00"+pin
        elif len(pin) == 2:
            pin = "0"+pin
        
        waiti = 0
        for j in range(N):
            if S[j] == pin[waiti]:
                waiti += 1
                if waiti == 3:
                    break
                    
        if waiti == 3:
            ans += 1

    print(ans)
            
            





if __name__ == "__main__":
    main()
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def int2str(i):
  t=str(i)
  if i <10:
    a="0"
    b="0"
    c=t[-1]
  elif i <100:
    a="0"
    b=t[-2]
    c=t[-1]
  else:
    a=t[-3]
    b=t[-2]
    c=t[-1]
  return a,b,c

N=int(input())
S=input()
ans=0
for i in range(1000):
  a,b,c=int2str(i)
  flag=0
  i1 = S.find(a)
  if i1 !=-1:
    S1=S[i1:]
    i2=S1.find(b)
    if i2 !=-1:
      S2=S1[i1:]
      i3=S2.find(c)
      if i3 !=-1:
        ans+=1
print(ans)
  
  

Failing test case input:
19
3204697633808504782

Expected output:
401


Actual output:
480


Fixed submission (verdict: Accepted):
def int2str(i):
  t=str(i)
  if i <10:
    a="0"
    b="0"
    c=t[-1]
  elif i <100:
    a="0"
    b=t[-2]
    c=t[-1]
  else:
    a=t[-3]
    b=t[-2]
    c=t[-1]
  return a,b,c

N=int(input())
S=input()
ans=0
for i in range(1000):
  S1=[]
  S2=[]
  a,b,c=int2str(i)
  flag=0
  i1 = S.find(a)
  if i1 !=-1:
    S1=S[i1+1:]
    i2=S1.find(b)
    if i2 !=-1:
      S2=S1[i2+1:]
      i3=S2.find(c)
      if i3 !=-1:
        ans+=1
print(ans)

Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
19
2028344673827913749

Expected output:
350


Actual output:
19 2028344673827913749
350


Fixed submission (verdict: Accepted):
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)

Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n = int(input())
l = [d for d in input()]
k = set(l[:-2])
c = 0
for kk in list(k):
    i = l[:-2].index(kk)
    o = set(l[i + 1:-1])
    for oo in list(o):
        ii = l[i + 1:-1].index(oo) + (i + 1)
        p = set(l[ii + 1:])
        c += len(p)
print(c)


Failing test case input:
19
1771789437871451386

Expected output:
254


Actual output:
303


Fixed submission (verdict: Accepted):


n = int(input())
l = [d for d in input()]
k = set(l[:-2])
c = 0
for kk in list(k):
    i = l[:-2].index(kk)
    o = set(l[i + 1:-1])
    for oo in list(o):
        ii = l[i + 1:-1].index(oo) + (i + 1)
        p = set(l[ii + 1:])
        c += len(p)
print(c)
Problem: p02844
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
s=input()

score = 0

for p in range(1000):
    
    pw = str(p).zfill(3)
    
    start = 0
    n_match = 0
    
    for j in range(3):
        for i in range(start, len(s)):
            
            if s[i] == pw[j]:
                start = i+1
                n_match = n_match+1
                
                if j == 3-1:
                    print(pw)
                    score = score+1
                
                break
        if n_match <= j:
            break
            
print(score)

Failing test case input:
19
4383955020590756283

Expected output:
328


Actual output:
000
002
003
005
006
007
008
009
020
022
023
025
026
027
028
029
050
052
053
055
056
057
058
059
062
063
068
072
073
075
076
078
083
090
092
093
095
096
097
098
200
202
203
205
206
207
208
209
223
228
250
252
253
255
256
257
258
259
262
263
268
272
273
275
276
278
283
290
292
293
295
296
297
298
300
302
303
305
306
307
308
309
320
322
323
325
326
327
328
329
330
332
333
335
336
337
338
339
350
352
353
355
356
357
358
359
362
363
368
372
373
375
376
378
380
382
383
385
386
387
388
389
390
392
393
395
396
397
398
399
400
402
403
405
406
407
408
409
420
422
423
425
426
427
428
429
430
432
433
435
436
437
438
439
450
452
453
455
456
457
458
459
462
463
468
472
473
475
476
478
480
482
483
485
486
487
488
489
490
492
493
495
496
497
498
499
500
502
503
505
506
507
508
509
520
522
523
525
526
527
528
529
550
552
553
555
556
557
558
559
562
563
568
572
573
575
576
578
583
590
592
593
595
596
597
598
623
628
683
723
728
752
753
756
758
762
763
768
783
800
802
803
805
806
807
808
809
820
822
823
825
826
827
828
829
830
832
833
835
836
837
838
839
850
852
853
855
856
857
858
859
862
863
868
872
873
875
876
878
883
890
892
893
895
896
897
898
899
900
902
903
905
906
907
908
909
920
922
923
925
926
927
928
929
950
952
953
955
956
957
958
959
962
963
968
972
973
975
976
978
983
990
992
993
995
996
997
998
328


Fixed submission (verdict: Accepted):
n=int(input())
s=input()

score = 0

for p in range(1000):
    
    pw = str(p).zfill(3)
    
    start = 0
    n_match = 0
    
    for j in range(3):
        for i in range(start, len(s)):
            
            if s[i] == pw[j]:
                start = i+1
                n_match = n_match+1
                
                if j == 3-1:
                    
                    score = score+1
                
                break
        if n_match <= j:
            break
            
print(score)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
  f1=fi(s,i)
  if f1==-1:
    continue
  s1=s[f1+1:]
  for j in range(10):
    f2=fi(s1,j)
    if f2==-1:
      continue
    s2=s1[f2+1:]
    for k in range(10):
      f3=fi(s2,k)
      if f3>0:
        ans+=1
print(ans)

Failing test case input:
19
3786359675370495481

Expected output:
356


Actual output:
300


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
  f1=fi(s,i)
  if f1==-1:
    continue
  s1=s[f1+1:]
  for j in range(10):
    f2=fi(s1,j)
    if f2==-1:
      continue
    s2=s1[f2+1:]
    for k in range(10):
      f3=fi(s2,k)
      if f3>=0:
        ans+=1
print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
ans = 0
 
pin = [str(i).zfill(3) for i in range(1000)]
 
for i in pin:
    idx = -1
    for j in i:
        idx = s.find(j,idx+1)
        if idx < 0:
            break
    else:
        print(j)
        ans += 1
 
print(ans)

Failing test case input:
19
3244262013239187318

Expected output:
271


Actual output:
1
2
3
7
8
9
1
3
7
8
9
1
2
3
7
8
9
1
3
8
1
3
7
8
1
3
7
8
1
3
7
8
1
3
7
8
9
1
2
3
7
8
9
1
3
8
1
3
7
8
1
3
7
8
1
2
3
7
8
9
1
2
3
7
8
9
0
1
2
3
6
7
8
9
1
2
3
7
8
9
0
1
2
3
4
6
7
8
9
0
1
2
3
7
8
9
1
3
8
1
3
7
8
1
3
7
8
1
2
3
7
8
9
1
2
3
7
8
9
0
1
2
3
4
6
7
8
9
1
2
3
7
8
9
0
1
2
3
4
6
7
8
9
0
1
2
3
7
8
9
1
3
8
1
3
7
8
1
3
7
8
1
2
3
7
8
9
1
2
3
7
8
9
0
1
2
3
6
7
8
9
1
2
3
7
8
9
0
1
2
3
6
7
8
9
0
1
2
3
7
8
9
1
3
8
1
3
7
8
1
3
7
8
1
2
3
7
8
9
1
2
3
7
8
9
0
1
2
3
7
8
9
1
2
3
7
8
9
1
3
8
1
3
7
8
1
3
7
8
8
1
8
8
1
8
1
3
8
1
3
7
8
1
8
1
3
8
1
3
7
8
271


Fixed submission (verdict: Accepted):
 
n = int(input())
s = input()
ans = 0
 
pin = [str(i).zfill(3) for i in range(1000)]
 
for i in pin:
    idx = -1
    for j in i:
        idx = s.find(j,idx+1)
        if idx < 0:
            break
    else:
        ans += 1
 
print(ans)
Problem: p02844
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

ans = 0

for i in range(10):
    a = S.find(str(i))
    if -1 == a:
        continue
    for j in range(10):
        b = S.find(str(j), a + 1)
        if -1 == b:
            continue
        for k in range(10):
            c = S.find(str(k), b + 1)
            if -1 == c:
                continue
            ans += 1
            print(''.join(map(str, [i, j, k])))

print(ans)

Failing test case input:
19
1036710694297327965

Expected output:
364


Actual output:
002
003
004
005
006
007
009
010
012
013
014
015
016
017
019
022
023
025
026
027
029
030
031
032
033
034
035
036
037
039
042
043
045
046
047
049
060
061
062
063
064
065
066
067
069
070
071
072
073
074
075
076
077
079
092
093
094
095
096
097
099
100
101
102
103
104
105
106
107
109
110
112
113
114
115
116
117
119
122
123
125
126
127
129
130
131
132
133
134
135
136
137
139
142
143
145
146
147
149
160
161
162
163
164
165
166
167
169
170
171
172
173
174
175
176
177
179
192
193
194
195
196
197
199
225
226
227
229
232
235
236
237
239
265
272
273
275
276
277
279
292
293
295
296
297
299
302
303
304
305
306
307
309
310
312
313
314
315
316
317
319
322
323
325
326
327
329
332
335
336
337
339
342
343
345
346
347
349
360
361
362
363
364
365
366
367
369
370
371
372
373
374
375
376
377
379
392
393
394
395
396
397
399
422
423
425
426
427
429
432
435
436
437
439
465
472
473
475
476
477
479
492
493
495
496
497
499
602
603
604
605
606
607
609
610
612
613
614
615
616
617
619
622
623
625
626
627
629
632
635
636
637
639
642
643
645
646
647
649
662
663
664
665
666
667
669
670
671
672
673
674
675
676
677
679
692
693
694
695
696
697
699
702
703
704
705
706
707
709
710
712
713
714
715
716
717
719
722
723
725
726
727
729
732
735
736
737
739
742
743
745
746
747
749
762
763
764
765
766
767
769
772
773
775
776
777
779
792
793
794
795
796
797
799
922
923
925
926
927
929
932
935
936
937
939
942
943
945
946
947
949
965
972
973
975
976
977
979
992
993
995
996
997
999
364


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

ans = 0

for i in range(10):
    a = S.find(str(i))
    if -1 == a:
        continue
    for j in range(10):
        b = S.find(str(j), a + 1)
        if -1 == b:
            continue
        for k in range(10):
            c = S.find(str(k), b + 1)
            if -1 == c:
                continue
            ans += 1
            

print(ans)
Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


import sys


def main():
    N = int(input())  
    S = str(input())

    ans = set()

    digit1 = set()
    digit2 = set()
    digit3 = set()

    for i in range(0, N - 2):
        if S[i] in digit1:
            continue
        digit1.add(S[i])
        for j in range(i + 1, N - 1):
            if S[j] in digit2:
                continue
            digit2.add(S[j])
            for k in range(j + 1, N):
                if len(digit3) == 10:
                    break
                code = S[i] + S[j] + S[k]
                ans.add(code)

    print(len(ans))


if __name__ == '__main__':
    main()


Failing test case input:
19
9352460586099976652

Expected output:
327


Actual output:
59


Fixed submission (verdict: Accepted):


import sys


def main():
    N = int(input())  
    S = str(input())

    ans = set()

    digit1 = set()

    for i in range(0, N - 2):
        if S[i] in digit1:
            continue
        digit1.add(S[i])
        digit2 = set()

        for j in range(i + 1, N - 1):
            if S[j] in digit2:
                continue
            digit2.add(S[j])
            digit3 = set()
            for k in range(j + 1, N):
                if len(digit3) == 10:
                    break
                code = S[i] + S[j] + S[k]
                ans.add(code)

    print(len(ans))


if __name__ == '__main__':
    main()
Problem: p02844
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import collections
import copy

N = int(input().split()[0])
S = input()

counter = collections.Counter(S)
total = 0
done_list = []
for i, ch in enumerate(S[::-1]):  
    if ch in done_list:
        continue
    sub_done_list = []
    counter[ch] = counter[ch] - 1
    if counter[ch] < 1:
        del counter[ch]
    sub_counter = copy.copy(counter)
    for ch_2 in S[:i:-1]:  
        if ch_2 in sub_done_list:
            continue
        sub_done_list.append(ch_2)
        sub_counter[ch_2] = sub_counter[ch_2] - 1
        if sub_counter[ch_2] < 1:
            del sub_counter[ch_2]
        total += len(sub_counter.keys())

    done_list.append(ch)

ans = total

print(ans)


Failing test case input:
19
8526743034401745542

Expected output:
308


Actual output:
370


Fixed submission (verdict: Accepted):
import collections
import copy

N = int(input().split()[0])
S = input()

counter = collections.Counter(S)
total = 0
done_list = []

for i, ch in enumerate(S[::-1]):  
    if ch in done_list:
        counter[ch] = counter[ch] - 1
        if counter[ch] < 1:
            del counter[ch]
        continue
    sub_done_list = []
    counter[ch] = counter[ch] - 1
    if counter[ch] < 1:
        del counter[ch]
    sub_counter = copy.copy(counter)

    for ch_2 in S[N - (i + 1) - 1 :: -1]:  
        if ch_2 in sub_done_list:
            sub_counter[ch_2] = sub_counter[ch_2] - 1
            if sub_counter[ch_2] < 1:
                del sub_counter[ch_2]
            continue
        sub_done_list.append(ch_2)
        sub_counter[ch_2] = sub_counter[ch_2] - 1
        if sub_counter[ch_2] < 1:
            del sub_counter[ch_2]
        total += len(sub_counter.keys())

    done_list.append(ch)

ans = total

print(ans)

Problem: p02844
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s=list(input())
n=len(s)
ans=0
for i in range(0,10):
  for x in range(0,n-2):
    if s[x]==str(i):
      for j in range(0,10):
        for y in range(x+1,n-1):
          if s[y]==str(j):
            for k in range(0,10):
              for z in range(y+1,n):
                if s[z]==str(k):
                  ans+=1
                  
print(ans)

Failing test case input:
19
9299831195035158503

Expected output:
202


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
s=list(input())
d={}
ans=0
for x in range(n-2):
  if s[x] not in d:
    d[s[x]]=0
    for y in range(x+1,n-1):
      if (s[x]+s[y]) not in d:
        d[(s[x]+s[y])]=0
        for z in range(y+1,n):
          if (s[x]+s[y]+s[z]) not in d:
            d[(s[x]+s[y]+s[z])]=0
            ans+=1
    
print(ans)