Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
n = str(input().rstrip())

def solve1(n):
    ans = 0

    a = list(map(int, list(n)))
    a = a[::-1]
    a.append(0)
    for i in range(len(a) - 1):
        c = a[i]
        if c < 5:
            ans += c
        else:
            if c == 5 and a[i+1] < 5:
                ans += 5
            else:
                a[i+1] += 1
                ans += 10 - c
    ans += n_list[-1]

    print(ans)

def solve2(n):
    INF = 10**9
    n = n[::-1]
    n += '0'
    n_len = len(n)
    dp = [INF for _ in range(2)]
    dp[0] = 0

    for i in range(n_len):
        pre_dp = deepcopy(dp)
        dp = [INF, INF]
        for j in range(2):
            x = int(n[i])
            x += j
            if x < 10:
                dp[0] = min(dp[0], pre_dp[j]+x)
            if x > 0:
                dp[1] = min(dp[1], pre_dp[j]+(10-x))

    print(dp[0])
solve2(n)

Fixed submission:
n = str(input().rstrip())

ans = 0

a = list(map(int, list(n)))
a = a[::-1]
a.append(0)
for i in range(len(a) - 1):
    c = a[i]
    if c < 5:
        ans += c
    else:
        if c == 5 and a[i+1] < 5:
            ans += 5
        else:
            a[i+1] += 1
            ans += 10 - c
ans += a[-1]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = str(input().rstrip())

def solve1(n):
    ans = 0

    a = list(map(int, list(n)))
    a = a[::-1]
    a.append(0)
    for i in range(len(a) - 1):
        c = a[i]
        if c < 5:
            ans += c
        else:
            if c == 5 and a[i+1] < 5:
                ans += 5
            else:
                a[i+1] += 1
                ans += 10 - c
    ans += n_list[-1]

    print(ans)

def solve2(n):
    INF = 10**9
    n = n[::-1]
    n += '0'
    n_len = len(n)
    dp = [[INF for _ in range(2)] for _ in range(n_len+1)]
    dp[0][0] = 0

    for i in range(n_len):
        for j in range(2):
            x = int(n[i])
            x += j
            if x < 10:
                dp[i+1][0] = min(dp[i+1][0], dp[i][j]+x)
            if x > 0:
                dp[i+1][1] = min(dp[i+1][1], dp[i][j]+(10-x))

    print(dp[n_len][0])
solve2(n)

Fixed submission:
n = str(input().rstrip())

ans = 0

a = list(map(int, list(n)))
a = a[::-1]
a.append(0)
for i in range(len(a) - 1):
    c = a[i]
    if c < 5:
        ans += c
    else:
        if c == 5 and a[i+1] < 5:
            ans += 5
        else:
            a[i+1] += 1
            ans += 10 - c
ans += a[-1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import ceil
input = sys.stdin.readline

n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
ans = 0
for i in range(n):
    if xh[i][1] > 0:
        # attack
        a_num = ceil(xh[i][1] / a)
        xh[i][1] -= a_num * a
        ans += a_num
        base_x = xh[i][0]
        for j in range(i, n):
            if xh[j][0] <= base_x + 2 * d:
                xh[j][1] -= a_num * a
            else:
                break
print(ans)

Fixed submission:
import sys
from math import ceil
from collections import deque

input = sys.stdin.readline

n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]
xh.sort()
q = deque()
ans = 0
dam = 0
for i in range(n):
    # attack
    while len(q) > 0:
        if q[0][0] < xh[i][0]:
            dam -= q[0][1]
            q.popleft()
        else:
            break
    xh[i][1] -= dam
    if xh[i][1] > 0:
        a_num = ceil(xh[i][1] / a)
        xh[i][1] -= a_num * a
        ans += a_num
        dam += a_num * a
        q.append((xh[i][0] + 2*d, a_num * a))
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from functools import reduce
input = sys.stdin.readline

# python > pypy
MOD = 10**9 + 7
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = list(map(int, input().split()))

lcm_ = a[0]
for i in range(n):
    lcm_ = lcm(lcm_, a[i])

