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

Fixed submission:
A,B,C = map(int,input().split())
S = A+B+C
if S == 17:
    S = S - max(A, B, C)
    if S == 10:
        S = S - min(A, B, C)
        if S == 5:
            print("YES")
        else:
            pass
    else:
        pass
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
#Iroha Loves Strings (ABC Edition)
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())
sort = sorted(S)
R = ""
for i in range(0,N):
    R = R + sort[i]
print(R)

Buggy submission (verdict: Runtime Error):
#Iroha Loves Strings (ABC Edition)
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())
R = []
K = ""
R.append(S[0])
for i in range(1, N):
    for j in range (0, i):
        if S[i] < R[j]:
            R.insert(j,S[i])
        if S[i] >= R[i-1]:
            R.append(S[i])
for i in range(0,N):
    K = K + R[i]
print(K)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    a = sorted(A)
    maxv1 = a[-1]
    maxi1 = A.index(maxv1)
    maxv2 = a[-2]

    for i in range(N):
        if i == maxi1:
            print(maxv2)        
        else:
            print(maxv1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    for i in range(N):
        if i == N - 1:
            print(max(A[:-1]))
        else:
            print(max(*A[:i], *A[i+1:]))
Problem p03037 (python)

Fixed submission:
_, m = map(int, input().split())

mi, mx = map(int, input().split())
flag = False
for i in range(m-1):
    l, r = map(int, input().split())
    if mi < l <= mx:
        mi = l
    if mi <= r < mx:
        mx = r
    if mx < l or r < mi:
        flag = True
        break

if flag:
    print(0)
else:
    print(mx - mi + 1)

Buggy submission (verdict: Runtime Error):
_, m = map(int, input().split())

mi, mx = map(int, input().split())
for i in range(m-1):
    l, r = map(int, input().split())
    if mi < l <= mx:
        mi = l
    if mi <= r < mx:
        mx = r
    if mx < l or r < mi:
        flag = True
        break

if flag:
    print(0)
else:
    print(mx - mi + 1)
Problem p03361 (python)

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

d = [(-1, 0), (1, 0), (0, -1), (0, 1)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            continue

        flag = False
        for dx, dy in d:
            i2, j2 = i+dx, j+dy
            if not (0 <= i2 < H and 0 <= j2 < W):
                continue

            if S[i2][j2] == "#":
                flag = True

        if not flag:
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

ds = [(1, 0), (-1, 0), (0, 1), (0, -1)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            continue

        flag = False
        for dx, dy in ds:
            x, y = i + dx, j + dy
            if x < 0 or W <= x or y < 0 or H <= y:
                continue

            if S[x][y] == "#":
                flag = True
                break

        if not flag:
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

ds = [(1, 0), (-1, 0), (0, 1), (0, -1)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            continue

        flag = False
        for dx, dy in ds:
            x, y = i + dy, j + dx
            if x < 0 or W <= x or y < 0 or H <= y:
                continue

            if S[x][y] == "#":
                flag = True
                break

        if not flag:
            print("No")
            exit()
print("Yes")
Problem p03543 (python)

Fixed submission:
N = input()
left = len(set(list(N[1:]))) == 1
right = len(set(list(N[:3]))) == 1
print("Yes" if left or right else "No")

Buggy submission (verdict: Runtime Error):
N = input()
left = len(set(list(N[1:]))) == 1
right = len(set(list(N[:3]))) == 1
print("Yes" if left or right "No")
Problem p03998 (python)

Fixed submission:
Sa = list(input())
Sb = list(input())
Sc = list(input())

now = Sa.pop(0)
ans = ""

while True:
    if now == "a":
        if not Sa:
            ans = "A"
            break
        now = Sa.pop(0)
    elif now == "b":
        if not Sb:
            ans = "B"
            break
        now = Sb.pop(0)
    else:
        if not Sc:
            ans = "C"
            break
        now = Sc.pop(0)
print(ans)

Buggy submission (verdict: Runtime Error):
S = {
    'a' : input(),
    'b' : input(),
    'c' : input()
}
ans = None
prv, nxt = None, 'a'
while True:
    if len(S[nxt]) != 1:
        prv = nxt
        nxt = S[nxt][1]
    else:
        ans = prv.upper()
        break
    S[prv] = S[prv][1:]
print(ans)
Problem p04045 (python)

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

nums = []
for x in range(10):
    if x in ds:
        nums.append(1)
    else:
        nums.append(0)

res = 0
for x in range(n, n*10):
    ys = list(map(int,list(str(x))))
    flag = False
    for y in ys:
        if nums[y]:
            flag = True
            break
    if flag:
        continue
    else:
        res = x
        break
print(res)

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

nums = []
for x in range(10):
    if x in ds:
        nums.append(1)
    else:
        nums.append(0)

for x in range(n, n*10):
    ys = list(map(int,list(str(x))))
    flag = False
    for y in ys:
        if nums[y]:
            flag = True
            break
    if flag:
        continue
    else:
        print(x)
        exit
Problem p03331 (python)

Fixed submission:
import sys

def digits_sum(x):
    return sum(list(map(int, str(x))))

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

if __name__ == '__main__':
    n = int(input())
    print(solve(n))

Buggy submission (verdict: Runtime Error):
import sys

def digits_sum(x):
    return sum(map(int, str(x)))

def solve(n):
    ans = sys.maxint
    for a in range(2, n//2):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

if __name__ == '__main__':
    n = int(input())
    print(solve(n))
Problem p02818 (python)

Fixed submission:
A, B, K = [int(i) for i in input().split()]

a = max(A - K, 0)
k = max(K - A, 0)
b = max(B - k, 0)
print(str(a) + ' ' + str(b))

Buggy submission (verdict: Runtime Error):
A, B, K = [int(i) for i in input().split()]

a = max(A - K, 0)
print(f"{a} {B - max(K - A, 0)}")
Problem p02887 (python)

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

ans = [S[0]]
for i in range(1, N):
    curr = S[i]
    if ans[-1] != curr:
        ans.append(curr)

print(len(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = []
for i in range(1, N):
    if S[i-1] != S[i]:
        ans.append(S[i-1])
if S[-1] != S[-2]:
    ans.append(S[-1])
if len(set(S)) == 1:
    ans.append(S[0])
print(len(ans))
Problem p02923 (python)

Fixed submission:
N = int(input())
Hs = [int(i) for i in input().split()]

ans = []
cnt = 0
for i in range(1, N):
    if Hs[i-1] >= Hs[i]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
if cnt != 0:
    ans.append(cnt)
if N == 1:
    ans = [0]
print(max(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
Hs = [int(i) for i in input().split()]

ans = []
cnt = 0
for i in range(1, N):
    if Hs[i-1] >= Hs[i]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
if cnt != 0:
    ans.append(cnt)
print(max(ans))
Problem p03076 (python)

Fixed submission:
dishes = [int(input()) for _ in range(5)]

dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1]))
a = list()
b = list()
for d in dishes:
    if d % 10 == 0:
        a.append(d)
    else:
        b.append(d)
if len(b) > 0:
    b = [d + 10 - d % 10 for d in b[:-1]] + [b[-1]]
dishes = a + b
print(sum(dishes))

Buggy submission (verdict: Runtime Error):
dishes = [int(input()) for _ in range(5)]

dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1]))
a = list()
b = list()
for d in dishes:
    if d % 10 == 0:
        a.append(d)
    else:
        b.append(d)
b = [d + 10 - d % 10 for d in b[:-1]] + [b[-1]]
dishes = a + b
# print(sum(dishes))
#
print(1)

Buggy submission (verdict: Runtime Error):
dishes = [int(input()) for _ in range(5)]

dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1]))
a = list()
b = list()
for d in dishes:
    if d % 10 == 0:
        a.append(d)
    else:
        b.append(d)
