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

if N == 2:
    print(abs(a[0] - a[1]))
    exit()

for i in range(1, N-1):
    xtemp = sum(a[:i])
    ytemp = sum(a[i:])
    ans = min(ans, abs(xtemp - ytemp))

print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
sa = [a[0]]
for i in range(1, N):
    sa.append(sa[-1] + a[i])

ans = int(1e20)
for i in range(N-1):
    ans = min(ans, abs(sa[i] - (sa[-1] - sa[i])))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
if N == 1:
    print(1)
    sys.exit()

# 数列の和
def re(x):
    return x*(x+1)//2

# 二分探索
l, r = 0, N+1
exact = -1
while abs(l - r) > 1:
    mid = (l + r) // 2
    if re(mid) > N:
        r = mid
    elif re(mid) == N:
        exact = mid
    else:
        l = mid

# 途中抜けしない場合
if exact != -1:
    for i in range(1, exact + 1):
        print(i)

# する場合
else:
    temp = re(r) - N
    for i in range(1, r+1):
        if i != temp:
            print(i)

Fixed submission:
import sys
N = int(input())
if N == 1:
    print(1)
    sys.exit()

# 数列の和
def re(x):
    return x*(x+1)//2

# 二分探索
l, r = 0, N+1
exact = -1
while abs(l - r) > 1:
    mid = (l + r) // 2
    if re(mid) > N:
        r = mid
    elif re(mid) == N:
        exact = mid
        break
    else:
        l = mid

# 途中抜けしない場合
if exact != -1:
    for i in range(1, exact + 1):
        print(i)

# する場合
else:
    temp = re(r) - N
    for i in range(1, r+1):
        if i != temp:
            print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = 2*(10**9)+1
low = 0
for j in range(N):
    t = sum(M[j])
    if low == t:
        s.append(M[j])
    elif low < t:
        low = t
        s = []
        s.append(M[j])

    if top == t:
        l.append(M[j])
    elif top > t:
        top = t
        l = []
        l.append(M[j])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


s.sort()
l.sort()


high = []
small = []
low = 2*(10**9)+1
top = 0
for j in range(N):
    t = M[j][1] - M[j][0]
    if low > t:
        low = t
        small = []
        small.append(M[j])
    elif low == t:
        small.append(M[j])

    if top < t:
        top = t
        high = []
        high.append(M[j])
    elif top == t:
        high.append(M[j])
high.sort()
small.sort()


print(max([cal_man(s[0], l[-1]), cal_man(s[-1], l[0]),
           cal_man(high[0], small[-1]), cal_man(high[-1], small[0])]))


Fixed submission:
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = 2*(10**9)+1
low = 0
for j in range(N):
    t = sum(M[j])
    if low == t:
        s.append(M[j])
    elif low < t:
        low = t
        s = []
        s.append(M[j])

    if top == t:
        l.append(M[j])
    elif top > t:
        top = t
        l = []
        l.append(M[j])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


s.sort()
l.sort()


high = []
small = []
lowest = 2*(10**9)+1
topest = -2*(10**9)+1
for j in range(N):
    t = M[j][1] - M[j][0]
    if lowest > t:
        lowest = t
        small = []
        small.append(M[j])
    elif lowest == t:
        small.append(M[j])

    if topest < t:
        topest = t
        high = []
        high.append(M[j])
    elif topest == t:
        high.append(M[j])
high.sort()
small.sort()


print(max([cal_man(s[0], l[-1]), cal_man(s[-1], l[0]),
           cal_man(high[0], small[-1]), cal_man(high[-1], small[0])]))
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = map(int, input().split())
if X < 0:
    X = -X
step = 0
while X > D and not K == 0:
    step += 1
    X -= D
    K -= 1
if K == 0:
    print(X)
    exit()
if K % 2 == 0:
    print(X)
else:
    print(abs(X-D))


Fixed submission:
X, K, D = map(int, input().split())
if X < 0:
    X = -X
step = X//D
X -= D*step
K -= step

if K <= 0:
    print(X-K*D)
    exit()
if K % 2 == 0:
    print(X)
else:
    print(abs(X-D))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
if N == 1:
    print(0)
    exit()
primes = []
i = 2
tmp = N
flag = False
while i**2 <= tmp:
    if N % i == 0:
        flag = True
        count = 0
        while N % i == 0:
            N //= i
            count += 1
        primes.append((i, count))
    i += 1

