Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for _ in range(N)]
L = [0]
i = 0
cnt = 0
while True:
    if a[i]-1 == 1:
        cnt += 1
        break
    elif a[i]-1 in L:
        cnt = -1
        break
    else:
        L.append(a[i]-1)
        cnt += 1
        i = a[i]-1
print(cnt)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
L = set([0])
i = 0
cnt = 0
while True:
    if a[i]-1 == 1:
        cnt += 1
        break
    elif a[i]-1 in L:
        cnt = -1
        break
    else:
        L.add(a[i]-1)
        cnt += 1
        i = a[i]-1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for _ in range(N)]
L = [0]
i = 0
cnt = 0
while True:
    if a[i]-1 == 1:
        cnt += 1
        break
    elif a[i]-1 in L :
        cnt = -1
        break
    else:
        L.append(a[i]-1)
        cnt += 1
        i = a[i]-1
print(cnt)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
L = set([0])
i = 0
cnt = 0
while True:
    if a[i]-1 == 1:
        cnt += 1
        break
    elif a[i]-1 in L:
        cnt = -1
        break
    else:
        L.add(a[i]-1)
        cnt += 1
        i = a[i]-1
print(cnt)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
list1 = [1,3,5,6,8,10,12,4,6,9,11,2]
list2 = [0,0,0,0,0,0,0,1,1,1,1,2]
d = dict(zip(list1, list2))
if d[x] == d[y]:
  print("Yes")
else:
  print("No")

Fixed submission:
x, y = map(int, input().split())
list1 = [1,3,5,7,8,10,12,4,6,9,11,2]
list2 = [0,0,0,0,0,0,0,1,1,1,1,2]
d = dict(zip(list1, list2))
if d[x] == d[y]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
flag = False
for i in range(H):
    for j in range(W):
        s = input()
        if s == "snuke":
            print(chr(ord('A')+j)+str(i+1))
            flag = True
            break

    if flag:
        break


Fixed submission:
H, W = map(int, input().split())
flag = False
for i in range(H):
    S = list(input().split())
    for j, s in enumerate(S):
        if s == "snuke":
            print(chr(ord('A')+j)+str(i+1))
            flag = True
            break

    if flag:
        break
Buggy python submission (verdict: Runtime Error):
A, B, C = [input() for _ in range(3)]
ca = 1
cb = 0
cc = 0
current = A[0]
while True:
    if current == 'a':
        ca += 1
        if ca == len(A):
            print('A')
            break    
        else:
            current =  A[ca]
    elif current == 'b':
        cb += 1
        if cb == len(B):
            print('B')
            break    
        else:
            current =  B[cb]
    elif current == 'c':
        cc += 1
        if cc == len(C):
            print('C')
            break    
        else:
            current =  C[cc]



Fixed submission:
A, B, C = [list(input()) for _ in range(3)]
x = 'a'
while True:
    if x == 'a':
        if len(A) == 0:
            print('A')
            exit()
        x = A[0]
        A.remove(x)
    elif x == 'b':
        if len(B) == 0:
            print('B')
            exit()
        x = B[0]
        B.remove(x)   
    elif x == 'c':
        if len(C) == 0:
            print('C')
            exit()
        x = C[0]
        C.remove(x)
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
book_list = list(map(int,input().split()))
book_list.extend(list(map(int,input().split())))
book_list.sort()
count=0
readTime=0
for i in range(n+m):
    if readTime+book_list[i]<=k:
        count+=1
        readTime+=book_list[i]
    else:
        break
print(count)

Fixed submission:
x=int(input())
print(x+x**2+x**3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  else:
    if d1 == d2:
      count += 1
    else:
      count = 0
if count > 2:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
if s[-1] == "s":
  print(s+"es")
else:
  print(s+"s")

Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count > 2:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
if s[-1] == "s":
  print(s+"es")
else:
  print(s+"s")

Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count > 2:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
if s[-1] == "s":
  print(s+"es")
else:
  print(s+"s")

Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count == 3:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count == 3:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
if s[-1] == "s":
  print(s+"es")
else:
  print(s+"s")
Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input())
  if count == 3:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count == 3:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  else:
    if d1 == d2:
      count += 1
    else:
      count = 0
if count > 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = input()
total = 0
for i in range(len(n)):
  total += int(n[i])
if total % 9 == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n, x, t = map(int, input().split())
if n % x == 0:
  print(int(n/x*t))
