Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03001 (python)

Fixed submission:
w,h,x,y=(map(int,input().split()))


if(x+x==w and y+y==h):
		print(w*h/2,1)
else:
	print(w*h/2,0)

Buggy submission (verdict: Runtime Error):
w,h,x,y=(map(int,input().split()))
xeven=(w%2==0)
yeven=(h%2==0)
if(xeven and yeven):
	if(x==w//2 and y==w//2):
		print(w*h/2,1)
elif(xeven and x==w//2):
	print(w*h/2,0)
elif(yeven and y==h//2):
	print(w*h/2,0)
else:
	a=[]
	a.append((0,0,0))
	a.append((0,w,0))
	a.append((h,0,0))
	a.append((h,w,0))
	i=0
	while(i<4):
		a[i][2]=(x-a[0])**2+(y-a[1])**2
		i+=1
	a.sort(key=lambda b:b[2])
	mini=a[0]
	maxi=a[4]
	xclose=abs(mini[0]-x)<abs(mini[1]-y)
	slope=abs(x-maxi[0])/abs(y-maxi[1])
	if(xclose):
		ynew=abs(mini[0]-x)/slope
		print(abs(maxi[1]-mini[1])*(abs(x-maxi[0])+ynew)/2,0)
	else:
		ynew=abs(mini[1]-y)*slope
		print(abs(maxi[0]-mini[0])*(abs(y-maxi[1])+ynew)/2,0)
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

l = [0]*(10**6 +1)
for i in a:
    l[i]+=1
num = 0

for i in range(10**6+1):
    if l[i] == 1:
        num += 1
    if l[i] != 0:
        for j in range(2*i, 10**6+1, i):
            if l[j]:
                l[j] += 1
print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
num = 0
l = []

for i in range(n):
    flag = 0
    if i == 0:
        if a[0]==a[1]:
            l.append(a[0])
            continue
        else:
            l.append(a[0])
            continue

    if a[i] in l:
        continue

    for j in l:
        if a[i]%j:
            flag = 1
            break
        else:
            break

    if flag:
        l.append(a[i])
        if i == 0:
            if a[i] != a[i+1]:
                num += 1
        elif i == n-1:
            if a[i] != a[i-1]:
                num += 1
        elif a[i] != a[i+1] and a[i] != a[i-1]:
            num += 1

print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
num = 0
l = []

for i in range(n):
    flag = 0
    if i == 0:
        if a[0]==a[1]:
            l.append(a[0])
            continue
        else:
            l.append(a[0])
            num += 1
            continue
    for j in l:
        if a[i]%j:
            flag = 1
            break
        else:
            break
    if flag:
        l.append(a[i])
        num += 1

print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
num = 0


for i in range(n):
    flag = 0
    if i == 0 and a[0]==a[1]:
        continue
    for j in range(i):
        if not a[i]%a[j]:
            flag = 1
            break

    if not flag:
        num += 1

print(num)
Problem p02684 (python)

Fixed submission:
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    num = 1
    l = []
    s = [1]*n

    while s[num-1]:
        l.append(num)
        s[num-1] = 0
        num = a[num-1]

    if l.index(num) <= k:
        l2 = l[l.index(num):]
        kk = (k-len(set(l)-set(l2)))%len(l2)
        print(l2[kk])
    else:
        print(l[k])

main()

Buggy submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    num = 1
    l = []
    s = [1]*n

    while s[num-1]:
        l.append(num)
        s[num-1] = 0
        num = a[num-1]
    
    if l.index(num) <= k:
        l2 = l[l.index(num):]
        kk = (k-len(set(l)-set(l2)))%len(l2)
        print(l2[kk])
    else:
        l2 = l[l.index(num):]
        print(l2[k])

main()

Buggy submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    num = 1
    l = []
    s = [1]*n

    while s[num-1]:
        l.append(num)
        s[num-1] = 0
        num = a[num-1]

    if l.index(num) <= k:
        l2 = l[l.index(num):]
        kk = (k-len(set(l)-set(l2)))%len(l2)
        print(l2[kk])
    else:
        print(l2[k])

main()
Problem p02732 (python)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
total = 0

c = Counter(a)

for r in list(c.values()):
    total += (r*(r-1))/2

#print(l)
#print(total)

for i in a:
    score = total - (c[i]-1)
    print(int(score))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = []
total = 0


for i in range(n):
    l.append(a.count(i))


for r in l:
    total += (r*(r-1))/2


#print(l)
#print(total)

for i in a:
    score = total - (l[i]-1)
    print(int(score))
Problem p02755 (python)

Fixed submission:
a, b = map(int, input().split())
num = -1

if a <= b:
    for i in range(1000000):
        if int(i*0.08) == a and int(i*0.1) == b:
            num = i
            break

        elif int(i*0.08) > a or int(i*0.1) > b:
            break

print(num)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

for i in range(1000000):
    if int(i*0.08) == a and int(i*0.1) == b:
        num = i
        break

    elif a/0.08 < b/0.1:
        num = -1
        break

print(num)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

for i in range(1001):
    if int(i*0.08) == a and int(i*0.1) == b:
        num = i
        break

    elif a/0.08 < b/0.1:
        num = -1
        break

print(num)
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
l = [0]*n

for _ in range(m):
    a, s = map(int, input().split())
    s = str(s)
    if n == 1 and (a==1 and s=="0"):
        l[0] = s
    elif (l[a-1] and l[a-1] != s) or (a==1 and s=="0"):
        l = [-1]
        break
    else:
        l[a-1] = s

num = "".join(map(str, l))

if num[0] == "0" and n != 1:
    print("1" + num[1:])
else:
    print(num)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [0]*n

for _ in range(m):
    a, s = map(int, input().split())
    s = str(s)
    if (l[a-1] and l[a-1] != s) or (a==1 and s=="0"):
        l = -1
        break
    else:
        l[a-1] = s

if l == -1:
    print(l)
else:
    print("".join(l))
Problem p02665 (python)

Fixed submission:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
import math

N = INT()
A = LIST()


if (N == 0 and A[0] != 1) or (N > 0 and A[0] != 0):
    print(-1)
    exit()


node_min, node_max = [0]*(N+1), [0]*(N+1)
node_min[-1] = A[-1]
node_max[-1] = A[-1]
for i in reversed(range(N)):
    node_min[i] = math.ceil(node_min[i+1]/2) + A[i]
    node_max[i] = node_max[i+1] + A[i]


if node_min[0] > 1:
    print(-1)
    exit()

ans = 1
node = 1
for i in range(1, N+1):
    node = min(node_max[i], 2*node)
    ans += node
    node = node - A[i]


print(ans)

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
import math

N = INT()
A = LIST()


if (N == 0 and A[0] != 1) or (N > 0 and A[0] != 0):
    print(-1)
    exit()


node_min, node_max = [0]*(N+1), [0]*(N+1)
node_min[-1] = A[-1]
node_max[-1] = A[-1]
for i in reversed(range(N)):
    node_min[i] = max(math.ceil(node_min[i+1]/2) + A[i]
    node_max[i] = node_max[i+1] + A[i]


if node_min[0] > 1:
    print(-1)
    exit()

ans = 1
node = 1
for i in range(1, N+1):
    node = min(node_max[i], 2*node)
    ans += node
    node = node - A[i]


print(ans)
Problem p02696 (python)

Fixed submission:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B, N = MAP()

left, right = 0, N

def f(x):
    return int(A*x/B) - A*int(x/B)


# while right-left > 1:
#     mid1 = (left + right)*1// 3
#     mid2 = (left + right)*2// 3

#     if f(mid1) < f(mid2):
#         if left == mid1:
#             break
#         left = mid1
#     else:
#         if right == mid1:
#             break
#         right = mid2

# ans = f(left)
# for i in range(left, right+1):
#     ans = max(ans, f(i))
# print(ans)
# ans = 0
# # whilefor i in range(1, N+1):
# #     ans = max(ans, f(i))
# # print(ans)

# x = N//2
# if f(x) <= f(x)
# direc = "R"

ans = 0
if B > N:
    ans = f(N)
else:
    ans = f(B-1)

print(ans)

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B, N = MAP()

left, right = 0, N

def f(x):
    return int(A*x/B) - A*int(x/B)


# while right-left > 1:
#     mid1 = (left + right)*1// 3
#     mid2 = (left + right)*2// 3

#     if f(mid1) < f(mid2):
#         if left == mid1:
#             break
#         left = mid1
#     else:
#         if right == mid1:
#             break
#         right = mid2

# ans = f(left)
# for i in range(left, right+1):
#     ans = max(ans, f(i))
# print(ans)
# ans = 0
# # whilefor i in range(1, N+1):
# #     ans = max(ans, f(i))
# # print(ans)

# x = N//2
# if f(x) <= f(x)
# direc = "R"

ans = 0
if B > N:
    ans = f(N)
else:
    ans = f(i*B-1)

print(ans)

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B, N = MAP()

left, right = 0, N

def f(x):
    return int(A*x/B) - A*int(x/B)


# while right-left > 1:
#     mid1 = (left + right)*1// 3
#     mid2 = (left + right)*2// 3

#     if f(mid1) < f(mid2):
#         if left == mid1:
#             break
#         left = mid1
#     else:
#         if right == mid1:
#             break
#         right = mid2

# ans = f(left)
# for i in range(left, right+1):
#     ans = max(ans, f(i))
# print(ans)
# ans = 0
# # whilefor i in range(1, N+1):
# #     ans = max(ans, f(i))
# # print(ans)

# x = N//2
# if f(x) <= f(x)
# direc = "R"

ans = 0
if B > N:
    ans = f(N)
else:
    f(i*B-1)

print(ans)
Problem p02744 (python)

Fixed submission:
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d

N = int(input())

alphabet = "abcdefghijklmnopqrstuvwxyz"

curr_str = []

def print_str(curr_str):
    string = ""
    for i in curr_str:
        string += alphabet[i]
    print(string)


def dfs(index, curr_str, curr_char):
    if curr_char > index:
        return None
    if curr_char > max(curr_str) + 1:
        return None

    if index == N-1:
        print_str(curr_str + [curr_char])
        return None

    for i in range(N):
        dfs(index+1, curr_str+[curr_char], i)


if N == 1:
    print("a")
else:    
    for i in range(N):
        dfs(1, [0], i)

Buggy submission (verdict: Runtime Error):

N = int(input())

alphabet = "abcdefghijklmnopqrstuvwxyz"

curr_str = []

def print_str(curr_str):
    string = ""
    for i in curr_str:
        string += alphabet[i]
    print(string)


def dfs(index, curr_str, curr_char):
    if curr_char > index:
        return None
    if curr_char > max(curr_str) + 1:
        return None

    if index == N-1:
        print_str(curr_str + [curr_char])
        return None

    for i in range(N):
        dfs(index+1, curr_str+[curr_char], i)

for i in range(N):
    dfs(1, [0], i)
Problem p02813 (python)

Fixed submission:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
P = LIST()
Q = LIST()

import itertools

for i, l in enumerate(itertools.permutations(range(1, N+1), N)):
    if list(l) == P:
        a = i+1
    if list(l) == Q:
        b = i+1

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
P = LIST()
Q = LIST()

import itertools

for i, l in enumerate(itertools.permutations(range(1, N+1), N)):
    if list(l) == P:
        a = i+1
    elif list(l) == Q:
        b = i+1

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
P = LIST()
Q = LIST()

import itertools

for i, l in enumerate(itertools.permutations(range(1, N+1), N)):
    if list(l) == P:
        a = i+1
    elif list(l) == Q:
        b = i+1

print(abs(a-b))
Problem p02936 (python)

Fixed submission:
# https://atcoder.jp/contests/abc138/tasks/abc138_d
#　木探索

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

from collections import deque

N, Q = MAP()
counter = [0]*N
tree = [[] for _ in range(N)]
parent = [-1]*N
for _ in range(N-1):
    a, b = MAP()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for _ in range(Q):
    p, x = MAP()
    counter[p-1] += x

q = deque()
q.append(0)

while q:
    index = q.pop()
    pindex = parent[index]
    for i in tree[index]:
        if i == pindex:
            continue
        counter[i] += counter[index]
        parent[i] = index
        q.append(i)

print(*counter)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc138/tasks/abc138_d

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, Q = MAP()
ab = []
for _ in range(N-1):
    a, b = MAP()
    ab.append((a, b))

ans = [None] + [0]*N

check = set()
def dfs(root, x):
    global ans, check
    for i in range(N-1):
        if ab[i][0] == root:
            if root not in check:
                ans[root] += x
                check.add(root)
            ans[ab[i][1]] += x
            check.add(ab[i][1])
            dfs(ab[i][1], x)
        if ab[i][1] == root:
            if root not in check:
                ans[root] += x
                check.add(root)


for _ in range(Q):
    p, x = MAP()
    dfs(p, x)
    check = set()

print(" ".join([str(i) for i in ans[1:]]))
Problem p03031 (python)

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
s = [LIST()[1:] for _ in range(M)]
p = LIST()

ans = 0
for x in product([0, 1], repeat=N):
    for i in range(M):
    	cnt = 0
    	for n in s[i]:
    		if x[n-1] == 1:
    			cnt += 1
    	if cnt%2 != p[i]:
    		break
    else:
    	ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
k = []
s = []
for _ in range(M):
    std_in = list(map(int, input().split()))
    k.append(std_in[0])
    for i in range(std_in[0]):
        std_in[i+1] -= 1
    s.append(std_in[1:])
p = [int(i) for i in input().split()]

switches = [0] * N

def judge_bulbs(switches):
    for i in range(M):

        k_sum = 0
        for ki in range(k[i]):
            k_sum += switches[ki]

        if k_sum % 2 == p[i]:
            continue
        else:
            return False
    return True

def solve(idx, switches):
    if idx == N:
        if judge_bulbs(switches):
            return 1
        else:
            return 0

    ans = 0
    switches = switches.copy()
    
    ans += solve(idx+1, switches)

    switches[idx] = 1
    ans += solve(idx+1, switches)
    return ans

print(solve(0, switches))

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc128/tasks/abc128_c

N, M = map(int, input().split())
k = []
s = []
for _ in range(M):
    std_in = list(map(int, input().split()))
    k.append(std_in[0])
    for i in range(std_in[0]):
        std_in[i+1] -= 1
    s.append(std_in[1:])
p = [int(i) for i in input().split()]

switches = [0] * N

def judge_bulbs(switches):
    for i in range(M):

        k_sum = 0
        for ki in range(k[i]):
            k_sum += switches[ki]

        if k_sum % 2 == p[i]:
            continue
        else:
            return False
    return True

def solve(idx, switches):
    if idx == N:
        if judge_bulbs(switches):
            return 1
        else:
            return 0

    ans = 0
    switches = switches.copy()
    
    ans += solve(idx+1, switches)

    switches[idx] = 1
    ans += solve(idx+1, switches)
    return ans

print(solve(0, switches))
Problem p03161 (python)

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

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()

Buggy submission (verdict: Runtime Error):
#atcoder https://atcoder.jp/contests/dp/tasks/dp_b

N, K = map(int, input().split())
h = list(map(int, input.split()))


dp = [0] * N
dp[0] = 0

for i in range(1, N):

    dp[i] = min(
        dp[k] + abs(h[i]-h[k]) for k in range(max(i-K,0), i)
    )

print(dp[N-1])
Problem p03323 (python)

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

if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
Problem p02642 (python)

Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))



cnt = Counter(A)
A.sort()
ans = 0
P = [0] * (10**6+1)
#print(cnt)
for a in A:
    if P[a]==0:
        for i in range(10**7):
            x = a*i
            if x>10**6:
                break
            P[x] = 1
        if cnt[a]==1:
            ans +=1

print (ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))



cnt = Counter(A)
A.sort()
ans = 0
P = [0] * (10**6+1)
#print(cnt)
for a in A:
    if P[a]==0
        for i in range(10**7):
            x = a*i
            if x>10**6:
                break
            P[x] = 1
        if cnt[a]==1:
            ans +=1

print (ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))