b = list(map(lambda x: lcm_//x, a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)


Fixed submission:
n = int(input())

c = [[0 for _ in range(10)] for _ in range(10)]
for k in range(1, n+1):
    s = str(k)
    c[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
from functools import reduce
input = sys.stdin.readline

# python > pypy
MOD = 10**9 + 7
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = list(map(int, input().split()))

lcm_ = a[0]
for i in range(n):
    lcm_ = lcm(lcm_, a[i])

b = list(map(lambda x: lcm_//x, a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)


Fixed submission:
n = int(input())

c = [[0 for _ in range(10)] for _ in range(10)]
for k in range(1, n+1):
    s = str(k)
    c[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())


def f()
def f(num):
    num = num - int(str(num)[-1])
    count = 0
    i = 1
    while True:
        if ((5 ** i) * (2)) > num:
            break
        count += (num // ((5 ** i) * (2)))
        i += 1
    return count


# 偶数 => 出てくる5の個数
# 奇数 => 0
if n % 2 == 1:
    print(0)
    exit()
else:
    print(f(n))

Fixed submission:
n = int(input())

def f(num):
    num = num - int(str(num)[-1])
    count = 0
    i = 1
    while True:
        if ((5 ** i) * (2)) > num:
            break
        count += (num // ((5 ** i) * (2)))
        i += 1
    return count


# 偶数 => 出てくる5の個数
# 奇数 => 0
if n % 2 == 1:
    print(0)
    exit()
else:
    print(f(n))
Buggy python submission (verdict: Runtime Error):
x = int(input())
def solve1(x):
    for c in range(1, x+1):
        if 100*c <= x <= 105*c:
            print(1)
            exit()
    print(0)

def solve2(x):
    dp = [0 for _ in range(x+1)]
    for i in range(100, 106):
        dp[i] = 1

    for i in range(100, x+1):
        for j in range(6):
            if dp[i-(100+j)]:
                dp[i] = 1
    print(dp[-1])

solve2(x)

Fixed submission:
x = int(input())
for c in range(1, x+1):
    if 100*c <= x <= 105*c:
        print(1)
        exit()
print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1, 10):
  for j in range(1, 10):
    l.appned(i*j)

if n in l:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
l = []
for i in range(1, 10):
  for j in range(1, 10):
    l.append(i*j)

if n in l:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1, 10):
  for j in range(1, 10):
    l.appned(i, j)

if n in l:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
l = []
for i in range(1, 10):
  for j in range(1, 10):
    l.append(i*j)

if n in l:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
abc = []
for i in range(m):
    a, b = map(int, input().split())
    c_ = list(map(int, input().split()))
    c = 0
    for v in c_:
        c += 2**(v-1)
    abc.append([a, b, c])

INF = 10**9
dp = [[INF for _ in range(1 << n)]for _ in range((m+1))]

for i in range(m):
    dp[i][0] = 0

for i in range(m):
    for j in range(1 << n):
        s = j | abc[i][2]
        dp[i+1][s] = min(dp[i+1][s], dp[i][j] + abc[i][0])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1])


Fixed submission:
n, m = map(int, input().split())
abc = []
for i in range(m):
    a, b = map(int, input().split())
    c_ = list(map(int, input().split()))
    c = 0
    for v in c_:
        c += 2**(v-1)
    abc.append([a, b, c])

INF = 10**9
dp = [[INF for _ in range(1 << n)]for _ in range((m+1))]

for i in range(m):
    dp[i][0] = 0

for i in range(m):
    for j in range(1 << n):
        s = j | abc[i][2]
        dp[i+1][s] = min(dp[i+1][s], dp[i][j] + abc[i][0])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = str(input())
a = []
b = []

count = 1
for i in range(1, n):
    if s[i] == s[i-1]:
        count += 1
    else:
        if s[i-1] == "L":
            a.append(count)
        else:
            b.append(count)
        count = 1
if s[i] == "L":
    a.append(count)
else:
    b.append(count)
count = 1

a.sort(reverse=True)
b.sort(reverse=True)
ans1 = sum(a) - len(a)
ans2 = sum(b) - len(b)
for i in range(min(2*k, len(b))):
    ans1 += b[i]
if len(b) < 2*k:
    ans1 += 2*k - len(b)
ans1 = min(n-1, ans1)
for i in range(min(2*k, len(a))):
    ans2 += a[i]
if len(a) < 2*k:
    ans2 += 2*k - len(a)
ans2 = min(n-1, ans2)
print(max(ans1, ans2))


Fixed submission:
n, k = map(int, input().split())
s = str(input())

lr = 0
rl = 0
for i in range(1, n):
    if s[i-1] == "L" and s[i] == "R":
        lr += 1
    if s[i-1] == "R" and s[i] == "L":
        rl += 1
ans = n - (lr + rl + 1) + (2 * min(min(lr, rl), k))

if k > min(lr, rl):
    if lr > rl and (s[0] == "L" or s[-1] == "R"):
        ans += 1
    if lr < rl and (s[0] == "R" or s[-1] == "L"):
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
MOD = 10**9+7

n = int(input())
s = input()

if s[0] == "W" or s[-1] == "W":
    print(0):
    exit()

kai = [1 for _ in range(n+1)]
for i in range(1, n+1):
    kai[i] = kai[i-1] * i
    kai[i] %= MOD

def mul(a, b):
    return (a * b) % MOD

a = "L"
l = ["L", "R"]
c = 0

for i in range(1, len(s)):
    if s[i] == s[i-1]:
        c = not c
    a = a + l[c]


ans = 1
num = 0
for i in range(len(s)):
    if a[i] == "L":
        num += 1
    else:
        ans *= num
        ans %= MOD
        num -= 1

ans *= kai[n]
ans %= MOD

print(ans)


Fixed submission:
N = int(input())
S = input()
ss = [1 if s == 'W' else 0 for s in S]

def mul(a, b):
    return (a * b) % (10**9 + 7)

ans = 1
num = 0
for s in ss:
    if num % 2 == s:
        num += 1
    else:
        ans = mul(ans, num)
        num -= 1

if num > 0:
    ans = 0

for i in range(2, N + 1):
    ans = mul(ans, i)

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
MOD = 10**9 + 7

if n % 2 == 1 and (s[0] == "W" or s[-1] == "W"):
    print(0)
    exit()

kai = [1 for _ in range(n+1)]
for i in range(1, n+1):
    kai[i] = (kai[i-1] * i) % MOD

ans = 1
count = 0
pre = s[0]
for i in range(1, 2*n):
    if s[i] == pre:
        count += 1
    else:
        ans *= kai[count+1]
        ans %= MOD
        count = 0
    pre = s[i]

ans *= kai[n]
ans %= MOD
print(ans)

Fixed submission:
N = int(input())
S = input()
ss = [1 if s == 'W' else 0 for s in S]

def mul(a, b):
    return (a * b) % (10**9 + 7)

ans = 1
num = 0
for s in ss:
    if num % 2 == s:
        num += 1
    else:
        ans = mul(ans, num)
        num -= 1

if num > 0:
    ans = 0

for i in range(2, N + 1):
    ans = mul(ans, i)

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
MOD = 10**9 + 7

if s[0] == "W" or s[-1] == "W":
    print(0)
    exit()

kai = [1 for _ in range(n+1)]
for i in range(1, n+1):
    kai[i] = (kai[i-1] * i) % MOD

ans = 1
count = 0
pre = ""
for i in range(2*n):
    if s[i] == pre:
        count += 1
    else:
        count += 1
        ans *= kai[count]
        ans %= MOD
        count = 0
    pre = s[i]
ans *= kai[n]
ans %= MOD
print(ans)

Fixed submission:
N = int(input())
S = input()
ss = [1 if s == 'W' else 0 for s in S]

def mul(a, b):
    return (a * b) % (10**9 + 7)

ans = 1
num = 0
for s in ss:
    if num % 2 == s:
        num += 1
    else:
        ans = mul(ans, num)
        num -= 1

if num > 0:
    ans = 0

for i in range(2, N + 1):
    ans = mul(ans, i)

print(ans)
Buggy python submission (verdict: Runtime Error):
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N, max, f = 0;
    in >> N;
    vector<ll> H(N);
    REP(i,N){
        in >> H[i];
    }

    max = H[0];
    REP_AB(i,1,N-1){
        if(max < H[i]){
            max = H[i] - 1;
        }
        if(max > H[i]){
            f = 1;
            break;
        }
    }


    if(f == 0){
           out << "Yes" << endl;
    }else if(f == 1){
           out << "No" << endl;
    }


 

 

}


Fixed submission:
n = int(input())
h = list(map(int, input().split()))

v = 1
flag = True
for i in range(n):
    if v < h[i]:
        v = h[i] - 1
    elif v == h[i]:
        pass
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import bisect
n = int(input())
a = int(input())

color = [a]
color_min = a

for i in range(1, n):
    a = int(input())
    if color_min >= a:
        bisect.insort_left(color, a)
        color_min = a
    else:
        j = bisect.bisect_left(color, a)
        color.pop(j-1)
        bisect.insort_left(color, a)
        color_min = color[0]

print(len(color))


Fixed submission:
r = int(input())

print(3 * r ** 2)
Buggy python submission (verdict: Runtime Error):
import math
MOD = 10**9 + 7
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k  = map(int, input().split())
ans = []
for i in range(1, k+1):
    if i % 2 == 1:
        print(combinations_count(n+1-k, i) % MOD)
    else:
        print(permutations_count(n+1-k, i) % MOD)


Fixed submission:
from math import factorial

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

class Facts():
    # 階乗のメモ化
    # 組み合わせ数、順列数の計算を高速に行う
    def __init__(self, max_num=10**5, p=10**9 + 7):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p

    def comb(self, n, k):
        # nCk mod p を求める
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[k]
        c = self.fact[n-k]
        return (a*self.power_func(b, self.p-2) *
                self.power_func(c, self.p-2)) % self.p

    def perm(self, n, k):
        # nPk mod p を求める
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[n-k]
        return (a * self.power_func(b, self.p-2)) % self.p


    def power_func(self, a, b):
        # a^b mod p　を繰り返し二乗法で求める
        if b == 0:
            return 1
        if b % 2 == 0:
            d = self.power_func(a, b//2)
            return d*d % self.p
        if b % 2 == 1:
            return (a*self.power_func(a, b-1)) % self.p

MOD = 10 ** 9 + 7
facts = Facts(n)

for i in range(1, k+1):
    ans = facts.comb(n-k+1, i) * facts.comb(k-1, i-1) % MOD
    print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
w, h, x, y = map(int, input().split())
area = []
# xの直線
area.append(min(h*x, h*(w-x)))

# yの直線
area.append(min(w*y, w*(h-y)))

# 角たち
a = w * h
tmp = h**2 * x / y
area.append(min(tmp, a - tmp))
tmp = w**2 * y / x
area.append(min(tmp, a - tmp))
tmp = w**2 * y / (w - x)
area.append(min(tmp, a - tmp))
tmp = h**2 * x / (h - y)
area.append(min(tmp, a - tmp))

ans_c = collections.Counter(area)

ans = sorted(ans_c.items(), reverse=True)[0]
size = ans[0]
a = 0
if ans[1] > 1:
    a = 1

print("{} {}".format(size, a))


Fixed submission:
import collections
w, h, x, y = map(int, input().split())

ans = 0
if x + x == w and y + y == h:
    ans = 1

print("{} {}".format(w * h / 2, ans))

Buggy python submission (verdict: Runtime Error):
import collections
w, h, x, y = map(int, input().split())
area = []
# xの直線
area.append(min(h*x, h*(w-x)))

# yの直線
area.append(min(w*y, w*(h-y)))

# 角たち
a = w * h
tmp = h**2 * x / y
area.append(min(tmp, a - tmp))
tmp = w**2 * y / x
area.append(min(tmp, a - tmp))

ans_c = collections.Counter(area)

ans = sorted(ans_c.items(), reverse=True)[0]
size = ans[0]
a = 0
if ans[1] > 1:
    a = 1

print("{} {}".format(size, a))

Fixed submission:
import collections
w, h, x, y = map(int, input().split())

ans = 0
if x + x == w and y + y == h:
    ans = 1

print("{} {}".format(w * h / 2, ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())

u = [0] * (n-1)
v = [0] * (n-1)
w = [0] * (n-1)

node = [i for i in range(n)]

group1 = []
group2 = []

for i in range(n-1):
    u[i], v[i], w[i] = map(int, input().split())
    u[i] -= 1
    v[i] -= 1
    w[i] = w[i] % 2
    # 同じなら0、違ったら1
    if w[i] == 0:
        if node[u[i]] == u[i]:
            node[u[i]] = node[v[i]]
        elif node[u[i]] != u[i]:
            node[v[i]] = node[u[i]]

for i in range(n-1):
    if w[i] == 1:
        if u[i] in group1:
            group2.append(node[v[i]])
        elif u[i] in group2:
            group1.append(node[v[i]])
        elif v[i] in group1:
            group2.append(node[u[i]])
        elif v[i] in group2:
            group1.append(node[u[i]])
        else:
            group1.append(node[v[i]])
            group2.append(node[u[i]])

for i in range(n):
    if node[i] in group1:
        node[i] = 0
    else:
        node[i] = 1

for color in node:
    print(color)


Fixed submission:
n, k = map(int, input().split())
s = str(input())

s = s[:k-1] + s[k-1].lower() + s[k:]
print(s)
Buggy python submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())

def calc(dise, k):
    return (1/2) ** math.ceil(math.log2(k/dise))

ans = 0

for i in range(n):
    if i+1 >= k:
        ans += 1/n
    else:
        ans += calc(i+1, k) / n
print(ans)


Fixed submission:
import math
n, k = map(int, input().split())

def calc(dise, k):
    return (1/2) ** math.ceil(math.log2(k/dise))

ans = 0

for i in range(n):
    if i+1 >= k:
        ans += 1/n
    else:
        ans += calc(i+1, k) / n
print(ans)
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
        self.size = [1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
        return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] > self.table[s2]:
                self.table[s2] = s1
                self.table[s1] -= 1
                self.size[s1] += self.size[s2]
                self.size[s2] = 0
            else:
                self.table[s1] = s2
                self.table[s2] -= 1
                self.size[s2] += self.size[s1]
                self.size[s1] = 0
        return

n = int(input())

uf = UnionFind(n)

for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    # 同じなら0、違ったら1
    if w % 2 == 0:
        uf.union(u, v)

ans = []
for i in range(n):
    ans.append(uf.find(i))
num = list(set(ans))[0]
out = list(map(lambda x: 0 if x == num else 1, ans))

for color in out:
    print(color)


Fixed submission:
import queue

n = int(input())
links = [set() for _ in [0] * n]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    links[u].add((v, w))
    links[v].add((u, w))
ans = [-1] * n
q = queue.Queue()
q.put((0, 0, -1))
while not q.empty():
    v, d, p = q.get()
    if d % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1
    for u, w in links[v]:
        if u == p:
            continue
        q.put((u, d + w, v))
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
r, g, b, n = map(int, input().split())

ans = 0

for i in range(3001):
    if i*r > n:
        break
    for j in range(3001):
        value = r*i + g*j
        if (n - value) < 0:
            break
        elif (n - value) % b == 0:
            ans += 1
print(ans)


Fixed submission:
n, k = map(int, input().split())

print(n+1-k)
Buggy python submission (verdict: Runtime Error):
# B
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    gain = v[i] - c[i]
    if gain > 0:
        ans += gain
print(ans)

Fixed submission:
# A
a, b, t = map(int, input().split())

count = a
ans = 0
while True:
    if count > t + 0.5:
        break
    count += a
    ans += b
print(ans)
Buggy python submission (verdict: Runtime Error):
# D
n = int(input())
a = list(map(int, input().split()))

l_minus = [i for i in a if i <= 0]
l_plus = [i for i in a if i > 0]
ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    plus = l_plus.extend(l_minus_edit)
    l_minus_edit.append(-min(plus) * 2)
    
ans = sum(l_plus) + sum(l_minus_edit)
print(ans)

Fixed submission:
# D
n = int(input())
a = list(map(int, input().split()))

l_minus = [i for i in a if i <= 0]
l_plus = [i for i in a if i > 0]

ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    temp = l_plus[:]
    temp.extend(l_minus_edit)
    l_minus_edit.append(-min(temp) * 2)

ans = sum(l_plus) + sum(l_minus_edit)
print(ans)

Buggy python submission (verdict: Runtime Error):
# D
n = int(input())
a = list(map(int, input().split()))

l_minus = [i for i in a if i < 0]
l_plus = [i for i in a if i >= 0]
ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    plus = min(l_plus)
    minus = min(l_minus_edit)
    l_minus_edit.append(-min(plus, minus) * 2)
    
ans = sum(l_plus) + sum(l_minus_edit)
print(ans)

Fixed submission:
# D
n = int(input())
a = list(map(int, input().split()))

l_minus = [i for i in a if i <= 0]
l_plus = [i for i in a if i > 0]

ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    temp = l_plus[:]
    temp.extend(l_minus_edit)
    l_minus_edit.append(-min(temp) * 2)

ans = sum(l_plus) + sum(l_minus_edit)
print(ans)