Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
n = 1
if b == 1:
    print(0)
else:
    while a*n-(n-1) < b:
        n += 1
    print(n)


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

total = 0
for i in range(n):
    total += b[a[i] - 1]
    if i < n-1:
        if a[i] + 1 == a[i+1]:
            total += c[a[i]-1]
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
cnt = 0
for i in range(n-1):
    j = i
    cnt_ = 0
    while h[j] >= h[j+1]:
        cnt_ += 1
        j += 1
        if j == n-1:
            break
    if cnt_ > cnt:
        cnt = cnt_
print(cnt)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
cnt = 0
cnt_ = 0
for i in range(n-1):
    if h[i] < h[i+1]:
        cnt_ = 0
    else:
        cnt_ += 1
        if cnt < cnt_:
            cnt = cnt_
print(cnt)
Buggy python submission (verdict: Runtime Error):
i = int(input())
print(int(n*(n-1)/2))

Fixed submission:
i = int(input())
print((i-1)*i//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = {}
total = 0

for i in range(n):
    string = list(input())
    string.sort(reverse = False)
    if tuple(string) in s:
        s[tuple(string)] += 1
    else:
        s[tuple(string)] = 1

for i in s:
    if i != 1:
        total += sum([i for i in range(1,i)])

print(total)

Fixed submission:
N = int(input())
s_dict = {}
ans = 0
for i in range(N):
  string = list(input())
  string.sort(reverse=False)
  if tuple(string) in s_dict:
    s_dict[tuple(string)] += 1
  else:
    s_dict[tuple(string)] = 1

for i in s_dict.values():
  if i != 1:
    ans += sum([i for i in range(1,i)])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
total = 0
for i in range(n):
    s.append(input())
    s[i] = sorted(s[i])
for i in range(n-1):
    for j in range(i+1,n):
        if s[i] == s[j]:
            total += 1
print(total)

Fixed submission:
N = int(input())
s_dict = {}
ans = 0
for i in range(N):
  string = list(input())
  string.sort(reverse=False)
  if tuple(string) in s_dict:
    s_dict[tuple(string)] += 1
  else:
    s_dict[tuple(string)] = 1

for i in s_dict.values():
  if i != 1:
    ans += sum([i for i in range(1,i)])

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
if(a % 2 != b % 2):
    print("IMPOSSIBLE")
else:
    print((a+b)/2)

Fixed submission:
a,b = map(int,input().split())
if(a % 2 != b % 2):
    print("IMPOSSIBLE")
else:
    print(int((a+b)/2))
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())

m = 10000000000000000
cnt_i = 0
for i in range(l,r+1):
    cnt_j = 0
    if cnt_i == 2019:
        break
    cnt_i += 1
    for j in range(i+1,r+1):
        if cnt_j == 2019:
            break
        cnt_j += 1
        m = min(m,i%2019*j%2019)
print(m)


Fixed submission:
l,r = map(int,input().split())

if r-l >= 672:
    m = 0
else:
    m = 10000000000000000
    cnt_i = 0
    for i in range(l,r+1):
        cnt_j = 0
        if cnt_i == 2019:
            break
        cnt_i += 1
        for j in range(i+1,r+1):
            if cnt_j == 2019:
                break
            cnt_j += 1
            m = min(m,i%2019*j%2019)
print(m)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

