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

pm = sum(A)
te = 1
if A[0] != 0 or A[N] == 0:
    print(-1)
else:
    for i in A:
        pm -= i
        e = min((e-i) * 2,pm)
        if e < 0:
            break
        te += e
    if e < 0:
        print(-1)
    else:
        print(te)

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

pm = sum(A)
e = 1
te = 1
for i in A:
    pm -= i
    e = min((e-i) * 2,pm)
    if e < 0:
        break
    te += e
if e < 0:
    print(-1)
else:
    print(te)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

pm = sum(A)
te = 1
if A[0] != 0 or A[N] == 0:
    print(-1)
else:
    for i in A:
        pm -= i
        e = min((e-i) * 2,pm)
        if e < 0:
            break
        te += e
    if e < 0:
        print(-1)
    else:
        print(te)

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

pm = sum(A)
e = 1
te = 1
for i in A:
    pm -= i
    e = min((e-i) * 2,pm)
    if e < 0:
        break
    te += e
if e < 0:
    print(-1)
else:
    print(te)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

if A[0] != 0:
    print(-1)
else:
    B = [0]*(N+1)
    C = [0]*(N+1)
    B[0] = 1
    C[N] = A[N]
    flag = True
    for i in range(1,N+1):
        B[i] = (B[i-1]-A[i-1]) * 2
        if (i < N and B[i] <= A[i]) or (i = N and B[i] < A[i]): flag = False
        C[N-i] = C[N+1-i]+A[N-i]
    sum = 0
    for i in range(0,N+1):
        sum += min(B[i],C[i])
    if flag == True:
        print(sum)
    else:
        print(-1)

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

pm = sum(A)
e = 1
te = 1
for i in A:
    pm -= i
    e = min((e-i) * 2,pm)
    if e < 0:
        break
    te += e
if e < 0:
    print(-1)
else:
    print(te)
Buggy python submission (verdict: Runtime Error):
#Beginner COnetst 145 /2019/11/16
#Probrem A
#import math
from operator import mul
from functools import reduce

DEBUG = 0

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def calc(x,y):
    if (x*2-y)%3 != 0 or (y*2-x)%3 != 0: return 0
    m = (x*2-y)//3
    n = (y*2-x)//3
    if m <= 0 or n <= 0:return 0
    return combinations_count(m+n,m)

X,Y = list(map(int, input().split()))

if DEBUG:print(X,Y)

print(calc(X,Y)%(10**9+7))


Fixed submission:
r = int(input())
S=r*r
print(int(S))

Buggy python submission (verdict: Runtime Error):
r = int(input())
S=r*r
print(f'{S}')


Fixed submission:
r = int(input())
S=r*r
print(int(S))

Buggy python submission (verdict: Runtime Error):
r = int(input())
S=r**2
print(f'{S}')


Fixed submission:
r = int(input())
S=r*r
print(int(S))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())

r, pow = 1, 10 ** 18
for num in A:
  r *= num
  if r == 0:
    break
print(-1 if r > pow else r)


Fixed submission:
a, b = map(int, input().split())
print(a * b)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
print(a * b)


Fixed submission:
a, b = map(int, input().split())
print(a * b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())

r = 1
for num in A:
  r *= num
  if r == 0:
    break
print(-1 if r > 10 ** 18 else r)


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

  if 0 in A:
    print(0)
    return

  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)

main ()

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

import functools

r = functools.reduce(lambda x, y: x * y, A, 1)
print(-1 if r > 10 ** 18 else r)


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

  if 0 in A:
    print(0)
    return

  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)

main ()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def gcd(m,n):
    if n==0:
        return m
    return gcd(n,m%n)
##print(gcd(5,3))
##print(gcd(2,4))
k=int(input())
d=defaultdict(int)
t=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            if list((i,j,k)) in [list(x) for x in d.keys()]:
                t+=d[(i,j,k)]
            else:
                d[tuple(sorted((i,j,k)))]=gcd(i,gcd(j,k))
                t+=d[tuple(sorted((i,j,k)))]