b = [d + 10 - d % 10 for d in b[:-1]] + [b[-1]]
dishes = a + b
print(sum(dishes))

Buggy submission (verdict: Runtime Error):
dishes = [int(input()) for _ in range(5)]

dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1]))
a = list()
b = list()
for d in dishes:
    if d % 10 == 0:
        a.append(d)
    else:
        b.append(d)
b = [dish + 10 - dish % 10 for dish in b[:-1]] + [b[-1]]
dishes = a + b
print(sum(dishes))

Buggy submission (verdict: Runtime Error):
dishes = [int(input()) for _ in range(5)]

dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1]))
a = list()
b = list()
for d in dishes:
    if d % 10 == 0:
        a.append(d)
    else:
        b.append(d)
b = [dish + 10 - dish % 10 for dish in b[:-1]] + [b[-1]]
dishes = a + b
print(sum(dishes))
Problem p03086 (python)

Fixed submission:
S = input()

d = set(['A', 'T', 'C', 'G'])
len_ = 0
ans = 0
for s in S:
    if s in d:
        len_ += 1
    else:
        if len_ > ans:
            ans = len_
        len_ = 0
if len_ > ans:
    ans = len_
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()

d = set(['A', 'T', 'C', 'G'])
ans = 0
nums = list()
for s in S:
    if s in d:
        ans += 1
    else:
        nums.append(ans)
        ans = 0
