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

Fixed submission:
#!/usr/bin/env python3
#import math
import fractions

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

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

g = A[0]
for i in range(1,N):
    g = lcm(g,A[i])
g -= 1

ans = 0
for a in A:
    ans += g % a
print(ans)

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


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

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

g = A[0]
for i in range(1,N):
    g = lcm(g,A[i])
g -= 1

ans = 0
for a in A:
    ans += g % a
print(ans)
Problem p03361 (python)

Fixed submission:
#!/usr/bin/env python3
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]

# yoko
for i in range(H):
    for j in range(W-1):
        if (M[i][j] == '#' or M[i][j] == 'M') and (M[i][j+1] == '#' or M[i][j+1] == 'M'):
            M[i][j] = 'M'
            M[i][j+1] = 'M'

#tate
for j in range(W):
    for i in range(H-1):
        if (M[i][j] == '#' or M[i][j] == 'M') and (M[i+1][j] == '#' or M[i+1][j] == 'M'):
            M[i][j] = 'M'
            M[i+1][j] = 'M'

ret = 0
for m in M:
    ret += m.count('#')

if ret == 0: print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
h, w = map(int, raw_input().split())

matrix = []
matrix.append('.'*(w+2))

for i in range(w):
    matrix.append('.' + raw_input() + '.')

matrix.append('.'*(w+2))

for i in range(1, h+1):
    for j in range(1, w+1):
        if matrix[i][j] == '#':
            if matrix[i+1][j] == '#' or matrix[i-1][j] == '#' or matrix[i][j-1] == '#' or matrix[i][j+1] == '#':
                continue
            else:
                print 'No'
                exit()
print 'Yes'

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
h, w = map(int, raw_input().split())

matrix = []

matrix.append(list('.'*(w+2)))
for i in range(w):
    matrix.append(['.'] + list(raw_input()) + ['.'])
matrix.append(list('.'*(w+2)))

for i in range(1, h+1):
    for j in range(1, w+1):
        if matrix[i][j] == '#':
            if matrix[i+1][j] == '#' or matrix[i-1][j] == '#' or matrix[i][j-1] == '#' or matrix[i][j+1] == '#':
                continue
            else:
                print 'No'
                exit()
print 'Yes'
Problem p03612 (python)

Fixed submission:
#!/usr/bin/env python3

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

cnt = 0
for i in range(N-1):
    if i+1 == P[i]:
        p = P[i]
        P[i] = P[i+1]
        P[i+1] = p
        cnt += 1

if P[N-1] == N:
    cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

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

cnt = 0
for i in range(N):
    if i+1 == P[i]:
        p = P[i]
        P[i] = P[i+1]
        P[i+1] = p
        cnt += 1

print(cnt)
Problem p02553 (python)

Fixed submission:
def main():
    INP = list(map(int, input().split()))
    list1 = [INP[0],INP[1]]
    list2 = [INP[2],INP[3]]
    if INP[0] < 0 and INP[1] > 0:
        list1.extend([-1,0,1])
    if INP[2] < 0 and INP[3] > 0:
        list2.extend([-1,0,1])
    ans = -(10**18)
    for item in list1:
        for item2 in list2:
            ans = max(ans,item*item2)
    print(ans)     


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    INP = list(map(int, input().split()))
    list1 = [INP[0],INP[1]]
    list2 = [INP[2],INP[3]]
    if INP[0] < 0 and INP[1] > 0:
        list1.append([-1,0,1])
    if INP[2] < 0 and INP[3] > 0:
        list2.append([-1,0,1])
    ans = -(10**18)
    for item in list1:
        for item2 in list2:
            ans = max(ans,item*item2)
    print(ans)       


if __name__ == '__main__':
    main()
Problem p02923 (python)

Fixed submission:
N = int(input().split()[0])
h_list = list(map(int, input().split()))

tentou_list = []

for i in range(N-1):
    if h_list[i] >= h_list[i+1]:
        t = 1
    else:
        t = 0
    tentou_list.append(t)

# 一番長い1はどれか
c = 0
c_list = []

for t in tentou_list:
    if t == 0:
        c_list.append(c)
        c = 0
    else:
        c += 1

if tentou_list:
    if t == 1:
        c_list.append(c)
    ans = max(c_list)
else:
    ans = 0

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input().split()[0])
h_list = list(map(int, input().split()))

tentou_list = []