print(t)
                
                
            
    


Fixed submission:
from collections import defaultdict
def gcd(m,n):
    if n==0:
        return m
    return gcd(n,m%n)

k=int(input())
t=0
for i in range(1,k+1):
    for j in range(1,k+1):
        g=gcd(i,j)
        for k in range(1,k+1):
            if k%g==0:
                t+=g
            elif g%k==0:
                t+=k
            else:
                t+=gcd(g,k)
print(t)
Buggy python submission (verdict: Runtime Error):
s=input()
if s[2]==s[3] and s[4]==s[5]:
          print("Yes")
else:
          print("No"


Fixed submission:
s=input()
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n,x,y=map(int,input().split())
d=defaultdict(list)
for i in range(1,n):
    for j in range(i+1,n+1):
        r=min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
        d[r].append((i,j))
for i in range(1,n):
    print(len(d[i]))


Fixed submission:
n,x,y=map(int,input().split())
l=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        l[(min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)))-1]+=1
for i in l:
    print(i)
Buggy python submission (verdict: Runtime Error):

def product(a, b):
    return a * b

def judge(num):
    if num % 2 == 0:
        print('Even')
    else:
        print('Odd')

a, b = map(int, input())

judge(product(a, b))

Fixed submission:
def product(a, b):
    return a * b

def judge(num):
    if num % 2 == 0:
        print('Even')
    else:
        print('Odd')

a, b = map(int, input().split())

judge(product(a, b))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split(' '))

res, l, r = 0, 0, 0
while r < n:
  l = r
  while r+1 < n and a[r+1] == a[l]:
    r += 1
  res += (r - l + 1) / 2
  r += 1
print res

Fixed submission:
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split(' '))

res, l, r = 0, 0, 0
while r < n:
  l = r
  while r+1 < n and a[r+1] == a[l]:
    r += 1
  res += (r - l + 1) / 2
  r += 1
print res
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split(' '))
ss, cc = 0, {0: 1}
rs = 0
for k in a:
  ss += k
  cc[k] += 1
  rs += cc[k] - 1

print rs

Fixed submission:
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split(' '))
ss, cc = 0, {0: 1}
rs = 0
for k in a:
  ss += k
  cc[ss] = cc.get(ss, 0) + 1
  rs += cc[ss] - 1

print rs
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N, K, *A = map(int, open(0).read().split())
for _ in range(min(K, 41)):
    next_A = [0] * (N + 1)
    for i, a in enumerate(A):
        next_A[max(0, i - a)] += 1
        next_A[min(N, i + a + 1)] -= 1
    A = list(accumulate(next_A))
A.pop()
print(*A)

Fixed submission:
from itertools import accumulate
N, K, *A = map(int, open(0).read().split())
for _ in range(min(K, 41)):
    next_A = [0] * (N + 1)
    for i, a in enumerate(A):
        next_A[max(0, i - a)] += 1
        next_A[min(N, i + a + 1)] -= 1
    A = list(accumulate(next_A))
A.pop()
print(*A)
Buggy python submission (verdict: Runtime Error):
from statistics import median
N = int(input())
A, B = zip(*tuple(tuple(map(int, input().split())) for _ in range(N)))
print(int((median(B) - median(A)) * (1 + (not N & 1))) + 1)

Fixed submission:
from itertools import accumulate
from bisect import bisect_right
def prime_factorize_dict(n):
    d = dict()
    while not n & 1:
        d[2] = d.get(2, 0) + 1
        n >>= 1
    f = 3
    while f * f <= n:
        if not n % f:
            d[f] = d.get(f, 0) + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = d.get(n, 0) + 1
    return d