a,b,c,d = map(int,input().split())
ac_can = int((a-1)//c)
ad_can = int((a-1)//d)
acd_can = int((a-1)//lcm(c,d))
bc_can = int(b//c)
bd_can = int(b//d)
bcd_can = int(b//lcm(c,d))
print(b-a+1-(bc_can+bd_can-bcd_can-(ac_can+ad_can-acd_can)))

Fixed submission:
W, H, x, y = map(int, input().rstrip().split())
 
max_area = W * H / 2.0
if x == W / 2 and y == H / 2:
    print(max_area, 1)
else:
    print(max_area, 0)
Buggy python submission (verdict: Runtime Error):
a,p = map(int,input().split()
print(int((a*3+p)/2))

Fixed submission:
a,p = map(int,input().split())
print(int((a*3+p)/2))

Buggy python submission (verdict: Runtime Error):
a,p = map(int,input().split()
print((a*3+p)/2

Fixed submission:
a,p = map(int,input().split())
print(int((a*3+p)/2))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]
maxl = max(li, key=lambda x:x[0])[0]
minr = min(li, key=lambda x:x[1])[1]
if maxl <= minr:
    print(r-l+1)
else:
    print(0)

Fixed submission:
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]
maxl = max(li, key=lambda x:x[0])[0]
minr = min(li, key=lambda x:x[1])[1]
if maxl <= minr:
    print(minr-maxl+1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] == 0:
        cnt -= 1000000000000
        break
    elif a[i] < 0:
        cnt += 1
a = [abs(a[i]) for i in range(n)]
if cnt < 0 or num % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2*min(a))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] == 0:
        cnt -= 1000000000000
        break
    elif a[i] < 0:
        cnt += 1
a = [abs(a[i]) for i in range(n)]
if cnt < 0 or cnt % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2*min(a))
Buggy python submission (verdict: Runtime Error):
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if i%s == 0:
        if s[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == "1":
            cnt1 += 1
        else:
            cnt2 += 1
print(min(cnt1,cnt2))

Fixed submission:
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == "1":
            cnt1 += 1
        else:
            cnt2 += 1
print(min(cnt1,cnt2))

Buggy python submission (verdict: Runtime Error):
num = input()
num_char = list(num)
num_char2 = list(num)
if num_char[0] == "0":
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 0
		num_char[i + 1] = 1
else:
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 1
		num_char[i + 1] = 0
        
cnt = 0
for i in range(len(num_char)):
  if str(num_char[i]) != num_char2[i]:
    cnt += 1
print(cnt)

Fixed submission:
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == "1":
            cnt1 += 1
        else:
            cnt2 += 1
print(min(cnt1,cnt2))

Buggy python submission (verdict: Runtime Error):
num = input()
num_char = list(num)
if num_char[0] == "0":
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 0
		num_char[i + 1] = 1
else:
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 1
		num_char[i + 1] = 0
for i in num_char:
	print(i, end = "")

Fixed submission:
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == "1":
            cnt1 += 1
        else:
            cnt2 += 1
print(min(cnt1,cnt2))

Buggy python submission (verdict: Runtime Error):
num = input()
num_char = list(num)
if num_char[0] == "0":
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 0
		num_char[i + 1] = 1
else:
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 1
		num_char[i + 1] = 0
for i in num_char:
  print(i, end = "")

Fixed submission:
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == "1":
            cnt1 += 1
        else:
            cnt2 += 1
print(min(cnt1,cnt2))
Buggy python submission (verdict: Runtime Error):
li = []
lis = []
time = 0
for i in range(5):
    li.append(int(input()))
    lis.append(li[i] % 10)
lista = sorted(lis)
a = lista
for i in range(5):
    if lista[i] != 0:
        a = lista[i]
        break
last = lis.index(a)
for i in range(5):
    if i == last:
        continue
    elif lis[i] == 0:
        time += li[i]
    elif 1 <= li[i] <= 9:
        time += 10
    else:
        time += int(li[i] / 10) * 10 + 10
print(time + li[last])

Fixed submission:
import itertools
C = []
for i in range(5):
    C.append(int(input()))

ans = float("inf")
for order in itertools.permutations(C, 5):
    total = 0
    for c in order:
        if total % 10 != 0:
            total = (total // 10 + 1) * 10
        total += c

    ans = min(total, ans)

print(ans)

Buggy python submission (verdict: Runtime Error):
li = []
lis = []
time = 0
for i in range(5):
    li.append(int(input()))
    lis.append(li[i] % 10)
lista = sorted(lis)
for i in range(5):
    if lista[i] != 0:
        a = lista[i]
        break
last = lis.index(a)
for i in range(5):
    if i == last:
        continue
    elif lis[i] == 0:
        time += li[i]
    elif 1 <= li[i] <= 9:
        time += 10
    else:
        time += int(li[i] / 10) * 10 + 10
print(time + li[last])

Fixed submission:
import itertools
C = []
for i in range(5):
    C.append(int(input()))

ans = float("inf")
for order in itertools.permutations(C, 5):
    total = 0
    for c in order:
        if total % 10 != 0:
            total = (total // 10 + 1) * 10
        total += c

    ans = min(total, ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
for i in range(q):
    a,b = map(int,input().split())
    print(s.count("AC",a-1,b))

Fixed submission:
n,q = map(int,input().split())
s = input()
cnt = [0] * (n+1)
for i in range(n):
    if s[i:i+2] == "AC":
        cnt[i+1] = cnt[i] + 1
    else:
        cnt[i+1] = cnt[i]
for i in range(q):
    l,r = map(int,input().split())
    print(cnt[r-1]-cnt[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
li = list(map(int,input().split()))
num = li[0]
want = li[1]
cost = []
max_num = []
total_num = 0
total_cost = 0
for i in range(num):
	a = list(map(int,input().split()))
	cost.append(a[0])
	max_num.append(a[1])
while want > total_num:
	min_cost = min(cost)
	m = cost.index(min_cost)
	if total_num + max_num[m] > want:
		total_cost += (want - total_num) * cost[m]
		total_num = want
	else:
		total_cost += max_num[m] * cost[m]
		total_num += max_num[m]
		cost.remove(cost[m])
		max_num.remove(max_num[m])
print(total_cost)

Fixed submission:
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(n)]
li = sorted(li, key=lambda x:x[0])
cnt = 0
coin = 0
for a,b in li:
    c_cnt = cnt + b
    if c_cnt < m:
        cnt += b
        coin += a*b
    else:
        cnt += b-(c_cnt - m)
        coin += a*(b-(c_cnt-m))
        break
print(coin)
Buggy python submission (verdict: Runtime Error):
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])
print(ans)

Fixed submission:
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
ans = h[0]
for i in range(1,n):
    if h[i-1] < h[i]:
        ans += h[i]-h[i-1]
print(ans)

Fixed submission:
a,b,c = map(int,input().split())
print(int(a*b/2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for _ in range(n)]
print(int(sum(p) - max(p)/2)

Fixed submission:
n = int(input())
p = [int(input()) for _ in range(n)]
print(int(sum(p) - max(p)/2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
li = list(map(int,input().split()))
nearest = 0
for i in li:
    if abs(nearest - a) < abs((t - i * 0.006) - a):
        nearest = i
print(li.index(nearest) + 1)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
dif = 1000
for i in range(N):
    Tx = T - H[i] * 0.006
    if  abs(Tx - A) < dif:
        dif = abs(Tx - A)
        ans = i + 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
li = list(map(int,input().split()))
nearest = 0
for i in li:
    if abs(nearest - a) > abs((t - i * 0.006) - a):
        nearest = i
print(li.index(nearest))

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
dif = 1000
for i in range(N):
    Tx = T - H[i] * 0.006
    if  abs(Tx - A) < dif:
        dif = abs(Tx - A)
        ans = i + 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
li = list(map(int,input().split()))
nearest = 0
for i in li:
    if abs(nearest - a) > abs((t - i * 0.006) - a):
        nearest = i
print(l.index(nearest) + 1)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
dif = 1000
for i in range(N):
    Tx = T - H[i] * 0.006
    if  abs(Tx - A) < dif:
        dif = abs(Tx - A)
        ans = i + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
for i in range(len(a)):
  if a[i] == "1":
    a[i] = "9"
  else:
    a[i] = "1"
print(a)

Fixed submission:
a = input()
b= ""
for i in range(len(a)):
  if a[i] == "1":
    b += "9"
  else:
    b += "1"
print(b)

Buggy python submission (verdict: Runtime Error):
a = input()
for i in range(a):
  if a[i] == "1":
    a[i] = "9"
  else:
    a[i] = "1"
print(a)

Fixed submission:
a = input()
b= ""
for i in range(len(a)):
  if a[i] == "1":
    b += "9"
  else:
    b += "1"
print(b)

Buggy python submission (verdict: Runtime Error):
a = input()
for i in range(a):
  if a[i] == 1:
    a[i] = 9
  else:
    a[i] = 1
print(a)

Fixed submission:
a = input()
b= ""
for i in range(len(a)):
  if a[i] == "1":
    b += "9"
  else:
    b += "1"
print(b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
max_f = int(n / 4)
max_s = int(n / 7)
switch = 0
for i in range(max_s + 1):
    for j in range(max_f + 1):
        if (7 * i + 4 * j) == n:
            switch = 1
if switch == 1:
    print(Yes)
else:
    print(No)

Fixed submission:
n = int(input())
max_f = int(n / 4)
max_s = int(n / 7)
switch = 0
for i in range(max_s + 1):
    for j in range(max_f + 1):
        if (7 * i + 4 * j) == n:
            switch = 1
if switch == 1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = input()
li = []
for i in n:
  li.append(int(i))
if n % sum(li) == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n = input()
li = []
for i in n:
  li.append(int(i))
if int(n) % sum(li) == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from collections import deque

def bfs():
    d = [[inf]*(w+1) for _ in range(h+1)]
    que = deque()
    que.append((0,0))
    d[0][0] = 0

    while que:
        cx,cy = que.popleft()
        if cx == w and cy == h:
            break
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            nx, ny = cx+dx, cy+dy
            if 0 <= nx <= w and 0 <= ny <= h and s[nx][ny] != "#" and d[nx][ny] == inf:
                que.append((nx,ny))
                d[nx][ny] = d[cx][cy] + 1
    return d[w][h]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
inf = float("inf")
h,w = h-1,w-1
cnt = bfs()
dot = 0
for i in s:
    dot += i.count(".")
if 0 < cnt < inf:
  print(dot-cnt-1)
else:
  print(-1)

Fixed submission:
from collections import deque

def bfs():
    d = [[inf]*(w+1) for _ in range(h+1)]
    que = deque()
    que.append((0,0))
    d[0][0] = 0

    while que:
        cx,cy = que.popleft()
        if cx == w and cy == h:
            break
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            nx, ny = cx+dx, cy+dy
            if 0 <= nx <= h and 0 <= ny <= w and s[nx][ny] != "#" and d[nx][ny] == inf:
                que.append((nx,ny))
                d[nx][ny] = d[cx][cy] + 1
    return d[h][w]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
inf = float("inf")
h,w = h-1,w-1
cnt = bfs()
dot = 0
for i in s:
    dot += i.count(".")
if 0 < cnt < inf:
  print(dot-cnt-1)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
from collections import deque

def bfs():
    d = [[inf]*(w+1) for _ in range(h+1)]
    que = deque()
    que.append((0,0))
    d[0][0] = 0

    while que:
        cx,cy = que.popleft()
        if cx == w and cy == h:
            break
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            nx, ny = cx+dx, cy+dy
            if 0 <= nx <= w and 0 <= ny <= h and s[nx][ny] != "#" and d[nx][ny] == inf:
                que.append((nx,ny))
                d[nx][ny] = d[cx][cy] + 1
    return d[w][h]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
inf = float("inf")
h,w = h-1,w-1
cnt = bfs()
sharp = 0
for i in s:
    sharp += i.count("#")
print((h+1)*(w+1)-sharp-cnt)

Fixed submission:
from collections import deque

def bfs():
    d = [[inf]*(w+1) for _ in range(h+1)]
    que = deque()
    que.append((0,0))
    d[0][0] = 0

    while que:
        cx,cy = que.popleft()
        if cx == w and cy == h:
            break
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            nx, ny = cx+dx, cy+dy
            if 0 <= nx <= h and 0 <= ny <= w and s[nx][ny] != "#" and d[nx][ny] == inf:
                que.append((nx,ny))
                d[nx][ny] = d[cx][cy] + 1
    return d[h][w]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
inf = float("inf")
h,w = h-1,w-1
cnt = bfs()
dot = 0
for i in s:
    dot += i.count(".")
if 0 < cnt < inf:
  print(dot-cnt-1)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
li = list(map(int,input().split())
if li[0] % 2 == 0 or li[1] & 2 == 0:
    print("Evem")
else:
    print("Odd")
    

Fixed submission:
a = list(map(int, input().split()))
if a[0] % 2 == 0 or a[1] % 2 == 0:
	print("Even")
else:
	print("Odd")

Buggy python submission (verdict: Runtime Error):
li = list(map(int(input().split()))
if li[0] % 2 == 0 or li[1] & 2 == 0:
    print("Evem")
else:
    print("Odd")
    

Fixed submission:
a = list(map(int, input().split()))
if a[0] % 2 == 0 or a[1] % 2 == 0:
	print("Even")
else:
	print("Odd")

Buggy python submission (verdict: Runtime Error):
li = list(map(intinput().split())
if li[0] % 2 == 0 or li[1] & 2 == 0:
    print("Evem")
else:
    print("Odd")
    

Fixed submission:
a = list(map(int, input().split()))
if a[0] % 2 == 0 or a[1] % 2 == 0:
	print("Even")
else:
	print("Odd")

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

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

Fixed submission:
s = input()
cnt = 0
strings = ""
for i in s:
    if cnt % 2 == 0:
        strings = strings + i
    cnt += 1
print(strings)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
total = 0
for i in range(k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            if s == i+j+l:
                if(i == j and j == l):
                    total += 1
                elif((i == j and j != l) or (i != j and j == l) or (i == l and j != l)):
                    total += 3
                else:
                    total += 6
print(total)


Fixed submission:
K,S = map(int,input().split())
cnt = 0
for i in range(K + 1):
    for j in range(K + 1):
        if i + j > S:
            continue
        elif i + j >= S - K:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
total = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if s == i+j+l:
                total+= 1
print(total)


Fixed submission:
K,S = map(int,input().split())
cnt = 0
for i in range(K + 1):
    for j in range(K + 1):
        if i + j > S:
            continue
        elif i + j >= S - K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
li ~ list(map(int,input().split()))
cnt = 3
if li[0] == li[1]:
	cnt -= 1
if li[0] == li[2]:
	cnt -= 1
if li[1] == li[2]:
	cnt -= 1
if li[0] == li[1] and li[1] == li[2]:
	cnt = 1
print(cnt)

Fixed submission:
li = list(map(int,input().split()))
cnt = 3
if li[0] == li[1]:
	cnt -= 1
if li[0] == li[2]:
	cnt -= 1
if li[1] == li[2]:
	cnt -= 1
if li[0] == li[1] and li[1] == li[2]:
	cnt = 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def dfs(i, sum):
    if i == len(s) - 1:
        return sum(list(map(int,sum.split("+"))))

    return dfs(i+1, sum + s[i+1]) + dfs(i+1, sum + "+" + s[i+1])

s = input()
print(dfs(0,s[0]))

Fixed submission:
def dfs(i, f):
    if i == len(s) - 1:
        return sum(list(map(int,f.split("+"))))

    return dfs(i+1, f + s[i+1]) + dfs(i+1, f + "+" + s[i+1])

s = input()
print(dfs(0,s[0]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

acc_r, acc_g, acc_b = [], [], []
cr, cg, cb = 0, 0, 0
for i in s:
    if i == "R":
        cr += 1
    elif i == "G":
        cg += 1
    elif i == "B":
        cb += 1

    acc_r.append(cr)
    acc_g.append(cg)
    acc_b.append(cb)

count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        si = s[i]
        sj = s[j]
        if (si == "R" and sj == "G") or (si == "G" and sj == "R"):
            count += acc_b[-1] - acc_b[j]
            if j+(j-i) < n and s[j+(j-i)] == "B":
                count -= 1
        if (si == "G" and sj == "B") or (si == "B" and sj == "G"):
            count += acc_r[-1] - acc_r[j]
            if j+(j-i) < n and s[j+(j-i)] == "R":
                count -= 1
        if (si == "R" and sj == "B") or (si == "B" and sj == "R"):
            count += acc_g[-1] - acc_g[j]
            if j+(j-i) < n and s[j+(j-i)] == "G":
                count -= 1
                
print(count)


Fixed submission:
n = int(input())
s = input()

acc_r, acc_g, acc_b = [], [], []
cr, cg, cb = 0, 0, 0
for i in s:
    if i == "R":
        cr += 1
    elif i == "G":
        cg += 1
    elif i == "B":
        cb += 1

    acc_r.append(cr)
    acc_g.append(cg)
    acc_b.append(cb)

count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        si = s[i]
        sj = s[j]
        if (si == "R" and sj == "G") or (si == "G" and sj == "R"):
            count += acc_b[-1] - acc_b[j]
            if j+(j-i) < n and s[j+(j-i)] == "B":
                count -= 1
        if (si == "G" and sj == "B") or (si == "B" and sj == "G"):
            count += acc_r[-1] - acc_r[j]
            if j+(j-i) < n and s[j+(j-i)] == "R":
                count -= 1
        if (si == "R" and sj == "B") or (si == "B" and sj == "R"):
            count += acc_g[-1] - acc_g[j]
            if j+(j-i) < n and s[j+(j-i)] == "G":
                count -= 1
                
print(count)