Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
res = []
while True:
    if N % -2 != 0:
        res.append("1")
    else:
        res.append("0")
    
    if N == 1:
        break

    if N % -2 != 0:
        N -= 1
    N //= -2

print("".join(reversed(res)))

Fixed submission:
N = int(input())
res = []
while N != 0:
    if N % -2 != 0:
        res.append("1")
    else:
        res.append("0")
    
    if N == 1:
        break

    if N % -2 != 0:
        N -= 1
    N //= -2

if N != 0:
    print("".join(reversed(res)))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
res = []
while True:
    if N % -2 != 0:
        res.append("1")
    else:
        res.append("0")
    
    if N == 1:
        break

    if N % -2 != 0:
        N -= 1
    N //= -2

print("".join(reversed(res)))

Fixed submission:
N = int(input())
res = []
while N != 0:
    if N % -2 != 0:
        res.append("1")
    else:
        res.append("0")
    
    if N == 1:
        break

    if N % -2 != 0:
        N -= 1
    N //= -2

if N != 0:
    print("".join(reversed(res)))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))

if A <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')

Fixed submission:
A,B = list(map(int,input().split()))
 
if A <= 8 and B <= 8:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split())
if A == B == C:
    print(0)
else:
    x = 10**18
    for _ in range(K):
        a = B+C
        b = A+C
        c = A+B
        A=a
        B=b
        C=c
        if A - B > x:
            print("Unfair")
            break
    else:
        print(A-B)

Fixed submission:
A, B, C, K = map(int, input().split())
if K % 2 == 0:
    print(A-B)
else:
    print(B-A)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split())
if A == B == C:
    print(0)
else:
    x = 10**18
    for _ in range(K):
        a = B+C
        b = A+C
        c = A+B
        A=a
        B=b
        C=c
        if A - B > x:
            print("Unfair")
            break
    else:
        print(A-B)

Fixed submission:
A, B, C, K = map(int, input().split())
if K % 2 == 0:
    print(A-B)
else:
    print(B-A)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0

for i in range(N):
    x = 0
    for j in range(i, N):
        x += A[j]
        if x == 0:
            ans += 1

print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

ans = 0

b = [A[0]]

for i in range(1, N):
    b.append(b[-1]+A[i])

cnt = Counter(b)
cnt[0] += 1

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

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

x = [0]*(H*W+1)

for h1 in range(H):
    for w1 in range(W):
        if A[h1][w1] > H*W-D:
            continue
        f = False
        for h2 in range(H):
            for w2 in range(W):
                if A[h1][w1]+D == A[h2][w2]:
                    x[A[h2][w2]] = abs(h1-h2)+abs(w1-w2)
                    f = True
                    break
            if f:
                break

y = x[:D+1]
for i in range(D+1, H*W+1):
    y.append(y[i-D]+x[i])

for _ in range(int(input())):
    l, r = map(int, input().split())
    print(y[r]-y[l])

Fixed submission:
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

x = [0]*(H*W+1)
p = [[] for _ in range(H*W+1)]

for h in range(H):
    for w in range(W):
        p[A[h][w]] = [h, w]

for i in range(D+1, H*W+1):
    x[i] = x[i-D]+abs(p[i][0]-p[i-D][0])+abs(p[i][1]-p[i-D][1])

for _ in range(int(input())):
    l, r = map(int, input().split())
    print(x[r]-x[l])

Buggy python submission (verdict: Time Limit Exceeded):
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

x = [0]*(H*W+1)

for h1 in range(H):
    for w1 in range(W):
        if A[h1][w1] > H*W-D:
            continue
        f = False
        for h2 in range(H):
            for w2 in range(W):
                if A[h1][w1]+D == A[h2][w2]:
                    x[A[h2][w2]] = abs(h1-h2)+abs(w1-w2)
                    f = True
                    break
            if f:
                break

y = x[:D+1]
for i in range(D+1, H*W+1):
    y.append(y[i-D]+x[i])

for _ in range(int(input())):
    l, r = map(int, input().split())
    print(y[r]-y[l])

Fixed submission:
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

x = [0]*(H*W+1)
p = [[] for _ in range(H*W+1)]

for h in range(H):
    for w in range(W):
        p[A[h][w]] = [h, w]

