Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = input()
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,len(B)):
    A[i] = min(B[i-1],B[i])
    i += 1

A[N] = B[-1]

print(sum(A))


Fixed submission:
N = int(input())
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])
    i += 1

A[-1] = B[-1]

print(sum(A))

Buggy python submission (verdict: Runtime Error):
N = input()
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,len(B)):
    A[i] = min(B[i-1],B[i])
    i += 1

A[N] = B[-1]

print(sum(A))


Fixed submission:
N = int(input())
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])
    i += 1

A[-1] = B[-1]

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
n = int( input())
total = 0
if n ==1:
    print(0)
else:
    for i in range(n):
        total += i
    print(total)

Fixed submission:
n = int( input())
total = 0
if n ==1:
    print(0)
else:
    print((n*(n-1))//2)
Buggy python submission (verdict: Runtime Error):
import sys

n=int(input())
ans=0
for i in range(n):
    if len(i)%2==1:
        ans+=1
print(ans)

Fixed submission:
import sys

n=int(input())
ans=0
for i in range(1,n+1):
    s=str(i)
    if len(s)%2==1:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = list(str(input()))
if (S[0]==S[1]) and (S[0]==S[2]) and (S[0]==S[3]):
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:

Fixed submission:
S = list(str(input()))
if (S[0]==S[1]) and (S[0]==S[2]) and (S[0]==S[3]):
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = list(str(input()))
if S[0]==S[1]==S[2]==S[3]:
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:

Fixed submission:
S = list(str(input()))
if (S[0]==S[1]) and (S[0]==S[2]) and (S[0]==S[3]):
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = list(str(input()))
if S[0]==S[1]==S[2]==S[3:
    print('No')]
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:


Fixed submission:
S = list(str(input()))
if (S[0]==S[1]) and (S[0]==S[2]) and (S[0]==S[3]):
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a >= 13:
    print(b)
elif 5 <= a <= 12:
    print(int(b/2))
else:
    print(0

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(b//2)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a >= 13:
    print(b):
elif 5 <= a <= 12:
    print(b//2)
else:
    print(0)

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(b//2)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a >= 13:
    print(b):
elif 5 <= a <= 12:
    print(a//2)
else:
    print(0)

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(b//2)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
b=input()
if b==A:
    print(T)
if b==T:
    print(A)
if b==G:
    print(C)
if b==C:
    print(G)


Fixed submission:
b=input()
if b=='A':
    print('T')
if b=='T':
    print('A')
if b=='G':
    print('C')
if b=='C':
    print('G')
Buggy python submission (verdict: Runtime Error):

import sys
import itertools
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        z=s-(x+y)
        if z>=0 andz<=k:
            ans+=1

print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        z=s-(x+y)
        if z>=0 and z<=k:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

money = 1000
stock = 0
if A[0] < A[1]:
    stock += (money//A[0])
    money %= A[0]
    
tmp = A[0]
for i in range(1,N):
    if tmp < A[i]:
        if i == N-1:
            money += (stock*A[i])
        if A[i] < A[i+1]:
            tmp = A[i]
            continue
        money += (stock*A[i])
        stock = 0
        tmp = A[i]
    elif tmp > A[i]:
        if i == N-1:
            money += (stock*A[i])
            break
        if A[i] > A[i+1]:
            tmp = A[i]
            continue
        stock += (money//A[i])
        money %= A[i]
        tmp = A[i]
        
print(max(money,1000))

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

money = 1000
stock = 0
cnt = 0
buy = True    

while True:
    if buy == False:
        while True:
            if cnt >= N-1:
                break
            if A[cnt+1] < A[cnt]:
                break
            cnt += 1
        if cnt >= N-1:
            break
        buy = True
        money += (stock*A[cnt])
        stock = 0
    else:
        while True:
            if cnt >= N-1:
                break
            if A[cnt+1] > A[cnt]:
                break
            cnt += 1
        if cnt >= N-1:
            break
        buy = False
        stock += (money//A[cnt])
        money %= A[cnt]
    if cnt >= N-1:
        break
money += (stock*A[-1])
print(max(money,1000))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

money = 1000
stock = 0
if A[0] < A[1]:
    stock += (money//A[0])
    money %= A[0]
    
tmp = A[0]
for i in range(1,N):
    if tmp < A[i]:
        money += (stock*A[i])
        stock = 0
        tmp = A[i]
    elif tmp > A[i]:
        if i == N:
            money += (stock*A[i])
            break
        if A[i] > A[i+1]:
            tmp = A[i]
            continue
        stock += (money//A[i])
        money %= A[i]
        tmp = A[i]
        
print(max(money,1000))

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

money = 1000
stock = 0
cnt = 0
buy = True    

while True:
    if buy == False:
        while True:
            if cnt >= N-1:
                break
            if A[cnt+1] < A[cnt]:
                break
            cnt += 1
        if cnt >= N-1:
            break
        buy = True
        money += (stock*A[cnt])
        stock = 0
    else:
        while True:
            if cnt >= N-1:
                break
            if A[cnt+1] > A[cnt]:
                break
            cnt += 1
        if cnt >= N-1:
            break
        buy = False
        stock += (money//A[cnt])
        money %= A[cnt]
    if cnt >= N-1:
        break
money += (stock*A[-1])
print(max(money,1000))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N = int(stdin.readline().rstrip())
for i in range(1,N+1):
    ans = 0
    for x in range(1,40):
        for y in range(1,40):
            for z in range(1,40):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    ans += 1
    print(ans)

Fixed submission:
from sys import stdin
from collections import defaultdict
N = int(stdin.readline().rstrip())
d = defaultdict(int)

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      v = x**2 + y**2 + z**2 + x*y + y*z + z*x
      d[v] += 1

for i in range(1,N+1):
    print(d[i])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
X,Y = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
tmp = 10**9+7
P = set(list(range(0,101))) - set(P)
P.sort(reverse=True)


ans = 0
for i in P:
    if abs(i-X) <= tmp:
        ans = i
        tmp = abs(i-X)
        
print(ans)
        

Fixed submission:
from sys import stdin
X, Y = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
tmp = 10**9+7
P = set(list(range(-200, 200))) - set(P)
P = list(P)
P.sort(reverse=True)


ans = 0
for i in P:
    if abs(X-i) <= tmp:
        ans = i
        tmp = abs(X-i)

print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from decimal import Decimal
N = int(stdin.readline().rstrip())
A = []
B = []
for i in range(N):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
    
A.sort()
B.sort()
if N % 2 == 0:
    C = A+B
    C.sort()
    ans = 2 * sum(C[::-1][:N]) - 2 * sum(C[:N])
    print(ans//2+1)
else:
    ans = B[N//2] - A[N//2] + 1
    print(ans

Fixed submission:
from sys import stdin
from decimal import Decimal
N = int(stdin.readline().rstrip())
A = []
B = []
for i in range(N):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
    
A.sort()
B.sort()

if N % 2 == 0:
    n = N // 2
    med1 = A[n-1] + A[n]
    med2 = B[n-1] + B[n]
    print(med2-med1+1)
else:
    ans = B[N//2] - A[N//2] + 1
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()[::-1]
rem = [0]*2019

n = 0
d = 0

for s in S:
    n = n%2019 + (int(s)*10**d)%2019
    tmp = n%2019
    rem[tmp] += 1
    d += 1
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])

Fixed submission:
S = input()[::-1]
rem = [0]*2019

n = 0
d = 1

for s in S:
    n = n%2019 + (int(s)*d)%2019
    tmp = n%2019
    rem[tmp] += 1
    d *= 10
    d %= 2019
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
rem = [0]*2019

n = 0
d = 0

for s in S[::-1]:
    n = n%2019 + (int(s)*10**d)%2019
    tmp = n%2019
    rem[tmp] += 1
    d += 1
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])

Fixed submission:
S = input()[::-1]
rem = [0]*2019

n = 0
d = 1

for s in S:
    n = n%2019 + (int(s)*d)%2019
    tmp = n%2019
    rem[tmp] += 1
    d *= 10
    d %= 2019
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
rem = [0]*2019

n = 0
d = 0

for s in S[::-1]:
    n = n + int(s)*10**d
    tmp = n%2019
    rem[tmp] += 1
    d += 1
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])

Fixed submission:
S = input()[::-1]
rem = [0]*2019

n = 0
d = 1

for s in S:
    n = n%2019 + (int(s)*d)%2019
    tmp = n%2019
    rem[tmp] += 1
    d *= 10
    d %= 2019
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
rem = [0]*2019

n = ""
for s in S[::-1]:
    n = s + n
    tmp = int(n)%2019
    rem[tmp] += 1
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])

Fixed submission:
S = input()[::-1]
rem = [0]*2019

n = 0
d = 1

for s in S:
    n = n%2019 + (int(s)*d)%2019
    tmp = n%2019
    rem[tmp] += 1
    d *= 10
    d %= 2019
    
ans = 0
for i in rem:
    ans += ((i*(i-1))//2)

print(ans+rem[0])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from collections import deque
from collections import Counter
N,X,Y = [int(x) for x in stdin.readline().rstrip().split()] 
ans = Counter()

for k in range(1,N+1):
    dist = [0] + [10**9]*(N)
    visited = [False for i in range(N+1)]
    visit_p = deque()
    visit_p.append((k,0))

    while visit_p:
        #print(visit_p)
        node,cnt = visit_p.popleft()
        dist[node] = min(cnt,dist[node])

        if node == X:
            #print(node,cnt,"s")
            if not visited[Y]:
                visit_p.append((Y,cnt+1))
                visited[Y] = True

        if node == Y:
            #print(node,cnt,"s")
            if not visited[X]:
            #ans[cnt+1] += 1
                visit_p.append((X,cnt+1))
                visited[X] = True
        #print(visit_p,"e")   
        for d in [-1,1]:
            if node + d < 1 or node + d > N:
                continue
            if visited[node+d]:
                continue
            #print(node+d,cnt,"e")
            #ans[cnt+1] += 1
            visited[node+d] = True
            visit_p.append((node+d,cnt+1))
        
    ans += Counter(dist)
    
for i in range(1,N):
    print(ans[i]//2)

Fixed submission:
from sys import stdin
from collections import deque
from collections import Counter
N,X,Y = [int(x) for x in stdin.readline().rstrip().split()] 
ans = Counter()

for k in range(1,N+1):
    dist = [0] + [10**9]*(N)
    visited = [False for i in range(N+1)]
    visit_p = deque()
    visit_p.append((k,0))

    while visit_p:
        #print(visit_p)
        node,cnt = visit_p.popleft()
        dist[node] = min(cnt,dist[node])

        if node == X:
            #print(node,cnt,"s")
            if not visited[Y]:
                visit_p.append((Y,cnt+1))
                visited[Y] = True

        if node == Y:
            #print(node,cnt,"s")
            if not visited[X]:
            #ans[cnt+1] += 1
                visit_p.append((X,cnt+1))
                visited[X] = True
        #print(visit_p,"e")   
        for d in [-1,1]:
            if node + d < 1 or node + d > N:
                continue
            if visited[node+d]:
                continue
            #print(node+d,cnt,"e")
            #ans[cnt+1] += 1
            visited[node+d] = True
            visit_p.append((node+d,cnt+1))
        
    ans += Counter(dist)
    
for i in range(1,N):
    print(ans[i]//2)
Buggy python submission (verdict: Runtime Error):
# 1-index
from sys import stdin
H, N = [int(x) for x in stdin.readline().rstrip().split()]

data = [0]*N

for i in range(N):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    data[i] = (A, B)
dp = [10**9]*(H+1)
dp[0] = 0

for h in range(0,H+1):
    for a,b in data:
        if h+a >= H:
            dp[H] = min(dp[h]+b,dp[H])
        else:
            dp[h+a] = min(dp[h]+b,dp[h+a])
print(dp[H])

Fixed submission:
from sys import stdin
H,A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
while True:
    H -= A
    ans += 1
    if H <= 0:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from sys import stdin
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

if __name__ == "__main__":
    mod = 10**9+7
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    ans = 0
    l = reduce(lcm,A)
    for j in A:
        ans += (l//j)
        ans %= mod
    print(ans)

Fixed submission:
from sys import stdin
import fractions
mod = 10**9+7
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, pow(b, mod-2,mod))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l = 1
for i in A:
    l = lcm(l,i)
    
for j in A:
    ans += div(l,j)
    ans %= mod
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import fractions
mod = 10**9+7
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l = 1
for i in A:
    l = lcm(l,i)
    
for j in A:
    ans += (l//j)
    ans %= mod
    
print(ans)


Fixed submission:
from sys import stdin
import fractions
mod = 10**9+7
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, pow(b, mod-2,mod))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l = 1
for i in A:
    l = lcm(l,i)
    
for j in A:
    ans += div(l,j)
    ans %= mod
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import fractions
mod = 10**9+7
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l = 1
for i in A:
    l = lcm(l,i)
    
for j in A:
    ans += (l//j)
    ans %= mod
    
print(ans)


Fixed submission:
from sys import stdin
import fractions
mod = 10**9+7
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, pow(b, mod-2,mod))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l = 1
for i in A:
    l = lcm(l,i)
    
for j in A:
    ans += div(l,j)
    ans %= mod
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
mod = 10**9+7
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

maxn = 2*10**6

fac  = [0 for _ in range(maxn)]
finv = [0 for _ in range(maxn)]
inv  = [0 for _ in range(maxn)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,maxn):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod // i) % mod
    finv[i] = finv[i-1] * inv[i] % mod

def combinations(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
A.sort()
for ind,a in enumerate(A):
    ans -= a*combinations(N-ind-1,K-1) % mod
    ans %= mod
    
A.reverse()
for ind,a in enumerate(A):
    ans += a*combinations(N-ind-1,K-1) % mod
    ans %= mod
    
print(ans%mod)

Fixed submission:
from sys import stdin
mod = 10**9+7
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

maxn = 2*10**6

fac  = [0 for _ in range(maxn)]
finv = [0 for _ in range(maxn)]
inv  = [0 for _ in range(maxn)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,maxn):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod // i) % mod
    finv[i] = finv[i-1] * inv[i] % mod

def combinations(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
A.sort()
for ind,a in enumerate(A):
    ans -= a*combinations(N-ind-1,K-1) % mod
    ans %= mod
    
A.reverse()
for ind,a in enumerate(A):
    ans += a*combinations(N-ind-1,K-1) % mod
    ans %= mod
    
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print(min((B-A)//2),N-A,B-1)
else:
    print(min(N-A,B-1))

Fixed submission:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    ans1 = 0
    a1 = A
    b1 = B
    ans1 += (a1-1)
    b1 -= (a1-1)
    a1 = 1
    
    if b1 % 2 == 0:
        b1 -= 1
        ans1 += 1
    ans1 += ((b1 -1)//2)
    
    ans2 = 0
    a2 = A
    b2 = B
    ans2 += (N-B)
    a2 += (N-B)
    b2 += (N-B)
    if (a2 % 2) != (b2 % 2):
        a2 += 1
        ans2 += 1
    ans2 += ((b2 - a2)//2)
    print(min(ans1,ans2,B-1,N-A))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N = int(stdin.readline().rstrip())
S = (stdin.readline().rstrip())
ans = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            i_a = 0
            i_b = 0
            i_c = 0
            for s in S:
                s = int(s)
                if s == a and (not i_a):
                    i_a = 1
                    continue
          
                if i_a and (s == b) and (not i_b):
                    i_b = 1
                    continue

                if i_a and i_b and (s == c):
                    ans += 1
                    break
            
print(ans)

Fixed submission:
from collections import defaultdict
from sys import stdin
N = int(stdin.readline().rstrip())
S = (stdin.readline().rstrip())
d = defaultdict(list)
for ind, i in enumerate(S):
    d[i].append(ind+1)
ans = 0

for a in range(10):
    for b in range(10):
        for c in range(10):
            if (a == b == c) and (len(d[str(a)]) < 3):
                continue
            if d[str(a)] and d[str(b)] and d[str(c)]:
                i_a = d[str(a)][0]
                i_b = -1
                i_c = -1
                for j in d[str(b)]:
                    if i_a < j:
                        i_b = j
                        break
                for k in d[str(c)]:
                    if i_b < k:
                        i_c = k
                        break
                if i_a < i_b < i_c:
                    ans += 1
            else:
                continue
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
D = [int(x) for x in stdin.readline().rstrip().split()]
mod = 998244353
ans = 1
if N == 1 and D[0] == 0:
    print(1)
elif len(set(D))==1:
    print(0)
elif D.count(0) != 1:
    print(0)
elif D[0] != 0:
    print(0)
else:
    tmp = 1
    cnt = Counter(D)
    #print(cnt)
    flag = True
    for i in range(1,max(D)+1):
        #print(cnt[i],tmp)
        if i != 1 and cnt[i] != tmp:
            flag = False
        c = (tmp**cnt[i]) % mod
        ans *= c % mod
        tmp = cnt[i]
        ans = ans % mod
    if flag:
        print(1)
    else:
        print(ans % mod)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
if N % 2 == 0:
    print(N//2-1)
else:
    print(N//2)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import itertools
import bisect
N = int(stdin.readline().rstrip())
L = [int(x) for x in stdin.readline().rstrip().split()]
L.sort()
ans = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = l[j]
        k = bisect.bisect_left(L, a+b)
        ans += (k-j-1)
print(ans)

Fixed submission:
from sys import stdin
import itertools
import bisect
N = int(stdin.readline().rstrip())
L = [int(x) for x in stdin.readline().rstrip().split()]
L.sort()
ans = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        k = bisect.bisect_left(L, a+b)
        ans += (k-j-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
S = (stdin.readline().rstrip())
if S{0} == "S":
    print("Cloudy")
elif S[0] == "C":
    print("Rainy")
else:
    print("Sunny")

Fixed submission:
from sys import stdin
S = (stdin.readline().rstrip())
if S[0] == "S":
    print("Cloudy")
elif S[0] == "C":
    print("Rainy")
else:
    print("Sunny")