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

Fixed submission:
import fractions

A, B = map(int, input().split())

# A, B の正の公約数から互いに素となる組み合わせを選ぶとき、最大でいくつ選べる？
# 最大公約数を求める
gcd = fractions.gcd(A, B)


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

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

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

    return arr


# 最大公約数を素因数分解する
f = factorization(gcd)
# 1のケースのみ1を出力する
if f == [[1, 1]]:
    print(1)
else:
    # 要素数＋１が選択可能な個数
    ans = len(f) + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

# A, B の正の公約数から互いに素となる組み合わせを選ぶとき、最大でいくつ選べる？
# 最大公約数を求める
gcd = math.gcd(A, B)


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

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

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

    return arr


# 最大公約数を素因数分解する
f = factorization(gcd)
# 1のケースでは1を出力する
if f == [[1, 1]]:
    print(1)
else:
    # 要素数＋１が選択可能な個数
    ans = len(f) + 1
    print(ans)
Problem p02953 (python)

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


def check():
    for i in range(1, N):
        if nums[i] == nums[i - 1]:
            continue
        elif nums[i] - 1 >= nums[i - 1]:
            nums[i] -= 1
            continue
        else:
            return "No"
    return "Yes"


print(check())

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


def check():
    for i in range(1, N):
        if nums[i] == nums[i - 1]:
            continue
        elif nums[i] - 1 >= nums[i - 1]:
            nums[i] -= 1
        else:
            return "No"
    return "Yes"


print(check()
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 総当たり
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))

    return ans


print(get_ans())

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

L, R = map(int, input().split())

# mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ
np_nums = np.sort(np.mod(np.arange(L, R + 1), 2019))


def get_ans():
    # mod後の最小値コンビを十分大きな値で初期化しておく
    nums = [2019, 2020]
    for n in range(L, R + 1):
        mod = n % 2019
        # 0が来た瞬間終了
        if mod == 0:
            return 0

        # 最小値コンビの内どっちかより小さいなら置き換える
        if nums[0] > n:
            nums[0] = n
        elif nums[1] > n:
            nums[1] = n

    # ループ終わったら最小値コンビの積のmodを取る
    return (nums[0] * nums[1]) % 2019


print(get_ans())

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

L, R = map(int, input().split())

# mod 2019 の答えは 0 ~ 2018 のいずれか
# modは積のそれぞれを取ってから掛けても同じ
np_nums = np.sort(np.mod(np.arange(L, R + 1), 2019))

# 最も小さい2値の積が答え
ans = (np_nums[0] * np_nums[1]) % 2019
print(ans)
Problem p03239 (python)

Fixed submission:
strN, strT = input().split()
N = int(strN)
max_t = int(strT)

min_cost = 0
for i in range(1, N+1):
    str_cost, str_time = input().split()
    cost = int(str_cost)
    t = int(str_time)
    if max_t < t:
        continue
    if min_cost == 0:
        min_cost = cost
    elif min_cost > cost:
        min_cost = cost

if min_cost == 0:
    print('TLE')
else:
    print(min_cost)

Buggy submission (verdict: Runtime Error):
strN, strT = input().split()
N = int(strN)
max_t = int(strT)

min_cost: int = 0
for i in range(1, N+1):
    str_cost, str_time = input().split()
    cost = int(str_cost)
    t = int(str_time)
    if max_t < t:
        continue
    if min_cost == 0:
        min_cost = cost
    elif min_cost > cost:
        min_cost = cost

if min_cost == 0:
    print('TLE')
else:
    print(min_cost)
Problem p02946 (python)

Fixed submission:
num = input().split()
k = int(num[0])
x = int(num[1])
ans = []
for i in range(x - k + 1, x + k):
    print(i)

Buggy submission (verdict: Runtime Error):
num = input().split()
k = int(num[0])
x = int(num[1])
ans = []
for i in range(x - k + 1, x + k):
    ans.append(i)
print(ans)
s
Problem p02953 (python)

Fixed submission:
n = int(input())
h = [int(i) for i in input().split()]
h[0] -= 1
flag = [True]
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i] > h[i - 1]:
            h[i] -= 1
        elif h[i] < h[i - 1]:
            print('No')
            exit()
    print('Yes')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]
if h[0] != 1:
    h[0] -= 1
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i] > h[i - 1]:
            h[i] -= 1
        elif h[i] < h[h - 1]:
            print('No')
            exit()
    print('Yes')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]
