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


index = 0
index2 = 0
stackedTime = 0

while(index<N and stackedTime + A[index] <= K):
  stackedTime += A[index]
  index += 1

while(index2 < M and stackedTime + B[index2] <= K):
  stackedTime += B[index2]
  index2 += 1

maxBook = index + index2
for i in range(N):
  if(index == 0 or index2 == M):
    break
  index -= 1
  stackedTime -= A[index]
  while(index2 < M and stackedTime + B[index2] <= K):
    stackedTime += B[index]
    index2 += 1

  maxBook = max(maxBook, index + index2)

print(maxBook)


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


index = 0
index2 = 0
stackedTime = 0

while(index<N and stackedTime + A[index] <= K):
  stackedTime += A[index]
  index += 1

while(index2 < M and stackedTime + B[index2] <= K):
  stackedTime += B[index2]
  index2 += 1

maxBook = index + index2
for i in range(N):
  if(index == 0 or index2 == M):
    break
  index -= 1
  stackedTime -= A[index]
  while(index2 < M and stackedTime + B[index2] <= K):
    stackedTime += B[index2]
    index2 += 1

  maxBook = max(maxBook, index + index2)

print(maxBook)
Buggy python submission (verdict: Runtime Error):
import queue

n, m = map(int, input().split())

road = [[] for i in range(m)]

for i in range(m):
    a, b = map(int, input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

# cost to isMin
result = [[999999999999999, None, False] for i in range(n)]

# from tom
q = queue.Queue()

result[0] = [0, None, True]
for i in road[0]:
    q.put([0,i])

while not q.empty():
    n = q.get()
    result[n[1]]=[result[n[0]][0]+1, n[0], True]
    for i in road[n[1]]:
        if(not result[i][2]):
            q.put([n[1], i])

flag = True
for i in result:
    if(not i[2]):
        flag = False
        break

if(flag):
    print("Yes")
    for i in range(1,len(result)):
        print(result[i][1]+1)
else:
    print("No")


    



Fixed submission:
import queue

n, m = map(int, input().split())

road = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

# cost to isMin
result = [[999999999999999, None, False] for i in range(n)]

# from tom
q = queue.Queue()

result[0] = [0, None, True]
for i in road[0]:
    q.put([0,i])

while not q.empty():
    n = q.get()
    if(not result[n[1]][2]):
        result[n[1]]=[result[n[0]][0]+1, n[0], True]
        for i in road[n[1]]:
            q.put([n[1], i])

flag = True
for i in result:
    if(not i[2]):
        flag = False
        break

if(flag):
    print("Yes")
    for i in range(1,len(result)):
        print(result[i][1]+1)
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import queue

n, m = map(int, input().split())

road = [[] for i in range(m)]

for i in range(m):
    a, b = map(int, input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

# cost to isMin
result = [[999999999999999, None, False] for i in range(n)]

# from tom
q = queue.Queue()

result[0] = [0, None, True]
for i in road[0]:
    q.put([0,i])

while not q.empty():
    n = q.get()
    if(not result[n[1]][2]):
        result[n[1]]=[result[n[0]][0]+1, n[0], True]
        for i in road[n[1]]:
            q.put([n[1], i])

flag = True
for i in result:
    if(not i[2]):
        flag = False
        break

if(flag):
    print("Yes")
    for i in range(1,len(result)):
        print(result[i][1]+1)
else:
    print("No")


    



Fixed submission:
import queue

n, m = map(int, input().split())

road = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

# cost to isMin
result = [[999999999999999, None, False] for i in range(n)]

# from tom
q = queue.Queue()

result[0] = [0, None, True]
for i in road[0]:
    q.put([0,i])

while not q.empty():
    n = q.get()
    if(not result[n[1]][2]):
        result[n[1]]=[result[n[0]][0]+1, n[0], True]
        for i in road[n[1]]:
            q.put([n[1], i])

flag = True
for i in result:
    if(not i[2]):
        flag = False
        break

if(flag):
    print("Yes")
    for i in range(1,len(result)):
        print(result[i][1]+1)
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
yen = map(int, input().slice(" "))
if yen[0] * 500 >= yen[1]:
    print("Yes")
else:
    print("No")

Fixed submission:
k,x = map(int, input().split())
if(k * 500 >= x):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):

def digits_of(n):
    digits = []
    while n != 0:
        r = n % 10
        digits.append(r) 
        n = n // 10 
    return digits

def is_multiple_of_9 (n):
    sum = 0
    for i in digits_of (n):
        sum += i
    if sum % 9 == 0:
        print("Yes")
    else:
        print("No")

def main():
    n = int(input())
    is_multiple_of_9(n)

main()

Fixed submission:
def main():
    n = int(input())
    if n == 0:
        print("Yes")
    elif n % 9 == 0:
        print("Yes")
    else:
        print("No")

main()

Buggy python submission (verdict: Time Limit Exceeded):

def digits_of(n):
    digits = []
    while n != 0:
        r = n % 10
        digits.append(r) 
        n = n // 10 
    return digits

def is_multiple_of_9 (n):
    sum = 0
    for i in digits_of (n):
        sum += i
    if sum % 9 == 0:
        print("Yes")
    else:
        print("No")

def main():
    n = int(input())
    is_multiple_of_9(n)

main()

Fixed submission:
def main():
    n = int(input())
    if n == 0:
        print("Yes")
    elif n % 9 == 0:
        print("Yes")
    else:
        print("No")

main()
Buggy python submission (verdict: Runtime Error):
n = input()

num = 0
for i in range(1, n+1):
    a = input()
    if i % 2 != 0:
        if a % 2 != 0:
            num = num + a

print(num)



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

num = 0
for i in range(0, len(a)):
    w = i + 1
    if w % 2 != 0:
        if a[i] % 2 != 0:
            num = num + 1

print(num)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

def main():
    if n == 0:
        print(x)
        return

    ans_l = list(range(1, 100))

    diff_l = list(set(p) ^ set(ans_l))
    diff_l.sort()

    cnt = 100
    ans = 100
    for i in range(0, len(diff_l)):
        check = abs(diff_l[i]-x)
        if check < cnt:
            cnt = check
            ans = diff_l[i]
    print(ans)
    return

main()

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

def main():
    if n == 0:
        print(x)
        return

    ans_l = list(range(-100, 201))

    diff_l = list(set(p) ^ set(ans_l))
    diff_l.sort()

    cnt = 100
    ans = 100
    for i in range(0, len(diff_l)):
        check = abs(diff_l[i]-x)
        if check < cnt:
            cnt = check
            ans = diff_l[i]
    print(ans)
    return

main()
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int, input().split())