if (not N == 1) and flag:
    i = 2
    tmp = N
    while N > 1:
        if N % i == 0:
            count = 0
            while N % i == 0:
                N //= i
                count += 1
            primes.append((i, count))
        i += 1

if not primes:
    print(1)
    exit()

count = 0
for p in primes:
    c = 0
    t = 0
    for i in range(1, 10 ** 9):
        c += i
        t += 1
        if c > p[1]:
            count += t - 1
            break
        elif c == p[1]:
            count += t
            break

print(count)


Fixed submission:
N = int(input())
if N == 1:
    print(0)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


primes = factorization(N)

count = 0
for p in primes:
    c = 0
    t = 0
    for i in range(1, 10 ** 9):
        c += i
        t += 1
        if c > p[1]:
            count += t - 1
            break
        elif c == p[1]:
            count += t
            break

print(count)
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
count = 0
for i in range(0, N):
    for j in range(i+1, N+1):
        if int(S[i:j]) % 2019 == 0:
            count += 1

print(count)


Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Time Limit Exceeded):

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


K = int(input())
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        tmp = gcd(a, b)
        for c in range(1, K+1):
            total += gcd(tmp, c)

print(total)


Fixed submission:
from math import gcd

K = int(input())
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        tmp = gcd(a, b)
        for c in range(1, K+1):
            total += gcd(tmp, c)

print(total)

Buggy python submission (verdict: Time Limit Exceeded):

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


K = int(input())
map = [[[None for _ in range(K)] for _ in range(K)] for _ in range(K)]
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            x, y, z = sorted([a, b, c])
            if map[x-1][y-1][z-1] != None:
                total += map[x-1][y-1][z-1]
            else:
                tmp = gcd(x, y)
                total += gcd(tmp, z)

print(total)


Fixed submission:
from math import gcd

K = int(input())
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        tmp = gcd(a, b)
        for c in range(1, K+1):
            total += gcd(tmp, c)

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd

K = int(input())
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            tmp = gcd(a, b)
            total += gcd(tmp, c)

print(total)


Fixed submission:
from math import gcd

K = int(input())
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        tmp = gcd(a, b)
        for c in range(1, K+1):
            total += gcd(tmp, c)

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

answer = 10**18+1
formar = 10*18+1
c_v = N

if N % K == 0:
    print(0)
else:
    N = N//K
    while True:
        if answer > c_v:
            answer = c_v
        n_v = abs(c_v - K)
        if formar == n_v:
            break
        formar = c_v
        c_v = n_v
    print(answer)


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

if N % K == 0:
    print(0)
else:
    N = N % K
    print(min([N, abs(N-K)]))
Buggy python submission (verdict: Runtime Error):
import itertools

n = 10
data = [_ for _ in range(1,n+1)]
print(data)

dt = [2,4635,534,534,5,2345,13,41,51,23]

for i in itertools.combinations(data, 1):
    print(i)





for i in fakePeople:
            if turndata[i] != []:
                for j in turndata[i]:
                    if j[1] == 0:
                        j[1] = 1
                    else:
                        j[1] = 0

import itertools
import copy

n = int(input())
indexes = [_ for _ in range(1, n+1)]

def ifCorrect(data, fakes):
    answer_sheet = [-1 for i in range(n+1)]
    for i in fakes:
        answer_sheet[i] = 0

    #このあたりで、fakeでない人の情報とも比較して、正直者の証言がそれらのリストと合致しているかを確認すれば良い
    for i in range(len(data)):
        for j in data[i]:
            if not i in fakes:
                if answer_sheet[j[0]] == -1:
                    if j[1] == 0 and not j[0] in fakes:
                        return False
                    else:
                        answer_sheet[j[0]] = j[1]
                elif not answer_sheet[j[0]] == j[1]:
                    return False
                    
    return True

data = [[] for _ in range(n+1)]
for i in range(n):
    id = int(input())
    for _ in range(id):
        x, y = map(int, input().split(" "))
        data[i+1].append([x,y])

fakePersonCount = 0
flag = True
while fakePersonCount <= n and flag:
    comb = itertools.combinations(indexes, fakePersonCount)
    for fakePeople in comb:
        if ifCorrect(data, fakePeople):
            print(n - fakePersonCount)
            flag = False
            break
    fakePersonCount += 1

if flag:
    print(0)

#[[], [[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

Fixed submission:
import itertools
import copy