N = int(input())
l = list(prime_factorize_dict(N).values())
L = list(accumulate(range(10 ** 6)))
print(sum(bisect_right(L, item) - 1 for item in l))

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
for i in range(2, int(N ** 0.5 + 1)):
    div, rem = divmod(N, i)
    if not rem:
        count += 1
        N = div
print(count + (N > i))

Fixed submission:
from itertools import accumulate
from bisect import bisect_right
def prime_factorize_dict(n):
    d = dict()
    while not n & 1:
        d[2] = d.get(2, 0) + 1
        n >>= 1
    f = 3
    while f * f <= n:
        if not n % f:
            d[f] = d.get(f, 0) + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = d.get(n, 0) + 1
    return d

N = int(input())
l = list(prime_factorize_dict(N).values())
L = list(accumulate(range(10 ** 6)))
print(sum(bisect_right(L, item) - 1 for item in l))
Buggy python submission (verdict: Runtime Error):
from collections import deque
def bfs(graph, N, start):
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        for n in graph[node]:
            if not visited[n]:
                visited[n] = node + 1
                que.append(n)
    return visited

N, M = map(int, input().split())
graph = [[] for _ in range(M)]
for _ in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
visited = bfs(graph, N, 0)[1:]
if all(visited):
    print("Yes")
    print(*visited, sep="\n")
else:
    print("No")

Fixed submission:
from collections import deque
def bfs(graph, N, start):
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        for n in graph[node]:
            if not visited[n]:
                visited[n] = node + 1
                que.append(n)
    return visited

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
visited = bfs(graph, N, 0)[1:]
if all(visited):
    print("Yes")
    print(*visited, sep="\n")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    g = gcd(a, b) * (a // abs(a) if a else 1)
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for a, b in counts.values():
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
print((total + MOD - 1) % MOD)

Fixed submission:
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
zeros = 0
a_zeros = 0
b_zeros = 0
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    if not any((a, b)):
        zeros += 1
        continue
    if not a:
        a_zeros += 1
        continue
    if not b:
        b_zeros += 1
        continue
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for k, v in counts.items():
    a, b = v
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
total = (total * (pow(2, a_zeros, MOD) + pow(2, b_zeros, MOD) - 1)) % MOD
print((total + zeros + MOD - 1) % MOD)

Buggy python submission (verdict: Runtime Error):
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for a, b in counts.values():
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
print((total + MOD - 1) % MOD)

Fixed submission:
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
zeros = 0
a_zeros = 0
b_zeros = 0
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    if not any((a, b)):
        zeros += 1
        continue
    if not a:
        a_zeros += 1
        continue
    if not b:
        b_zeros += 1
        continue
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for k, v in counts.items():
    a, b = v
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
total = (total * (pow(2, a_zeros, MOD) + pow(2, b_zeros, MOD) - 1)) % MOD
print((total + zeros + MOD - 1) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [(f := 1) if not i else (f := f * i % MOD) for i in range(FACT_MAX)]
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)

Fixed submission:
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)

Buggy python submission (verdict: Runtime Error):
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [(f := 1 if not i else (f := f * i % MOD)) for i in range(FACT_MAX)]
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)

Fixed submission:
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [(f := 1 if not i else (f := f * i % MOD)) for i in range(FACT_MAX)]
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)

Fixed submission:
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)
Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
dic = {
    "A": A,
    "B": B,
    "C": C
}
ans = [0] * N
def part_solve(dic, depth):
    while depth < N:
        key1, key2 = inputs[depth]
        if dic[key1] < dic[key2]:
            dic[key1] += 1
            dic[key2] -= 1
            ans[depth] = key1
        elif dic[key1] > dic[key2]:
            dic[key2] += 1
            dic[key1] -= 1
            ans[depth] = key2
        else:
            if not dic[key1]:
                return False
            else:
                key3 = "ABC".replace(key1, "").replace(key2, "")
                return part_solve({
                    key1: dic[key1] + 1,
                    key2: dic[key2] - 1,
                    key3: dic[key3]
                }, depth) or part_solve({
                    key1: dic[key1] - 1,
                    key2: dic[key2] + 1,
                    key3: dic[key3]
                }, depth)
        depth += 1
    return True