print(max(nums))
Problem p03273 (python)

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

# 列から確認
ans = []
for i in range(H):
    row = mat[i]
    if all(['.' == r for r in row]):
        continue
    ans.append(row)

columns = [''.join([a[w] for a in ans]) for w in range(W)]
tmp = len(ans)
columns = [c for c in columns if '.' * tmp != c]

ans = [''.join([c[i] for c in columns]) for i in range(len(columns[0]))]
print('\n'.join(ans))

Buggy submission (verdict: Runtime Error):
import functools
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])


def get_bool(x, value, axis):
    return np.where(x == value, True, False).all(axis=axis)


custom_get_bool = functools.partial(mat, '.')
mat = mat[:, ~custom_get_bool(0)]
mat = mat[~custom_get_bool(1)]
print('\n'.join([''.join(row) for row in mat]))

Buggy submission (verdict: Runtime Error):
import functools
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])


def get_bool(x, value, axis):
    return np.where(x == value, True, False).all(axis=axis)


custom_get_bool = functools.partial((mat, '.'))
mat = mat[:, ~custom_get_bool(0)]
mat = mat[~custom_get_bool(1)]
print('\n'.join([''.join(row) for row in mat]))
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())

if len(S) > K:
    print(S[K-1])
else:
    num = '1'
    for s in S:
        if s != '1':
            num = s
            break
    print(num)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

if S[0] == '1':
    print(S[1])
else:
    print(S[0])
Problem p03316 (python)

Fixed submission:
N = input()
sn = sum([int(i) for i in str(N)])
if int(N) % sn == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
sn = sum([int(i) for i in str(N)])
if N % sn == 0:
    print('Yes')
else:
    print('No')
Problem p03386 (python)

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

a_list = list(range(A, min(B, A+K)))
b_list = list(range(max(A, B-K+1), B+1))
for i in sorted(list(set(a_list + b_list))):
    print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
 
tmp = list(range(a, b+1))
for a in sorted(set(tmp[:k] + tmp[-k:])):
    print(a)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
 
tmp = range(a, b+1)
for a in sorted(list(set(tmp[:k] + tmp[-k:]))):
    print(a)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

tmp = list(range(a, b+1))
for a in sorted(list(set(tmp[:k] + tmp[-k:]))):
    print(a)

Buggy submission (verdict: Runtime Error):
a, b, k = [int(i) for i in input().split()]

tmp = list(range(a, b+1))
for a in sorted(list(set(tmp[:k] + tmp[::-1][:k]))):
    print(a)
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())
# N = 9
# Y = 45000


def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            z = n - x - y
            total = 10000 * x + 5000 * y + 1000 * z
            if total == target:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'


print(judge(N, Y))

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())  
 
def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            # z = n - x - y
            tmp = Y - 10000 * x - 5000 * y
            if z == tmp / 1000:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'
 
 
print(judge(N, Y))

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())  
 
def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            # z = n - x - y
            tmp = total - 10000 * x - 5000 * y
            if z == tmp / 1000:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'
 
 
print(judge(N, Y))

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
# N = 9
# Y = 45000
  

def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            # z = n - x - y
            tmp = total - 10000 * x + 5000 * y
            if z == tmp / 1000:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'
 
 
print(judge(N, Y))
Problem p03501 (python)

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