n = int(input())
indexes = [_ for _ in range(1, n+1)]

def ifCorrect(data, fakes):
    answer_sheet = [1 for i in range(n+1)]
    answer_sheet[0] = -1
    for i in fakes:
        answer_sheet[i] = 0

    #このあたりで、fakeでない人の情報とも比較して、正直者の証言がそれらのリストと合致しているかを確認すれば良い
    for i in range(len(data)):
        for j in data[i]:
            if not i in fakes and not answer_sheet[j[0]] == j[1]:
                return False
                    
    return True

data = [[] for _ in range(n+1)]
for i in range(n):
    id = int(input())
    for _ in range(id):
        x, y = map(int, input().split(" "))
        data[i+1].append([x,y])

fakePersonCount = 0
flag = True
while fakePersonCount <= n and flag:
    comb = itertools.combinations(indexes, fakePersonCount)
    for fakePeople in comb:
        if ifCorrect(data, fakePeople):
            print(n - fakePersonCount)
            flag = False
            break
    fakePersonCount += 1

if flag:
    print(0)

#[[], [[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]
Buggy python submission (verdict: Runtime Error):
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

yakusu = make_divisors(n)

k = (len(yakusu)-1)//2
a = yakusu[k] + yakusu[k+1] -2

if len(yakusu) <= 2:
    print(a)
else:
    b = yakusu[k-1] + yakusu[k+2] - 2
    if a > b :
        print(b)
    else:
        print(a)
    




Fixed submission:
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

yakusu = make_divisors(n)

answers = []
for i in range(len(yakusu)):
    answers.append(yakusu[i] + yakusu[-(i+1)] - 2)

print(min(answers))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

for _ in range(M):
    A[A.index(max(A))] = max(A)//2

print(sum(A))


Fixed submission:
import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)
for _ in range(M):
    pop = heapq.heappop(A)
    if pop % 2 == 0:
        num = pop//2
    else:
        num = (pop+1)//2
    heapq.heappush(A, num)

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]


count = 0
for i in range(n-1):
    if a[i] - b[i] < 0:
        count += a[i]
        diff = a[i+1] - (b[i] - a[i]) 
        if diff < 0:
            b[i+1] += a[i+1]
        else:
            count += b[i] - a[i]
            a[i+1] -= b[i] - a[i]
    elif a[i] - b[i] >= 0:
        count += b[i]
        
if b[n-1] - a[n-1] > 0:
    count += a[n-1]
    rest = b[n-1] - a[n-1]
    if rest < a[n]:
        count += rest
    else:
        count += a[n]
else:
    count += b[i]


print(count)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]


count = 0
for i in range(n-1):
    if a[i] - b[i] < 0:
        count += a[i]
        diff = a[i+1] - (b[i] - a[i]) 
        if diff < 0:
            b[i+1] += a[i+1]
        else:
            count += b[i] - a[i]
            a[i+1] -= b[i] - a[i]
    elif a[i] - b[i] >= 0:
        count += b[i]

if b[n-1] - a[n-1] > 0:
    count += a[n-1]
    rest = b[n-1] - a[n-1]
    if rest < a[n]:
        count += rest
    else:
        count += a[n]
else:
    count += b[n-1]


print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]


count = 0
for i in range(n-1):
    if a[i] - b[i] < 0:
        if a[i+1] - b[i] + a[i] < 0:
            b[i+1] += a[i+1]
        count += a[i]
    elif a[i] - b[i] >= 0:
        count += b[i]

if b[n-1] - a[n-1] > 0:
    count += a[n-1]
    rest = b[n-1] - a[n-1]
    if rest < a[n]:
        count += rest
    else:
        count += a[n]
else:
    count += b[i]


print(count)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]


count = 0
for i in range(n-1):
    if a[i] - b[i] < 0:
        count += a[i]
        diff = a[i+1] - (b[i] - a[i]) 
        if diff < 0:
            b[i+1] += a[i+1]
        else:
            count += b[i] - a[i]
            a[i+1] -= b[i] - a[i]
    elif a[i] - b[i] >= 0:
        count += b[i]

if b[n-1] - a[n-1] > 0:
    count += a[n-1]
    rest = b[n-1] - a[n-1]
    if rest < a[n]:
        count += rest
    else:
        count += a[n]
else:
    count += b[n-1]


print(count)
Buggy python submission (verdict: Runtime Error):
from math import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C, D)


divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
divL = B//lcm - (A-1)//lcm