inputs = tuple(tuple(input()) for _ in range(N))
if part_solve(dic, 0):
    print("Yes")
    print(*ans, sep="\n")
else:
    print("No")


Fixed submission:
N, A, B, C = map(int, input().split())
inputs = tuple(tuple(input()) for _ in range(N))

dic = {
    "A": A,
    "B": B,
    "C": C
}

ans = [0] * N
depth = 0
while depth < N:
    key1, key2 = inputs[depth]
    if dic[key1] < dic[key2]:
        dic[key1] += 1
        dic[key2] -= 1
        ans[depth] = key1
    elif dic[key1] > dic[key2]:
        dic[key2] += 1
        dic[key1] -= 1
        ans[depth] = key2
    else:
        if not dic[key1]:
            break
        elif dic[key1] == 1 and depth + 1 < N:
            next_key1, next_key2 = inputs[depth + 1]
            common_key, *_ = {key1, key2} & {next_key1, next_key2}
            else_key, *_ = {key1, key2} - {common_key}
            dic[common_key] += 1
            dic[else_key] -= 1
            ans[depth] = common_key
        else:
            dic[key1] += 1
            dic[key2] -= 1
            ans[depth] = key1
    depth += 1
else:
    print("Yes")
    print(*ans, sep="\n")
    quit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D = map(int, input().split())
turn = 0
while (turn := turn + 1) and ((C := C - B) if turn & 1 else (A := A - D)): pass
print("Yes" if turn & 1 else "No")