else:
  print(int((n//x+1)*t))

Buggy python submission (verdict: Runtime Error):
n, x, t = map(int, input())
print((n//x+1)*t)

Fixed submission:
n, x, t = map(int, input().split())
if n % x == 0:
  print(int(n/x*t))
else:
  print(int((n//x+1)*t))

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = int(input())
t = int(input())
print((n//x+1)*t)

Fixed submission:
n, x, t = map(int, input().split())
if n % x == 0:
  print(int(n/x*t))
else:
  print(int((n//x+1)*t))

Buggy python submission (verdict: Runtime Error):
n, x, t = int(input()).split(" ")
print((n//x+1)*t)

Fixed submission:
n, x, t = map(int, input().split())
if n % x == 0:
  print(int(n/x*t))
else:
  print(int((n//x+1)*t))

Buggy python submission (verdict: Runtime Error):
n, x, t = int(input())
print((n//x+1)*t)

Fixed submission:
n, x, t = map(int, input().split())
if n % x == 0:
  print(int(n/x*t))
else:
  print(int((n//x+1)*t))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
total = 0
for i in range(len(str(n))):
  total += int(str(n)[i])
if total % 9 == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n = input()
total = 0
for i in range(len(n)):
  total += int(n[i])
if total % 9 == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%k==0:
    print("OK")
    break
else:
  print("NG")
  break

Fixed submission:
k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%k==0:
    print("OK")
    break
else:
  print("NG")
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(2000)

n,k = map(int,input().split())
lisN = list(range(1,n+1))
lis = set([])

for i in range(k):
    a =int(input())
    for j in range(a):
        lis.add(int(input()))
        

    
print(len(set(lisN) ^ set(lis)))


    

Fixed submission:
s = input()

if s == 'ABC':
    print('ARC')
elif s == 'ARC':
    print('ABC')
Buggy python submission (verdict: Runtime Error):
##import math

x = int(input())
counter = 0
goukei = 100

while goukei < x:
    counter += 1
    goukei += int(1 + counter * 0.01)
    print(goukei)

    
print(counter)





Fixed submission:

x = int(input())
counter = 0
goukei = 100

while goukei < x:
    goukei += int( goukei * 0.01)
    counter += 1
    
print(counter)
Buggy python submission (verdict: Runtime Error):
lis =[]
abc =[]
count = 0

N = int(input())
lis =[lis.append(input()) for _ in range(N)]

for i in lis:
    if any(i == j for j in abc):
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

Fixed submission:
S,W = map(int,input().split())

if S > W:
    print('safe')
else:
    print('unsafe')
Buggy python submission (verdict: Time Limit Exceeded):
lis =[]
abc =[]
count = 0

N = int(input())
for _ in range(N):
    lis.append(input()) 

for i in lis:
    if i in abc:
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

Fixed submission:
n = int(input())

ans = len(set(input() for i in range(n)))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
lis =[]
abc =[]
count = 0

N = int(input())
for _ in range(N):
    lis.append(input()) 

for i in lis:
    if i in abc:
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

Fixed submission:
n = int(input())

ans = len(set(input() for i in range(n)))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)

lis =[]
abc =[]
count = 0

N = int(input())
for _ in range(N):
    lis.append(input())

for i in lis:
    if any(i == j for j in abc):
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

Fixed submission:
n = int(input())

ans = len(set(input() for i in range(n)))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
lis =[]
abc =[]
count = 0

N = int(input())
for _ in range(N):
    lis.append(input())

for i in lis:
    if any(i == j for j in abc):
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

Fixed submission:
n = int(input())

ans = len(set(input() for i in range(n)))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
lis =[]
abc =[]
count = 0

N = int(input())
for _ in range(N):
    lis.append(input())

for i in lis:
    if any(i == j for j in abc):
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

Fixed submission:
n = int(input())

ans = len(set(input() for i in range(n)))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,k = map(int,input().split())
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if(j<n):
            dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print(dp[n-1])

Fixed submission:
import sys
n,k = map(int,input().split())
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if(j<n):
            dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
 N = int(input())
nd = [0] * (N+1)
for i in range(1, N):
    for j in range(i, N, i):
        nd[j] += 1
print(sum(nd))

Fixed submission:
N = int(input())
nd = [0] * (N+1)
for i in range(1, N):
    for j in range(i, N, i):
        nd[j] += 1
print(sum(nd))
Buggy python submission (verdict: Runtime Error):
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
n = 1
P = 10 % L
while True:
    if P == 1:
        print(n)
        break
    n += 1
    P = (10 * P) % L

Fixed submission:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
    n = 1
    P = 10 % L
    while True:
        if P == 1:
            print(n)
            break
        n += 1
        P = (10 * P) % L

Buggy python submission (verdict: Runtime Error):
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
n = 1
P = 10 % L
while True:
    if P == 1:
        print(n)
        break
    n += 1
    P = (10 * P) % L

Fixed submission:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
    n = 1
    P = 10 % L
    while True:
        if P == 1:
            print(n)
            break
        n += 1
        P = (10 * P) % L

Buggy python submission (verdict: Runtime Error):
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
n = 1
P = 10 % L
while True:
    if P == 1:
        print(n)
        break
    n += 1
    P = (10 * P) % K

Fixed submission:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
    n = 1
    P = 10 % L
    while True:
        if P == 1:
            print(n)
            break
        n += 1
        P = (10 * P) % L

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    W = 7 % K
    while True:
        if W % K == 0:
            print(i)
            break
        W += 7 * 10**i % K
        i += 1

Fixed submission:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
    n = 1
    P = 10 % L
    while True:
        if P == 1:
            print(n)
            break
        n += 1
        P = (10 * P) % L
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c = input()
C = []
for c_i in c:
    C.append(c_i)
count = 0
left = N - 1
for i in range(N):
    if i >= left:
        print(count)
        break
    if C[i] == 'W':
        for j in reversed(range(N)):
            if i == 1:
                if j == i:
                    C[i] = 'R'
                    left = i
                    break
            else:
                if j == i-1:
                    left = i
                    break
            if C[j] == 'R':
                C[i] = 'R'
                C[j] = 'W'
                left = j
                count += 1
                break

Fixed submission:
N = int(input())
c = input()
C = []
for c_i in c:
    C.append(c_i)
count = 0
left = N-1
for i in range(N):
    if i >= left:
        print(count)
        break
    if C[i] == 'W':
        for j in reversed(range(left+1)):
            if i == 1:
                if j == i:
                    C[i] = 'R'
                    left = i
                    break
            else:
                if j == i-1:
                    left = i
                    break
            if C[j] == 'R':
                C[i] = 'R'
                C[j] = 'W'
                left = j
                count += 1
                break
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_max = max(A)
if K == 0:
    print(A_max)
else:
    X = A_max+1//2
    y = (X+1)//2
    while True:
        c = 0
        d = 0
        for i in range(N):
            c += A[i]//X
            d += A[i]//(X+1)
        if d <= K and c > K:
            print(X+1)
            break
        elif d > K:
            X += y
            y = (y+1) // 2
        elif c <= K:
            X -= y
            y = (y+1) // 2

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

def is_ok(mid):
    s = 0
    for j in range(N):
        if mid < A[j]:
            s += A[j] // mid
    return s <= K

max_A = 10**9 + 1
ng = 0
ok = max_A

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid
        
print(ok)
Buggy python submission (verdict: Runtime Error):
N = int(input())
SUM = 0
for i in range(1, N+1):
    print (i,(i*(N//i)*((N//i)+1))//2)
    SUM += (i*(N//i)*((N//i)+1))//2
print(SUM)

Fixed submission:
N = int(input())
SUM = 0
for i in range(1, N+1):
    SUM += (i*(N//i)*((N//i)+1))//2
print(SUM)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = [2]
for i in range(3, int(10**(7/2))):
    for prime in p:
        if i % prime == 0:
            break
        if prime == p[-1] or prime**2 > i:
            p.append(i)
            break      
SUM = 1
for K in range(2, N+1):
    d_K = K
    for prime in p:
        if K == 1:
            break
        count_p = 1
        while K % prime == 0:
            count_p += 1
            K = K // prime
        d_K *= count_p
    SUM += d_K
print(SUM)

Fixed submission:
N = int(input())
SUM = 0
for i in range(1, N+1):
    SUM += (i*(N//i)*((N//i)+1))//2
print(SUM)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = [2]
for i in range(3, int(10**(7/2))):
    for prime in p:
        if i % prime == 0:
            break
        if prime == p[-1] or prime**2 > i:
            p.append(i)
            break      
SUM = 1
for K in range(2, N+1):
    d_K = K
    for prime in p:
        count_p = 1
        while K % prime == 0:
            count_p += 1
            K = K // prime
        d_K *= count_p
    SUM += d_K
print(SUM)

Fixed submission:
N = int(input())
SUM = 0
for i in range(1, N+1):
    SUM += (i*(N//i)*((N//i)+1))//2
print(SUM)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        data[C[i]] += data[B[i]]
        data[B[i]] = 0
    print(SUM)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        if C[i] in data:
            data[C[i]] += data[B[i]]
        else:
            data[C[i]] = data[B[i]]
        data[B[i]] = 0
    print(SUM)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)a
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        data[C[i]] += data[B[i]]
        data[B[i]] = 0
    print(SUM)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        if C[i] in data:
            data[C[i]] += data[B[i]]
        else:
            data[C[i]] = data[B[i]]
        data[B[i]] = 0
    print(SUM)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = [1 for i in range(N)]
for i in range(N):
    if B[i] != 0:
        for j in range(i+1, N):
            if A[i] == A[j]:
                B[i] = 0
                B[j] = 0
            elif A[j] % A[i] == 0:
                B[j] = 0
print(sum(B))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
LN = max(A) + 1
L = [0 for i in range(LN)]
count = 0
for i in A:
    for j in range(i, LN, i):
        L[j] += 1
for i in A:
    if L[i] == 1:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
is_Prime = [True] * (10**6 + 1)
is_Prime[0] = False
is_Prime[1] = False
for i in range(2, int(10**3)+1):
    for j in range(2*i, 10**6+1, i):
        if j % i == 0:
            is_Prime[j] = False
P = [i for i in range(n+1) if is_Prime[i]]

N = int(input())
count = 0
for p in P:
    count_p = 0
    while N % p == 0:
        count_p += 1
        N /= p
    count += int((-1+(1+8*count_p)**(1/2))/2)
    if p == P[-1] and N != 1:
        count += 1
print(count)

Fixed submission:
N = int(input())
n = min(N, 10**6)
is_Prime = [True] * (n + 1)
is_Prime[0] = False
is_Prime[1] = False
for i in range(2, int(n**(1/2)+1)):
    for j in range(2*i, n+1, i):
        if j % i == 0:
            is_Prime[j] = False
P = [i for i in range(n+1) if is_Prime[i]]

count = 0
for p in P:
    count_p = 0
    while N % p == 0:
        count_p += 1
        N /= p
    count += int((-1+(1+8*count_p)**(1/2))/2)
    if p == P[-1] and N != 1:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
c = []
for i in range(M):
    s_i, c_i = map(int, input().split())
    s.append(s_i)
    c.append(c_i)
sc.sort(key = lambda x: x[0], reverse = True)
for i in range(10**(N-1), 10**N):
    for j in range(M):
        if str(i)[s[j]-1] != str(c[j]):
            break
        if j == M - 1:
            print(i)
            c = 1
            break
    if c == 1:
        break
    if i == 10**N -1:
        print(-1)


Fixed submission:
N, M = map(int, input().split())
s = []
c = []
if M == 0:
    if N != 1:
        print(10**(N-1))
    else:
        print(0)
else:   
    for i in range(M):
        s_i, c_i = map(int, input().split())
        s.append(s_i)
        c.append(c_i)
    if N != 1:
        for i in range(10**(N-1), 10**N):
            for j in range(M):
                if str(i)[s[j]-1] != str(c[j]):
                    break
                if j == M - 1:
                    print(i)
                    c = 1
                    break
            if c == 1:
                break
            if i == 10**N -1:
                print(-1)
    else:
        for i in range(0, 10):
            for j in range(M):
                if str(i)[s[j]-1] != str(c[j]):
                    break
                if j == M - 1:
                    print(i)
                    c = 1
                    break
            if c == 1:
                break
            if i == 10**N -1:
                print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N  = int(input())
S = input()
P = 0
count = 0
for j in range(1000):
    V = str(P).zfill(3)
    p1 = False
    p2 = False
    for i in range(N):
        if S[i] == V[0] and not p1:
            p1 = True
            continue
        if S[i] == V[1] and p1 and not p2:
            p2 = True
            continue
        if S[i] == V[2] and p2:
            count += 1
            break
    P += 1
print (count)

Fixed submission:
N  = int(input())
S = input()
P = 0
count = 0
for j in range(1000):
    V = str(P).zfill(3)
    p1 = False
    p2 = False
    for i in range(N):
        if S[i] == V[0] and not p1:
            p1 = True
            continue
        if S[i] == V[1] and p1 and not p2:
            p2 = True
            continue
        if S[i] == V[2] and p2:
            count += 1
            break
    P += 1
print (count)

Buggy python submission (verdict: Time Limit Exceeded):
N  = int(input())
S = input()
result = []
for i in range(0, N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            num = S[i] + S[j] + S[k]
            if num not in result:
                result.append(num)
print(len(result))

Fixed submission:
N  = int(input())
S = input()
P = 0
count = 0
for j in range(1000):
    V = str(P).zfill(3)
    p1 = False
    p2 = False
    for i in range(N):
        if S[i] == V[0] and not p1:
            p1 = True
            continue
        if S[i] == V[1] and p1 and not p2:
            p2 = True
            continue
        if S[i] == V[2] and p2:
            count += 1
            break
    P += 1
print (count)