print((B-A+1) - divC - divD + divL)


Fixed submission:
from fractions import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C, D)


divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
divL = B//lcm - (A-1)//lcm

print((B-A+1) - divC - divD + divL)
Buggy python submission (verdict: Time Limit Exceeded):
# 白色マスで４方向のマスに黒マスが一つ以上存在するものを黒にかえる。
# 何回の操作でマスが全て黒マスになるか？
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
black_list = []
for h in range(H):
    for w in range(W):
        if field[h][w] == "#":
            black_list.append((h, w))

count = 0
move = ((0, 1), (1, 0), (-1, 0), (0, -1))
while black_list:
    n_pl = []
    for b in black_list:
        for m in move:
            n_p = (b[0] + m[0], b[1] + m[1])
            if not(n_p[0] < 0 or n_p[1] < 0 or n_p[0] >= H or n_p[1] >= W) and field[n_p[0]][n_p[1]] == ".":
                field[n_p[0]][n_p[1]] = "#"
                n_pl.append(n_p)
    black_list = n_pl
    count += 1
print(count-1)


Fixed submission:
# 白色マスで４方向のマスに黒マスが一つ以上存在するものを黒にかえる。
# 何回の操作でマスが全て黒マスになるか？
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
black_list = []
for h in range(H):
    for w in range(W):
        if field[h][w] == "#":
            black_list.append((h, w))

count = 0
move = ((0, 1), (1, 0), (-1, 0), (0, -1))
# 広がり方は一点の黒から一定なのでそれを行うことで、計算量を改善できる？
while black_list:
    n_pl = []
    for b in black_list:
        for m in move:
            n_p = (b[0] + m[0], b[1] + m[1])
            if not(n_p[0] < 0 or n_p[1] < 0 or n_p[0] >= H or n_p[1] >= W) and field[n_p[0]][n_p[1]] == ".":
                field[n_p[0]][n_p[1]] = "#"
                n_pl.append(n_p)
    black_list = n_pl
    count += 1
print(count-1)
Buggy python submission (verdict: Runtime Error):
s = list(input())
ACGT = ['A', 'C', 'G', 'T']

count = 0
result = []
for w in s:
    if w in ACGT:
        count += 1
    else:
        result.append(count)
        count = 0

print(max(result))

Fixed submission:
s = list(input())
ACGT = ['A', 'C', 'G', 'T']

count = 0
result = []
for w in s:
    if w in ACGT:
        count += 1
    else:
        result.append(count)
        count = 0
result.append(count)

print(max(result))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())
holder = []
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        holder.append(i)
for _ in range(Q):
    l, r = map(int, input().split())
    count = 0
    for index in holder:
        if index+1 >= l and index+2 <= r:
            count += 1
    print(count)


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
holder = set()
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        holder.add(i+1)

# 累積和でどうぞ
prefix = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if i-1 in holder:
        prefix[i] = prefix[i-1] + 1
    else:
        prefix[i] = prefix[i-1]

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

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())
for _ in range(Q):
    l, r = map(int, input().split())
    line = S[l-1:r]
    count = 0
    for i in range(r-l):
        if line[i] == 'A' and line[i+1] == 'C':
            count += 1
    print(count)


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
holder = set()
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        holder.add(i+1)

# 累積和でどうぞ
prefix = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if i-1 in holder:
        prefix[i] = prefix[i-1] + 1
    else:
        prefix[i] = prefix[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(prefix[r] - prefix[l])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split(" "))
weights = []
values = []

for _ in range(N):
    w, v = map(int, input().split(" "))
    weights.append(w)
    values.append(v)

dp = [[None for _ in range(W+1)] for _ in range(N+1)]
for _ in range(W+1):
    dp[0][_] = 0

for i in range(N):
    item_weight = weights[i]
    for j in range(W+1):
        if j >= item_weight:
            dp[i+1][j] = max([dp[i][j-weights[i]] + values[i], dp[i][j]])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Fixed submission:
N, W = map(int, input().split(" "))
weights = []
values = []

for _ in range(N):
    w, v = map(int, input().split(" "))
    weights.append(w)
    values.append(v)

dp = [[None for _ in range(W+1)] for _ in range(N+1)]
for _ in range(W+1):
    dp[0][_] = 0

for i in range(N):
    item_weight = weights[i]
    for j in range(W+1):
        if j >= item_weight:
            dp[i+1][j] = max([dp[i][j-weights[i]] + values[i], dp[i][j]])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split(" "))
