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

Fixed submission:
s = list(input())
odd = []
even = []
for i in range(len(s)):
  if i % 2 == 0:
    odd.append(s[i])
  else:
    even.append(s[i])
if "L" in odd or "R" in even:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
s = list(input())
odd = []
even = []
for i in range(len(s)):
  if i % 2 == 0:
    odd.aapend(s[i])
  else:
    even.append(s[i])
o = 0
e = 0
if "L" in odd:
  o = -1
if "R" in even:
  e = -1
if o * e == 0:
  print("Yes")
else:
  print("No")
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())
n = 1
e = a
if b == 1:
  print(0)
  quit()
while n > 0:
  if e >= b:
    print(n)
    n = 0
  else:
    e += a-1
    n += 1

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = 1
e = a
if b = 1:
  print(0)
  quit()
while n > 0:
  if e >= b:
    print(n)
    n = 0
  else:
    e += a-1
    n += 1
Problem p02934 (python)

Fixed submission:
n = int(input())
a_n = input().split(" ")
rev = float(0)
for i in range(n):
  rev += 1/int(a_n[i])
print(1/rev)

Buggy submission (verdict: Runtime Error):
n = input()
nums = input().split(" ")
rev = float(0)
for i in range(int(n)):
  rev += 1/nums[i]
print(1/rev)
Problem p02981 (python)

Fixed submission:
ns = input().split(" ")
if int(ns[0])*int(ns[1]) <= int(ns[2]):
  print(int(ns[0])*int(ns[1]))
else:
  print(int(ns[2]))

Buggy submission (verdict: Runtime Error):
ns = input().split(" ")
if int(ns[0])*int(ns[1]) <= int(ns[2]):
  print(int(ns[0])*int(ns[1]))