cnt = 0

if k >= a:
    k = k - a #3
    cnt = cnt + 1*a  #1

    if k >= b:
        k = k - b #1

        if k >= c:
            cnt = cnt + -1*c
            k = k - c

        else:
            for i in range(0, k):
                cnt += -1
                k -= 1
    
    else:
        for i in range(0, k):
            k -= 1

else:
    for i in range(0, k):
        cnt += 1
        k -= 1
print(cnt)

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

cnt = 0

if k >= a:
    k = k - a #3
    cnt = cnt + 1*a  #1

    if k >= b:
        k = k - b #1

        if k >= c:
            cnt = cnt + -1*c
            k = k - c

        else:
            cnt = cnt + -1*k
            k = k - k
    
    else:
        k = k - k

else:
    cnt = cnt + 1*k
    k = k - k
    
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int, input().split())

cnt = 0

if a <= k:
    cnt = cnt + 1*a #1
    k = k - a #3
elif a > k:
    for i in range(0, k):
        cnt += 1
        k -= 1

if b <= k:
    k = k - b #1
elif b > k:
    for i in range(0, k):
        k -= 1

if c <= k:
    cnt = cnt + -1*c
    k = k - c
elif c > k:
    for i in range(0, k):
        cnt += -1
        k -= 1

print(cnt)

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

cnt = 0

if k >= a:
    k = k - a #3
    cnt = cnt + 1*a  #1

    if k >= b:
        k = k - b #1

        if k >= c:
            cnt = cnt + -1*c
            k = k - c

        else:
            cnt = cnt + -1*k
            k = k - k
    
    else:
        k = k - k

else:
    cnt = cnt + 1*k
    k = k - k
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(input().split())
l = [0] * n

for i in range(0, int(m)):
    a, b = map(int, input().split())
    a_int = int(h[int(a)-1])
    b_int = int(h[int(b)-1])

    if (a_int < b_int):
        l[b_int - 1] = 1
       
cnt = 0
for k in range(0, len(l)):
    if(l[k]==1):
        cnt+=1

print(cnt)

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

for i in range(0, int(m)):
    a, b = map(int, input().split())
    a_int = int(h[int(a)-1])
    b_int = int(h[int(b)-1])

    if (a_int < b_int):
        l[a - 1] = 0
    
    if (a_int > b_int):
        l[b - 1] = 0
    
    if (l[a-1] == 1):
        if (a_int == b_int):
            l[a - 1] = 0
            l[b - 1] = 0
    elif (l[b-1] == 1):
        if (a_int == b_int):
            l[a - 1] = 0
            l[b - 1] = 0 
       