print(min(N * A, B))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

print(min(N * A), B)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

if n == 1:
    print(times[0])
else:
    prev_lcm = times[0]
    for t in times[1:]:
        tmp = gcd(prev_lcm, t)
        lcm = prev_lcm * (t // tmp)
        prev_lcm = lcm
    print(lcm)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

if n == 1:
    print(times[0])
else:
    prev_lcm = times[0]
    for t in times[1:]:
        tmp = gcd(prev_lcm, t)
        lcm = int(prev_lcm * t / tmp)
        prev_lcm = lcm
    print(lcm)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

prev_lcm = times[0]
for t in times[1:]:
    tmp = gcd(prev_lcm, t)
    lcm = int(prev_lcm * t / tmp)
    prev_lcm = lcm
if n == 1:
    print(times[0])
else:
    print(lcm)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

prev_lcm = times[0]
for t in times[1:]:
    tmp = gcd(prev_lcm, t)
    lcm = int(prev_lcm * t / tmp)
    prev_lcm = lcm
print(lcm)
Problem p03636 (python)

Fixed submission:
s = input()

print(s[0] + str(len(s[1:-1])) + s[-1])

Buggy submission (verdict: Runtime Error):
s = input()

print(s[0] + len(s[1:-1]) + s[-1])
Problem p03695 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
rates = [int(i) for i in input().split()]
# N = 4
# rates = [2100, 2500, 2700, 2700]

color_nums = defaultdict(int)

for rate in rates:
    if rate <= 399:
        color_nums['灰'] += 1
    elif rate <= 799:
        color_nums['茶'] += 1
    elif rate <= 1199:
        color_nums['緑'] += 1
    elif rate <= 1599:
        color_nums['水'] += 1
    elif rate <= 1999:
        color_nums['青'] += 1
    elif rate <= 2399:
        color_nums['黄'] += 1
    elif rate <= 2799:
        color_nums['橙'] += 1
    elif rate <= 3199:
        color_nums['赤'] += 1
    else:
        color_nums['自由'] += 1

free_num = color_nums['自由']
if free_num == 0:
    # 自由に変えられる人がいない場合
    # -1 は free_num = color_nums['自由']で増えてしまったので...
    print(len(color_nums)-1, len(color_nums)-1)
elif free_num == N:
    # 自由に変えられる人しかいない場合
    print(1, free_num)
elif free_num != N:
    # 自由な人と混在
    tmp = dict(color_nums)  # コピーを作る
    tmp.pop('自由')
    l_tmp = len(tmp)
    min_num = l_tmp
    max_num = l_tmp + free_num
    print(min_num, max_num)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
rates = [int(i) for i in input().split()]

color_nums = defaultdict(int)

for rate in rates:
    if rate <= 399:
        color_nums['灰'] += 1
    elif rate <= 799:
        color_nums['茶'] += 1
    elif rate <= 1199:
        color_nums['緑'] += 1
    elif rate <= 1599:
        color_nums['水'] += 1
    elif rate <= 1999:
        color_nums['青'] += 1
    elif rate <= 2399:
        color_nums['黄'] += 1
    elif rate <= 2799:
        color_nums['橙'] += 1
    elif rate <= 3199:
        color_nums['赤'] += 1
    else:
        color_nums['自由'] += 1

free_num = color_nums['自由']
if free_num == 0:
    # 自由に変えられる人がいない場合
    print(len(color_nums), len(color_nums))
elif free_num == N:
    # 自由に変えられる人しかいない場合
    print(min(N, 8), 1)
elif free_num != N:
    # 自由な人と混在
    tmp = dict(free_num)  # コピーを作る
    tmp.pop('自由')
    l_tmp = len(tmp)
    min_num = l_tmp
    max_num = l_tmp + free_num
    print(max_num, min_num)
Problem p03720 (python)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
city_road_nums = defaultdict(int)

for _ in range(M):
    a, b = map(int, input().split())
    city_road_nums[a] += 1
    city_road_nums[b] += 1

for i in range(1, N+1):
    print(city_road_nums[i])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]
 
 
MPs = {}
for a, b in ABs:
	a = int(a)
    b = int(b)
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1
 