else:
  print(int(ns[2])
Problem p02988 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
m = 0
for i in range(n-2):
  if p[i] < p[i+1] < p[i+2] or p[i+2] < p[i+1] < p[i]:
    m += 1
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
pis = list(map(int, input().split()))
m = 0
for i in range(n-2):
  if p[i] < p[i+1] < p[i+2] or p[i+2] < p[i+1] < p[i]:
    m += 1
print(m)
Problem p02993 (python)

Fixed submission:
s = list(str(input()))
for i in range(3):
  if s[i] == s[i+1]:
    print("Bad")
    quit()
print("Good")

Buggy submission (verdict: Runtime Error):
import fractions
a, b, c, d = map(int, input().split())
ans = 0
nc = 1
nc2 = 0
nd = 1
nd2 = 0 
ndc = 1
ndc2 = 0
while b >= c*nc:
  nc2 += 1
  nc += 1
while b >= d*nd:
  nd += 1
  nd2 += 1
cd = c*d//fractions.gcd(c,d)
while b >= cd*ndc:
  ndc += 1
  ndc2 += 1
nc2 -= a//c
nd2 -= a//d
ndc2 -= a//(cd)
ans = b-a+1-nc2-nd2+ndc2
print(ans)
Problem p03308 (python)

Fixed submission:
n = int(input())
ais = list(map(int, input().split()))
ais_sort = sorted(ais)
print(ais_sort[n-1] - ais_sort[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
ais = list(map(int, input().split()))
a_mini = ais[0]
a_max = ais[0]
for i in rnage(1, n):
  if ais[i] < a_mini:
    a_mini = ais[i]
  if ais[i] > a_max:
    a_max = ais[i]
print(a_max - a_mini)
Problem p03434 (python)

Fixed submission:
n = int(input())
ais = input().split()
ais_int = [int(a) for a in ais]
ais_sort = ais_int.sort()
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(n):
    if i % 2 == 1:
      alice += int(ais_int[i])
    else:
      bob += int(ais_int[i])
else:
  for j in range(n):
    if j % 2 == 0:
      alice += int(ais_int[j])
    else:
      bob += int(ais_int[j])
print(alice - bob)

Buggy submission (verdict: Runtime Error):
n = int(input())
ais = input().split()
ais_sort = sort(ais)
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(n):
    if i % 2 == 1:
      alice += int(ais_sort[i])
    else:
      bob += int(ais_sort[i])
else:
  for j in range(n):
    if i % 2 == 0:
      alice += int(ais_sort[i])
    else:
      bob += int(ais_sort[i])
print(alice - bob)
Problem p03486 (python)

Fixed submission:
s = input()
t = input()
sl = list(s)
tl = list(t)
sl_asc = sorted(sl)
tl_desc = sorted(tl, reverse=True)
s2 = ''.join(sl_asc)
t2 = ''.join(tl_desc)
if s2 < t2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
m = 0
if len(ss) <= len(ts):
  m = len(ss)
  l = 0
  for j in range(m):
    if alph.index(ss[j]) < alph.index(ts[j]):
      print("Yes")
      break
    elif alph.index(ss[j]) == alph.index(ts[j]) :
      if j == m -1:
        print("Yes")
      else:
        pass
    else:
      print("No")
      break
elif len(ss) == len(ts):
  m = len(ss)
  l = 0
  for j in range(m):
    if alph.index(ss[j]) < alph.index(ts[j]):
      print("Yes")
      break
    elif alph.index(ss[j]) == alph.index(ts[j]) :
      if j == m -1:
        print("No")
      else:
        pass
    else:
      print("No")
      break
else:
  m = len(ts)
  l = 0
  for j in range(m):
    if alph.index(ss[j]) < alph.index(ts[j]):
      print("Yes")
      break
    elif alph.index(ss[j]) == alph.index(ts[j]) :
      if j == m - 1:
        print("No")
    else:
      print("No")
      break
Problem p03386 (python)

Fixed submission:
# https://atcoder.jp/contests/abc093/tasks/abc093_b
a, b, k = [int(x) for x in input().split()]
s = list(range(a, b + 1)[:k])
t = list(range(a, b + 1)[-k:])
for v in sorted(set(s + t)):
    print(v)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc093/tasks/abc093_b
a, b, k = [int(x) for x in input().split()]
r = list(range(a, b + 1))
for v in sorted(set(r[:k] + r[-k:])):
    print(v)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc093/tasks/abc093_b
a, b, k = [int(x) for x in input().split()]
r = list(range(a, b + 1))
for v in sorted(set(r[:k] + r[-k:])):
    print(v)
Problem p03469 (python)

Fixed submission:
s=input()
print(s.replace("2017","2018"))

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[int(input()) for _ in range(n)]
print(len(set(sorted(d))))
Problem p04043 (python)

Fixed submission:
a,b,c=[int(x) for x in input().split()]
print("YES") if sorted([a,b,c]) == [5,5,7] else print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=[int(x) for x in input().split()]
print("YES") if sorted([a,b,c]) == [5,5,7] else print("NO")
Problem p02843 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
Xs = input()
X = int(Xs)
if X < 100:
  print("0")
  exit()
X_ = int(Xs[-3:])
_X = int(Xs[0:-3])
if X_ == 0 or X_ == 1 or X_ == 2 or X_ == 3 or X_ == 4 or X_ == 5:
  print("1")
  exit()
count = 0
count += X_ // 5
X_ = X_ %  5
count += X_ //4
X_=X_%4
count += X_ //3
X_=X_%3
count += X_ //2
X_=X_%2
count += X_ //1
X_=X_%1
if _X - count >= 0:
  print("1")
else:
  print("0")
if em: sys.stdin = open('/dev/tty')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
Xs = input()
X = int(Xs)
X_ = int(Xs[-3:])
_X = int(Xs[0:-3])
if X < 100:
  print("0")
  exit()
if X_ == 0 or X_ == 1 or X_ == 2 or X_ == 3 or X_ == 4 or X_ == 5:
  print("1")
  exit()
count = 0
count += X_ // 5
X_ = X_ %  5
count += X_ //4
X_=X_%4
count += X_ //3
X_=X_%3
count += X_ //2
X_=X_%2
count += X_ //1
X_=X_%1
if _X - count >= 0:
  print("1")
else:
  print("0")
if em: sys.stdin = open('/dev/tty')
Problem p02882 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
a, b, x = map(int, input().split())
if a**2*b == x:
  print(0)
  exit()
import math
if 2*x <= a**2*b:
  t1 = a*b**2
  t2 = 2*x
  ans = math.degrees(math.atan(t1/t2))
else:
  t1 = a**3
  t2 = 2*a**2*b - 2*x
  ans = 90 - math.degrees(math.atan(t1/t2))
print(ans)
if em: sys.stdin = open('/dev/tty')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
a, b, x = map(int, input().split())
import math
if 2*x/b <= a:
  ans = math.degrees(math.atan(a*b**2/(2*x)))
else:
  ans = 90 - math.degrees(math.atan(a/(2*b - 2*x/(a**2))))
print(ans)
if em: sys.stdin = open('/dev/tty')
Problem p02910 (python)

Fixed submission:
step = input()

ng = ["L", "R"]

for i in range(0, len(step)):
  if step[i] == ng[i%2]:
    print("No")
    exit()
print("Yes")

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

ng = ["L", "R"]

for i in range(0, len(step)):
  if step[i] == ng[i%2]:
    return "No"
return "Yes"
Problem p02911 (python)

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

import sys
# from IPython import embed

N, K, Q = map(int, input().split(" "))

A = []
for i in range(0, Q):
  A.append(int(input()))

wins = [0] * N
for i in A:
  wins[i - 1] = wins[i - 1] + 1

# sys.stdin = open('/dev/tty')
# embed()

for i in range(0, N):
  score = K - Q + wins[i]
  if score > 0:
    print("Yes")
  else:
    print("No")

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

import sys
from IPython import embed

N, K, Q = map(int, input().split(" "))

A = []
for i in range(0, Q):
  A.append(int(input()))

wins = [0] * N
for i in A:
  wins[i - 1] = wins[i - 1] + 1

# sys.stdin = open('/dev/tty')
# embed()

for i in range(0, N):
  score = K - Q + wins[i]
  if score > 0:
    print("Yes")
  else:
    print("No")
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
# 遅延評価で加えてあげるだけ
 
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))
 
answer = ' '.join(map(str,value[1:]))
print(answer)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import cupy
import sys
from operator import itemgetter
# import math
# import numpy as np
# from functools import lru_cache

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

# sys.setrecursionlimit(10000)


input = sys.stdin.readline
#### input
N, Q = list(map(int, input().split()))
ABs = [None]*(N-1)
for i in range(0, N-1):
  ABs[i] = list(map(int, input().split()))

ABs.sort(key=itemgetter(0))

PXs = [None]*Q
for i in range(0, Q):
  PXs[i] = list(map(int, input().split()))
# a = list(map(int, input().split()))
# required_list = list(map(lambda x: int(x)*(-1), target_list))  # 各要素を-1倍


# n = int(input())
# t = [int(input()) for i in range(n)]
if em: sys.stdin = open('/dev/tty')
#### class
# class Node:
#   def __init__(self, data):
#     self.data = data
#     self.child= []
#     self.below = []

#### function
# @lru_cache(maxsize=10000)

#### process
scores = [0] * N
above_nodes  = [[x+1] for x in range(0, N)]

for AB in ABs:
  above_nodes[AB[1]-1].extend(above_nodes[AB[0]-1])

for PX in PXs:
  scores[PX[0]-1] = scores[PX[0]-1] + PX[1]

node_scores = [None] * N
for i in range(0, N):
  node_score = 0
  for above_node in above_nodes[i]:
    node_score = node_score + scores[above_node-1]
  node_scores[i] = node_score
print(' '.join(map(str, node_scores)))

# if em: embed()
## heapsort, O(NlogN)
# import heapq
# As = [0,1,2,3]
# heapq.heapify(As)
# min = heapq.heappop(As)
# heapq.heappush(As, inserted_element)
Problem p03160 (python)

Fixed submission:
import sys
# import pdb
input = sys.stdin.readline

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

cost1 = 0
cost2 = abs(hs[1] - hs[0])

if N == 2:
  print(cost2)
  exit()
# pdb.set_trace()
for i in range(2, N):
  cost3 = min(cost2 + abs(hs[i] - hs[i-1]), cost1 + abs(hs[i] - hs[i-2]))
  cost1 = cost2
  cost2 = cost3

print(cost3)

Buggy submission (verdict: Runtime Error):
import sys
# import pdb
input = sys.stdin.readline

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

dp_list = [-1 for _ in range(N)]
dp_list[0] = 0
dp_list[1] = abs(hs[1] - hs[0])

sys.setrecursionlimit(10000)
def dp_memo(p):
  if dp_list[p] != -1:
    return dp_list[p]

  result = min(dp_memo(p-1) + abs(hs[p] - hs[p-1]), dp_memo(p-2) + abs(hs[p] - hs[p-2]))
  dp_list[p] = result
  return result


def dp_recur():
  cost1 = 0
  cost2 = abs(hs[1] - hs[0])

  if N == 2:
    print(cost2)
    exit()
  # pdb.set_trace()
  for i in range(2, N):
    cost3 = min(cost2 + abs(hs[i] - hs[i-1]), cost1 + abs(hs[i] - hs[i-2]))
    cost1 = cost2
    cost2 = cost3
  return cost3

# print(dp_recur())
print(dp_memo(N-1))

Buggy submission (verdict: Runtime Error):
import sys
# import pdb
input = sys.stdin.readline

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

dp_list = [-1 for _ in range(N)]
dp_list[0] = 0
dp_list[1] = abs(hs[1] - hs[0])

def dp_memo(p):
  if dp_list[p] != -1:
    return dp_list[p]

  result = min(dp_memo(p-1) + abs(hs[p] - hs[p-1]), dp_memo(p-2) + abs(hs[p] - hs[p-2]))
  dp_list[p] = result
  return result


def dp_recur():
  cost1 = 0
  cost2 = abs(hs[1] - hs[0])

  if N == 2:
    print(cost2)
    exit()
  # pdb.set_trace()
  for i in range(2, N):
    cost3 = min(cost2 + abs(hs[i] - hs[i-1]), cost1 + abs(hs[i] - hs[i-2]))
    cost1 = cost2
    cost2 = cost3
  return cost3

# print(dp_recur())
print(dp_memo(N-1))

Buggy submission (verdict: Runtime Error):
import sys
# import pdb
input = sys.stdin.readline

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

dp_list = [-1 for _ in range(N)]

def dp_memo(p):
  if dp_list[p] != -1:
    return dp_list[p]

  if p == 0:
    return 0

  if p == 1:
    return abs(hs[1] - hs[0])

  result = min(dp_memo(p-1) + abs(hs[p] - hs[p-1]), dp_memo(p-2) + abs(hs[p] - hs[p-2]))
  dp_list[p] = result
  return result


def dp_recur():
  cost1 = 0
  cost2 = abs(hs[1] - hs[0])

  if N == 2:
    print(cost2)
    exit()
  # pdb.set_trace()
  for i in range(2, N):
    cost3 = min(cost2 + abs(hs[i] - hs[i-1]), cost1 + abs(hs[i] - hs[i-2]))
    cost1 = cost2
    cost2 = cost3
  return cost3

# print(dp_recur())
print(dp_memo(N-1))
Problem p03163 (python)

Fixed submission:
import sys
import pdb
input = sys.stdin.readline

N, W = map(int, input().split())
ws = []
vs = []
for _ in range(N):
  w, v = map(int, input().split())
  ws.append(w)
  vs.append(v)

inf = 1e10

# Value[i番目までの品番][重さj以下]
Value = [[-inf for _ in range(W+1)] for __ in range(N)]

for load in range(W+1):
  if load < ws[0]:
    # 1番目の品物を入れようがなければスキップ
    Value[0][load] = 0
  else:
    Value[0][load] = vs[0]

for num in range(1, N):
  for load in range(W+1):
    if load >= ws[num]:
      # pdb.set_trace()
      # print(num, load, ws[num], vs[num])
      Value[num][load] = max(Value[num][load], Value[num-1][load], Value[num-1][load-ws[num]] + vs[num])
    else:
      Value[num][load] = max(Value[num][load], Value[num-1][load])

print(Value[N-1][W])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
W = []
V = []

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

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

for i in range(W+1):
  if i >= W[0]
  Ans[0][i] = V[0]

for i in range(1, N):
  for w in range(W+1):
    if w - W[i] >= 0:
      Ans[i][w] = max(Ans[i-1][w-W[i]], Ans[i-1][w], Ans[i][w])
    else:
      Ans[i][w] = max(Ans[i-1][w], Ans[i][w])

print(max(Ans[N-1]))

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
W = []
V = []

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

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

for i in range(W+1):
  if i >= W[0]
  Ans[0][i] = V[0]

for i in range(1, N):
  for w in range(W+1):
    Ans[i][w] = max(Ans[i-1][w-W[i]], Ans[i-1][w])

print(max(Ans[N-1]))
Problem p03164 (python)

Fixed submission:
import sys
import pdb
input = sys.stdin.readline

N, W = map(int, input().split())
ws = [0]
vs = [0]

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

inf = 2e11
V = int(sum(vs))   # N * max(vs)
# V = int(100 * 1e3)   # N * max(vs)
# Weight[i番目までの品番][価値j]
Weight = [[inf for _ in range(V+1)] for __ in range(N+1)]

if ws[1] <= W:
  Weight[1][vs[1]] = ws[1]
  value_max = vs[1]
else:
  value_max = 0

for _ in range(N+1):
  Weight[_][0] = 0

# pdb.set_trace()

for num in range(2, N+1):
  for value in range(1, V+1):
    if value >= vs[num]:   # 新しい品物を入れられるとき
      Weight[num][value] = min(Weight[num][value], Weight[num-1][value], Weight[num-1][value-vs[num]] + ws[num])
      if Weight[num][value] <= W:
        value_max = max(value_max, value)
      else:
        Weight[num][value] = inf
    else:   # 新しい品物を入れられないとき
      # 重さを変えることはできない
      Weight[num][value] = Weight[num-1][value]
      # Weight[num][value] = max(Weight[num][value], Weight[num-1][value])

# print(Weight)
print(value_max)

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

Ws = []
Vs = []

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

Ans = [[0 for _ in range(N * max(Vs))+1] for _ in range(N)]

Ans[0][Vs[0]] = Ws[0]

for i in range(1, N):
  for v in range(N*max(Vs)+1):
    if v-Vs[i] >= 0:
      Ans[i][v] = max(Ans[i-1][v-Vs[i]] + Ws[i], Ans[i-1][v], Ans[i][v])
    else:
      Ans[i][v] = max(Ans[i-1][v], Ans[i][v])

AnsW = Ans[N-1]
AnsW.sorted()
for i in range(len(AnsW)-1):
  if AnsW[i+1] > W:
    print(AnsW[i])
    break

Buggy submission (verdict: Runtime Error):
import sys
import pdb
input = sys.stdin.readline

N, W = map(int, input().split())
ws = [0]
vs = [0]

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

inf = 2e11
V = int(sum(vs))   # N * max(vs)
# V = int(100 * 1e3)   # N * max(vs)
# Weight[i番目までの品番][価値j]
Weight = [[inf for _ in range(V+1)] for __ in range(N+1)]

if ws[1] <= W:
  Weight[1][vs[1]] = ws[1]
  value_max = vs[1]
else:
  value_max = 0

for _ in range(N+1):
  Weight[_][0] = 0

pdb.set_trace()

for num in range(2, N+1):
  for value in range(1, V+1):
    if value >= vs[num]:   # 新しい品物を入れられるとき
      Weight[num][value] = min(Weight[num][value], Weight[num-1][value], Weight[num-1][value-vs[num]] + ws[num])
      if Weight[num][value] <= W:
        value_max = max(value_max, value)
      else:
        Weight[num][value] = inf
    else:   # 新しい品物を入れられないとき
      # 重さを変えることはできない
      Weight[num][value] = Weight[num-1][value]
      # Weight[num][value] = max(Weight[num][value], Weight[num-1][value])

# print(Weight)
print(value_max)
Problem p03167 (python)

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

As = []
for _ in range(H):
  As.append(input())
paths = [[0 for _ in range(W)] for _ in range(H)]

paths[0][0] = 1

mod = 1e+9 + 7

for width in range(W):
  for height in range(H):
    if As[height][width] == "#":
      # 壁のマスであればスキップする
      continue
    if height < H-1:
      if As[height + 1][width] == ".":
        # 次のマスが通行可能であれば、これまでの経路を加える
        paths[height + 1][width] = int((paths[height + 1][width] + paths[height][width]) % mod)
    if width < W-1:
      if As[height][width + 1] == ".":
        # 次のマスが通行可能であれば、これまでの経路を加える
        paths[height][width + 1] = int((paths[height][width + 1] + paths[height][width]) % mod)

print(paths[H-1][W-1])

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

As = []
for _ in range(H):
  As.append(input())
paths = [[0 for _ in range(W)] for _ in range(H)]

paths[0][0] = 1

mod = 1e+9 + 7

for width in range(W):
  for height in range(H):
    if As[height][width] == "#":
      # 壁のマスであればスキップする
      continue
    if height < H-1:
      if As[height + 1][width] == ".":
        # 次のマスが通行可能であれば、これまでの経路を加える
        paths[height + 1][width] += paths[height][width]
    if width < W-1:
      if As[height][width + 1] == ".":
        # 次のマスが通行可能であれば、これまでの経路を加える
        paths[height][width + 1] += paths[height][width]

print(int(paths[H-1][W-1] % mod))
Problem p03168 (python)

Fixed submission:
# input
N = int(input())
Ps = list(map(float, input().split()))

# probs[i][k] : コインiまでを投げて表がk枚出る確率
probs = [[0 for _ in range(N+1)] for _ in range(N)]

probs[0][1] = Ps[0]
probs[0][0] = 1 - Ps[0]
# for i in range(2, N+1):
#   probs[0][i] = 0

for i in range(1, N):
  for k in range(0, N+1):
    if k == 0:
      probs[i][k] = probs[i-1][k]*(1-Ps[i])
    else:
      probs[i][k] = probs[i-1][k-1]*Ps[i] + probs[i-1][k]*(1-Ps[i])

# print(probs)

sum_all = sum(probs[N-1])
sum_ok = 0

start = int(N/2) + 1
for i in range(start, N+1):
  sum_ok += probs[N-1][i]

print(sum_ok / sum_all)

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

# probs[i][k] : コインiまでを投げて表がk枚出る確率
probs = [[None for _ in range(N+1)] for _ in range(N)]

probs[0][1] = Ps[0]
probs[0][0] = 1 - Ps[0]
for i in range(2, N+1):
  probs[0][i] = 0

sum_all = 0
sum_ok  = 0
start = int(N/2) + 1

for i in range(1, N):
  for k in range(0, N+1):
    if k == 0:
      probs[i][k] = probs[i-1][k]*(1-Ps[i])
    else:
      probs[i][k] = probs[i-1][k-1]*Ps[i] + probs[i-1][k]*(1-Ps[i])
    if i == N - 1:
      sum_all += probs[i][k]
      if k >= start:
        sum_ok += probs[i][k]


# print(probs)

# sum_all = sum(probs[N-1])
# sum_ok = 0

# start = int(N/2) + 1
# for i in range(start, N+1):
#   sum_ok += probs[N-1][i]

print(sum_ok / sum_all)
Problem p02837 (python)

Fixed submission:
n = int(input())
 
g = [[-1 for j in range(n)] for i in range(n)]
 
for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y
 
ans = 0
for s in range(2**n):
    ok = True
    for i in range(n):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1: continue
                if (s>>j&1) != g[i][j]: ok = False
    if ok:#あっているなら、ビット内に何個1があるかを数える
        #print("s = ", s)
        t = 0
        x = s#xを変えてもsは変化しない
        t = str(bin(x)).count("1")
        ans = max(ans, t)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    for _ in range(int(input())):
        x,y = map(int,input().split())
        g[i][x-1] = y

ans = 0
for s in range(2**n):#bit全探索
    ok = True
    for i in range(n):#行ごとのfor
        if (s>>i&1) == 1:#iが正直者であったら
            for j in range(n):#列の要素のfor,iの言っていることが矛盾がないか確かめる
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False#breakにしないのは、breakでは抜けきれないから
    if ok:
        t = str(bin(x)).count("1")
        ans = max(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
    for _ in range(int(input())):
        x,y = map(int,input().split())
        q[i][x-1] = y

ans = 0
for s in range(2**n):
    ok = True
    for i in range(n):
        if (s>>i&1) == 1:
            for j in range(n):
                if g[i][j] == -1:continue
                if (s>>j&1) != g[i][j]:ok = False
    if ok:
        t = str(bin(x)).count("1")
        ans = max(ans,t)
print(ans)
Problem p02885 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        a,b = L[i],L[j]
        cnt += sum(abs(a-b)< l < a+b for l in L if l != a and l != b)
print(cnt//3)