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

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while max(a) != 0:
  # print(a,cnt)
  betweenZero = True
  for i in range(len(a)):
    if a[i] != 0:
      a[i] -= 1
      betweenZero = False
    elif betweenZero == False:
      cnt += 1
      betweenZero = True
  if betweenZero == False:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while max(a) != 0:
  # print(a,cnt)
  for i in range(n):
    if a[i] != 0:
      a[i] -= 1
      betweenZero = False
    elif betweenZero == False:
      cnt += 1
      betweenZero = True
  if betweenZero == False:
    cnt += 1
  betweenZero = True
print(cnt)
Problem p03263 (python)

Fixed submission:
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
c = []
hold = False
for y in range(h):
    for x in list(range(w))[::-1+(y % 2 == 0)*2]:
        # print((y + 1, x + 1))
        if hold:
            c.append((back[0], back[1], y + 1, x + 1))
            if a[y][x] % 2 == 1:
                hold = False
                continue
        if not hold and a[y][x] % 2 == 1:
            hold = True
        back = (y + 1, x + 1)
print(len(c))
for i in range(len(c)):
    print(*c[i])

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
c = []
hold = False
for y in range(h):
    for x in list(range(w))[::-1+(y % 2 == 0)*2]:
        # print((y + 1, x + 1))
        if hold:
            c.append((*back, y + 1, x + 1))
            if a[y][x] % 2 == 1:
                hold = False
                continue
        if not hold and a[y][x] % 2 == 1:
            hold = True
        back = (y + 1, x + 1)
print(len(c))
for i in range(len(c)):
    print(*c[i])
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
front1 = 0
if s == "1":
  print(1)
  exit()
for i in range(len(s)):
  if s[i] == "1":
    front1 += 1
  else:
    break
print(s[min(k-1, front1)])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
if s[0] == "1":
  if s[:k] == "1"*k:
    print(s[0])
  else:
    print(s[k-1])
else:
  print(s[0])
Problem p04020 (python)

Fixed submission:
n = int(input())
a = []
cnt = 0
for i in range(n):
  a.append(int(input()))
stack = -1
for i in range(n):
  if i+1 - stack <= 1 and a[i] > 0:
    cnt += 1
    a[i] -= 1
    stack = -1
  cnt += a[i] // 2
  if a[i] % 2 == 1:
    stack = i+1
  else:
    stack = -1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = []
for i in range(n):
  c += [i+1]*int(input())
cnt = 0
paired = False
for i in range(len(c)-1):
  if paired:
    paired = False
    continue
  if c[i+1] - c[i] <= 1 and not paired:
    cnt += 1
    paired = True
print(cnt)
Problem p02609 (python)

Fixed submission:
#!/usr/bin/env python3
n = int(input())
x = input()
c = x.count("1")
m = 0
m2 = 0
for i in range(n):
    if x[i] == "1":
        m += pow(2, (n - i - 1), c + 1)
        m %= c + 1
m2 = 0
if c!=1:
    for i in range(n):
        if x[i] == "1":
            m2 += pow(2, (n - i - 1), c - 1)
            m2 %= c - 1

for i in range(n):
    if x[i] == "1":
        if c != 1:
            t = m2 - pow(2, (n - i - 1), c - 1)
            t %= c - 1
            count = 1
        else:
            t = 0
            count = 0
    else:
        t = m + pow(2, (n - i - 1), c + 1)
        t %= c + 1
        count = 1
    while t > 0:
        t %= bin(t).count("1")
        count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n = int(input())
x = input()
c = x.count("1")
m = 0
for i in range(n):
    if x[i] == "1":
        m += pow(2, (n - i - 1), c + 1)
m %= c + 1
m2 = 0
for i in range(n):
    if x[i] == "1":
        m2 += pow(2, (n - i - 1), c - 1)
m2 %= c - 1

for i in range(n):
    if x[i] == "1":
        t = m2 - pow(2, (n - i - 1), c - 1)
        t %= c - 1
    else:
        t = m + pow(2, (n - i - 1), c + 1)
        t %= c + 1
    count = 1
    while t > 0:
        t %= bin(t).count("1")
        count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n = int(input())