cnt = 0
for k in range(0, len(l)):
    if(l[k]==1):
        cnt+=1

print(cnt)
Buggy python submission (verdict: Runtime Error):
r = int(input())
ans = 2r * 3.14
print(ans)

Fixed submission:
r = int(input())
ans = (r + r) * 3.14 
print(ans)
Buggy python submission (verdict: Runtime Error):
day = list(int(input()))
ans = list(int(input()))
num = 0
for i in range(0, len(ans)):
    num += ans[i]

target = day[0] - num

if target >= 0:
    print(target)
else:
    print("-1")

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

num = 0
for i in range(0, len(a)):
    num += int(a[i])

target = n - num

if target >= 0:
    print(target)
else:
    print("-1")
Buggy python submission (verdict: Runtime Error):
n = list(str(input()))

cnt = 0
for i in range(0, len(n)):
    if int(s[i]) == 7:
        print("Yes")
        cnt += 1
        break
if cnt == 0:
    print("No") 

Fixed submission:
n = list(str(input()))

cnt = 0
for i in range(0, len(n)):
    if int(n[i]) == 7:
        print("Yes")
        cnt += 1
        break
if cnt == 0:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())

ans = 0

for i in range(1,n):
    m = n - i
    soinsu = 0
    for j in range(1, m+1):
        if m % j == 0:
            soinsu += 1
    ans += soinsu

print(ans)

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

n = int(input())
ans = 0
for i in range(1, n):
    ans += (n-1) // i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
AS = list(map(int,input().split()))

m = 1
j = 0

if 0 in AS:
    print(0)
    j = 1

for i in AS:
    m = m * i
    if m > 10**18 and j == 0:
        print(-1)
        j = 1
        break
    elif m == 0:
        break
    else:
        continue

if j == 0:
    print(m)

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

n = int(input())
AS = list(map(int,input().split()))

m = 1
j = 0

if 0 in AS:
    print(0)
    j = 1
    

if j == 0:
    for i in AS:
        m = m * i
        if m > 10**18 and j == 0:
            print(-1)
            j = 1
            break
        elif m == 0:
            break
        else:
            continue

if j == 0:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
AS = list(map(int,input().split()))

m = 1
for i in AS:
    m = m * i

if m > 10**18:
    print(-1)
else:
    print(m)

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

n = int(input())
AS = list(map(int,input().split()))

m = 1
j = 0

if 0 in AS:
    print(0)
    j = 1
    

if j == 0:
    for i in AS:
        m = m * i
        if m > 10**18 and j == 0:
            print(-1)
            j = 1
            break
        elif m == 0:
            break
        else:
            continue

if j == 0:
    print(m)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def comb(n):
    if n == 1:
        return 0
    else:
        return int(n*(n-1)/2)

n = int(input())
AS = list(map(int,input().split()))

origin = list(set(AS))
num = []
for i in origin:
    num.append(AS.count(i))
comb_list = [-1]*(max(num)+1)
all_num = 0
for i in num:
    if comb_list[i] == -1:
        all_num += comb(i)
        comb_list[i] = comb(i)
    else:
        all_num += comb_list[i]
    
for i in range(n):
    j = num[origin.index(AS[i])]
    ans = all_num - (j-1)
    print(ans)

Fixed submission:
from math import factorial

n, m = map(int, input().split())
if n > 1 and m > 1:
    print(int(factorial(n)/factorial(2)/factorial(n-2) + factorial(m)/factorial(2)/factorial(m-2)))
elif n > 1:
    print(int(factorial(n)/factorial(2)/factorial(n-2)))
elif m > 1:
    print(int(factorial(m)/factorial(2)/factorial(m-2)))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
m1,d1 = map(int,input().split)
m2,d2 = map(int,input().split)
if d2 == 1:
	print(1)
else:
	print(0)

Fixed submission:
m,d = map(int,input().split())
mm,dd = map(int,input().split())
if dd == 1:
	print(1)
else:
	print(0)
Buggy python submission (verdict: Runtime Error):
s = input()
li = [-1,1]
a = '+'
b = '+'
c = '+'
for i in li:
	for j in li:
		for k in li:
			if int(s[0])+(i*int(s[1]))+(j*int(s[2]))+(k*int(s[3])) == 7:
				if i == -1:
					a = '-'
				if j == -1:
					b = '-'
				if k == -1:
					c = '-'
				print(s[0] + a + s[1] + b + s[2] + c + s[3] + '=7')
				break
		else:
			continue
		break
	else:
		contiue
	break


