Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

exp = []
sum_list = [0]
result_list = []
result = 0
for i in range(N):
    exp.append((p[i]+1)/2)
    sum_list.append(sum(exp))  
for i in range(N-K+1):
    tmp = sum_list[K+i] - sum_list[i]
    if result < tmp:
        result = tmp
    
print(result)


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
exp = []
sum_list = []
result_list = []
result = 0
count = 0
tmp = 0
for i in range(N):
    if count < K-1:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
    else:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
        sum_list.append(tmp)
        tmp -= exp[count-K+1]
    count += 1

print(max(sum_list))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

exp = []
sum_list = [0]
result_list = []
result = 0
for i in range(N):
    exp.append((p[i]+1)/2)
    sum_list.append(sum(exp))  
for i in range(N-K+1):
    tmp = sum_list[K+i] - sum_list[i]
    if result < tmp:
        result = tmp
    
print(result)


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
exp = []
sum_list = []
result_list = []
result = 0
count = 0
tmp = 0
for i in range(N):
    if count < K-1:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
    else:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
        sum_list.append(tmp)
        tmp -= exp[count-K+1]
    count += 1

print(max(sum_list))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

exp = []
sum_list = [0]
result_list = []
for i in range(N):
    exp.append((p[i]+1)/2)
    sum_list.append(sum(exp))  
for i in range(N-K+1):
    result_list.append(sum_list[K+i] - sum_list[i])
print(max(result_list))


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
exp = []
sum_list = []
result_list = []
result = 0
count = 0
tmp = 0
for i in range(N):
    if count < K-1:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
    else:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
        sum_list.append(tmp)
        tmp -= exp[count-K+1]
    count += 1

print(max(sum_list))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

exp = []
for i in range(N):
    exp.append((p[i]+1)/2)    
sum_list = []
for i in range(N-K+1):
    sum_list.append(sum(exp[i:K+i]))
print(max(sum_list))


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
exp = []
sum_list = []
result_list = []
result = 0
count = 0
tmp = 0
for i in range(N):
    if count < K-1:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
    else:
        a = (p[i]+1)/2
        exp.append(a)
        tmp += a
        sum_list.append(tmp)
        tmp -= exp[count-K+1]
    count += 1

print(max(sum_list))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N):
    mi = min(P[:i+1])
    if P[i] <= mi:
        cnt += 1
print(cnt)


Fixed submission:
N = int(input())
P = list(map(int, input().split()))
cnt = 0
mi = P[0]
for i in range(N):
    if mi > P[i]:
        mi = P[i]
    if P[i] <= mi:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def kaijou(x):
    result = 1
    for i in range(1, x+1):
        result *= i
    return result

def nokori(X, y):

    X = sorted(X)
    idx = 0
    for i in X:
        if i == y:
            return idx
        idx += 1
a = 1
tmp_P = P.copy()
for idx, i in enumerate(P):
    if idx < len(P):
        a = a + (nokori(tmp_P,i))*kaijou(N-idx-1)
        tmp_P.remove(i)
b = 1
tmp_Q = Q.copy()
for idx, i in enumerate(Q):
    if idx < len(Q):
        b += (nokori(tmp_Q,i))*kaijou(N-idx-1)
        tmp_Q.remove(i)
if a > b:
    print(a-b)
else:
    print(b-a)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def kaijou(x):
    result = 1
    for i in range(1, x+1):
        result *= i
    return result

def nokori(X, y):

    X = sorted(X)
    idx = 0
    for i in X:
        if i == y:
            return idx
        idx += 1
a = 1
tmp_P = P.copy()
for idx, i in enumerate(P):
    if idx < len(P):
        a = a + (nokori(tmp_P,i))*kaijou(N-idx-1)
        tmp_P.remove(i)
b = 1
tmp_Q = Q.copy()
for idx, i in enumerate(Q):
    if idx < len(Q):
        b += (nokori(tmp_Q,i))*kaijou(N-idx-1)
        tmp_Q.remove(i)
if a > b:
    print(a-b)
else:
    print(b-a)

Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def kaijou(x):
    result = 1
    for i in range(1, x+1):
        result *= i
    return result

def nokori(X, y):

    X = sorted(X)
    idx = 0
    for i in X:
        if i == y:
            return idx
        idx += 1