x = input()
c = x.count("1")
m = 0
for i in range(n):
    if x[i] == "1":
        m += pow(2, (n - i - 1), c + 1)
m %= c + 1
m2 = 0
for i in range(n):
    if x[i] == "1":
        m2 += pow(2, (n - i - 1), c - 1)
m2 %= c - 1

for i in range(n):
    if x[i] == "1":
        t = m2 - pow(2, (n - i - 1), c - 1)
        t %= c - 1
    else:
        t = m + pow(2, (n - i - 1), c + 1)
        t %= c + 1
    count = 1
    while t > 0:
        t %= bin(t).count("1")
        count += 1
    print(count)
Problem p02630 (python)

Fixed submission:
import collections
_ = input()
a = [*map(int, input().split())]
q = int(input())
s = sum(a)
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    if j not in c:
        c[j] = 0
    if i not in c:
        c[i] = 0
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)

Buggy submission (verdict: Runtime Error):
import collections 
_ = input()
a = [*map(int, input().split())]
q = int(input())
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    c[j]+=c[i]
    c.pop(i)
    print(sum(k*v for k,v in c.items()))
Problem p02639 (python)

Fixed submission:
print(input().split().index("0")+1)

Buggy submission (verdict: Runtime Error):
_, *a = map(int, open(0).read().split())
a.sort()
m = -~a[-1]
c = [0] * m
for i in a:
    c[i] += 1
    if c[i] > 1:
        continue
    for j in range(i * 2, m, i):
        c[j] = 2
print(sum(c[i]for i in a))

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
i = 0
while a:
    if a.count(a[0]) == 1:
        i+=1
    a = list(filter(lambda x: x%a[0] >0,a))
print(i)
Problem p02642 (python)

Fixed submission:
_,*a = map(int, open(0).read().split())
a.sort()
m = -~a[-1]
c = [0]*m
for i in a:
    c[i] += 1
    if c[i] > 1:
        continue
    for j in range(i * 2, m, i):
        c[j] = 2
print(sum(c[i]==1for i in a))

Buggy submission (verdict: Runtime Error):
_, *a = map(int, open("/Users/rikuo/Downloads/03-LargeRandom-23 (1)").read().split())
a.sort()
m = -~a[-1]
c = [0] * m
for i in a:
    c[i] += 1
    if c[i] > 1:
        continue
    for j in range(i * 2, m, i):
        c[j] = 2
print(sum(c[i]for i in a))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,*a=map(int,open(0).read().split())
a=np.array(sorted(a))
i = 0
while len(a):
    if a[0] != a[1]:
        i+=1
    a = a[a%a[0] != 0]
print(i)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
i = 0
while a:
    if a.count(a[0]) == 1:
        i+=1
    a = list(filter(lambda x: x%a[i] >0,a))
print(i)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
a.sort()
i = 0
while a:
    if a.count(a[0]) == 1:
        i+=1
    a = list(filter(lambda x: x%a[i] >0,a))
print(i)
Problem p02658 (python)

Fixed submission:
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=i
    if  s > 1e18:
        print(-1)
        exit()
print(s)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
a.sort()
for i in a:
    s *= i
    if s > 1e18:
        print(-1)
        exit()
print(s)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=a
    if  s > 10**18:
        print(-1)
        exit()
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=eval(input().replace(" ", "*"))
print([-1,s][s<=10**18])
Problem p02732 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import Counter

from scipy.special import comb

_, *a = map(int, open(0).read().split())
c = Counter(a)
s = sum(comb(i, 2, exact=True) for i in c.values())
for i in a:
    print(s - c[i] + 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import Counter

from scipy.special import comb

_, *a = map(int, open(0).read().split())
c = Counter(a)
s = sum(comb(i, 2, exact=True) for i in c.values())
for i in a:
    print(s - c[i] + 1)
Problem p02741 (python)

Fixed submission:
a =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

Buggy submission (verdict: Runtime Error):
a =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1]

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
print([1,sum(divmod(h*w, 2))][h>1<w])
Problem p02742 (python)

Fixed submission:
h,w=map(int,input().split())
print([1,sum(divmod(h*w, 2))][h>1<w])

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
print([1,sum(divmod(h*w), 2)][h>0<w])
Problem p02786 (python)