Fixed submission:
s = input()
li = [-1,1]
a = '+'
b = '+'
c = '+'
for i in li:
	for j in li:
		for k in li:
			if int(s[0])+(i*int(s[1]))+(j*int(s[2]))+(k*int(s[3])) == 7:
				if i == -1:
					a = '-'
				if j == -1:
					b = '-'
				if k == -1:
					c = '-'
				print(s[0] + a + s[1] + b + s[2] + c + s[3] + '=7')
				break
		else:
			continue
		break
	else:
		continue
	break
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
 
a=list(map(int,input().split()))
num=0
for i in range(n):
  for j in range(n-1,i,-1):
    num=num+a[i]*a[j]
else:
  print(num % 1000000007)

Fixed submission:
n=int(input())

l = 1000000007
a=list(map(int,input().split()))
s = sum(a)
num = 0
for i in range(n):
  s = s- a[i]
  num =num+a[i]*s
else:
  print(num%l)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans = 0
for i in range(n-2):
  s = a[i+1] -a[i] 
  if s >=0:
    ans = ans +0
    else:
      ans = ans - s
      a[i+1]=a[i]-s
else:
  print(ans)
      

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans = 0
for i in range(n-1):
  s = a[i+1] -a[i] 
  if s < 0:
      ans = ans - s
      a[i+1]=a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a =int(input())
b =int(input())
if a & 2 ==0 or b % 2 == 0:
  print("Even")
else:
  print("Odd")


Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 ==0 :
  print("Even")
else:
  print("Odd")

Buggy python submission (verdict: Runtime Error):
a =int(input())
b =int(input())
if a & 2 ==0 or a % 2 == 0:
  print("Even")
else:
  print("Odd")

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 ==0 :
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = list(map(int,input().split()))

ans = 1
for i in ls:
    ans *= i

if ans > 10**18:
    print("-1")
else:
    print(ans)

Fixed submission:
import math
n = int(input())
li = sorted(list(map(int,input().split())), reverse = True)

if 0 in li:
    print(0)
else:
    ans = 1
    limit = 10**18
    for i in range(n):
        if li[i] > limit:
            ans = -1
            break
        else:
            ans = ans * li[i]
            limit = limit/li[i]
    if ans > 10**18:
        ans = -1
    print(ans)
Buggy python submission (verdict: Runtime Error):
import decimal
import math
a, b = map(float,input().split())
a = Decimal("a")
b = Decimal("b")
print(a*b)

Fixed submission:
from decimal import Decimal
a, b = map(str,input().split())
c = Decimal(a)
d = Decimal(b)
e = c * d
print(int(e))
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 1:
    print(0)
else:
    answer = 0
    for factor in factorization(n):
        x = factor[1]
        kouho = int((2*x)**0.5)-1
        if (kouho)*(kouho+1)/2 <=x and x < (kouho+1)*(kouho+2)/2:
            kaisu = kouho
        else:
            kaisu = kouho+1
        answer += kaisu

    print(answer)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
if n == 1:
    print(0)
else:
    answer = 0
    for factor in factorization(n):
        x = factor[1]
        kouho = int((2*x)**0.5)-1
        if (kouho)*(kouho+1)/2 <=x and x < (kouho+1)*(kouho+2)/2:
            kaisu = kouho
        else:
            kaisu = kouho+1
        answer += kaisu

    print(answer)
Buggy python submission (verdict: Runtime Error):

blist.sort()
# 偶数の場合
if N % 2 == 0:
    median1 = N/2
    median2 = N/2 + 1
    median1 = int(median1) - 1
    median2 = int(median2) - 1
    amedian = (alist[median1] + alist[median2]) / 2
    bmedian = (blist[median1] + blist[median2]) / 2
    print(bmedian-amedian+1)
# 奇数の場合
else:
    median = (N + 1) / 2
    median = int(median) - 1
    amedian = alist[median]
    bmedian = blist[median]
    print((bmedian-amedian)*2+1)


Fixed submission:
n = int(input())
alist = []
blist = []
for i in range(n):
    a,b = map(int,input().split())
    alist.append(a)
    blist.append(b)

N = len(alist)
alist.sort()
blist.sort()
# 偶数の場合
if N % 2 == 0:
    median1 = N/2
    median2 = N/2 + 1
    median1 = int(median1) - 1
    median2 = int(median2) - 1
    amedian = (alist[median1] + alist[median2]) / 2
    bmedian = (blist[median1] + blist[median2]) / 2
    ans = (bmedian-amedian)*2+1
# 奇数の場合
else:
    median = (N + 1) / 2
    median = int(median) - 1
    amedian = alist[median]
    bmedian = blist[median]
    ans = bmedian-amedian+1