a = 1
tmp_P = P.copy()
for idx, i in enumerate(P):
    if idx < len(P):
        a = a + (nokori(tmp_P,i))*kaijou(N-idx-1)
        tmp_P.remove(i)
b = 1
tmp_Q = Q.copy()
for idx, i in enumerate(Q):
    if idx < len(Q):
        b += (nokori(tmp_Q,i))*kaijou(N-idx-1)
        tmp_Q.remove(i)
if a > b:
    print(a-b)
else:
    print(b-a)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def kaijou(x):
    result = 1
    for i in range(1, x+1):
        result *= i
    return result

def nokori(X, y):

    X = sorted(X)
    idx = 0
    for i in X:
        if i == y:
            return idx
        idx += 1
a = 1
tmp_P = P.copy()
for idx, i in enumerate(P):
    if idx < len(P):
        a = a + (nokori(tmp_P,i))*kaijou(N-idx-1)
        tmp_P.remove(i)
b = 1
tmp_Q = Q.copy()
for idx, i in enumerate(Q):
    if idx < len(Q):
        b += (nokori(tmp_Q,i))*kaijou(N-idx-1)
        tmp_Q.remove(i)
if a > b:
    print(a-b)
else:
    print(b-a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

As = list(map(int, input().split()))

ans = 1

for a in As:
    ans *= a

if ans <= 10**18:
    print(ans)
else:
    print(-1)

Fixed submission:
N = int(input())
 
As = list(map(int, input().split()))

if 0 in As:
    print(0)
    exit()
 
ans = 1
 
for a in As:
    ans *= a
    
    if ans > 10**18:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
# N = int(input())

import numpy as np

N,K = list(map(int, input().split()))
As = list(map(int, input().split()))

visited = set()
from2to = {}
for i,a in enumerate(As):
    from2to[i+1] = a

id2n_warp = {}
current = 1
loop_anchor = -1
n_warp = 0
visited.add(1)
id2n_warp[1] = 0
while True:
    n_warp += 1
    next_ = from2to[current]
    if n_warp == K:
        print(next_)
        exit()
    if next_ in visited:
        loop_anchor = next_
        break
    else:
        id2n_warp[n_warp] = next_
        visited.add(next_)
    current = next_

K -= id2n_warp[loop_anchor]
# print(n_warp)
# print(K)
# print(id2n_warp[loop_anchor])
K = K % (n_warp - id2n_warp[loop_anchor]) if n_warp - id2n_warp[loop_anchor] > 0 else K

current = loop_anchor
for i in range(K):
    next_ = from2to[current]
    current = next_

print(next_)


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

import numpy as np

N,K = list(map(int, input().split()))
As = list(map(int, input().split()))

visited = set()
from2to = {}
for i,a in enumerate(As):
    from2to[i+1] = a

id2n_warp = {}
current = 1
loop_anchor = -1
n_warp = 0
visited.add(1)
id2n_warp[1] = 0
while True:
    n_warp += 1
    next_ = from2to[current]
    if n_warp == K:
        print(next_)
        exit()
    if next_ in visited:
        loop_anchor = next_
        break
    else:
        id2n_warp[next_] = n_warp
        visited.add(next_)
    current = next_

K -= id2n_warp[loop_anchor]
# print(n_warp)
# print(K)
# print(id2n_warp[loop_anchor])
K = K % (n_warp - id2n_warp[loop_anchor])
# K = K % (n_warp - id2n_warp[loop_anchor]) if n_warp - id2n_warp[loop_anchor] > 0 else K

current = loop_anchor
for i in range(K):
    next_ = from2to[current]
    current = next_

print(next_)
Buggy python submission (verdict: Runtime Error):
import numpy as np

def saisho_ko_baisu(A, B):
    # A < B
    if A > B:
        A,B = B,A
    x = A*B
    r = B%A
    while r!=0:
        B = A
        A = r
        r = B%A
    saisho_ko_baisu = x//A
    return saisho_ko_baisu

H,N = list(map(int, input().split()))
As = []
Bs = []
for i in range(N):
    a, b = list(map(int, input().split()))
    As.append(a)
    Bs.append(b)

skb = saisho_ko_baisu(As[0], As[1])
for i in range(2,N):
    skb = saisho_ko_baisu(skb, As[i])

most_eff = 100000000
most_eff_id = -1
for i in range(N):
    tmp = (skb // As[i])*Bs[i]
    if most_eff > tmp:
        most_eff = tmp
        most_eff_id = i

cost = (H//skb)*(skb//As[most_eff_id])*Bs[most_eff_id]
H -= (H//skb)*skb

if H == 0:
    print(cost)
    exit()

dp = np.full((N+1, H+1), np.inf)
dp[:, 0] = 0

for r in range(1,N+1):
    for c in range(1,H+1):
        if c >= As[r-1]:
            dp[r, c] = min(dp[r-1, c], dp[r, c-As[r-1]] + Bs[r-1])
        else:
            dp[r, c] = min(dp[r-1, c], Bs[r-1])

# print(dp)
print(cost + int(dp[-1, -1]))


Fixed submission:
import numpy as np

H,N = list(map(int, input().split()))
As = []
Bs = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    As.append(a)
    Bs.append(b)
As = np.array(As)
Bs = np.array(Bs)

dp = np.full((H+1), np.inf)
dp[0] = 0

for c in range(1,H+1):
    dp[c] = np.amin(dp[np.maximum(c - As, 0)] + Bs)

print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H,N = list(map(int, input().split()))
As = []
Bs = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    As.append(a)
    Bs.append(b)

dp = np.full((N+1, H+1), np.inf)
dp[:, 0] = 0

for r in range(1,N+1):
    for c in range(1,H+1):
        if c >= As[r-1]:
            dp[r, c] = min(dp[r-1, c], dp[r, c-As[r-1]] + Bs[r-1])
        else:
            dp[r, c] = min(dp[r-1, c], Bs[r-1])

# print(dp)
print(int(dp[-1, -1]))


Fixed submission:
import numpy as np

H,N = list(map(int, input().split()))
As = []
Bs = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    As.append(a)
    Bs.append(b)
As = np.array(As)
Bs = np.array(Bs)

dp = np.full((H+1), np.inf)
dp[0] = 0

for c in range(1,H+1):
    dp[c] = np.amin(dp[np.maximum(c - As, 0)] + Bs)

print(int(dp[-1]))
Buggy python submission (verdict: Runtime Error):
import math

a, b ,x = list(map(int, input().split()))

if x >= a*a*b/2:
    tan_theta = a**2 / (2*(a*b - x/a))
    theta = math.atan(tan_theta)
    print(90 - math.degrees(theta))
else:
    tan_theta = 2*x / (a*(b**2))
    theta = math.atan(tan_theta)
    print(90 - math.degrees(theta))


Fixed submission:
import math

a, b ,x = list(map(int, input().split()))

if a*a*b == x:
    print(0)
    exit()

if x >= a*a*b/2:
    tan_theta = a**2 / (2*(a*b - x/a))
    theta = math.atan(tan_theta)
    print(90 - math.degrees(theta))
else:
    tan_theta = 2*x / (a*(b**2))
    theta = math.atan(tan_theta)
    print(90 - math.degrees(theta))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

# A,B = list(map(int, input().split()))

# N = int(input())
N,M = list(map(int, input().split()))
As = np.array(list(map(int, input().split())))

# As.sort(reverse=True)
#
# for i in range(N-1):
#     A = As[i]
#     A_next = As[i+1]
#     while A > A_next and M>0:
#         A = A//2
#         M -= 1
#         print("use",M)
#
#     As[i] = A
#     print(As)
# print(sum(As))


for i in range(M):
    ind = np.argmax(As)
    As[ind] = As[ind] // 2

print(np.sum(As))


Fixed submission:
import numpy as np

# A,B = list(map(int, input().split()))

# N = int(input())
N,M = list(map(int, input().split()))
As = np.array(list(map(int, input().split())))

# As.sort(reverse=True)
As[::-1].sort()
max_A = As[0]

while M > 0:
    i=1
    for i in range(1, min(M, N)):
        if As[i] <= max_A//2:
            break
    # print(M)
    # print(As)
    # print(i)
    As[:min(M,i)] = As[:min(M,i)] // 2
    # print(As)
    M -= i
    As[::-1].sort()
    max_A = As[0]
    # print(As)

print(np.sum(As))
Buggy python submission (verdict: Time Limit Exceeded):
# K,X = list(map(int, input().split()))

import numpy as np

N = int(input())

mat = np.zeros(N)
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(N):
    word = input()
    for s in word:
        mat[i] += 2**alphabet.index(s)
# print(mat)
ans = 0
for i in range(N):
    for j in range(i+1, N):
        # print(mat[i])
        # print(mat[j])
        # print("{}, {}".format(i,j))
        # print(mat[i] - mat[j])
        if mat[i] - mat[j] == 0:
            # print(i)
            # print(j)
            # print()
            ans += 1

print(ans)


Fixed submission:
# K,X = list(map(int, input().split()))

N = int(input())

alphabet = "abcdefghijklmnopqrstuvwxyz"

ans_dic = {}

for i in range(N):
    word = input()
    tmp = 0
    for s in word:
        tmp += 10**alphabet.index(s)

    if tmp in ans_dic:
        ans_dic[tmp] += 1
    else:
        ans_dic[tmp] = 1
ans = 0
for k, v in ans_dic.items():
    ans += v * (v-1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A = A + A
# all_neg = sum(A)

res = ""
for i in range(N):
    res_tmp = 0
    for j, a in enumerate(A[i:i+N]):
        res_tmp += a if j % 2 == 0 else -a
    # res.append(res_tmp)
    res += (str(res_tmp) + " ")
    # print(res_tmp, end=" ")
print(res[:-1])


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
res = ""
res_tmp = 0
for j, a in enumerate(A):
    res_tmp += a if j % 2 == 0 else -a
res += (str(res_tmp) + " ")

for i, a in enumerate(A[:-1]):
    res_tmp = -res_tmp + a*2
    res += (str(res_tmp) + " ")
print(res[:-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = n

exp = []
div = []
for i in range(2, int(n**(1/2))+2):
    cnt = 0
    if n%i == 0:
        div.append(n//i)
        while n%i == 0:
            cnt += 1
            n //= i
        exp.append(cnt)

for i in div:
    cnt = 0
    while n%i == 0:
        cnt += 1
        n //= i
    if cnt >= 1:
        exp.append(cnt)

if n == m and m > 1:
    exp.append(1)

opr = 0
for x in exp:
    opr += int((-1+(8*x+1)**(1/2))/2)

print(opr)

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

exp = []

cnt = 0
while n%2 == 0:
    cnt += 1
    n //= 2
if cnt > 0:
    exp.append(cnt)

i = 3
while i*i <= n:
    cnt = 0
    while n%i == 0:
        cnt += 1
        n //= i
    exp.append(cnt)
    i += 2

if n != 1:
    exp.append(1)

opr = 0
for x in exp:
    opr += int((-1+(8*x+1)**(1/2))/2)

print(opr)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = n

exp = []
div = []
for i in range(2, int(n**(1/2))+2):
    cnt = 0
    if n%i == 0:
        div.append(n//i)
        while n%i == 0:
            cnt += 1
            n //= i
        exp.append(cnt)

for i in div:
    cnt = 0
    while n%i == 0:
        cnt += 1
        n //= i
    if cnt >= 1:
        exp.append(cnt)

if n == m and m > 1:
    exp.append(1)

opr = 0
for x in exp:
    for i in range(x+1):
        if i*(i+1)//2 <= x < (i+1)*(i+2)//2:
            opr += i
            break

print(opr)

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

exp = []

cnt = 0
while n%2 == 0:
    cnt += 1
    n //= 2
if cnt > 0:
    exp.append(cnt)

i = 3
while i*i <= n:
    cnt = 0
    while n%i == 0:
        cnt += 1
        n //= i
    exp.append(cnt)
    i += 2

if n != 1:
    exp.append(1)

opr = 0
for x in exp:
    opr += int((-1+(8*x+1)**(1/2))/2)

print(opr)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys

LI = lambda: list(map(int, sys.stdin.readline().rstrip().split()))

def main():
    n, s = LI()
    a = LI()
    dp = np.zeros((n+1, s+1), dtype=np.int)
    dp[0][0] = 1

    for i in range(n):
        for w in range(s+1):
            dp[i+1][w] = 2*dp[i][w]
            if w >= a[i]:
                dp[i+1][w] += dp[i][w-a[i]]
            dp[i+1][w] %= 998244353

    print(dp[n][s])

if __name__ == '__main__':
    main()

Fixed submission:
import sys

LI = lambda: list(map(int, sys.stdin.readline().rstrip().split()))

def main():
    n, s = LI()
    a = LI()
    dp = [[0 for i in range(s+1)] for j in range(n+1)]
    dp[0][0] = 1

    for i in range(n):
        for w in range(s+1):
            dp[i+1][w] = 2*dp[i][w]
            if w >= a[i]:
                dp[i+1][w] += dp[i][w-a[i]]
            dp[i+1][w] %= 998244353

    print(dp[n][s])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import numpy as np

LI = lambda: list(map(int, input().split()))

n, s = LI()
a = LI()
dp = np.zeros((n+1, s+1), dtype=np.int)
dp[0][0] = 1

for i in range(n):
    for w in range(s+1):
        dp[i+1][w] = 2*dp[i][w]
        if w >= a[i]:
            dp[i+1][w] += dp[i][w-a[i]]
        dp[i+1][w] %= 998244353

print(dp[n][s])

Fixed submission:
import sys

LI = lambda: list(map(int, sys.stdin.readline().rstrip().split()))

def main():
    n, s = LI()
    a = LI()
    dp = [[0 for i in range(s+1)] for j in range(n+1)]
    dp[0][0] = 1

    for i in range(n):
        for w in range(s+1):
            dp[i+1][w] = 2*dp[i][w]
            if w >= a[i]:
                dp[i+1][w] += dp[i][w-a[i]]
            dp[i+1][w] %= 998244353

    print(dp[n][s])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

LI = lambda: list(map(int, input().split()))

n, s = LI()
a = LI()
dp = np.zeros((n+1, s+1), dtype=np.int)
dp[0][0] = 1

for i in range(n):
    for w in range(s+1):
        dp[i+1][w] = 2*dp[i][w]
        if w >= a[i]:
            dp[i+1][w] += dp[i][w-a[i]]
        dp[i+1][w] %= 998244353

print(dp[n][s])

Fixed submission:
import sys

LI = lambda: list(map(int, sys.stdin.readline().rstrip().split()))

def main():
    n, s = LI()
    a = LI()
    dp = [[0 for i in range(s+1)] for j in range(n+1)]
    dp[0][0] = 1

    for i in range(n):
        for w in range(s+1):
            dp[i+1][w] = 2*dp[i][w]
            if w >= a[i]:
                dp[i+1][w] += dp[i][w-a[i]]
            dp[i+1][w] %= 998244353

    print(dp[n][s])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque, defaultdict

n, m = list(map(int, input().split()))
a, b = [], []
d = defaultdict(list)
for i in range(m):
    data = list(map(int, input().split()))
    a.append(data[0])
    b.append(data[1])
    d[data[0]].append(data[1])
    d[data[1]].append(data[0])

mindist = defaultdict(lambda: 1000000)
mindist[1] = 0
sign = defaultdict(int)

dq = deque()
dq.append([1, 0])
while len(dq) > 0:
    room, dist = dq.pop()
    for nroom in d[room]:
        if dist + 1 < mindist[nroom]:
            mindist[nroom] = dist + 1
            sign[nroom] = room
            dq.append([nroom, dist + 1])

print('Yes')
for i in range(2, n+1):
    print(sign[i])

Fixed submission:
from collections import deque, defaultdict

n, m = list(map(int, input().split()))
d = defaultdict(list)
for i in range(m):
    data = list(map(int, input().split()))
    d[data[0]].append(data[1])
    d[data[1]].append(data[0])

mindist = defaultdict(lambda: 1000000)
mindist[1] = 0
sign = defaultdict(int)

dq = deque()
dq.append([1, 0])
while len(dq) > 0:
    room, dist = dq.popleft()
    for nroom in d[room]:
        if dist + 1 < mindist[nroom]:
            mindist[nroom] = dist + 1
            sign[nroom] = room
            dq.append([nroom, dist + 1])

print('Yes')
for i in range(2, n+1):
    print(sign[i])
Buggy python submission (verdict: Runtime Error):
from math import gcd
from collections import defaultdict

def sign(a):
    if a == 0:
        return 0
    else:
        return a//abs(a)

n = int(input())
a, b = [], []
for i in range(n):
    data = list(map(int, input().split()))
    a.append(data[0])
    b.append(data[1])

d = defaultdict(lambda: [0, 0])
zeros = 0

for i in range(n):
    g = gcd(a[i], b[i])
    a[i] //= g
    b[i] //= g
    if a[i]*b[i] > 0:
        d[(abs(a[i]), abs(b[i]))][0] += 1
    elif a[i]*b[i] < 0:
        d[(abs(b[i]), abs(a[i]))][1] += 1
    elif a[i] == 0 and b[i] != 0:
        d[(0, 1)][0] += 1
    elif b[i] == 0 and a[i] != 0:
        d[(0, 1)][1] += 1
    elif a[i] == b[i] == 0:
        zeros += 1

mod = 1000000007
cnt = 1
for pair in d.values():
    cnt *= pow(2, pair[0], mod) + pow(2, pair[1], mod) - 1
    cnt %= mod
cnt += zeros - 1
print(cnt)

Fixed submission:
from math import gcd
from collections import defaultdict

n = int(input())
a, b = [], []
for i in range(n):
    data = list(map(int, input().split()))
    a.append(data[0])
    b.append(data[1])

d = defaultdict(lambda: [0, 0])
zeros = 0

for i in range(n):
    if a[i] * b[i] != 0:
        g = gcd(a[i], b[i])
        a[i] //= g
        b[i] //= g
    if a[i]*b[i] > 0:
        d[(abs(a[i]), abs(b[i]))][0] += 1
    elif a[i]*b[i] < 0:
        d[(abs(b[i]), abs(a[i]))][1] += 1
    elif a[i] == 0 and b[i] != 0:
        d[(0, 1)][0] += 1
    elif b[i] == 0 and a[i] != 0:
        d[(0, 1)][1] += 1
    elif a[i] == b[i] == 0:
        zeros += 1

mod = 1000000007
cnt = 1
for pair in d.values():
    cnt *= pow(2, pair[0], mod) + pow(2, pair[1], mod) - 1
    cnt %= mod
cnt += zeros - 1
cnt %= mod
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

loop = [0]
town = 0
visited = defaultdict(lambda: None)
visited[town] = 0

for i in range(1, k):
    town = a[town]
    if visited[town] != None:
        offset = visited[town]
        period = i - offset 
        break
    else:
        loop.append(town)
        visited[town] = i

print(loop[offset+((k-offset)%period)]+1)

Fixed submission:
from collections import defaultdict

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

loop = [0]
town = 0
visited = defaultdict(lambda: None)
visited[town] = 0

period = 0
for i in range(1, k+1):
    town = a[town]
    if visited[town] != None:
        offset = visited[town]
        period = i - offset 
        break
    else:
        loop.append(town)
        visited[town] = i

if period == 0:
    print(town+1)
else:
    print(loop[offset+((k-offset)%period)]+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

x = int(input())

div = []

i = 1
while i*i <= x:
    if x%i == 0:
        div.append(i)
        if i*i != x:
            div.append(x//i)
    i += 1

for d in div:

    minr = math.floor(math.sqrt(math.sqrt((x//d)/5)))
    if minr-d <= 0:
        minr = 0
    a = minr

    while (a-d)<=0 or 5*((a-d)**4) < x//d:
        a += 1
        b = a-d
        if a**5-b**5 == x:
            print(a, b)
            exit()
        if -a**5+b**5 == x:
            print(-a, -b)
            exit()

Fixed submission:
import math

x = int(input())

a = 0
b = 0
while b**5 > -x:
    b -= 1

while a**5-b**5 != x:
    if a**5-b**5 < x:
        a += 1
    else:
        b += 1
        
print(a, b)

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

div = []

i = 1
while i*i <= x:
    if x%i == 0:
        div.append(i)
        if i*i != x:
            div.append(x//i)
    i += 1

for d in div:
    a = 0
    while (a-d)<=0 or 5*((a-d)**4) < x//d:
        a += 1
        b = a-d
        if a**5-b**5 == x:
            print(a, b)
            exit()
        if -a**5+b**5 == x:
            print(-a, -b)
            exit()

Fixed submission:
import math

x = int(input())

a = 0
b = 0
while b**5 > -x:
    b -= 1

while a**5-b**5 != x:
    if a**5-b**5 < x:
        a += 1
    else:
        b += 1
        
print(a, b)