Fixed submission:
print(~-(1<<len(bin(int(input()))[2:])))

Buggy submission (verdict: Runtime Error):
print(~-1<<len(bin(int(input()))-3))
Problem p02813 (python)

Fixed submission:
import itertools
(n,),p,q=[tuple(map(int, i.split())) for i in open(0)]
j=list(itertools.permutations(range(1, -~n)))
print(abs(j.index(p) - j.index(q)))

Buggy submission (verdict: Runtime Error):
import math
n,p,q=[list(map(int, i.split())) for i in open(0)]
def ps(l):
    s=0
    t=list(range(1,n+1))
    for i in range(n):
        s+=t.index(l[i])*math.factorial(n-i-1)
        t.remove(l[i])
print(abs(ps(p)-ps(q)))
Problem p02855 (python)

Fixed submission:
#!/usr/bin/env python3
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
ans = []
c = 1
for i in s:
    if i == "." * w:
        if ans:
            ans.append(ans[-1])
        else:
            ans.append([0]*w)
    else:
        f = i.index("#")
        ans.append([c] * (f + 1))
        for j in i[f + 1:]:
            if j == "#":
                c += 1
            ans[-1].append(c)
        c += 1
for i in range(h):
    if ans[i] != [0]*w:
        for j in range(i):
            ans[j] = ans[i]
        break
for i in ans:
    print(*i)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
ans = []
c = 1
for i in s:
    if i == "." * w:
        ans.append([0] * w)
    else:
        f = i.index("#")
        ans.append([c] * (f + 1))
        for j in i[f + 1:]:
            if j == "#":
                c += 1
            ans[-1].append(c)
        c += 1
for i in range(h):
    if s[i] == "."*w:
        ans[i] = ans[i-1 if i > 1 else i +1]

for i in ans:
    print(*i)
Problem p02936 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import deque

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

