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

Fixed submission:
# できなかった
# a1,...,anがdivisorで割り切れる、すなわちdivisorはMの約数である
n,m=map(int,input().split())

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

divisors.sort(key=lambda x:-x)
# print(divisors)
for d in divisors:
    if d<=m//n:
        print(d)
        break

Buggy submission (verdict: Runtime Error):
import fraction
# import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if m%n==0:
    print(m//n)
else:
    print(fraction.gcd(m//n,m%n))
    # print(math.gcd(m//n,m%n))

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if m%n==0:
    print(m//n)
else:
    print(math.gcd(m//n,m%n))

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if n%m==0:
    print(m//n)
else:
    print(math.gcd(m//n,m%n))
Problem p02662 (python)

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

mod = 998244353

dp = [[0] * 4000 for _ in range(4000)]

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % mod
        x *= x % mod
        n //= 2

    return K * x % mod

inv2 = pow_k(2, mod - 2)
pow2n = pow_k(2, n)

dp[0][0] = pow2n
for i in range(1, n + 1):
    for j in range(s + 1):
        if j >= a[i - 1]:
            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - a[i - 1]] * inv2 % mod) % mod
        else:
            dp[i][j] = dp[i - 1][j]
print(dp[n][s])

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

mod = 998244353

dp = [[0] * (n + 1) for _ in range(s + 1)]

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % mod
        x *= x % mod
        n //= 2

    return K * x % mod

inv2 = pow_k(2, mod - 2)
pow2n = pow_k(2, n)

dp[0][0] = pow2n
for i in range(1, n + 1):
    for j in range(s + 1):
        if j >= a[i - 1]:
            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - a[i - 1]] * inv2 % mod) % mod
        else:
            dp[i][j] = dp[i - 1][j]
print(dp[n][s])
Problem p02681 (python)

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

S = list(input())
T = list(input())

if len(T) == len(S) + 1:
    flag = True
    for i in range(len(S)):
        if S[i] != T[i]:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

S = list(input())
T = list(input())

if len(T) == len(S) + 1:
    flag = True
    for i in len(S):
        if S[i] != T[i]:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Problem p02684 (python)

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

from pprint import pprint
import sys
sys.setrecursionlimit(10 ** 6)

n_towns, k_times = map(int, input().split())
teleport = list(map(int, input().split()))

seq = []
flags = [False] * n_towns
visited = [0] * n_towns

flags[0] = True
seq.append(0)
visited[0] += 1

town_prev = 0

while True:
    town_next = teleport[town_prev] - 1
    visited[town_next] += 1
    if flags[town_next]:
        seq.append(town_next)
        break
    seq.append(town_next)
    flags[town_next] = True
    town_prev = town_next

loop_len = 0
for town, count in enumerate(visited):
    if count == 2:
        loop_idx = seq.index(town)
# print(loop_idx)

# print(f'seq: {seq}')

if k_times < loop_idx:
    print(seq[k_times] + 1)
else:
    arr = seq[loop_idx:len(seq) - 1]
    r = (k_times - loop_idx) % len(arr)
    print(arr[r] + 1)

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

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

n_towns, k_times = map(int, input().split())
teleport = list(map(int, input().split()))

seq = []
flags = [False] * n_towns
visited = [0] * n_towns

flags[0] = True
seq.append(0)
visited[0] += 1

town_prev = 0

while True:
    town_next = teleport[town_prev] - 1
    visited[town_next] += 1
    if flags[town_next]:
        seq.append(town_next)
        break
    seq.append(town_next)
    flags[town_next] = True
    town_prev = town_next

loop_len = 0
for town, count in enumerate(visited):
    if count == 2:
        loop_idx = seq.index(town)
# print(loop_idx)

if k_times < loop_idx:
    print(seq[k_times])
else:
    arr = seq[loop_idx:len(seq) - 1]
    r = (k_times - loop_idx + 1) % (len(seq) - loop_idx)
    # print(arr, r)
    print(arr[r])
Problem p02690 (python)

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

import sys

input = sys.stdin.buffer.readline

x = int(input())


def find(x):
    for a in range(-300, 300):
        for b in range(-300, 300):
            b = -b
            if a ** 5 - b ** 5 == x:
                return [a, b]


a, b = find(x)
print(a, b)

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

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float("inf")

x = int(input())


def find(x):
    for a in range(300):
        for b in range(300):
            b = -b
            if a ** 5 - b ** 5 == x:
                return [a, b]


a, b = find(x)
print(a, b)
Problem p02791 (python)

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

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

count = 0
min_prev = P[0] + 1
for i in range(N):
    if P[i] < min_prev:
        min_prev = P[i]
        count += 1

print(count)

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

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

count = 0
for i in range(N):
    l = P[:i+1]
    print(l)
    if P[i] <= min(l):
        count += 1

print(count)
Problem p02844 (python)

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

import itertools

N = int(input())
S = str(input())

# 暗証番号Vを000から999まで決め打ちすると、次の問題を1000回解けば良いことになる。
# SからN-3桁を消して、Vを作ることができるか。
# この問題は貪欲法で解くことができる。
# - 1. S_i = V_1であるようなiのうち、最小のiをp_1とする。そのようなiが存在しなければ、Vを作ることはできない。
# - 2. S_i = V_2であるようなiのうち、p_1より大きい、かつ最も小さいiをp_2とする。そのようなiが存在しなければ、Vを作ることはできない。
# - 3. S_i = V_3であるようなiのうち、p_2より大きい、かつ最も小さいiをp_3とする。そのようなiが存在しなければ、Vを作ることはできない。
# e.g., S = 869120, V = 812
# - V_1 = 8より、p_1 = 0
# - V_2 = 1, p_1 = 0より、p_2 = 3
# - V_3 = 2, p_2 = 3より、p_3 = 4

def can_make_pw(S, password):
    # step1
    v1 = password[0]
    p1 = S.find(v1)
    if p1 == -1:
        return False
    # step2
    v2 = password[1]
    p2 = S.find(v2, p1+1)
    if p2 == -1:
        return False
    # step3
    v3 = password[2]
    p3 = S.find(v3, p2+1)
    if p3 == -1:
        return False
    return True

passwords = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            password = str(i) + str(j) + str(k)
            passwords.append(password)
# print(passwords)

count = 0
for password in passwords:
    if can_make_pw(S, password):
        # print(f"You can make {password} from {S}")
        count += 1

print(count)

# 全探索はTLE
# l_pw = []
# if N-3 == 1:
#     for i in range(N):
#         l_S = list(S)
#         l_S.pop(i)
#         l_pw.append(','.join(l_S))
# else:
#     combs = list(itertools.combinations(range(N), N-3))
#     for comb in combs:
#         l_S = list(S)
#         for i in sorted(comb, reverse=True):
#             l_S.pop(i)
#         l_pw.append(','.join(l_S))
# print(len(set(l_pw)))

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

import itertools

N = int(input())
S = str(input())

if N-3 == 1:
    combs = list(range(N))
else:
    combs = list(itertools.combinations(range(N), N-3))

l_pw = []
for comb in combs:
    l_S = list(S)
    for idx in sorted(comb, reverse=True):
        l_S.pop(idx)
    l_pw.append(','.join(l_S))

# print(l_pw)

print(len(set(l_pw)))
Problem p03436 (python)

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

from collections import deque

H, W = map(int, input().split())

field = []
for _ in range(H):
    line = list(input())
    field.append(line)
# print(H, W, field)


def is_valid(i, j):
    cond_i = 0 <= i <= H - 1
    cond_j = 0 <= j <= W - 1
    return cond_i and cond_j


def is_reachable(i, j, ):
    if is_valid(i, j):
        if field[i][j] == '.':
            return True
    return False


def adj(i, j):
    up, down = [i - 1, j], [i + 1, j]
    left, right = [i, j - 1], [i, j + 1]
    res = []
    for i_adj, j_adj in up, down, left, right:
        if is_reachable(i_adj, j_adj):
            res.append([i_adj, j_adj])
    return res


def bfs(que, dist):
    while len(que) > 0:
        i, j = que.popleft()
        # print(f"i, j: {i}, {j}")
        for i_adj, j_adj in adj(i, j):
            # print(f"i_adj, j_adj: {i_adj}, {j_adj}")
            if dist[(i_adj, j_adj)] == -1:
                que.append([i_adj, j_adj])
                dist[(i_adj, j_adj)] = dist[(i, j)] + 1


que = deque()
keys = [(i, j) for i in range(H) for j in range(W)]
values = [-1 for _ in range(H * W)]
dist = dict(zip(keys, values))
# print(dist)

n_black = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            n_black += 1

que.append([0, 0])
dist[(0, 0)] = 0
bfs(que, dist)

if dist[(H - 1, W - 1)] == -1:
    print(-1)
else:
    steps_min = dist[(H - 1, W - 1)] + 1
    n_white = W * H - n_black
    ans = n_white - steps_min
    print(ans)

Buggy submission (verdict: Runtime Error):
if field[0][0] == '#':
    print(-1)
elif dist[(H - 1, W - 1)] == -1:
    print(-1)
else:
    steps_min = dist[(H - 1, W - 1)] + 1
    n_white = W * H - n_black
    ans = n_white - steps_min
    print(ans)
Problem p03471 (python)

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

n, y = map(int, input().split())
# print(n, y)

found = False
for i in range(n+1):
    for j in range(n+1):
        if i + j > n:
            break
        k = n - (i + j)
        if 10000 * i + 5000 * j + 1000 * k == y and i + j + k == n:
            found = True
            print("{} {} {}".format(i, j, k))
            break
    if found:
        break

if not found:
    print("-1 -1 -1")

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

n, y = map(int, input().split())
# print(n, y)

found = False
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if 10000 * i + 5000 * j + 1000 * k == y and i + j + k == n:
                found = True
                print(f"{i} {j} {k}")
                break
        if found:
            break
    if found:
        break

if not found:
    print("-1 -1 -1")

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

n, y = map(int, input().split())
# print(n, y)

flag = False
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if 10000 * i + 5000 * j + 1000 * k == y and i + j + k == n:
                flag = True
                print(f"{i} {j} {k}")
                break
        if flag:
            break
    if flag:
        break

if not flag:
    print("-1 -1 -1")
Problem p02756 (python)

Fixed submission:
from collections import deque
S = deque(list(input()))
Q = int(input())
parity = 0

for i in range(Q):
    query = input().split()
    if len(query) == 1:
        parity += 1
    else:
        if int(query[1]) == 1 + (parity % 2):
            S.appendleft(query[2])
        else:
            S.append(query[2])
S = ''.join([c for c in S])
if parity % 2 == 1:
    S = S[::-1]
print(S)

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
parity = 0

for i in range(Q):
    query = input().split()
    if query == '1':
        parity += 1
    else:
        if int(query[1]) == 1 + (parity % 2):
            S = query[2] + S
        else:
            S = S + query[2]

if parity % 2 == 1:
    S = S[::-1]
print(S)
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
print(max(A - 2 * B, 0))

Buggy submission (verdict: Runtime Error):
import sys
import bisect

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
l = sorted(nm())

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        a = l[i]
        b = l[j]
        idx = bisect.bisect_left(l, a + b)
        if idx > j: ans += idx - j - 1
print(ans)
Problem p03060 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list()
for benefit, cost in zip(a, b):
  if benefit - cost > 0:
    c.append(benefit - cost)
print(sum(c))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list()
for benefit, cost in a, b:
  if benefit - cost > 0:
    c.append(benefit - cost)
print(sum(c))
Problem p03062 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
abs_A = list(map(lambda x: abs(x), A))

pos = []
neg = []
ans = 0

for e in A:
    if e > 0:
        pos.append(e)
    else:
        neg.append(e)
if len(neg) % 2 == 0:
    ans = sum(abs_A)
else:
    """pos.sort(reverse=True)
    neg.sort(reverse=True)
    if len(neg) == N:
        ans = -sum(neg[:-1]) + neg[-1]
    else:"""
    #ans = max(-sum(neg[:-1]) + neg[-1], -sum(neg[:-3]) + sum(neg[-3:]))
    #ans = max(sum(pos[:-1])-pos[-1]-sum(neg), sum(pos) + neg[0] -sum(neg[1:]))
    ans = sum(abs_A)
    ans -= 2 * min(abs_A)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
abs_A =  map(lambda x: abs(x), A)

pos = []
neg = []
ans = 0

for e in A:
    if e > 0:
        pos.append(e)
    else:
        neg.append(e)
if len(neg) % 2 == 0:
    ans = sum(abs_A)
else:
    """pos.sort(reverse=True)
    neg.sort(reverse=True)
    if len(neg) == N:
        ans = -sum(neg[:-1]) + neg[-1]
    else:"""
    #ans = max(-sum(neg[:-1]) + neg[-1], -sum(neg[:-3]) + sum(neg[-3:]))
    #ans = max(sum(pos[:-1])-pos[-1]-sum(neg), sum(pos) + neg[0] -sum(neg[1:]))
    ans = sum(abs_A)
    ans -= 2 * min(abs_A)
print(ans)

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

pos = []
neg = []
ans = 0

for e in A:
    if e > 0:
        pos.append(e)
    else:
        neg.append(e)
if len(neg) % 2 == 0:
    ans = sum(pos) - sum(neg)
else:
    """pos.sort(reverse=True)
    neg.sort(reverse=True)
    if len(neg) == N:
        ans = -sum(neg[:-1]) + neg[-1]
    else:"""
    #ans = max(-sum(neg[:-1]) + neg[-1], -sum(neg[:-3]) + sum(neg[-3:]))
    #ans = max(sum(pos[:-1])-pos[-1]-sum(neg), sum(pos) + neg[0] -sum(neg[1:]))
    ans = sum(pos) - sum(neg)
    ans -= 2 * min(min(pos), -max(neg))
print(ans)
Problem p03071 (python)

Fixed submission:
a, b = map(int, input().split())
if a < b:
  a, b = b, a

if a - b >= 2:
  print(2 * a - 1)
else:
  print(a + b)

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

if a - b >= 2:
  print(2 * a - 1)
else:
  print(a + b)
Problem p03076 (python)

Fixed submission:
def tenth(a):
  temp = a
  while True:
    if temp % 10 == 0:
      return temp
    else:
      temp += 1

li = list()
ans = 0

for i in range(5):
  li.append(int(input()))
  ans += tenth(li[i])
  li[i] = tenth(li[i]) - li[i]
  
ans -= max(li)

print(ans)

Buggy submission (verdict: Runtime Error):
def tenth(a):
  temp = a
  while True:
    if temp % 10 == 0:
      return temp
    else:
      temp += 1

li = list()
ans = 0

for i in range(5):
  li[i] = int(input())
  ans += tenth(li[i])
  li[i] = tenth(li[i]) - li[i]
  
ans -= min(li)

print(ans)

Buggy submission (verdict: Runtime Error):
def tenth(a):
  temp = a
  if temp % 10 == 0:
    return temp
  else:
    temp += 1

a = tenth(int(input()))
b = tenth(int(input()))
c = tenth(int(input()))
d = tenth(int(input()))
e = int(input())

print(a + b + c + d + e)

Buggy submission (verdict: Runtime Error):
def tenth(int a):
  temp = a
  if temp % 10 == 0:
    return temp
  else:
    temp += 1

a = tenth(int(input()))
b = tenth(int(input()))
c = tenth(int(input()))
d = tenth(int(input()))
e = int(input())

print(a + b + c + d + e)

Buggy submission (verdict: Runtime Error):
def tenth(int a):
  if a % 10 == 0:
    return a
  else:
    a += 1

a = tenth(int(input()))
b = tenth(int(input()))
c = tenth(int(input()))
d = tenth(int(input()))
e = tenth(int(input()))

print(a + b + c + d + e)
Problem p03085 (python)

Fixed submission:
acid = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'}
c = input()
print(acid[c])

Buggy submission (verdict: Runtime Error):
acid = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'}
c = input()
print(acid(c))
Problem p03087 (python)

Fixed submission:
n, q = list(map(int, input().split()))
s = input()
dp = [0, 0]
for i in range(1, n):
    if s[i-1]=="A" and s[i]=="C":
        dp.append(dp[-1]+1)
    else:
        dp.append(dp[-1])
for i in range(q):
    l, r = map(int, input().split())
    ans = dp[r] - dp[l]
    print(ans)

Buggy submission (verdict: Runtime Error):
n, q = list(map(int, input().split()))
s = input()
lr = []
for _ in range(q):
    lr.append(list(map(int, input().split())))
dp = [0]*(10^5+1)
for i in range(1, n):
    if s[i-1]=="A" and s[i]=="C":
        dp[i+1]=dp[i]+1
    else:
        dp[i+1]=dp[i]
for i in range(q):
    l = lr[i][0]
    r = lr[i][1]
    ans = dp[r] - dp[l]
    print(ans)
Problem p03385 (python)

Fixed submission:
s=input()
if 'a' in s and 'b' in s and 'c' in s:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
if s.sorted() == 'abc':
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
if s.sort() == 'abc':
  print('Yes')
else:
  print('No')
Problem p03447 (python)

Fixed submission:
x=int(input())
a=int(input())
b=int(input())
ans=x-a
while ans>=b:
  ans-=b
print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
a=int(input())
b=int(input())
ans=x-a
print(ans>=b):
  ans-=b
print('ans')
Problem p03469 (python)

Fixed submission:
a=input()
print(a.replace('2017/','2018/'))

Buggy submission (verdict: Runtime Error):
a=input()
print(a.replace('2017/','2018/')

Buggy submission (verdict: Runtime Error):
a=input()
a[3]='8'
print(a)

Buggy submission (verdict: Runtime Error):
a=imput()
a[3]='8'
print(a)
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0

for num in range(1, n+1):
  bits = list()
  numm = num
  while num > 0:
    tmp = num % 10
    bits.append(tmp)
    num -= tmp
    num /= 10
  if a <= sum(bits) <= b:
    ans += numm

print(ans)

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

for num in range(1, n+1):
  bits = list()
  while num > 0:
    tmp = num % 10
    bits.append(tmp)
    num -= tmp
    num /= 10
  if a <= bits.sum() <= b:
    ans += 1

print(ans)

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

for num in range(1, n+1):
  bits = list()
  while num > 0:
    tmp = num % 10
    bits.append(tmp)
    num //= 10
  if a <= bits.sum() <= b:
    ans += 1

print(ans)
Problem p03494 (python)

Fixed submission:
import sys
n = int(input())
a = list(map(int, input().split()))
ans = sys.maxsize

for num in a:
  tmp = 0
  while num % 2 == 0:
    num /= 2
    tmp += 1
  ans = min(tmp, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0

for num in a:
  tmp = 0
  while num % 2 == 0:
    num /= 2
    tmp += 1
  	ans = min(tmp, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0

for num in a:
  tmp = 0
  while num % 2 == 0:
    num /= 2
    tmp　+= 1
  	ans = min(tmp, ans)

print(ans)
Problem p03563 (python)

Fixed submission:
r=int(input())
g=int(input())
print(2*g-r)

Buggy submission (verdict: Runtime Error):
g,r=map(int,input().split())
print(2*g-r)
Problem p03574 (python)

Fixed submission:
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      continue
    cnt=0
    for dx in [-1,0,1]:
      for dy in [-1,0,1]:
        if not(0<=dx+i<=h-1 and 0<=dy+j<=w-1):
          continue
        if s[i+dx][j+dy]=='#':
          cnt+=1
    s[i][j]=str(cnt)
for m in s:
  print(''.join(m))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      continue
    cnt=0
    for dx in [-1,0,1]:
      for dy in [-1,0,1]:
        if not(0<=dx+i<=h and 0<=dy+j<=w):
          continue
        if s[i+dx][j+dy]=='#':
          cnt+=1
    s[i][j]=str(cnt)
for m in s:
  print(''.join(m))
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
ans=a.upper()[0]+b.upper()[0]+c.upper()[0]
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
ans=a.upper[0]+b.upper[0]+c.upper[0]
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c=input().split
ans=a.upper[0]+b.upper[0]+c.upper[0]
print(ans)
Problem p03844 (python)

Fixed submission:
a,b,c=input().split()
a=int(a)
c=int(c)
if b=='+':
  print(a+c)
else:
  print(a-c)

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
a=int(a)
c=int(c)
if b=='+':
  print(a+b)
else:
  print(a-b)
Problem p03854 (python)

Fixed submission:
er = ["dreamer", "eraser"]
noter = ["dream", "erase"]
words = er + noter
s = input()
while len(s) > 0:
  flag = True
  for word in words:
    if s.endswith(word):
      s = s[:-len(word)]
      flag = False
  if flag:
    print("NO")
    exit()
print("YES")

Buggy submission (verdict: Runtime Error):
//words = ['dream', 'dreamer', 'erase', 'eraser']
words = ['dream', 'erase', 'aser*', 'er', 'as']
s = input()
for word in words:
  s = s.replace(word, '*')
s = s.replace('*', '')
if len(s) == 0:
  print('YES')
else:
  print('NO')
Problem p03993 (python)

Fixed submission:
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
l = nl()
ans = 0

for i, usa in enumerate(l):
    if l[usa - 1] == i + 1:
        ans += 1
print(ans // 2)

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
l = nl()
ans = 0

for i, usa in enumerate(l):
    if l[usa] - 1 == i:
        ans += 1
print(ans // 2)
Problem p03254 (python)

Fixed submission:
N, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
  print(N)
else:
  while sum(a) > x:
    a.remove(max(a))
  l = len(a)
  if l == N:
    print(l - 1)
  else:
    print(l)

Buggy submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
  print(N)
else:
  while sum(a) > x:
    a.remove(max(a))
  print(len(l))

Buggy submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
  print(N)
else:
  sort(a)
  while sum(a) > x:
    a.remove(max(a))
  print(len(l))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if a * b % 2 == 1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a * b mod 2 == 1:
  print('Odd')
else:
  print('Even')