for i in range(N-1):
    if h_list[i] >= h_list[i+1]:
        t = 1
    else:
        t = 0
    tentou_list.append(t)

# 一番長い1はどれか
c = 0
c_list = []

for t in tentou_list:
    if t == 0:
        c_list.append(c)
        c = 0
    else:
        c += 1

if t == 1:
    c_list.append(c)

ans = max(c_list)
print(ans)
Problem p02945 (python)

Fixed submission:
A, B = list(map(int, input().split()))
  
print(max([A+B, A-B, A*B]))

Buggy submission (verdict: Runtime Error):
A, B, C = list(map(int, input().split()))
  
print(max([A+B, A-B, A*B]))

Buggy submission (verdict: Runtime Error):
A, B, C = list(map(int, input().split()))
  
print(max(A+B, A-B, A*B))
Problem p02972 (python)

Fixed submission:
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = sum(b_list[idx : N + 1 : idx])

    if total % 2 != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
b_list = [0] * N
b_list[-1] = a_list[-1]

for i in range(N):
    # 大きい方から決めていく
    idx = N - (i + 1)
    total = 0
    for j in b_list[:: idx + 1]:
        # idx + 1の倍数のボールの個数を数える
        total += b_list[j]

    if total % (idx + 1) != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i + 1) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list)
print(ans)
print(" ".join(idx_list))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
b_list = [0] * N
b_list[-1] = a_list[-1]

for i in range(1, N + 1):
    # 大きい方から決めていく
    idx = N - i
    total = 0
    for j in b_list[:: idx + 1]:
        # idx + 1の倍数のボールの個数を数える
        total += b_list[j]

    if total % (idx + 1) != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i + 1) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list)
print(ans)
print(" ".join(idx_list))
Problem p02995 (python)

Fixed submission:
import fractions

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