print(int(ans))
Buggy python submission (verdict: Runtime Error):
import math
a,b,n = map(int,input().split())

if b =< n:
    k = math.floor(n/b)
    ans = max(math.floor(a*(b-1)/b), math.floor(a*n/b)- a*math.floor(n/b),math.floor(a*(k*b-1)/b)-a*math.floor((k*b-1)/b))
    print(ans)
else:
    print(math.floor(a*n/b))


Fixed submission:
import math
a,b,n = map(int,input().split())
print(min(math.floor(a*n/b),math.floor(a*(b-1)/b)))
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
print(len(c))

Fixed submission:
s,w = map(int,input().split())
if s <=w:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
n = int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
print(len(c))



Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
print(len(set(s)))

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
print(len(c))



Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
print(len(set(s)))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
prize_list=[]
for i in range(n):
    x = input()
    if x not in prize_list:
        prize_list.append(x)

print(len(prize_list))

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
print(len(set(s)))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
prize_list=[]
for i in range(n):
    x = input()
    if x not in prize_list:
        prize_list.append(x)

print(len(prize_list))

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
print(len(set(s)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

rlist, glist, blist = [], [], []
for i in range(N):
    if S[i] == "R":
        rlist.append(i)
    elif S[i] == "G":
        glist.append(i)
    else:
        blist.append(i)

rnumber = len(rlist)
gnumber = len(glist)
bnumber = N - rnumber - gnumber
total = rnumber * gnumber * bnumber

overcount = 0
for r in rlist:
    for g in glist:
        if (2*r-g) in blist: 
            overcount +=1
        if (2*g-r) in blist:
            overcount +=1
        if (r+g)/2 in blist:
            overcount +=1            
print(total - overcount)

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

x = S.count("R")
y = S.count("G")

total = x*y*(N-x-y)

count = 0
for i in range(N):
    texta = S[i]
    for j in range(i,int((N-1+i)/2)+1):
        if S[j] != texta:
            textb = S[j]
            if S[2*j-i] != texta and S[2*j-i] !=textb:
                count += 1

print(total - count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

rlist, glist, blist = [], [], []
for i in range(N):
    if S[i] == "R":
        rlist.append(i)
    elif S[i] == "G":
        glist.append(i)
    else:
        blist.append(i)

rnumber = len(rlist)
gnumber = len(glist)
bnumber = N - rnumber - gnumber
total = rnumber * gnumber * bnumber

overcount = 0
for r in rlist:
    for g in glist:
        for b in blist:
            options = sorted([r,g,b])
            if options[0]+options[2] == 2*options[1]:
                overcount += 1
    
print(total - overcount)

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

x = S.count("R")
y = S.count("G")

total = x*y*(N-x-y)

count = 0
for i in range(N):
    texta = S[i]
    for j in range(i,int((N-1+i)/2)+1):
        if S[j] != texta:
            textb = S[j]
            if S[2*j-i] != texta and S[2*j-i] !=textb:
                count += 1

print(total - count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

rlist, glist, blist = [], [], []
for i in range(N):
    if S[i] == "R":
        rlist.append(i)
    if S[i] == "G":
        glist.append(i)
    if S[i] == "B":
        blist.append(i)
#print(rlist)

rnumber = len(rlist)
gnumber = len(glist)
bnumber = len(blist)
total = rnumber * gnumber * bnumber
#print(total)

overcount = 0
for r in rlist:
    for g in glist:
        for b in blist:
            options = sorted([r,g,b])
            if options[0]+options[2] == 2*options[1]:
                overcount += 1
    
print(total - overcount)

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

x = S.count("R")
y = S.count("G")

total = x*y*(N-x-y)

count = 0
for i in range(N):
    texta = S[i]
    for j in range(i,int((N-1+i)/2)+1):
        if S[j] != texta:
            textb = S[j]
            if S[2*j-i] != texta and S[2*j-i] !=textb:
                count += 1

print(total - count)
Buggy python submission (verdict: Runtime Error):
M = 1000000007
n = int(input())
a = list(map(int,input().split()))
S = [0]
for i in range(n):
 S.append(S[-1]+a[i])%M
sum = 0
for i in range(n-1):
 sum += (a[i]*(S[n]-S[i+1]))%M
print(sum%M)


Fixed submission:
M = 1000000007
n = int(input())
a = list(map(int,input().split()))
S = [0]
for i in range(n):
 S.append((S[-1]+a[i])%M)
sum = 0
for i in range(n-1):
 sum += (a[i]*(S[n]-S[i+1]))%M
print(sum%M)