cnt = Counter(A)
A.sort()
ans = 0
for j in range(len(A)):

    a = A[j]
    if cnt[a] > 1:
        continue
    if j==0:
        ans+=1

    i = bisect.bisect_right(A, pow(a,0.5))
    #print(a,i)


    ok = True

    while(i>=0):
        if a % A[i]==0:
            #print (a,A[i])
            ok = False
            break
        i-=1
    if ok:
        #print(a)
        ans+=1
print (ans)
Problem p02665 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
P = [2**i for i in range(len(A))]
import sys
sys.setrecursionlimit(10**9)
# A = A[::-1]
# P = P[::-1]

# ans = 0
# node = 0
# for i in range(len(A)-1):
#     node = node + A[i]
#     node = min(node,2 * (P[i+1] - A[i+1]))
#     ans += node
#     if node <= 0:
#         print (-1)
#         exit()
#     print (node)
    
# ans += 1
# print (ans)

if N==0 and A[0]==1:
    print(1)
    exit()
if A[0] > 0:
    print(-1)
    exit()
# if A[-1] > 2**N:
#     print (-1)
#     exit()

# for a,p in zip(A[::-1],P[::-1]):
#     if a > p:
#         print (-1)
#         exit()

ans = [0]
node = [0]
def rec(i):
    if i==0:
        ans[0]+=1
        return 1
    node[0] = node[0] + A[i]
    node[0] = min(node[0], 2*rec(i-1))
    ans[0] += node[0]
    #print (node[0],node[0]-A[i])

    if (i!=N and node[0] - A[i] <= 0) or (node[0] - A[i] < 0):
        print(-1)
        exit()
    return node[0] - A[i]