for i in range(D+1, H*W+1):
    x[i] = x[i-D]+abs(p[i][0]-p[i-D][0])+abs(p[i][1]-p[i-D][1])

for _ in range(int(input())):
    l, r = map(int, input().split())
    print(x[r]-x[l])
Buggy python submission (verdict: Time Limit Exceeded):
X, Y = map(int, input().split())
num = X
l = 10**18
while num <= l:
    if num % Y != 0:
        print(num)
    num += X
else:
    print(-1)

Fixed submission:
X, Y = map(int, input().split())
if X % Y != 0:
    print(X)
elif X*2%Y != 0:
    print(X*2)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
X, Y = map(int, input().split())
num = X
l = 10**18
while num <= l:
    if num % Y == 0:
        print(num)
    num += X
else:
    print(-1)

Fixed submission:
X, Y = map(int, input().split())
if X % Y != 0:
    print(X)
elif X*2%Y != 0:
    print(X*2)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = input()
if N % sum(map(int, N)):
    print("No")
else:
    print("Yes")

Fixed submission:
N = input()
if int(N) % sum(map(int, N)):
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input())
if A+B+C+D==7:
    a = "+"
    b = "+"
    c = "+"
elif A+B+C-D==7:
    a = "+"
    b = "+"
    c = "-"
elif A+B-C+D==7:
    a = "+"
    b = "-"
    c = "+"
elif A+B-C-D==7:
    a = "+"
    b = "-"
    c = "-"
elif A-B+C+D==7:
    a = "-"
    b = "+"
    c = "+"
elif A-B+C-D==7:
    a = "-"
    b = "+"
    c = "-"
elif A-B-C+D==7:
    a = "-"
    b = "-"
    c = "+"
elif A-B-C-D==7:
    a = "-"
    b = "-"
    c = "-"

print(f"{A}{a}{B}{b}{C}{c}{D}=7")

Fixed submission:
A, B, C, D = map(int, input())
if A+B+C+D==7:
    a = "+"
    b = "+"
    c = "+"
elif A+B+C-D==7:
    a = "+"
    b = "+"
    c = "-"
elif A+B-C+D==7:
    a = "+"
    b = "-"
    c = "+"
elif A+B-C-D==7:
    a = "+"
    b = "-"
    c = "-"
elif A-B+C+D==7:
    a = "-"
    b = "+"
    c = "+"
elif A-B+C-D==7:
    a = "-"
    b = "+"
    c = "-"
elif A-B-C+D==7:
    a = "-"
    b = "-"
    c = "+"
elif A-B-C-D==7:
    a = "-"
    b = "-"
    c = "-"

print(str(A)+a+str(B)+b+str(C)+c+str(D)+"=7")
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
a = 1
for _ in range(N):
    a = min(a*2, a+k)
print(a)

Fixed submission:
N = int(input())
K = int(input())
a = 1
for _ in range(N):
    a = min(a*2, a+K)
print(a)
Buggy python submission (verdict: Runtime Error):
l = liet(map(int, input().split()))
for ll in l:
    if l.count(ll)==1:
        print(ll)
        break

Fixed submission:
l = list(map(int, input().split()))
for ll in l:
    if l.count(ll)==1:
        print(ll)
        break
Buggy python submission (verdict: Runtime Error):
print("YNeos"[s:=input()==s[::-1]]::2)

Fixed submission:
print("YNeos"[(s:=input())!=s[::-1]::2])
Buggy python submission (verdict: Runtime Error):
print("YNeos"[notA%3==0orB%3==0or(A+B)%3==0::2])