weights = []
values = []

for _ in range(N):
    w, v = map(int, input().split(" "))
    weights.append(w)
    values.append(v)

dp = [[None for _ in range(W+1)] for _ in range(N+1)]
for _ in range(W+1):
    dp[0][_] = 0

for i in range(N):
    item_weight = weights[i]
    for j in range(W+1):
        if j >= item_weight:
            dp[i+1][j] = max([dp[i][j-weights[i]] + values[i], dp[i][j]])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Fixed submission:
N, W = map(int, input().split(" "))
weights = []
values = []

for _ in range(N):
    w, v = map(int, input().split(" "))
    weights.append(w)
    values.append(v)

dp = [[None for _ in range(W+1)] for _ in range(N+1)]
for _ in range(W+1):
    dp[0][_] = 0

for i in range(N):
    item_weight = weights[i]
    for j in range(W+1):
        if j >= item_weight:
            dp[i+1][j] = max([dp[i][j-weights[i]] + values[i], dp[i][j]])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
pos = []
for i in range(len(S)):
    if S[i] == T[0]:
        flag = 1
        for j in range(len(T)):
            if not T[j] == S[i+j] and not S[i+j] == '?':
                flag = 0
                break
        if flag:
            pos.append(i)

if not pos:
    print('UNRESTORABLE')
    exit()

words = []
for p in pos:
    word = S[0:p] + T + S[p+len(T):]
    for i in range(len(word)):
        if word[i] == '?':
            word[i] = 'a'
    words.append(word)
words.sort()
print("".join(words[0]))


Fixed submission:
S = input()
T = input()
def checkstr(ss):
    for (s,t) in zip(ss,T):
        check = True
        if s=="?":
            continue
        elif s!=t:
            check = False
            break
    return check
ans = ""
for i in range(len(S)-len(T)+1):
    strs = S[i:i+len(T)]
    if checkstr(strs):
        ans = S[:i].replace("?","a")+T+S[i+len(T):].replace("?","a")
if ans=="":
    print("UNRESTORABLE")
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(max(a*c, a*d, b*c, b*d))

Fixed submission:
x = int(input())

if x == 0:
  print(1)
elif x == 1:
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
A=max(a,b)
B=max(c,d)

if (A>0 and B>0):
  print(A*B)
elif A<0 and B>0:
  print(A*min(c,d))
elif A>0 and B<0:
  print(min(a,b)*B)
elif A<=0 and B<=0:
  print(min(a,b)*min(c,d))


Fixed submission:
x = int(input())

if x == 0:
  print(1)
elif x == 1:
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
A=max(a,b)
B=max(c,d)

if (A<=0 and B<=0) or (A>0 and B>0):
  print(A*B)
elif A<0 and B>0:
  print(A*min(c,d))
elif A>0 and B<0:
  print(min(a,b)*B)


Fixed submission:
x = int(input())

if x == 0:
  print(1)
elif x == 1:
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
A=max(a,b)
B=max(c,d)

if (A<=0 and B<=0) or (A>0 and B>0):
  print(A*B)
elif A<0 and B>0:
  print(A*min(c,d))
else:
  print(min(a,b)*B)


Fixed submission:
x = int(input())

if x == 0:
  print(1)
elif x == 1:
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
A=max(a,b)
B=max(c,d)

if (A<=0 and B<=0) or (A>0 and B>0):
  print(A*B)
elif A<0 and B>0:
  print(min(a,b)*B)
else:
  print(A*min(c,d))

Fixed submission:
x = int(input())

if x == 0:
  print(1)
elif x == 1:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
ans=0

ans = sum([x*y % mod for x in A[0:N-1] for y in A[A.index(x)+1:N]])%mod

print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
aa = 0
b = 0
for i in range(n):
    aa += a[i] ** 2  
    b += a[i]
    #aa %= mod
    #b %= mod
print((b ** 2 - aa)//2%mod)

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

N=int(input())
A=np.array(list(map(int,input().split())))
L=len(str(max(A)))//4
A=A/10**L

x=np.sum(np.outer(A,A))-np.sum(A*A)
print(int(x/2*10**(2*L)%(10**9+7)))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
aa = 0
b = 0
for i in range(n):
    aa += a[i] ** 2  
    b += a[i]
    #aa %= mod
    #b %= mod
print((b ** 2 - aa)//2%mod)