rec(N)
print (ans[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
P = [2**i for i in range(len(A))]

# A = A[::-1]
# P = P[::-1]

# ans = 0
# node = 0
# for i in range(len(A)-1):
#     node = node + A[i]
#     node = min(node,2 * (P[i+1] - A[i+1]))
#     ans += node
#     if node <= 0:
#         print (-1)
#         exit()
#     print (node)
    
# ans += 1
# print (ans)

if A[0] > 0:
    print(-1)
    exit()
if A[-1] >= 2**N:
    print (-1)
    exit()

ans = [0]
node = [0]
def rec(i):
    if i==0:
        ans[0]+=1
        return 1
    node[0] = node[0] + A[i]
    node[0] = min(node[0], 2*rec(i-1))
    ans[0] += node[0]
    #print (node[0],node[0]-A[i])
    if i!=N and node[0] - A[i] <= 0:
        print(-1)
        exit()
    return node[0] - A[i]
rec(N)
print (ans[0])
Problem p02702 (python)

Fixed submission:
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**7)
INF = 10**10

N = 2019
cnt = [0] * N
#print (cnt)

def dec(cnt,s):
    new = [0] * N
    for n in range(N):
        idx = (10 * n + s) % N
        new[idx] += cnt[n]
    return new


S = input()[:-1]
ans = 0
for s in S:
    s = int(s)
    cnt = dec(cnt,s)
    cnt[s] += 1
    ans += cnt[0]
    # if cnt[0] != 0:
    #     print (cnt[0])
print (ans)

Buggy submission (verdict: Runtime Error):
S = input()
MOD = 2019
cnt = [0]*MOD
cur = 0 # 現在考えている部分文字列
cnt[cur] = 1 # 部分文字列'0'も作れると考える
d = 1 # 位を表す
for s in for S[::-1]:
    cur += int(s)*d # 新たな桁を追加
    r %= MOD
    cnt[cur] += 1
    # 後処理
    d *= 10 # 位を上げる
    d %= MOD # ただし数が巨大になるため、剰余をとる
ans = 0
for c in cnt:
    ans += c*(c-1)//2
print (ans)
Problem p02714 (python)

Fixed submission:
from collections import Counter
N = int(input())
S = input()
#c = Counter(S)
#print (c.most_common())
#ls = list(c.values())
ans = S.count('R') * S.count('G') * S.count('B')


for i in range(N):
    for j in range(1,N):
        if (i-j<0 or i+j>=N):
            break
        #print (i,j)
        #s = set([S[i-j],S[i],S[i+j]])
        l = S[i-j]
        m = S[i]
        r = S[i+j]

        if l!=m and m!=r and r!=l:
            ans -= 1
        # if len(s)==3:
        #     ans -= 1
print (ans)

Buggy submission (verdict: Runtime Error):
 from collections import Counter
N = int(input())
S = input()
#c = Counter(S)
#print (c.most_common())
#ls = list(c.values())
ans = S.count('R') * S.count('G') * S.count('B')


for i in range(N):
    for j in range(1,N):
        a = i + j
        b = i + j + j
        if (b >= N):
            break
        else:
            l = S[i]
            m = S[a]
            r = S[b]
            if l!=m and m!=r and r!=l:
                ans -= 1
        # if (i-j<0 or i+j>=N):
        #     break
        # l = S[i-j]
        # m = S[i]
        # r = S[i+j]
        # if l!=m and m!=r and r!=l:
        #     ans -= 1
print (ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = input()
c = Counter(S)
#print (c.most_common())
ls = list(c.values())
ans = ls[0] * ls[1] * ls[2]


for i in range(N):
    for j in range(1,N):
        if (i-j<0 or i+j==N):
            break
        #print (i,j)
        s = set([S[i-j],S[i],S[i+j]])
        if len(s)==3:
            ans -= 1
print (ans)
Problem p02717 (python)

Fixed submission:
x,y,z = map(int,input().split())
print (z,x,y)

Buggy submission (verdict: Runtime Error):
code = '9876543210000000000'
def judge(n):
    n = str(n)
    for i in range(len(n)-1):
        ni = int(n[i])
        if abs((ni) - int(n[i+1])) > 1:
            if ni==9:

                return int(n[:i]+code[:len(n)-i])
            else:
                idx = 8 - ni
                return int(n[:i]+code[idx:idx+len(n)-i])
    return -1


i = 1
cnt = 0
k = int(input())
while(1):
    j = judge(i)
    if j==-1:
        cnt += 1

        i+=1
    else:
        i = j
    if cnt == k:
        print(i-1)
        exit()