if h[0] != 1:
    h[0] -= 1
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i - 1] < h[i]:
            h[i] -= 1
        elif h[i] < h[h - 1]:
            print('No')
            exit()
    print('Yes')
Problem p03029 (python)

Fixed submission:
a, b = map(int, input().split())
print((a*3 + b) // 2)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print((a*3 + b) // 2)
Problem p02900 (python)

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

    return divisors

A, B = map(int, input().split())

listA = make_divisors(A)
listB = make_divisors(B)
lst = list(set(listA) & set(listB))

lst.sort()

if len(lst) == 1:
    print(1)
else:
    check = [lst[1]]
    for i in range(1, len(lst)):
        for c in check:
            if lst[i] % c == 0:
                break
        else:
            check.append(lst[i])
    print(len(check)+1)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

lst = []
for i in range(1,math.gcd(A, B)+1):
    if A % i == 0 and B % i == 0:
        lst.append(i)

if len(lst) == 1:
    print(1)
else:
    check = [lst[1]]
    for i in range(1, len(lst)):
        for c in check:
            if lst[i] % c == 0:
                break
        else:
            check.append(lst[i])
    print(len(check)+1)
Problem p02898 (python)

Fixed submission:
n, m = [int(i) for i in input().split()]
cnt = 0
for i in input().split():
  if m <= int(i):
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
cnt = 0
for i in input().split();
	if m <= int(i):
    	cnt += 1
print(cnt)
Problem p02900 (python)

Fixed submission:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+1)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if temp != 1:
    arr.append(D)
print(len(arr)+1)