Fixed submission:
A, B = map(int, input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
a = [input()for _ in range(H)]
print("#"*(W+2))
for r in a:
    print(f"#{r}#")
print("#"*(W+2))

Fixed submission:
H, W = map(int, input().split())
a = [input()for _ in range(H)]
print("#"*(W+2))
for r in a:
    print("#"+r+"#")
print("#"*(W+2))

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
print("#"*(W+2))
for _ in range(H):
    print(f"#{input()}#")
print("#"*(W+2))

Fixed submission:
H, W = map(int, input().split())
a = [input()for _ in range(H)]
print("#"*(W+2))
for r in a:
    print("#"+r+"#")
print("#"*(W+2))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C = map(int, input().split())

cnt = 0
while A%2 == B%2 == C%2 == 0:
    x = (B+C)//2
    y = (A+C)//2
    z = (A+B)//2
    A = x
    B = y
    C = z
    cnt += 1

if A == B == C and A%2==0:
    print(-1)
else:
    print(cnt)

Fixed submission:
A, B, C = map(int, input().split())

if A == B == C and A%2==0:
    print(-1)
else:
    cnt = 0
    while A%2 == B%2 == C%2 == 0:
        x = (B+C)//2
        y = (A+C)//2
        z = (A+B)//2
        A = x
        B = y
        C = z
        cnt += 1
    print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
A, B, C = map(int, input().split())
if C%math.gcd(A, B) == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
import fractions
A, B, C = map(int, input().split())
if C % fractions.gcd(A, B) == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
print("".join(s[0] for s in input()split()))

Fixed submission:
print("".join(s[0] for s in input().split()))
Buggy python submission (verdict: Runtime Error):
print((int(input())+int(input()))*int(input()//2)

Fixed submission:
print((int(input())+int(input()))*int(input())//2)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], -1, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

MOD = 10**9 + 7
F = Factorial(200000, MOD)
s = int(input())
p = 0
for i in range(s // 3):
    i += 1
    d = F.comb(s - i * 2 - 1, i - 1)
    p = (p + d) % MOD
print(p)

Fixed submission:
class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], mod - 2, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

MOD = 10**9 + 7
F = Factorial(200000, MOD)
s = int(input())
p = 0
for i in range(s // 3):
    i += 1
    d = F.comb(s - i * 2 - 1, i - 1)
    p = (p + d) % MOD
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n = int(input())
t = input()
*c, = map(int, t.replace(*"W1").replace(*"R0"))

"""
1100 -> 0101 -> 0011
00
10110100 -> 00111100 -> 00011110 -> 00001111
"""

a = 0
i, j = 0, 1
while i + j < n:
    if c[i] == 1 and c[-j] == 0:
        a += 1
        i += 1
        j += 1
    elif c[i] == c[-j] == 0:
        i += 1
    elif c[i] == c[-j] == 1:
        j += 1
print(a)

Fixed submission:
#!/usr/bin/env python3
n = int(input())
t = input()
*c, = map(int, t.replace(*"W1").replace(*"R0"))

"""
1100 -> 0101 -> 0011
00
10110100 -> 00111100 -> 00011110 -> 00001111
"""

a = 0
i, j = 0, 1
while i + j < n:
    if c[i] == 1 and c[-j] == 0:
        a += 1
        i += 1
        j += 1
    elif c[i] == c[-j] == 0:
        i += 1
    elif c[i] == c[-j] == 1:
        j += 1
    else:
        i += 1
        j += 1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
class Bit:
    # Binary Indexed Tree
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i + 1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

(n, q), c, *d = [[*map(int, o.split())] for o in open(0)]

d = sorted(enumerate(d), key = lambda x: x[1][1])

B = Bit(n)
ans = [-1] * q
last = [-1] * (n + 1)
ind = 0  # [-, ind) まで確認終了
for i, (l, r) in d:
    for j in range(ind, r):
        if last[c[j]] != -1:
            B.add(last[c[j]], -1)
        B.add(j, 1)
        last[c[j]] = j
    ind = r
    ans[i] = B.sum(r) - B.sum(l - 1)
for a in ans:
    print(a)

Fixed submission:
#!/usr/bin/env python3
class Bit:
    # Binary Indexed Tree
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i + 1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

(n, q), c, *d = [[*map(int, o.split())] for o in open(0)]

d = sorted(enumerate(d), key = lambda x: x[1][1])

B = Bit(n)
ans = [-1] * q
last = [-1] * (n + 1)
ind = 0  # [-, ind) まで確認終了
for i, (l, r) in d:
    for j in range(ind, r):
        if last[c[j]] != -1:
            B.add(last[c[j]], -1)
        B.add(j, 1)
        last[c[j]] = j
    ind = r
    ans[i] = B.sum(r) - B.sum(l - 1)
for a in ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
I=N=9**9
P,M,L,R,U='x+y','x-y',[],[],[]
for t in[*open(0)][1:]:*z,u=t.split();exec(u+'+=[*map(int,z)],')
for*A,S,D in(D,U,*'xy'),(L,R,*'yx'),(U,R,P,M),(L,D,P,M),(L,U,M,P),(D,R,M,P):
 n=p=-I
 for x,y,r in eval(f"sorted(({S},{D},Q)for Q,P in enumerate(A)for x,y in P)"):
  if r:n,p=x,y  
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')

Fixed submission:
_, *a = map(str.split, open(0))
U, R, D, L = "URDL"
INF = float("inf")
d = {}
for *z, u in a:
  d.setdefault(u, []).append([*map(int, z)])
N = INF
for A, B, S in [(U, D, "x, y"), (R, L, "y, x"), 
                (R, U, "x+y, x-y"), (D, L, "x+y, x-y"), 
                (U, L, "x-y, x+y"), (R, D, "x-y, x+y")]:
  n = p = -INF
  L = eval(f"[({S}, Q) for P, Q in [(A, 1), (B, 0)] for x, y in d.get(P, [])]")
  for x, y, r in sorted(L):
    if x != n:
      if r:n = x;p = y
    elif r:p = y
    else:N = min(N, (y - p)*5)
print("SAFE" if N == INF else N)
Buggy python submission (verdict: Time Limit Exceeded):
class Osa_k:
    def __init__(self, n_max):
        self.n_max = n_max
        self.min_factor = min_factor = list(range(n_max + 1))
        min_factor[2::2] = [2] * (n_max // 2)
        min_factor[3::6] = [3] * ((n_max + 3) // 6)
        for i in range(5, int(n_max ** .5) + 1, 2):
            if min_factor[i] == i:
                for j in range(i*i, n_max + 1, i):
                    if min_factor[j] == j:
                        min_factor[j] = i

    def __call__(self, n):
        min_factor = self.min_factor
        t = []
        while n > 1:
            if t and t[-1][0] == min_factor[n]:
                t[-1][1] += 1
            else:
                t.append([min_factor[n], 1])
            n //= min_factor[n]
        return t

def f(K):
    res = 1
    for _, i in K:
        res *= i + 1
    return res

P = Osa_k(10**7)
print(sum(i * f(P(i)) for i in range(1, int(input()) + 1)))


Fixed submission:
n = int(input())
print(sum(n//i * (i + n//i*i)//2 for i in range(1, n + 1)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

class Osa_k:
    def __init__(self, n_max):
        self.n_max = n_max
        self.min_factor = min_factor = list(range(n_max + 1))
        min_factor[2::2] = [2] * (n_max // 2)
        min_factor[3::6] = [3] * ((n_max + 3) // 6)
        for i in range(5, int(n_max ** .5) + 1, 2):
            if min_factor[i] == i:
                for j in range(i*i, n_max + 1, i):
                    if min_factor[j] == j:
                        min_factor[j] = i

    def __call__(self, n):
        if not 1 <= n <= self.n_max: raise ValueError("Invaild Value!")
        min_factor = self.min_factor
        n_twoes = (n & -n).bit_length() - 1
        res = {2 : n_twoes}
        n >>= n_twoes
        while n > 1:
            p = min_factor[n]
            res[p] = res.get(p, 0) + 1
            n //= p
        return res.values()

def f(K):
    res = 1
    for i in K:
        res *= i + 1
    return res

P = Osa_k(10**7)
print(sum(i * f(P(i)) for i in range(1, int(input()) + 1)))


Fixed submission:
n = int(input())
print(sum(n//i * (i + n//i*i)//2 for i in range(1, n + 1)))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env pypy
n = int(input())
F = [1] * -~n
for i in range(2, n + 1):
    for j in range(i, n + 1, i):
        F[j] += 1
print(sum(e * v for e, v in enumerate(F)))

Fixed submission:
n = int(input())
print(sum(n//i * (i + n//i*i)//2 for i in range(1, n + 1)))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import*
n, k, *A = map(int, open(0).read().split())

def imos(l, r):
    B[l] += 1
    if r + 1 != n:
        B[r + 1] -= 1

for _ in [0] * min(k, 41):
    B = [0] * n
    for i, a in enumerate(A):
        imos(max(i - a, 0), min(i + a, n - 1))
    *A, = accumulate(B)
print(*A)

Fixed submission:
#!/usr/bin/env python3
from itertools import*
n, k, *A = map(int, open(0).read().split())

def imos(l, r):
    B[l] += 1
    if r + 1 != n:
        B[r + 1] -= 1

for _ in [0] * min(k, 41):
    B = [0] * n
    for i, a in enumerate(A):
        imos(max(i - a, 0), min(i + a, n - 1))
    *A, = accumulate(B)
print(*A)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
n, k, *a = map(int, open(0).read().split())
F = [0 for _ in range(n)]  # 来た？
T = [None for _ in range(n)]  # いつ来た？
def main(now, time, K):
    time += 1
    if F[now-1]:
        P = T[now-1]
        print(T.index(P + (K - time + 1) % (time - P)) + 1)
        exit()
    F[now-1] = 1
    T[now-1] = time
    main(a[now-1], time, K)
    if time == K:
        print(now)
        exit()

main(1, 0, k)

Fixed submission:
#!/usr/bin/env python3
print("YNeos"[input()!=input()[:-1]::2])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, k, *a = map(int, open(0).read().split())
F = [0 for _ in range(n)]  # 来た？
T = [None for _ in range(n)]  # いつ来た？
def main(now, time, K):
    time += 1
    if F[now-1]:
        P = T[now-1]
        print(T.index(P + (K - time + 1) % (time - P)) + 1)
        exit()
    F[now-1] = 1
    T[now-1] = time
    main(a[now-1], time, K)

main(1, 0, k)

Fixed submission:
n, k, *a = map(int, open(0).read().split())
a = [0] + a
p = 1
while k:
    if k % 2:
        p = a[p]
    a = [a[b] for b in a]
    k //= 2
print(p)
Buggy python submission (verdict: Runtime Error):
a = 0
x = int(input())
for a in range(x):
    b = (x - a**5)**.2
    if type(b) in (int,float) and float.is_integer(float(b)):
        print(a, -int(b))
        exit()

Fixed submission:
#!/usr/bin/env python3
n, m = map(int, input().split())
*h, = map(int, input().split())
h = [0] + h
i = [0] + [1] * n

for j in range(m):
    a, b = map(int, input().split())
    if h[a] >= h[b]:
        i[b] = 0
    if h[a] <= h[b]:
        i[a] = 0
print(sum(i))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
a = 1
x = int(input())
while True:
    bz = (x-a**5)**.2
    if float.is_integer(bz):
        print(a, -int(bz))
        exit()
    a += 1

Fixed submission:
#!/usr/bin/env python3
n, m = map(int, input().split())
*h, = map(int, input().split())
h = [0] + h
i = [0] + [1] * n

for j in range(m):
    a, b = map(int, input().split())
    if h[a] >= h[b]:
        i[b] = 0
    if h[a] <= h[b]:
        i[a] = 0
print(sum(i))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = 1
x = int(input())
while True:
    bz = (x-a**5)**.2
    if float.is_integer(bz):
        print(int(bz), -a)
        exit()
    a += 1

Fixed submission:
x = int(input())

for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i ** 5 - j ** 5 == x:
            print(i,j)
            quit()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
s = input()
l = len(s)
if 4>l:
    print(0)
    exit()
c = 0
a = [0] + list(accumulate(map(int, list(s))))
for i in range(l-3):
    for j in range(i+4, l):
        if (a[j+1] - a[i]) % 3 == 0:
            if int(s[i:j+1]) % 673 == 0:
                c += 1
print(c)

Fixed submission:
m = 2019
l = [0]*m
a = b = 0;k = 1
for c in input():
  l[b % m] += 1
  b -= int(c)*k
  a += l[b % m]
  k = k*202 % m
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations as c
co = 0
r = range(1, int(input())+1)
s = "0" + input()
for i, j, k in c(r, 3):
  if s[i] != s[j] and s[j] != s[k] and s[k] != s[i] and j-i != k-j:
    co += 1
print(co)

Fixed submission:
n, s = open(0)
r, g, b = map(s.count, "RGB")
e = enumerate
print(r*g*b - sum(f != g != s[i+j] != f for i, f in e(s) for j, g in e(s[i:-1:2])))