Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from fraction import gcd
A, B, C, D = map(int, input().split())
BdivC, BdivD = B // C, B // D
AdivC, AdivD = A // C, A // D
GCD = gcd(C, D)
BdivCD, AdivCD = B // ((C * D) // GCD), A // ((C * D) // GCD)
N1 = BdivC + BdivD - BdivCD
N2 = AdivC + AdivD - AdivCD
ans = (B - A) - (N1 - N2)
if(A % C != 0): ans += 1
print(ans)


Fixed submission:
from fractions import gcd
A, B, C, D = map(int, input().split())
BdivC, BdivD = B // C, B // D
AdivC, AdivD = A // C, A // D
GCD = gcd(C, D)
BdivCD, AdivCD = B // ((C * D) // GCD), A // ((C * D) // GCD)
N1 = BdivC + BdivD - BdivCD
N2 = AdivC + AdivD - AdivCD
ans = (B - A) - (N1 - N2)
if(A % C != 0): ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
l, r = [0] * Q, [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
for i in range(Q):
    print(S[l[i] - 1:r[i]].count("AC"))


Fixed submission:
N, Q = map(int, input().split())
S = input()
l, r = [0] * Q, [0] * Q
cnt = [0] * len(S)
for i in range(Q):
    l[i], r[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
for i in range(1, len(S)):
    if(i == 0): pass
    cnt[i] = cnt[i - 1]
    if (S[i] == 'C' and S[i - 1] == 'A'):
        cnt[i] += 1
for i in range(Q):
    print(cnt[r[i]] - cnt[l[i]])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
l, r = [0] * Q, [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
for i in range(Q):
    print(S[l[i] - 1:r[i]].count("AC"))


Fixed submission:
N, Q = map(int, input().split())
S = input()
l, r = [0] * Q, [0] * Q
cnt = [0] * len(S)
for i in range(Q):
    l[i], r[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
for i in range(1, len(S)):
    if(i == 0): pass
    cnt[i] = cnt[i - 1]
    if (S[i] == 'C' and S[i - 1] == 'A'):
        cnt[i] += 1
for i in range(Q):
    print(cnt[r[i]] - cnt[l[i]])
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
if (a == 1 or b == 1):
    print(1)
    exit(0)
div = []
ans = 0
for i in range(1, max(a, b)):
    if (a % i == 0 and b % i == 0):
        div.append(i)
div.reverse()
print(div[k - 1])


Fixed submission:
a, b, k = map(int, input().split())
if (a == 1 or b == 1):
    print(1)
    exit(0)
div = []
ans = 0
for i in range(1, max(a, b) + 1):
    if (a % i == 0 and b % i == 0):
        div.append(i)
div.reverse()
print(div[k - 1])
Buggy python submission (verdict: Runtime Error):
#提出の際にmathをfractionsにする(2020/1/17現在)
from math import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
if (N == 1):
   print(ans)
   exit(0)
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)


Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
if (N == 1):
   print(ans)
   exit(0)
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
#提出の際にmathをfractionsにする(2020/1/17現在)
from math import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
if (N == 1):
   print(x[0])
   exit(0)
ans = abs(X - x[0])
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)


Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
if (N == 1):
   print(ans)
   exit(0)
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
if (s[0] != '1'):
    print(s[0])
    exit(0)
first = s.find('1')
print(1) if k < first else print(s[first+1])


Fixed submission:
s = input()
k = int(input())
first = len(s)
for i in range(len(s)):
  if s[i] != '1': first = i; break
if s[0] != '1': print(s[0]); exit(0)
print(1) if k <= first else print(s[first])

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
if (s[0] != '1'):
    print(s[0])
    exit(0)
first = s.find('1')
print(1) if k <= first or first == len(s) else print(s[first + 1])


Fixed submission:
s = input()
k = int(input())
first = len(s)
for i in range(len(s)):
  if s[i] != '1': first = i; break
if s[0] != '1': print(s[0]); exit(0)
print(1) if k <= first else print(s[first])

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
if (s[0] != '1'):
  print(s[0])
  exit(0)
first = s.find('1')
print(1) if k <= first else print(s[first + 1])


Fixed submission:
s = input()
k = int(input())
first = len(s)
for i in range(len(s)):
  if s[i] != '1': first = i; break
if s[0] != '1': print(s[0]); exit(0)
print(1) if k <= first else print(s[first])
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
m = [int(input()) for i in range(n)]
ans, x = n, x - sum(m)
while (x - min(m) >= 0):
    x, ans -= min(m), ans + 1
print(ans)


Fixed submission:
n, x = map(int, input().split())
m = [int(input()) for i in range(n)]
ans, x = n, x - sum(m)
while (x - min(m) >= 0):
    x -= min(m)
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
a, b = map(int, input().split())
s = input()
flag = 0
for i in range(len(a + b - 1)):
    if (s[a]) == '-': flag = True
    if (s[not a] == '-'):
        print('No')
        sys.exit()
print('Yes') if flag else print('No')


Fixed submission:
a, b = map(int, input().split())
s = input()
flag = True
if (s[a] != '-'): flag = False
for i in range(a + b - 1):
    if (i == a): pass
    elif s[i] == '-': flag = False
print('Yes') if flag else print('No')
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if (b <= c or d <= a): print(0)
elif (b <= d or c <= a): print(max(abs(a - d) - abs(a - c) - abs(b - d), abs(b - c) - abs(a - c) - abs(b - d)))
else: print(max(abs(a - b) - abs(a - c) - abs(b - d), abs(c - d) - abs(a - c) - abs(b - d))


Fixed submission:
a, b, c, d = map(int, input().split())
if (d < a or b < c): print(0)
else: print(min(b, d) - max(a, c))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if (b <= c or d <= a): print(0)
if (b < d or c < a): print(max(abs(a - d) - abs(a - c) - abs(b - d), abs(b - c) - abs(a - c) - abs(b - d)))
if((a - d) * (b - c) < 0): print(max(abs(a - b) - abs(a - c) - abs(b - d), abs(c - d) - abs(a - c) - abs(b - d)))


Fixed submission:
import fractions
N = int(input())
T = [int(input()) for i in range(N)]
a = T[0]
for i in range(1, N):
    b = T[i]
    a = a * b // fractions.gcd(a, b)
print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
color = [0] * 8
for p in a:
    if p >= 3200: color[8] += 1
    else: color[p // 400] += 1
small = len([c for c in color[0:8] if c > 0])
big = small + color[8]
if not small: small += 1
print(small, big)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
color = [0] * 9
for p in a:
    if p >= 3200: color[8] += 1
    else: color[p // 400] += 1
small = len([c for c in color[0:8] if c > 0])
big = small + color[8]
if not small: small += 1
print(small, big)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
ans = T
wait = 0
start = 0
for i in range(1, N):
    if (t[i] - t[i - 1] >= T):
        ans += wait + T
        start = t[i]
        wait = 0
    else:
      wait = t[i] - start
        if (wait > T):
            ans, wait = ans + T, wait - T
print(ans + wait)


Fixed submission:
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
ans = T
for i in range(0, N-1):
  ans += min(t[i+1]-t[i],T)
print(ans)
Buggy python submission (verdict: Runtime Error):
x, y = input().split()
print('Alice') if (x + y) > 1 else print('Brown')


Fixed submission:
x, y = map(int, input().split())
print('Alice') if abs(x - y) > 1 else print('Brown')
Buggy python submission (verdict: Runtime Error):
# -*- coding: UTF-8 -*-
s = input()
a = []
for c in s:
    if (c == '0'):
        a.append('0')
    elif (c == '1'):
        a.append('1')
    else:
        a.pop()

answer = ''.join(a)
print(answer)


Fixed submission:
# -*- coding: UTF-8 -*-
s = input()
ans = ''
for c in s:
    if c == 'B':
      ans = ans[:-1]
    else:
      ans += c

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: UTF-8 -*-
L, N = map(int, input().split())
a = [input() for i in range(N)]
a.sort()
b = "".join(a)
print(b)

Fixed submission:
# -*- coding: UTF-8 -*-
N, L = map(int, input().split())
a = [input() for i in range(N)]
a.sort()
b = "".join(a)
print(b)

Buggy python submission (verdict: Runtime Error):
# -*- coding: UTF-8 -*-
L, N = map(int, input().split())
a = list(input() for i in range(N))
a.sort()
b = "".join(a)
print(b)


Fixed submission:
# -*- coding: UTF-8 -*-
N, L = map(int, input().split())
a = [input() for i in range(N)]
a.sort()
b = "".join(a)
print(b)

Buggy python submission (verdict: Runtime Error):
# -*- coding: UTF-8 -*-
L, N = map(int, input().split())
a = list(input() for i in range(N))
a.sort()
b = " ".join(a)
print(b)

Fixed submission:
# -*- coding: UTF-8 -*-
N, L = map(int, input().split())
a = [input() for i in range(N)]
a.sort()
b = "".join(a)
print(b)
Buggy python submission (verdict: Runtime Error):
a = float(input())
b = float(input())
print(int(a*(b*100))/100)

Fixed submission:
import math
from decimal import Decimal
num = list(map(str,input().split(" ")))
print(math.floor(Decimal(num[1]) * Decimal(num[0])))
Buggy python submission (verdict: Runtime Error):
def solve(height, road):
    graph = collections.defaultdict(set)
    for a, b in road:
        graph[a].add(b)
        graph[b].add(a)
    ans = 0
    no_good = set()
    for k in graph:
        for nei in graph[k]:
            if height[nei-1] >= height[k-1]:
                no_good.add(k)
    return len(height) -  len(no_good)

obs, k = map(int, input().split())
height = list(map(int, input().split()))
road = []
for _ in range(k):
    r = list(map(int, input().split()))
    road.append(r)
print(solve(height, road))


Fixed submission:
import collections

def solve(height, road):
    graph = collections.defaultdict(set)
    for a, b in road:
        graph[a].add(b)
        graph[b].add(a)
    ans = 0
    no_good = set()
    for k in graph:
        for nei in graph[k]:
            if height[nei-1] >= height[k-1]:
                no_good.add(k)
    return len(height) -  len(no_good)

obs, k = map(int, input().split())
height = list(map(int, input().split()))
road = []
for _ in range(k):
    r = list(map(int, input().split()))
    road.append(r)
print(solve(height, road))
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def solve(K, r):
    dic = collections.defaultdict(set)
    for i, n in enumerate(r):
        dic[n].add(i)
    ans = 0
    for i, n in enumerate(r):
        for k in range(i,K):
            target_sum = abs(k-i)-n
            if k in dic[target_sum]:
                ans+=1
    return ans
k = int(input())
r = list(map(int, input().split()))
print(solve(k, r))

Fixed submission:
import collections

def solve(k, r):
    count = {}
    ans = 0
    for i, n in enumerate(r):
        target = i-n
        ans += count.get(target, 0)
        count[i+n] = count.get(i+n, 0)+1
    return ans
k = int(input())
r = list(map(int, input().split()))
print(solve(k, r))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = list(map(int, input().split()))
r = 1

for i in range(len(a)):
  r *= a[i]

if r > pow(10, 18):
  print(-1)
else:
  print(r)

Fixed submission:
import sys
def input():
  return sys.stdin.readline()[:-1]


n = input()
a = input().split()
r = 1

if '0' in a:
  print(0)
  exit()

for i in range(len(a)):
  aa = int(a[i])
  r *= aa
  if r > pow(10, 18):
    print(-1)
    exit()

print(r)
Buggy python submission (verdict: Runtime Error):
a, b, c = input().splita, b, c = [int(x) for x in input().strip().split()]

water = c - (a - b)
if water < 0:
    print(0)
else:
    print(water)


Fixed submission:
a, b, c = [int(x) for x in input().strip().split()]

water = c - (a - b)
if water < 0:
    print(0)
else:
    print(water)
Buggy python submission (verdict: Runtime Error):
import math

nd = input().strip().split()
n = nd[0]
d = nd[1]

inspectors = math.ceil(n / (2 * d + 1))
print(inspectors)

Fixed submission:
import math

nd = [int(x) for x in input().strip().split()]
n = nd[0]
d = nd[1]

inspectors = math.ceil(n / (2 * d + 1))
print(inspectors)
Buggy python submission (verdict: Runtime Error):
a,b=int(input().split())

print(a*b)

Fixed submission:
a,b = list(map(int, input().split())) 
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=1
for i in range(1,n+1):
    s = s*i
a = s % (10**9 + 7)
print(a)


Fixed submission:
n=int(input())
s=1
for i in range(1,n+1):
    s = (s*i) % (10**9 + 7)
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
As = list(map(int, input().split()))

number_counter = {}
for i in As:
    if str(i) in number_counter:
        number_counter[str(i)] += 1
    else:
        number_counter[str(i)] = 1
# 自分の数字以外の方法の合計は一緒。

howmanyways_in_number_by_default = {}
for k, v in number_counter.items():
    if v == 1:
        howmanyways_in_number_by_default[k] = 0
    else:
        howmanyways_in_number_by_default[k] = (v*(v-1))/2

for i in range(n):
    ways = 0
    # 自分以外の通りから自分のとこを引く
    for k, v in howmanyways_in_number_by_default.items():
        if int(k) == As[i]:
            ways += ((number_counter[str(As[i])]-1)*(number_counter[str(As[i])]-2))/2
        else:
            ways += v

    print(int(ways))

Fixed submission:
import sys

s = str(input())
n = len(s)
left = s[0:int((n-1)/2)]
right = s[int(((n+3)/2)-1):n]
l = len(left)

for i in range(int((n-1)/2)):
    if s[i] == s[n-1-i]:
        continue
    else:
        print("No")
        sys.exit()

for i in range(int((n-1)/4)):
    if left[i] == left[l-1-i] and right[i] == right[l-1-i]:
        continue
    else:
        print("No")
        sys.exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
        exit
    else:
        print(a)
        exit

ans = a*NumberOfRotations
if a > n - ((a+b)*NumberOfRotations):
    print(ans+surplus)
else:
    print(ans+a)

Fixed submission:
s = str(input())

def solve():
    if s =="AAA" or s == "BBB":
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    solve()

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

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
    else:
        print(a)
else:
    ans = a*NumberOfRotations
    if a > n - ((a+b)*NumberOfRotations):
        print(ans+surplus)
    else:
        print(ans+a)

Fixed submission:
s = str(input())

def solve():
    if s =="AAA" or s == "BBB":
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

for i in range(a, b+1):
    if i <= a + k - 1 or b + 1 - k <= i:
        print(i)

Fixed submission:
import sys

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

for i in range(a, min(b, a + k)):
    print(i)

 # 左側の幅だけで全部網羅する場合
if b < a + k:
    print(b)
    sys.exit()

 # ベン図みたいにかぶってる時
for i in range(max( a + k, b + 1 - k ), b + 1):
    print(i)

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

for i in range(a, b+1):
    if i <= a + k - 1 or b + 1 - k <= i:
        print(i)

Fixed submission:
import sys

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

for i in range(a, min(b, a + k)):
    print(i)

 # 左側の幅だけで全部網羅する場合
if b < a + k:
    print(b)
    sys.exit()

 # ベン図みたいにかぶってる時
for i in range(max( a + k, b + 1 - k ), b + 1):
    print(i)
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal


def main():
    A, B = map(Decimalt,input().split())

    print(int(A*B))
    return

if __name__ == '__main__':
    main()


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

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal


def main():
    A, B = map(Decimalt,input().split())
    print(int(A*B))

if __name__ == '__main__':
    main()


Fixed submission:
x,y = map(int,input().split())
print(x*y)
Buggy python submission (verdict: Runtime Error):
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 ()

Fixed submission:
N = input()
A = list(map(int,input().split()))
def main(A):
    if 0 in A:
        print(0)
        return

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

    print(prod)

main(A)

Buggy python submission (verdict: Runtime Error):
def main():
    N = 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()


Fixed submission:
N = input()
A = list(map(int,input().split()))
def main(A):
    if 0 in A:
        print(0)
        return

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

    print(prod)

main(A)

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

    if 0 in A:
        print(0)
        return

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

print(prod)

main()


Fixed submission:
N = input()
A = list(map(int,input().split()))
def main(A):
    if 0 in A:
        print(0)
        return

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

    print(prod)

main(A)

Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vals(N);
  for (int i = 0; i < N;i++){
    cin >> vals.at(i);
  }
  int prod = std::accumulate(vals.begin(), vals.end(), 1, [](int init, int v) { return init * v; });
  if (prod > pow(10, 18)){
    cout << "-1" << endl;
  }
  else cout << prod << endl;
}


Fixed submission:
N = input()
A = list(map(int,input().split()))
def main(A):
    if 0 in A:
        print(0)
        return

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

    print(prod)

main(A)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = list(map(int,input().split()))
total = 1
for i in a:
    total = total * i
if total > 10**18:
    print("-1")
else:
    print(total)



Fixed submission:
N = input()
A = list(map(int,input().split()))
def main(A):
    if 0 in A:
        print(0)
        return

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

    print(prod)

main(A)
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal


def main():
    A, B = map(Decimalt,input().split())

    print(int(A*B))
    return

if __name__ == '__main__':
    main()


Fixed submission:
from decimal import Decimal


def main():
    A, B = map(Decimal, input().split())

    print(int(A*B))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal

def main():
    x,y = map(Decimalt,input().split())
    print(int(x*y))

if __name__ == '__main__':
    main()


Fixed submission:
from decimal import Decimal


def main():
    A, B = map(Decimal, input().split())

    print(int(A*B))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal

x,y = map(Decimalt,input().split())
print(int(x*y))


Fixed submission:
from decimal import Decimal


def main():
    A, B = map(Decimal, input().split())

    print(int(A*B))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
count = int(input())

strlist = []
for i in range(count):
  strlist.append(input())

for i in range(count - 1):
  for j in range(i + 1, count):
    if strlist[i] > strlist[j]:
      tmp = strlist[i]
      strlist[i] = strlist[j]
      strlist[j] = tmp

duplication = 0
for i in range(count - 1):
  if strlist[i] == strlist[i + 1]:
    duplication += 1
    
print(count - duplication)

Fixed submission:
count = int(input())

strlist = set()
for i in range(count):
  strlist.add(input())

print(len(strlist))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = '0'
S += input()
R_count = 0
G_count = 0
B_count = 0
for i in range(1, N + 1):
  if S[i] == 'R':
    R_count += 1
  if S[i] == 'G':
    G_count += 1
  if S[i] == 'B':
    B_count += 1
res = R_count * G_count * B_count
for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    if 2 * j - i > N:
      break
    temp = []
    temp += S[i] + S[j] + S[2 * j - i]
    temp.sort()
    if temp[0] == 'B' and temp[1] == 'G' and temp[2] == 'R':
      res -= 1
print(res)

Fixed submission:
N = int(input())
S = '0'
S += input()
R_count = 0
G_count = 0
B_count = 0
for i in range(1, N + 1):
  if S[i] == 'R':
    R_count += 1
  if S[i] == 'G':
    G_count += 1
  if S[i] == 'B':
    B_count += 1
res = R_count * G_count * B_count
for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    if 2 * j - i > N:
      break
    temp = []
    temp += S[i] + S[j] + S[2 * j - i]
    temp.sort()
    if temp[0] == 'B' and temp[1] == 'G' and temp[2] == 'R':
      res -= 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split(' '))
dist = [[0 for _ in range(N + 10)] for _ in range(N + 10)]
dist[X][Y] = 1
res = [0 for i in range(N + 10)]
for i in range(1, N):
  for j in range(i + 1, N + 1):
    dist[i][j] = min(j - i, abs(j - X) + 1 + abs(i - Y), abs(j - Y) + 1 + abs(i - X))
    res[dist[i][j]] += 1
for i in range(1, N):
  print(res[i])

Fixed submission:
N, X, Y = map(int, input().split(' '))
dist = [[0 for _ in range(N + 10)] for _ in range(N + 10)]
dist[X][Y] = 1
res = [0 for i in range(N + 10)]
for i in range(1, N):
  for j in range(i + 1, N + 1):
    dist[i][j] = min(j - i, abs(j - X) + 1 + abs(i - Y), abs(j - Y) + 1 + abs(i - X))
    res[dist[i][j]] += 1
for i in range(1, N):
  print(res[i])