Buggy submission (verdict: Runtime Error):
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D != 1:
  for i in range(2, int(-(-D**0.5//1)+2)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
    if len(arr) == 0:
      append.arr(D)
print(len(arr)+1)

Buggy submission (verdict: Runtime Error):
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D != 1:
  for i in range(2, int(-(-D**0.5//1)+2)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
    if len(arr) == 0:
      append.arr(D)
else:
  pass
print(len(arr)+1)
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
D = [0] * N
T = [0] * N
for i in range(N):
  t[i+1], x[i+1], y[i+1] = map(int, input().split())
for i in range(N-1):
  D[i] = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
  T[i] = t[i+1] - t[i]
ans = 'Yes'
for i in range (N-1):
  if D[i] <= T[i] and (D[i] - T[i])%2 == 0:
    ans = 'Yes'
  else:
    ans = 'No'
print(ans)
Problem p03493 (python)

Fixed submission:
s = input()
print(int(s[0])+int(s[1])+int(s[2]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
t = 0
def exist_odd(A):
  for i in A:
    if i % 2 == 1:
      break
    return 1
  else:
    return 0
while exist_odd(A) ==1:
  A = list(map(lambda x: x / 2, A))
  t = t+1
print(t)
Problem p03112 (python)

Fixed submission:
import bisect
sn, tn, qn = map(int, input().split())

LARGE = -100000000
sa = []
ta = []
qa = []
for i in range(sn):
    sa.append(int(input()))
for i in range(tn):
    ta.append(int(input()))
for i in range(qn):
    qa.append(int(input()))

def find_nearest(q, al, s, e):
    idx = bisect.bisect_right(al, q)
    if idx == 0:
        return [al[0], al[0]]
    if idx == len(al):
        return [al[idx - 1], al[idx - 1]]
    return [al[idx - 1], al[idx]]

def move_cost(q, al, bl):
    a1, a2 = find_nearest(q, al, 0, len(al) - 1)
    b1, b2 = find_nearest(q, bl, 0, len(bl) - 1)

    def calc(x1, x2, x3):
        y1 = min(x1, x2)
        y2 = max(x1, x2)
        if x3 >= y1 and x3 <= y2:
            return abs(x1 - x2)
        return abs(x1 - x2) + abs(x2 - x3)
    return min(
        calc(q, a1, b1),
        calc(q, a1, b2),
        calc(q, a2, b1),
        calc(q, a2, b2),
        calc(q, b1, a1),
        calc(q, b1, a2),
        calc(q, b2, a1),
        calc(q, b2, a2),
    )

for q in qa:
    print(move_cost(q, sa, ta))

Buggy submission (verdict: Runtime Error):
# sn, tn, qn = map(int, input().split())

sa = []
ta = []
qa = []
for i in range(sn):
    sa.append(int(input()))
for i in range(tn):
    ta.append(int(input()))
for i in range(qn):
    qa.append(int(input()))


def find_nearest(q, al, s, e):
    if e - s < 2:
        d1 = abs(q - al[s])
        d2 = abs(q - al[e])
        if d1 < d2:
            return al[s]
        return al[e]
    idx = (e - s) // 2 + s
    if al[idx] == q:
        return al[idx]
    if al[idx] > q:
        return find_nearest(q, al, s, idx)
    return find_nearest(q, al, idx, e)

def find_range(q1, q2, al, s, e):
    if al[s] >= q1 and al[s] <= q2:
        return True
    if al[e] >= q1 and al[e] <= q2:
        return True
    if al[s] >= q2 or al[e] <= q1 or e - s < 2:
        return False
    idx = (e - s) // 2 + s
    if al[idx] < q1:
        return find_range(q1, q2, al, s, idx)
    return find_range(q1, q2, al, idx, e)

def move_cost(q, al, bl):
    mx = find_nearest(q, al, 0, len(al) - 1)
    min_x = min(mx, q)
    max_x = max(mx, q)
    if find_range(min_x, max_x, bl, 0, len(bl) - 1):
        return max_x - min_x

    mx2 = find_nearest(mx, bl, 0, len(bl) - 1)
    return (max_x - min_x) + abs(mx2 - mx)

for q in qa:
    a1 = move_cost(q, sa, ta)
    a2 = move_cost(q, ta, sa)
    print(min(a1, a2))
Problem p03148 (python)

Fixed submission:
N, K = map(int, input().split())
sushi = []
for i in range(N):
    s = list(map(int, input().split()))
    sushi.append(s)


sushi.sort(key=lambda x: x[1], reverse=True)

# pick from first
point = 0
neta_set = set()
removable_idx = list()
for i in range(K):
    s = sushi[i]
    point += s[1]
    if s[0] not in neta_set:
        neta_set.add(s[0])
    else:
        removable_idx.append(i)
point += len(neta_set) **2
max_point = point

# pick latest
for s in sushi[K:]:
    if len(removable_idx) == 0:
        break
    if s[0] in neta_set:
        continue
    idx = removable_idx[-1]
    count = len(neta_set)
    point += s[1] - sushi[idx][1]
    point += (count + 1) ** 2 - count ** 2
    neta_set.add(s[0])
    removable_idx = removable_idx[:-1]

    if point > max_point:
        max_point = point
print(max_point)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
sushi = []
for i in N:
    s = list(map(int, input().split()))
    sushi.append(s)


sushi.sort(key=lambda x: x[1], reverse=True)

def find_next(start, curr, point, tlist, tcount):
    if start == N:
        return [point, curr]
    max_c = curr
    max_p = point
    for s in sushi[start:]:
        if tlist[s[0]] > 0:
            continue
        for ri in range(len(curr) - 1, -1, -1):
            r = curr[ri]
            if tlist[r[0]] >= 2:
                c2 = [c for c in curr]
                t2 = [t for t in tlist]
                del c2[ri]
                c2.append(s)
                t2[r[0]] -= 1
                t2[s[0]] = 1
                p2 = point - r[1] + s[1] + (tcount + 1) * (tcount + 1) - tcount * tcount
                np, pc = find_next(start + 1, c2, p2, t2, tcount + 1)

                if np > max_p:
                    max_p = np
                    max_c = pc
                break
    return [max_p, max_c]

result = sushi[0: K]
type_count = [0] * (N + 1)

for r in result:
    type_count[r[0]] += 1
type_num = 0
for t in type_count:
    if t > 0:
        type_num += 1
point = type_num * type_num
for r in result:
    point += r[1]
ans_p, ans_c = find_next(K, result, point, type_count, type_num)

print(ans_p)
Problem p03262 (python)

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

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

Xi = list(map(int, input().split()))
Xi.sort()
Di = []
for i in range(N):
    Di.append(abs(X - Xi[i]))
DLen = len(Di)
g = Di[0]
for i in range(1, DLen):
    if Di[i] != 0:
        g = gcd(g, Di[i])
print(g)

Buggy submission (verdict: Runtime Error):
import math
N, X = map(int, input().split())

Xi = list(map(int, input().split()))
Xi.sort()
Di = []
found = False
for i in range(N - 1):
    if not found and Xi[i] < X and Xi[i + 1] >= X:
        Di.append(X - Xi[i])
        Di.append(Xi[i  + 1] - X)
        found = True
    elif Xi[i] != Xi[i + 1]:
        Di.append(Xi[i + 1] - Xi[i])
if not found:
    Di.append(X - Xi[-1])
Dl = len(Di)
if Dl == 0:
    print(abs(X - Xi[0]))
else:
    gcd = Di[0]
    for i in range(1, Dl):
        gcd = math.gcd(gcd, Di[i])
    print(gcd)

Buggy submission (verdict: Runtime Error):
import math
N, X = map(int, input().split())

Xi = list(map(int, input().split()))
Xi.sort()
Di = []
found = False
for i in range(N - 1):
    if not found and Xi[i] >= X and Xi[i + 1] < X:
        Di.append(X - Xi[i])
        Di.append(Xi[i  + 1] - X)
        found = True
    else:
        Di.append(Xi[i + 1] - Xi[i])

if len(Di) == 0:
    print(abs(X - Xi[0]))
else:
    gcd = Di[0]
    for i in range(1, N - 1):
        gcd = math.gcd(gcd, Di[i])
    print(gcd)
Problem p03287 (python)

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

#---------------
d = defaultdict(int)
d[0] = 1
total = 0
for i in range(N):
    total = (total + Ai[i]) % M
    d[total] += 1
#-----------------
ans = 0
for k, c in d.items():
    if c > 1:
        ans += c * (c - 1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
Ai = list(map(int, input().split()))

#-----------------
fact = [0 for _ in range(N + 1)]
fact[0] = 1
for i in range(1, N + 1):
    fact[i] = fact[i - 1] * i

def comb(n, m):
    return fact[n] // (fact[m] * fact[n - m])

#---------------
d = defaultdict(int)
total = Ai[0] % M
d[0] = 1
d[total] += 1
for i in range(1, N):
    total = (total + Ai[i]) % M
    d[total] += 1
#-----------------
ans = 0
for k in d.keys():
    c = d[k]
    if c > 1:
        ans += comb(c, 2)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
Ai = list(map(int, input().split()))

for i in range(N):
    for j in range(i, N):
        t = 0
        for k in range(i, j + 1):
            t += Ai[k]

#-----------------
fact = [0 for _ in range(N + 1)]
fact[0] = 1
for i in range(1, N + 1):
    fact[i] = fact[i - 1] * i

def comb(n, m):
    return fact[n] // (fact[m] * fact[n - m])

#---------------
d = defaultdict(int)
total = Ai[0] % M
d[0] = 1
d[total] += 1
for i in range(1, N):
    total = (total + Ai[i]) % M
    d[total] += 1
#-----------------
ans = 0
for k in d.keys():
    c = d[k]
    if c >= 1:
        ans += comb(c, 2)
print(ans)
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split())
Ci = [list(map(int, input().split())) for _ in range(D)]


MAX_BIT = (1 << D)
minimum = 1000000000
# 各ビットが1のとき全部解く
for patternBit in range(MAX_BIT):
    if patternBit >= MAX_BIT:
        continue
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            continue
        ans1 += add_count
    minimum = min(minimum, ans1)
    
print(minimum)

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
Ci = [list(map(int, input().split())) for _ in range(D)]


MAX_BIT = (1 << D)
# 各ビットが1のとき全部解く
def calc(patternBit):
    if patternBit >= MAX_BIT:
        return None
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        if use_c == None:
            return calc(patternBit + 1)
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            return calc(patternBit + 1)
        ans1 += add_count
    ans2 = calc(patternBit + 1)
    if ans2 != None:
        return min(ans1, ans2)
    return ans1
    
print(calc(0))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
Ci = [list(map(int, input().split())) for _ in range(D)]


MAX_BIT = (1 << D)
# 各ビットが1のとき全部解く
def calc(patternBit):
    if patternBit >= MAX_BIT:
        return None
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            return calc(patternBit + 1)
        ans1 += add_count
    ans2 = calc(patternBit + 1)
    if ans2 != None:
        return min(ans1, ans2)
    return ans1
    
print(calc(0))
Problem p03361 (python)

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

diff = [[-1, 0], [1, 0], [0, -1], [0, 1]]
def is_isolated(y, x):
    if Sij[y][x] != "#":
        return False
    for d in diff:
        y2 = y + d[0]
        x2 = x + d[1]
        if y2 >= 0 and y2 < H and x2 >= 0 and x2 < W:
            if Sij[y2][x2] == "#":
                return False
    return True

out = "Yes"
for y in range(H):
    for x in range(W):
        if is_isolated(y, x):
            out = "No"
            break
print(out)

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

diff = [[-1, 0], [1, 0], [0, -1], [0, 1]]
def is_isolated(y, x):
    if Sij[y][x] != "#":
        return False
    for d in diff:
        y2 = y + d[0]
        x2 = x + d[1]
        if y2 >= 0 and y2 < H and x2 >= 0 and x2 < W:
            if Sij[y2][x2] == "#":
                return False
    return True

out = "Yes"
for y in range(H):
    for x in range(W):
        if is_isolated(x, y):
            out = "No"
            break
print(out)
Problem p03362 (python)

Fixed submission:
N = int(input())

sosuu = []

def next_sosuu():
    if len(sosuu) == 0:
        sosuu.append(2)
        return 2
    if len(sosuu) == 1:
        sosuu.append(3)
        return 3
    curr = sosuu[-1] + 2

    while True:
        flag = True
        for s in sosuu:
            if curr % s == 0:
                flag = False
                break
        if flag:
            sosuu.append(curr)
            return curr
        curr += 2

results = []
while len(results) < N:
    n = next_sosuu()
    if n % 5 == 1:
        results.append(n)

txt = ""
for r in results:
    txt += str(r) + " "
txt = txt[0:-1]
print(txt)

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

out = [i * 2 for i in range(1, N + 1)]

print(*out, " ")
Problem p03436 (python)

Fixed submission:
H, W = map(int, input().split())
##計算の都合、 通路(.)を正の整数、壁(#)を-1に変換する
LARGE_VALUE = 100000
Mij = [[0] * W for _ in range(H)]
space_count = 0
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == ".":
            space_count += 1
            Mij[i][j] = LARGE_VALUE
        else:
            Mij[i][j] = -1

dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]]

queue = [[0, 0]]

def search():
    while len(queue):
        p = queue[0]
        del queue[0]
        i = p[0]
        j = p[1]
        step = Mij[i][j]

        for d in dirs:
            i2 = i + d[0]
            j2 = j + d[1]
            if 0 <= i2 < H and 0 <= j2 < W:
                if step + 1 < Mij[i2][j2]:
                    Mij[i2][j2] = step + 1
                    queue.append([i2, j2])

Mij[0][0] = 1
search()
total_steps = Mij[H - 1][W - 1]
if total_steps == LARGE_VALUE:
    print(-1)
else:
    print(space_count - total_steps)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
##計算の都合、 通路(.)を正の整数、壁(#)を-1に変換する
Mij = [[0] * W for _ in range(H)]
space_count = 0
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == ".":
            space_count += 1
            Mij[i][j] = 100000
        else:
            Mij[i][j] = -1

dirs = [[1, 0], [-1, 0], [0, 1], [0, -1]]

def search(i, j, step):
    if i == H - 1 and j == W - 1:
        return step

    best = None
    for d in dirs:
        i2 = i + d[0]
        j2 = j + d[1]
        if 0 <= i2 < H and 0 <= j2 < W:
            if step + 1 < Mij[i2][j2]:
                Mij[i2][j2] = step
                r = search(i2, j2, step + 1)
                if not r:
                    continue
                if not best or best > r:
                    best = r
    return best

total_steps = search(0, 0, 1)
if total_steps is None:
    print(-1)
else:
    print(space_count - total_steps)
Problem p03547 (python)

Fixed submission:
x,y = map(str,raw_input().split())
x = int(x,16)
y = int(y,16)
if x>y:
	print ">"
elif x<y:
	print "<"
else:
	print "="

Buggy submission (verdict: Runtime Error):
x,y = map(raw_input().split())
x = int(x,16)
y = int(y,16)
if x>y:
	print ">"
elif x<y:
	print "<"
else:
	print"="

Buggy submission (verdict: Runtime Error):
x,y = map(raw_input().split())
x = int(x,16)
y = int(y,16)
if x>y :
	print ">"
elif x<y :
	print "<"
else :
	print"="

Buggy submission (verdict: Runtime Error):
x,y = map(raw_input().split())
x = int(x,16)
y = int(y,16)
if x>y :
	print ">"
elif x<y :
	print "<"
else :
	print"="

Buggy submission (verdict: Runtime Error):
x,y = map(int(raw_input().split(),16))
if x>y :
	print ">"
elif x<y :
	print "<"
else :
	print "="