Fixed submission:
A, B, C, D = map(int, input().split())
turn = 0
while (turn := turn + 1) and ((C := C - B) if turn & 1 else (A := A - D)) > 0: pass
print("Yes" if turn & 1 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
from math import log10
from collections import Counter
S = int(input())
l = int(log10(S)) + 1
counts = Counter((S := S % 10 ** (l - i)) % 2019 for i in range(l + 1))
print(sum(n * (n - 1) // 2 for n in counts.values()))


Fixed submission:
from collections import Counter
S = list(reversed(input()))
l = len(S)
N = 0
counts = Counter([(N := N + (pow(10, i, 2019) * int(S[i])) % 2019) % 2019 for i in range(l)] + [0])
print(sum(n * (n - 1) // 2 for n in counts.values()))

Buggy python submission (verdict: Runtime Error):
from math import log10
from collections import Counter
S = int(input())
l = int(log10(S)) + 1
print(sum(n * (n - 1) // 2 for n in Counter((S := S % 10 ** (l - i)) % 2019 for i in range(l + 1)).values()))


Fixed submission:
from collections import Counter
S = list(reversed(input()))
l = len(S)
N = 0
counts = Counter([(N := N + (pow(10, i, 2019) * int(S[i])) % 2019) % 2019 for i in range(l)] + [0])
print(sum(n * (n - 1) // 2 for n in counts.values()))

Buggy python submission (verdict: Time Limit Exceeded):
from math import log10
from collections import Counter
from scipy.special import comb
S = int(input())
l = int(log10(S)) + 1
counts = Counter((S := S % 10 ** (l - i)) % 2019 for i in range(l + 1))
print(sum(comb(n, 2, exact=True) for n in counts.values()))


Fixed submission:
from collections import Counter
S = list(reversed(input()))
l = len(S)
N = 0
counts = Counter([(N := N + (pow(10, i, 2019) * int(S[i])) % 2019) % 2019 for i in range(l)] + [0])
print(sum(n * (n - 1) // 2 for n in counts.values()))
Buggy python submission (verdict: Runtime Error):
from numpy import prod
N = int(input())
S = input()
appearances = {"R": 0, "G": 0, "B": 0}
for c in S:
    appearances[c] += 1
print(prod(list(appearances.values())) - sum(sum(len(set(S[start] + S[start + step] + S[start + step * 2])) == 3 for start in range(N - step * 2)) for step in range(1, N // 2 + 1)))


Fixed submission:
from numpy import prod
N = int(input())
S = input()
appearances = {"R": 0, "G": 0, "B": 0}
for c in S:
    appearances[c] += 1
print(prod(list(appearances.values())) - sum(sum(len(set(S[start] + S[start + step] + S[start + step * 2])) == 3 for start in range(N - step * 2)) for step in range(1, N // 2 + 1)))

Buggy python submission (verdict: Runtime Error):
def diff_is_unequal(a, b, c):
    s, m, l = sorted([a, b, c])
    return (m - s) != (l - m)

input()
indices = dict()
for idx, c in enumerate(input()):
    indices[c] = indices.get(c, []) + [idx]

print(sum(diff_is_unequal(r, g, b) for b in indices["B"] for g in indices["G"] for r in indices["R"]))


Fixed submission:
from numpy import prod
N = int(input())
S = input()
appearances = {"R": 0, "G": 0, "B": 0}
for c in S:
    appearances[c] += 1
print(prod(list(appearances.values())) - sum(sum(len(set(S[start] + S[start + step] + S[start + step * 2])) == 3 for start in range(N - step * 2)) for step in range(1, N // 2 + 1)))
Buggy python submission (verdict: Runtime Error):
K = int(input())
if K < 13:
    print(K)
    quit()

now = [*range(1, 10)]

count = 9
while True:
    nxt = []
    for l in now:
        tail = l % 10
        for t in range(max(0, tail - 1), min(10, tail + 2)):
            nxt.append(l * 10 + t)
            count += 1
            if count == K:
                print(l * 10 + t)
                quit()
    now = nxt


Fixed submission:
K = int(input())
if K < 13:
    print(K)
    quit()

now = list(range(1, 10))

count = 9
while True:
    nxt = []
    for l in now:
        tail = l % 10
        for t in range(max(0, tail - 1), min(10, tail + 2)):
            nxt.append(l * 10 + t)
            count += 1
            if count == K:
                print(l * 10 + t)
                quit()
    now = nxt
Buggy python submission (verdict: Runtime Error):
import numpy as np

def divisors(N):
    return sorted(sum(([*{n, N // n}] for n in range(1, int(N ** 0.5) + 1) if not N % n), []))

def prime_factorize_dict(n):
    d = dict()
    while not n & 1:
        d[2] = d.get(2, 0) + 1
        n >>= 1
    f = 3
    while f * f <= n:
        if not n % f:
            d[f] = d.get(f, 0) + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = d.get(n, 0) + 1
    return d

N = int(input())
count = 0
for n in divisors(N)[1:]:
    M = N
    while not M % n:
        M //= n
    count += M % n == 1
fact_Nm1 = np.array(list(prime_factorize_dict(N - 1).values()), dtype=np.int32)
print(count + np.prod(fact_Nm1 + 1) - 1)

Fixed submission:
import numpy as np

def divisors(N):
    return sorted(sum((list({n, N // n}) for n in range(1, int(N ** 0.5) + 1) if not N % n), []))

def prime_factorize_dict(n):
    d = dict()
    while not n & 1:
        d[2] = d.get(2, 0) + 1
        n >>= 1
    f = 3
    while f * f <= n:
        if not n % f:
            d[f] = d.get(f, 0) + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = d.get(n, 0) + 1
    return d

N = int(input())
count = 0
for n in divisors(N)[1:]:
    M = N
    while not M % n:
        M //= n
    count += M % n == 1
fact_Nm1 = np.array(list(prime_factorize_dict(N - 1).values()), dtype=np.int32)
print(count + np.prod(fact_Nm1 + 1) - 1)