for mp in range(1, N+1):
    if mp not in MPs:
        MPs[mp] = '0'
 
for _, y in sorted(MPs.items()):
    print(y)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]
 
 
MPs = {}
for a, b in ABs:
    a = int(a)
    b = int(b)
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1
 
for mp in range(1, N+1):
    if mp not in MPs:
        MPs[mp] = '0'
 
for y in sorted(MPs.values()):
    print(y)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]
 
 
MPs = {}
for a, b in ABs:
	a = int(a)
    b = int(b)
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1
 
for mp in range(1, N+1):
    if mp not in MPs:
        MPs[mp] = '0'
 
for y in sorted(MPs.values()):
    print(y)
Problem p03729 (python)

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

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Problem p03830 (python)

Fixed submission:
from collections import Counter


def prime_factorize(n):
    p = 2
    fct = []
    # 素数pはp**2がnを超えないもの（ただしnはある素数で割り切れるだけ割り切れたもの）
    # これはある素数p(i)でnを割れる時、他の素数p(i以外)はn//p(i) を割り切れるものになるため

    # 例えば、nが54なら
    # p が2のとき 54 // 2 で27
    # 27はもう2で割り切れないので2は1個
    # この時点でnは27に更新されている
    # 次にp が3の時、何度もpで割る（3度）
    while n >= p ** 2:
        while n % p == 0:
            n //= p
            fct.append(p)
        p += 1
    if n > 1:
        fct.append(n)
    return fct


N = int(input())
MOD = 1000000007
numbers = []
for i in range(1, N+1):
    numbers += prime_factorize(i)

count_numbers = Counter(numbers)
ans = 1
for n in count_numbers.values():
    ans *= ((n+1) % MOD)

print(ans % MOD)

Buggy submission (verdict: Runtime Error):
from collections import Counter


def prime_factorize(n):
    p = 2
    fct = []
    # 素数pはp**2がAを超えないもの
    while n >= p ** 2:
        if n % p == 0:
            # このpは、2乗がAを超えないもの
            # 2乗がnを超えない限り割り続ける: 各pの積で割る
            n //= p
            fct.append(p)
        p += 1
    if n > 1:
        fct.append(n)
    return fct


N = int(input())
MOD = 1000000007
numbers = [prime_factorize(i) for i in range(1, N+1)]

count_numbers = Counter(numbers)
ans = 1
for n in count_numbers.values():
    ans *= ((n+1) % MOD)

print(ans % MOD)
Problem p03999 (python)

Fixed submission:
s = input()
n = len(s) - 1

if n == 0:
    print(s)
else:
    ans = 0
    for i in range(2 ** n):
        tmp = ''
        for j in range(n):
            tmp += s[j]
            if i & 1 << j:
                tmp += '+'
        tmp += s[j+1]
        if '+' in tmp:
            ans += eval(tmp)
        else:
            ans += int(tmp)

    print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s) - 1

ans = 0
for i in range(2 ** n):
    tmp = ''
    for j in range(n):
        tmp += s[j]
        if i & 1 << j:
            tmp += '+'
    tmp += s[j+1]
    if '+' in tmp:
        ans += eval(tmp)
    else:
        ans += int(tmp)

print(ans)
Problem p03227 (python)

Fixed submission:
s = input()

x = s
if len(s) == 2 :
    print (s)
elif len(s) == 3 :
    print (x[2] + x[1] + x[0])

Buggy submission (verdict: Runtime Error):
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(S):
    x = S
    if len(S) == 2:
        return S
    elif len(S) == 3 :
        return x[2] + x[1] + x[0]

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(S):
    x = S
    if len(S) == 2:
        return S
    elif len(S) == 3 :
        return x[2] + x[1] + x[0]

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()
Problem p03288 (python)

Fixed submission:
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(R): #104-A
    if 1200>R :
        return 'ABC'
    if 2800>R :
        return 'ARC'
    else:
        return 'AGC'

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def solve(R):
    if R < 1200 :
        return 'ABC'
    elif R < 2800 :
        return 'ARC'
    else :
        return 'AGC'

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    R = int(ws[0])
    return (R,)

def main():
    solve(*readQuestion())

Uncomment before submission
main()