c_n = (b // c) - ((a - 1) // c)
d_n = (b // d) - ((a - 1) // d)

lcm = (c * d) // fractions.gcd(c, d)
lcm_n = (b // lcm) - ((a - 1) // lcm)

ans = (b - a + 1) - (c_n + d_n - lcm_n)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

c_n = (b // c) - ((a - 1) // c)
d_n = (b // d) - ((a - 1) // d)

lcm = (c * d) // math.gcd(c, d)
lcm_n = (b // lcm) - ((a - 1) // lcm)

ans = (b - a + 1) - (c_n + d_n - lcm_n)
print(ans)
Problem p03000 (python)

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

c = 1
d = 0

for i in range(n):
    d += l_list[i]
    if d <= x:
        c += 1
    else:
        break

print(c)

Buggy submission (verdict: Runtime Error):
n, x = list(map(int, input().split()))
l_list = list(map(int, input().split()))

c = 0
d = 0

for i in range(n+1):
    if d <= x:
        d += l_list[i]
        c += 1
    else:
        break

print(c)
Problem p03101 (python)

Fixed submission:
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

ans = (H - h) * (W - w)
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

ans = (H - h) * (W - w)
print(ansj
Problem p03125 (python)

Fixed submission:
from sys import stdin

a, b = stdin.readline().rstrip().split()
a, b = int(a), int(b)

for i in range(1, 21):
    if a * i > b:
        print(b - a)
        break

    if b % (a * i) == 0:
        print(a + b)
        break
else:
    print(b - a)

Buggy submission (verdict: Runtime Error):
from sys import stdin

a, b = stdin.readline().rstrip().split()

for i in range(1, 21):
    if a * i > b:
        break

    if b % (a * i) == 0:
        print(a + b)
        break
else:
    print(b - a)

Buggy submission (verdict: Runtime Error):
for i in range(1, 21):
    if a * i > b:
        break

    if b % (a * i) == 0:
        print(a + b)
        break
else:
    print(b - a)
Problem p03164 (python)

Fixed submission:
#!/usr/bin/env python3

N, W = list(map(int, input().split()))
item_list = []

for _ in range(N):
    w, v = list(map(int, input().split()))
    item_list.append((w, v))

max_v = (10 ** 3) * 100
dp_table = [[0] + [float("inf")] * (max_v + 1) for _ in range(N + 1)]
total_v = 0

for i in range(1, N + 1):  # 最大で10**2
    w, v = item_list[i - 1]
    # 品物iまで考慮したときの価値の最大値
    total_v += v
    for j in range(total_v + 1):  # 最大で10 ** 5
        # 品物iを入れない場合
        dp_table[i][j] = dp_table[i - 1][j]
        before_min_weight = dp_table[i - 1][j]
        # dp_table[i][j] = before_min_weight
        # 品物iを入れる場合
        if j - v < 0:
            continue
        weight = dp_table[i - 1][j - v] + w
        min_weight = min(before_min_weight, weight)
        dp_table[i][j] = min_weight
        if i == N:
            if min_weight <= W:
                max_value = j

ans = max_value
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

N, W = list(map(int, input().split()))
item_list = []

for _ in range(N):
    w, v = list(map(int, input().split()))
    item_list.append((w, v))

dp_table = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    w, v = item_list[i - 1]
    for j in range(W + 1):
        # 品物iを入れない場合
        before_best_value = dp_table[i - 1][j]
        dp_table[i][j] = before_best_value
        # 品物iを入れる場合
        if j - w < 0:
            continue
        value = dp_table[i - 1][j - w] + v
        best_value = max(before_best_value, value)
        dp_table[i][j] = best_value

ans = max(dp_table[-1])
print(ans)
Problem p03206 (python)

Fixed submission:
n = int(input().split()[0])

data = {25:"Christmas",
        24:"Christmas Eve",
        23:"Christmas Eve Eve",
        22:"Christmas Eve Eve Eve"}

print(data[n])

Buggy submission (verdict: Runtime Error):
n = int(input().split()[0])

data = dict(25="Christmas", 24="Christmas Eve",
            23="Christmas Eve Eve",
            22="Christmas Eve Eve Eve")

print(data[n])
Problem p03244 (python)

Fixed submission:
# https://atcoder.jp/contests/abc111/tasks/arc103_a
# C - /\/\/\/
import collections

n = int(input().split()[0])
v_list = list(map(int, input().split()))

# 奇数番目の数
odd_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 1]
# 偶数番目の数
even_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 0]

# 奇数の最頻値（No1とNo2)
odd_counter = collections.Counter(odd_list)
odd_1 = odd_counter.most_common()[0][0]

if len(odd_counter) >= 2:
    odd_2 = odd_counter.most_common()[1][0]
else:
    odd_2 = '*' # dummy

# 偶数の最頻値（No1とNo2)
even_counter = collections.Counter(even_list)
even_1 = even_counter.most_common()[0][0]

if len(even_counter) >= 2:
    even_2 = even_counter.most_common()[1][0]
else:
    even_2 = '+' # dummy

# 以前の方法だと条件分岐が複雑になるので
# とりうる操作を全部試して、回数が少ない方をとる

if even_1 == odd_1:
    # 偶数側の操作回数（最頻値で置き換え）
    even_op_count = len([v for v in even_list if v != even_1])
    # 奇数の操作回数
    odd_op_count = len([v for v in odd_list if v != odd_2])
    count_1 = even_op_count + odd_op_count

    # 偶数側の操作回数
    even_op_count = len([v for v in even_list if v != even_2])
    # 奇数側の操作回数（最頻値で置き換え）
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count_2 = even_op_count + odd_op_count

    count = min(count_1, count_2)
else:
    # 偶数側も奇数側も最頻値で置き換えればよい
    even_op_count = len([v for v in even_list if v != even_1])
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count = even_op_count + odd_op_count

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input().split()[0])
v_list = list(map(int, input().split()))

# 奇数番目の数
odd_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 1]
# 偶数番目の数
even_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 0]

# 奇数の最頻値（No1とNo2)
odd_counter = collections.Counter(odd_list)
odd_1 = odd_counter.most_common()[0][0]

if len(odd_counter) >= 2:
    odd_2 = odd_counter.most_common()[1][0]
else:
    odd_2 = '*' # dummy

# 偶数の最頻値（No1とNo2)
even_counter = collections.Counter(even_list)
even_1 = even_counter.most_common()[0][0]

if len(even_counter) >= 2:
    even_2 = even_counter.most_common()[1][0]
else:
    even_2 = '+' # dummy

# 以前の方法だと条件分岐が複雑になるので
# とりうる操作を全部試して、回数が少ない方をとる

if even_1 == odd_1:
    # 偶数側の操作回数（最頻値で置き換え）
    even_op_count = len([v for v in even_list if v != even_1])
    # 奇数の操作回数
    odd_op_count = len([v for v in odd_list if v != odd_2])
    count_1 = even_op_count + odd_op_count

    # 偶数側の操作回数
    even_op_count = len([v for v in even_list if v != even_2])
    # 奇数側の操作回数（最頻値で置き換え）
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count_2 = even_op_count + odd_op_count

    count = min(count_1, count_2)
else:
    # 偶数側も奇数側も最頻値で置き換えればよい
    even_op_count = len([v for v in even_list if v != even_1])
    odd_op_count = len([v for v in odd_list if v != odd_1])
    count = even_op_count + odd_op_count

print(count)
Problem p03434 (python)

Fixed submission:
# https://atcoder.jp/contests/abc088/tasks/abc088_b
n = input().split()[0]
a_list = list(map(int, input().split()))

alice_list = []
bob_list = []
sorted(a_list)

for i in range(len(a_list)):
    max_a = max(a_list)
    a_list.remove(max_a)

    if i % 2 == 0:
        alice_list.append(max_a)
    else:
        bob_list.append(max_a)

answer = sum(alice_list) - sum(bob_list)
print(answer)

Buggy submission (verdict: Runtime Error):
n = input().split()[0]
a_list = list(map(int, input().split()))

alice_list = []
bob_list = []

for i in range(len(a_list) - 1):
    max_a = max(a_list)
    a_list = a_list.remove(max_a)

    if i % 2 == 0:
        alice_list.append(max_a)
    else:
        bob_list.append(max_a)

answer = sum(alice_list) - sum(bob_list)
print(answer)
Problem p03470 (python)

Fixed submission:
n = int(input().split()[0])
length_list = []
for _ in range(n):
    x = int(input().split()[0])
    length_list.append(x)

print(len(list(set(length_list))))

Buggy submission (verdict: Runtime Error):
length_list = []
for _ in range(n):
    x = int(input().split()[0])
    length_list.append(x)

print(len(list(set(length_list))))
Problem p03474 (python)

Fixed submission:
a, b = list(map(int, input().split()))
s = input()
l = s.split("-")
if len(l) != 2:
  ans = "No"
elif len(l[0])==a and len(l[1]) == b:
  ans = "Yes"
else:
  ans = "No"
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
s = input()
l = s.split("-")
if len(l) != 2:
  ans = "No"
elif len[0]==a and len[1] == b:
  ans = "Yes"
else:
  ans = "No"
print(ans)
Problem p03545 (python)

Fixed submission:
# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう
is_ok = False

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - d
            if work_3 == 7:
                is_ok = True
                op_list = [op1, op2, op3]
                break
        if is_ok:
            break
    if is_ok:
        break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう
is_ok = False

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - c
            if work_3 == 7:
                is_ok = True
                op_list = [op1, op2, op3]
                break
        if is_ok:
            break
    if is_ok:
        break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - c
            if work_3 == 7:
                op_list = [op1, op2, op3]
                break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - c
            if work_3 == 7:
                op_list = [op1, op2, op3]
                break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)
Problem p03563 (python)

Fixed submission:
# https://atcoder.jp/contests/abc076/tasks/abc076_a
# A - Rating Goal

r = int(input().split()[0])
g = int(input().split()[0])

next = g * 2 - r
print(next)

Buggy submission (verdict: Runtime Error):
r = int(input().split()[0])
g = int(input().split()[0])

next = g * 2 - r
print(next
Problem p03569 (python)

Fixed submission:
#!/usr/bin/env python3

S = input()
N = len(S)
count = 0
is_ok = True

right_index = 0
left_index = N - 1

while right_index < left_index:

    if right_index == left_index:
        break

    if S[right_index] == S[left_index]:
        right_index += 1
        left_index -= 1
        continue
    if S[right_index] == "x":
        count += 1
        right_index += 1
        continue

    if S[left_index] == "x":
        count += 1
        left_index -= 1
        continue

    count = -1
    break

ans = count

print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

S = input()
N = len(S)
count = 0
is_ok = True

right_index = 0
left_index = N - 1

while right_index != left_index:

    if right_index == left_index:
        break

    if S[right_index] == S[left_index]:
        right_index += 1
        left_index -= 1
        continue
    if S[right_index] == "x":
        count += 1
        right_index += 1
        continue

    if S[left_index] == "x":
        count += 1
        left_index -= 1
        continue

    count = -1
    break

ans = count

print(ans)
Problem p03599 (python)

Fixed submission:
# https://atcoder.jp/contests/abc074/tasks/arc083_a
# C - Sugar Water
import math
w_A, w_B, s_C, s_D, limit_E, max_F = list(map(int, input().split()))

# それ以上溶かすことができるか
# それ以上重量を増やせるか

# 取りうる水の組み合わせ
w_A_list = [w_A * x * 100 for x in range(math.floor(max_F / (w_A * 100)) + 1)]
w_B_list = [w_B * x * 100 for x in range(math.floor(max_F / (w_B * 100)) + 1)]

# 最悪で3000*3000
w_list = []
for a in w_A_list:
    for b in w_B_list:
        if a + b <= max_F:
            w_list.append(a + b)
w_list = list(set(w_list))  # 3000以下

# 取りうる水の組み合わせ
s_C_list = [s_C * x  for x in range(math.floor(max_F / s_C) + 1)]
s_D_list = [s_D * x  for x in range(math.floor(max_F / s_D) + 1)]

# 最悪で3000*3000
s_list = []
for c in s_C_list:
    for d in s_D_list:
        if c + d <= max_F:
            s_list.append(c + d)
s_list = list(set(s_list))  # 3000以下

max_d = -float('inf')
for w in w_list:
    for s in s_list:
        limit_s = w * limit_E / 100
        if w + s <= max_F and w + s != 0 and s <= limit_s:
            d = (s / (w + s)) * 100
            if d > max_d:
                max_d = d
                ans_ws, ans_s = w + s, s

ans = ' '.join([str(ans_ws), str(ans_s)])
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc074/tasks/arc083_a
# C - Sugar Water
import math
w_A, w_B, s_C, s_D, limit_E, max_F = list(map(int, input().split()))

# それ以上溶かすことができるか
# それ以上重量を増やせるか

# 取りうる水の組み合わせ
w_A_list = [w_A * x * 100 for x in range(math.floor(max_F / (w_A * 100)) + 1)]
w_B_list = [w_B * x * 100 for x in range(math.floor(max_F / (w_B * 100)) + 1)]

# 最悪で3000*3000
w_list = []
for a in w_A_list:
    for b in w_B_list:
        if a + b <= max_F:
            w_list.append(a + b)
w_list = list(set(w_list))  # 3000以下

# 取りうる水の組み合わせ
s_C_list = [s_C * x  for x in range(math.floor(max_F / s_C) + 1)]
s_D_list = [s_D * x  for x in range(math.floor(max_F / s_D) + 1)]

# 最悪で3000*3000
s_list = []
for c in s_C_list:
    for d in s_D_list:
        if c + d <= max_F:
            s_list.append(c + d)
s_list = list(set(s_list))  # 3000以下

max_d = 0
for w in w_list:
    for s in s_list:
        limit_s = w * limit_E / 100
        if w + s <= max_F and w + s != 0 and s <= limit_s:
            d = (s / (w + s)) * 100
            if d > max_d:
                max_d = d
                ans_ws, ans_s = w + s, s

ans = ' '.join([str(ans_ws), str(ans_s)])
print(ans)
Problem p03612 (python)

Fixed submission:
#!/usr/bin/env python3

N = int(input().split()[0])
p_list = list(map(int, input().split()))
count = 0
for i in range(N):
    index = i + 1
    if index == p_list[i]:
        if i != 0 and i != N - 1:
            if p_list[i + 1] == index + 1:
                p_list[i] = p_list[i + 1]
                p_list[i + 1] = index
            else:
                p_list[i] = p_list[i - 1]
                p_list[i - 1] = index
        elif i != 0:
            p_list[i] = p_list[i - 1]
            p_list[i - 1] = index
        elif i != N - 1:
            p_list[i] = p_list[i + 1]
            p_list[i + 1] = index

        count += 1

ans = count
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

N = int(input().split()[0])
p_list = list(map(int, input().split()))
count = 0
for i in range(N):
    index = i + 1
    if index == p_list[i]:
        if i != 0 and i != 1:
            if p_list[i + 1] == index + 1:
                p_list[i] = p_list[i + 1]
                p_list[i + 1] = index
            else:
                p_list[i] = p_list[i - 1]
                p_list[i - 1] = index
        elif i != 0:
            p_list[i] = p_list[i - 1]
            p_list[i - 1] = index
        elif i != 1:
            p_list[i] = p_list[i + 1]
            p_list[i + 1] = index

        count += 1

ans = count
print(ans)