graph = [deque([]) for _ in range(n + 1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

a = [0] * -~n
b = [True] * -~n
for i in range(q):
    p, x = map(int, input().split())
    a[p] += x

d = deque([1])
b[1] = False

while len(d):
    p = d.popleft()
    for i in graph[p]:
        if b[i]:
            a[i] += a[p]
            b[i] = False
            d.append(i)
print(*a[1:])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import deque

import networkx as nx

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

g = nx.Graph()
for i in range(n - 1):
    g.add_edge(*map(int, input().split()))
nx.set_node_attributes(g, name="a", values=0)
nx.set_node_attributes(g, name="b", values=True)

for i in range(q):
    p, x = map(int, input().split())
    g.nodes[p]["a"] += x

d = deque([1])
g.nodes[1]["b"] = False
while len(d):
    p = d.popleft()
    for i in g.neighbors(p):
        if g.nodes[i]["b"]:
            g.nodes[i]["a"] += g.nodes[p]["a"]
            g.nodes[i]["b"] = False
            d.append(i)
for i in range(1, n + 1):
    print(g.nodes[i]["a"], end=" ")
print("")
Problem p03006 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict

(n, ), *p = [[*map(int, i.split())] for i in open(0)]
d = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i != j:
            d[(p[i][0] - p[j][0], p[i][1] - p[j][1])] += 1
print(n*(n<2) or n - max(d.values()))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict

(n, ), *p = [[*map(int, i.split())] for i in open(0)]
d = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i != j:
            d[(p[i][0] - p[j][0], p[i][1] - p[j][1])] += 1
print(n - max(d.values()))
Problem p03254 (python)

Fixed submission:
n,x,*a=map(int, open(0).read().split())
a.sort()
for i in range(n):
    x-=a[i]
    if x<0:
      print(i)
      exit()
    elif x==0:
      print(-~i)
      exit()
print(n-1)

Buggy submission (verdict: Runtime Error):
n,x,*a=map(int,open(0).read().split())
a.sort()
s=0
i=0
while s<x or i<=n:
    i+=1
    s+=a[i]
print(~-i)
Problem p03268 (python)

Fixed submission:
#!/usr/bin/env python3
n, k = map(int, input().split())
ans = (n // k)**3
if k % 2 < 1:
    ans += (n // (k // 2) - n // k)**3
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
print((n // k)**3 + (~k & 1) * (n // (k // 2) - n // k)**3)
Problem p03290 (python)

Fixed submission:
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
def c(i,t,l):
    if i==d:
        if t>=g:
            return sum(l)
        else:
            m=d-l[::-1].index(0)
            e = (t - g) // (m * 100)
            if -e < s[m-1][0]:
                return sum(l)-e
            else:
                return 10**3
    return min(c(i+1,t,l+[0]),c(i+1,t+s[i][0]*-~i*100+s[i][1],l+[s[i][0]]))
print(c(0,0,[]))

Buggy submission (verdict: Runtime Error):
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**9
for b in range(1 << d):
    su = sum(s[i][0] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su <= g:
        m = d-bin(b)[2:].zfill(d).find("0")
        if m==-1:
            if su==g:
              print(n)
              exit()
            continue
        e =-~(g-su)//(m*100)
        if e < s[m-1][1]:
            a = min(a,n + e)
    if su > g:
        a = min(a,n)
print(a)

Buggy submission (verdict: Runtime Error):
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**9
for b in range(1 << d):
    su = sum(s[i][0] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su <= g:
        m = d-bin(b)[2:].zfill(d).find("0")
        e =-~(g-su)//(m*100)
        if e < s[m-1][1]:
            a = min(a,n + e)
    if su > g:
        a = min(a,n)
print(a)

Buggy submission (verdict: Runtime Error):
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**9
for b in range(1 << d):
    su = sum(s[i] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su <= g:
        m = d-bin(b)[2:].zfill(d).find("0")
        e =-~(g-su)//(m*100)
        if e < s[m-1][1]:
            a = min(a,n + e)
    if su > g:
        a = min(a,n)
print(a)
Problem p03434 (python)

Fixed submission:
_, *a = map(int, open(0).read().split())
a.sort()
print(sum(a[-1::-2]) - sum(a[-2::-2]))

Buggy submission (verdict: Runtime Error):
_, *a = map(int, open(0).read().split())
a.sorted()
print(sum(a[-1::2]) - sum(a[-2::2]))

Buggy submission (verdict: Runtime Error):
_, *a = map(int, open(0).read().split())
a.sorted()
print(sum(a[-1::2] - a[-2::2]))
Problem p03436 (python)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
map = [list(input()) for _ in range(h)]
dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

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

    d[0][0] =  ~-sum(1 for i in range(h) for j in range(w) if map[i][j] == ".")

    while q:
        x,y = q.popleft()
        if (x,y) == (h-1,w-1):
            break
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]
            if 0<=nx<h and 0<=ny<w and d[nx][ny]==-1 and map[nx][ny]!="#":
                q.append((nx,ny))
                d[nx][ny]= d[x][y] -1
    return d[h-1][w-1]
print(bfs())

Buggy submission (verdict: Runtime Error):
from collections import deque
h,w = map(int,input().split())
map = [list(input()) for _ in range(h)]
dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

def bfs():
    q = deque([])
    q.append((0,0))
    d = [([-1]*m)for _ in range(n)]

    d[0][0] = 0

    while q:
        x,y = q.popleft()
        if (x,y) == (h-1,w-1):
            break
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]
            if 0<=nx<h and 0<=ny<w and d[nx][ny]==-1 and map[nx][ny]!="#":
                q.append((nx,ny))
                d[nx][ny]= d[x][y]+1
    if map[h-1][w-1]:
        return h*w - d[h-1][w-1] - 1 - sum(1 for i in range(h) for j in range(w) if map[i][j] == "#")
    else:
        return -1

print(bfs())
Problem p03545 (python)

Fixed submission:
c,*s=input()
n=len(s)
for b in range(1<<n):
    t = c + ""
    for i in range(n):
        t += ["-","+"][b>>i & 1] + s[i]
    if eval(t) == 7:
        print(t+"=7")
        exit()

Buggy submission (verdict: Runtime Error):
c,*s=input()
for b in range(1<<n):
    t = c + ""
    for i in range(n):
        t += ["-","+"][b>>i & 1] + s[i]
    if eval(t) == 7:
        print(t+"=7")
        exit()
Problem p03607 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict
n, *a = map(int, open(0).read().split())
b = defaultdict(int)
for i in a:
    b[i] += 1
print(sum(i % 2 > 0 for i in b.values()))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0] * (10**5 + 1)
for i in a:
    b[i] += 1
print(sum(i % 2 > 0 for i in b))
Problem p02658 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
res=1
z=10**18
for i in a:
    if(i==0):
        res=0
        break
i=n-1
while(i>=0):
    if(a[i]==0):
        res=0
        break
    if(res>z/a[i]):
        res=z+1
        break
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=n-1
res=1
z=10**18
for i in a:
    if(i==0):
        res=0
        break
while(i>=0):
    if(res>z/a[i]):
        res=z+1
        break
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)
Problem p03363 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
list_S = [0]
ans = 0
for i in range(n):
    list_S.append(list_S[i] + a[i])

list_S.sort()
pre = list_S[0]
acc = 1
for i in range(1,n+1):
    if list_S[i] == pre:
        acc += 1
    else:
        ans += acc * (acc-1) // 2
        pre = list_S[i]
        acc = 1

ans += acc * (acc-1) // 2

    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
list_S = [0]
ans = 0
for i in range(n):
    list_S.append(list_S[i] + a[i])

dict_S = {}
for i in list_S:
    if i in dict_S:
        dict_S[i] = 1
    else:
        dict_S[i] += 1

for v in dict_S.values():
    ans += v * (v-1) // 2

print(ans)
Problem p02641 (python)

Fixed submission:
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
a = []
for i in range(-2,102):
    if i not in p:
        a.append(i)

m = []
for i in range(len(a)):
    m.append(abs(a[i] - x))

miner = min(m)
res = []
for i in a:
    if abs(x - i) == miner:
        res.append(i)

print(min(res))

Buggy submission (verdict: Runtime Error):
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
a = []
for i in range(1,101):
    if i not in p:
        a.append(i)

m = []
for i in range(len(a)):
    m.append(abs(a[i] - x))

miner = min(m)
res = []
for i in a:
    if abs(x - i) == miner:
        res.append(i)

print(min(res))
Problem p02714 (python)

Fixed submission:
a = int(input())
b = input()

import math

def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)


R = 0
G = 0
B = 0
for i in b:
    if i == "R":
        R += 1
    elif i == "G":
        G += 1
    else:
        B += 1


if R == 0 or G == 0 or B == 0:
    print(0)
else:
    res = 0
    for i in range(0, len(b)):
        for k in range(i + 1, len(b)):
            if (i + k) % 2 == 0:
                if b[i] != b[k] and b[i] != b[(i + k) //2] and b[k] != b[(i + k) //2]:
                    res += 1

    print(nCr(R, 1) * nCr(G, 1) * nCr(B, 1) - res)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = input()

import math

def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)


R = 0
G = 0
B = 0
for i in b:
    if i == "R":
        R += 1
    elif i == "G":
        G += 1
    else:
        B += 1

res = 0
for i in range(0, len(b)):
    for k in range(i + 1, len(b)):
        if (i + k) % 2 == 0:
            if b[i] != b[k] and b[i] != b[(i + k) //2] and b[k] != b[(i + k) //2]:
                res += 1

print(nCr(R, 1) * nCr(G, 1) * nCr(B, 1) - res)
Problem p02743 (python)

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

if c <= a + b:
    print("No")
elif 4*a*b < (c - a - b)*(c - a - b):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = [int(i) for i in input().split()]

if a*b < (c - a - b)*(c - a - b)/4 and 4*a*b - (c - a - b)*(c - a - b) < 0:
    print("Yes")
else:
    print("No")
Problem p03260 (python)

Fixed submission:
a = input().split()
a = [int(i) for i in a]

if a[0] * a[1] % 2 == 0:
	print ('No')
else:
	print('Yes')

Buggy submission (verdict: Runtime Error):
a = input().split()
a = [int(i) for i in a]

if a*b % 2 == 0:
	print ('No')
else:
	print('Yes')