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

Fixed submission:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))-1
print(a.sum())

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    x,y = max(x,y),min(x,y)
    while(y>0):
        x,y = y,x%y
    return(x)
    
def lcm(a,b):
    return(int(a*b/gcd(a,b)))

n = int(input())
a = list(map(int,input().split()))
least_common_multiple = 1
for i in range(n):
    least_common_multiple = lcm(least_common_multiple,a[i])
ans = 0
for i in range(n):
    ans += (least_common_multiple-1)%a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    x,y = max(x,y),min(x,y)
    while(y>0):
        x,y = y,x%y
    print(x)
def lcm(a,b):
    return(int(a*b/gcd(a,b)))

n = int(input())
a = list(map(int,input().split()))
least_common_multiple = 1
for i in range(n):
    least_common_multiple = lcm(least_common_multiple,a[i])
ans = 0
for i in range(n):
    ans += (least_common_multiple-1)%a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
least_common_multiple = 1
for i in range(n):
    least_common_multiple = int(least_common_multiple*a[i]/math.gcd(least_common_multiple,a[i]))
ans = 0
for i in range(n):
    ans += (least_common_multiple-1)%a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return(int(a*b/math.gcd(a,b)))

n = int(input())
a = list(map(int,input().split()))
least_common_multiple = 1
for i in range(n):
    least_common_multiple = lcm(least_common_multiple,a[i])
ans = 0
for i in range(n):
    ans += (least_common_multiple-1)%a[i]
print(ans)
Problem p03304 (python)

Fixed submission:
n, m, d = map(int,input().split())
pnt = 0.
if d==0:
    pnt = (1./n)*(m-1)
else:
    a = max(n-2*d,0)
    pnt = ((a*2 +(n-a))/n**2)*(m-1)
print(pnt)

Buggy submission (verdict: Runtime Error):
n, m, d = map(int,input().split())
pnt = 0.
if d==0:
    pnt = max(n*(m-2),1)/n**2
else:
    a = max(n-2*d,0)
    pnt = ((a*2 +(n-a))**(m-1))*max(n*(m-2),1)
    for i in range(m):
        pnt /= n
print(pnt)
Problem p03399 (python)

Fixed submission:
a =[]
for i in range(4):
 a.append(int(input()))
print((min(a[0],a[1])+min(a[2],a[3])))

Buggy submission (verdict: Runtime Error):
a =[]
for i in range(4):
 a[i] = int(input())
print((min(a[0],a[1])+min(a[2],a[3])))
Problem p03712 (python)

Fixed submission:

H, W = [int(n) for n in input().split()]
image = []
for i in range(H):
    image.append(input())

print("#"*(W+2))
for i in range(H):
    print("#"+image[i]+"#")
print("#"*(W+2))

Buggy submission (verdict: Runtime Error):
H, W = [int(n) for n in input().split()]
for i in range(H):
    image = []
    image.append(input())

print("#"*(W+2))
for i in range(H):
    print("#"+image[i]+"#")
print("#"*(W+2))

Buggy submission (verdict: Runtime Error):
H, W = [int(n) for n in input().split()]
for i in range(H):
    image = []
    image.append(input())

print("#"*(W+2))
for i in range(H):
    print("#"+image(i)+"#")
print("#"*(W+2))
Problem p03854 (python)

Fixed submission:

S = input()
S = S[::-1]

pattern = ['maerd', 'remaerd', 'esare', 'resare']

pos = 0
possible = True

while pos < len(S):
    no_match = True
    for candidate in pattern:
        if S[pos : pos + len(candidate)] == candidate:
            pos += len(candidate)
            no_match = False
            break

    if no_match:
        possible = False
        break

if possible:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):

pattern = ["maerd", "remaerd", "esare", "resare"]

def rec(s):
    if (len(s) == 0):
        return True

    for candidate in pattern:
        if s[:len(candidate)] == candidate:
            rec(s[len(candidate):])
            return True

    return False

def main():
    S = input()
    S = S[::-1]

    if rec(S):
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()
Problem p02576 (python)

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

print(math.ceil(N / X)*T)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) 
s = [0]*(N-1)
 
for n in range(N-1):
  s[n] = A[n] - A[n+1]
  if s[n] <= 0: 
    continue
  else:
    A[n+1] += s[n]

print(sum(int(s)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) 
ans = 0
 
for n in range(N-1):
  t = A[n] - A[n+1]
  if t <= 0: 
    continue
  else:
    A[n+1] += t
    ans += t
 
print(ans)
Problem p02582 (python)

Fixed submission:
S = input()
 
ans = 0
if S == 'RRR': ans = 3
else:
  if ('RR' in S): ans = 2
  else:
    if('R' in S): ans = 1
    else: ans = 0
 
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
 
# 高々2^3=8通りなので、全て列挙すればよい
# RRR RRS SRR RSR RSS SRS SSR SSS
ans = 0
if S == 'RRR': ans = 3
elif S == 'SRR' and S == 'RRS': ans = 2
elif S == 'SSS': ans = 0
else: ans = 1
  
print(ans)

RSR SSR SRS RSS

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
 
ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if(L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and abs(L[j]-L[k]) < L[i] and L[i] < L[j]+L[k]):
          ans +=1
          
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
 
ans = 0
if(N >= 3):
  t = []
  for i in range(N):
    for j in range(i+1, N):
      for k in range(j+1, N):
        if((abs(L[j]-L[k]) < L[i]) & (L[i] < L[j]+L[k])): t.append((L[i], L[j], L[k]))
  ans = len(set(t))

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
 
ans = 0
if S == 'RRR': ans = 3
else:
  if ('RR' in S) ans = 2
  else:
    if('R' in S) ans = 1
    else: ans = 0

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
 
ans = 0
if S ='RRR': ans = 3
else:
  if ('RR' in S) ans = 2
  else:
    if('R' in S) ans = 1
    else: ans = 0

print(ans)

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

ans = 0
if S ='RRR': ans = 3
else:
  if ('RR' in S) ans = 2
  else:
    if('R' in S) ans = 1
    else: ans = 0
    
print(ans)
Problem p02583 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
 
ans = 0
if(N >= 3):
  t = []
  for i in range(N):
    for j in range(i+1, N):
      for k in range(j+1, N):
        if((L[i] != L[j]) & (L[i] != L[k]) & (L[j] != L[k]) & (abs(L[j]-L[k]) < L[i]) & (L[i] < L[j]+L[k])): t.append((L[i], L[j], L[k]))
  ans = len(t)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
 
ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if(L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and abs(L[j]-L[k]) < L[i] and L[i] < L[j]+L[k]): t.append((L[i], L[j], L[k])):
          ans +=1
          
print(ans)

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

ans = 0
t = []
if(N >= 3):
  for i in range(N):
    for j in range(N):
      for k in range(N):
        if((abs(j-k) < a) && (a < j+k)): t.append([i, j, k])

t = list(set(t))
print(len(t))
Problem p02613 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
 
ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == 'AC': ac += 1
  elif s == 'WA': wa += 1
  elif s == 'TLE': tle += 1
  elif s == 'RE': re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
 
ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == 'AC': ac += 1
  elif s == 'WA': wa += 1
  elif s == 'TLE': tle += 1
  elif s == 'RE': re += 1

print('AC x ' + ac)
print('WA x ' + wa)
print('TLE x ' + tle)
print('RE x ' + re)

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

ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == 'AC': ac += 1
  elif s == 'WA': wa += 1
  elif s == 'TLE': tle += 1
  elif s == 'RE'; re += 1

print('AC x ' + ac)
print('WA x ' + wa)
print('TLE x ' + tle)
print('RE x ' + re)
Problem p02658 (python)

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

ans = 0
if 0 not in A:
  ans = 1
  for i in range(N):
    ans *= A[i]
    if ans > 10**18:
      ans = '-1'
      break

print(ans)

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

ans = 1
for i in range(N):
  ans *= A[i]

if ans > 10**18: ans = '-1'
print(ans)
Problem p02677 (python)

Fixed submission:
import math
A, B, H, M = map(int, input().split())
 
X, Y = A*math.cos(math.pi*(60*H+M)/360), -A*math.sin(math.pi*(60*H+M)/360)
x, y = B*math.cos(math.pi*M/30), -B*math.sin(math.pi*M/30)
 
print(math.sqrt((X-x)**2+(Y-y)**2))

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

X, Y = A*math.cos(math.pi*(60*H+M)/360), -A*math.sin(math.pi*(60*H+M)/360)
x, y = B*math.cos(math.pi*M/30), -B*math.sin(math.pi*M/30)

print(math.sqrt((X-x)**2+(Y-y)**2))
Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split())
C = [(list(map(int, input().split()))) for _ in range(N)]

# bit全探索を行い、参考書に関する全ての組みについて、値段と理解度を求める
val = []
for i in range(2**N):
  U = [0]*(M+1)
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        U[k] += C[j][k]
  
  # ある組みが条件を満たすなら、その値段をvalに追加
  if sum([u >= X for u in U[1:]]) == M:
    val.append(U[0])

# 条件を満たす組みの中で、値段が最小のものを出力し、組みが無ければ-1を出力する
ans = 0
if len(val) == 0: ans = -1
else: ans = min(val)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
C = [(list(map(int, input().split()))) for _ in range(N)]
 
# bit全探索を行い、参考書に関する全ての組みについて、値段と理解度を求める
ans = 10**10
for i in range(2**N):
  U = [0]*(M+1)
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        U[k] += C[j][k]
  
  # ある組みが条件を満たすなら、その値段をvalに追加
  if sum([u >= X for u in U[1:]]) == M:
    ans = min(ans, U[0])

if ans = 10**10: print(-1)
else: print(ans)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
C = [(list(map(int, input().split()))) for _ in range(N)]
 
# bit全探索を行い、参考書に関する全ての組みについて、値段と理解度を求める
ans = 10**10
for i in range(2**N):
  U = [0]*(M+1)
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        U[k] += C[j][k]
  
  # ある組みが条件を満たすなら、その値段をvalに追加
  if sum([u >= X for u in U[1:]]) == M:
    ans = min(ans, M[0])

if ans == 10**10: print(-1)
else: print(ans)
Problem p02687 (python)

Fixed submission:
S = input()
if S == 'ABC': print('ARC')
elif S == 'ARC': print('ABC')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(M)]
 
ans = 0
for i in range(1, N+1):
  # ノードi(=1,...,N)と結合しているノードを全て求め、connectに格納
  connect = []
  for j in range(M):
    if i in l[j]:
      if i == l[j][0]: connect.append(l[j][1])
      else: connect.append(l[j][0])
  
  # ノードiの標高が、結合している任意のノードの標高より高いなら ans += 1
  n = 0
  for c in connect:
    if H[i-1] > H[c-1]: n += 1
  if n == len(connect): ans += 1

print(ans)
Problem p02705 (python)

Fixed submission:
import math
R = int(input())
 
print(2*math.pi*R)

Buggy submission (verdict: Runtime Error):
import math
R = int(input)

print(2*math.pi*R)
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split()) 
A = list(map(int, input().split()))
 
# N-sum(A)が残り日数である
s = sum(A)
ans = -1
if N >= s: ans = N - s
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split()) 
A = [int(input()) for _ in range(M)]

s = sum(A)
ans = -1
if N >= s: ans = N - s
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().spit())
A = [input() for _ in range(M)]

s = sum(A)
ans = -1
if N >= s: ans = N - s
print(ans)
Problem p02717 (python)

Fixed submission:
X, Y, Z = input().split()
print(Z + ' ' + X + ' ' + Y)

Buggy submission (verdict: Runtime Error):
X, Y, Z = map(int, input().split())
print(Z X Y)
Problem p02718 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
s = sum(A)
A = sorted(A, reverse=True)
ans = 'Yes'
for i in range(M):
  if A[i]*(4*M) < s: 
    ans = 'No'
    break

print(ans)

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

s = sum(A)
A = sorted(A)
ans = 'Yes'
for i in M:
  if A[i] < s/(4*M): 
    ans = 'No'
    break
    
print(ans)
Problem p02760 (python)

Fixed submission:
A = []
A += input().split()
A += input().split()
A += input().split()
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  if b[i] in A:
    A[A.index(b[i])] = '.'
    
if (A[0] == '.' and A[3] == '.' and A[6] == '.') or (A[1] == '.' and A[4] == '.' and A[7] == '.') or (A[2] == '.' and A[5] == '.' and A[8] == '.') or (A[0] == '.' and A[1] == '.' and A[2] == '.') or (A[3] == '.' and A[4] == '.' and A[5] == '.') or (A[6] == '.' and A[7] == '.' and A[8] == '.') or (A[0] == '.' and A[4] == '.' and A[8] == '.') or (A[2] == '.' and A[4] == '.' and A[6] == '.'): print('Yes')
else: print('No')

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

# 2次元配列として処理
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True
    
if (A[0][0] and A[1][0] and A[2][0]) or (A[0][1] and A[1][1] and A[2][1]) or (A[0][2] and A[1][2] and A[2][2]) or (A[0][0] and A[0][1] and A[0][2]) or (A[1][0] and A[1][1] and A[1][2]) or (A[2][0] and A[2][1] and A[2][2]) or (A[0][0] and A[1][1] and A[2][2]) or (A[0][2] and A[1][1] and A[2][0]): print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
A = []
A.append(input().split())
A.append(input().split())
A.append(input().split())
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True
    
if (A[0] and A[3] and A[6]) or (A[1] and A[4] and A[7]) or (A[2] and A[5] and A[8]) or (A[0] and A[1] and A[2]) or (A[3] and A[4] and A[5]) or (A[6] and A[7] and A[8]) or (A[0] and A[4] and A[8]) or (A[2] and A[4] and A[6]): print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
A = []
A.append(input().split())
A.append(input().split())
A.append(input().split())
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True
    
if (A[0] and A[3] and A[6]) or (A[1] and A[4] and A[7]) or (A[2] and A[5] and A[8]) or (A[0] and A[1] and A[2]) or (A[3] and A[4] and A[5]) or (A[6] and A[7] and A[8]) or (A[0] and A[4] and A[8]) or (A[2] and A[4] and A[6]): print('Yes')

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

for i in range(N):
  if b[i] in A:
    A[A.index(b[i])] = '.'
    
if (A[0] == '.' and A[3] == '.' and A[6] == '.') or (A[1] == '.' and A[4] == '.' and A[7] == '.')
or (A[2] == '.' and A[5] == '.' and A[8] == '.') or (A[0] == '.' and A[1] == '.' and A[2] == '.')
or (A[3] == '.' and A[4] == '.' and A[5] == '.') or (A[6] == '.' and A[7] == '.' and A[8] == '.')
or (A[0] == '.' and A[4] == '.' and A[8] == '.') or (A[2] == '.' and A[4] == '.' and A[6] == '.'):
  print('Yes')
else: print('No')
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
s_c = [list(map(int, input().split())) for _ in range(M)]

if N == 1:
  a, b = 0, 10**N
elif N >= 2:
  a, b = 10**(N-1), 10**N

ans = '-1'
for i in range(a, b):
  flag = True
  for j in range(M):
    if str(i)[s_c[j][0]-1] != str(s_c[j][1]):
      flag = False
  if flag:
    ans = i
    break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
s_c = [list(map(int, input().split())) for _ in range(M)]
 
if N == 1:
  a, b = 0, 10**N
elif N >= 2:
  a, b = 10**(N-1), 10**N
 
ans = '-1'
for i in range(a, b):
  flag = True
  for j in range(M):
    if str(i)[s_c[j][0]-1] != str(s_c[j][1]):
      flag = False
  if flag:
    ans = i
    break
 
print(ans)



n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(m)]
if n==1:
  for i in range(10):
    tmp=str(i)
    flag=True
    for j in range(m):
      if tmp[arr[j][0]-1]!=str(arr[j][1]):
        flag=False
    if flag==True:
      print(i)
      break
  else:
    print(-1)
else:
  for i in range(10**(n-1),10**n):
    tmp=str(i)
    flag=True
    for j in range(m):
      if tmp[arr[j][0]-1]!=str(arr[j][1]):
        flag=False
    if flag==True:
      print(i)
      break
  else:
    print(-1)
Problem p02765 (python)

Fixed submission:
N, R = map(int, input().split())
 
if N >= 10: print(R)
else: print(R + 100*(10-N))

Buggy submission (verdict: Runtime Error):
N, R = map(int, input().split())
 
if N >= 10: print(K)
else: print(100*(10-K))

Buggy submission (verdict: Runtime Error):
N, R = map(int, input().split()))
 
if N >= 10: print(K)
else: print(100*(10-K))

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

if N >= 10: print(K)
else: print(100*(10-K))
Problem p02767 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
 
ans = 10000000000
for i in range(100):
  s = 0
  for j in range(N):
    s += (X[j]-i)**2
    
  ans = min(ans, s)
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = map(int, input().split())
 
ans = 10000000000
for i in range(100):
  s = 0
  for j in range(N):
    s += (X[j]-i)**2
    
  ans = min(ans, s)
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = map(int, input().split())
 
ans = 100000
for i in range(100):
  s = 0
  for j in range(N):
    s += (X[j]-i)**2
    
  ans = min(ans, s)
  
print(ans)

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

ans = 100000
for i in range(100):
  s = 0
  for j in range(N):
    s += (X[i]-i)**2
    
  ans = min(ans, s)
  
print(ans)
Problem p02772 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
ans = 'APPROVED'
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      ans = 'DENIED'
      break
      
print(ans)

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

ans = 'APPROVED'
for i in range(N):
  if N[i] % 2 == 0:
    if N[i] % 3 != 0 or N[i] % 5 != 0:
      ans = 'DENIED'
      break
      
print(ans)
Problem p02786 (python)

Fixed submission:
H = int(input())
 
# 体力がHのモンスター1体に勝つために必要な攻撃回数をf(H)とする
# すると、f(H)は以下の漸化式に従って求まる
# f(H)=2*f(floor(H/2)+1) (H>1)
# f(H)=1 (H=1)
 
def attack_num(x):
  if x == 1: return 1
  else: return 2*attack_num(x // 2) + 1
  
print(attack_num(H))

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

# 体力がHのモンスター1体に勝つために必要な攻撃回数をf(H)とする
# すると、f(H)は以下の漸化式に従って求まる
# f(H)=2*f(floor(H/2)+1) (H>1)
# f(H)=1 (H=1)

def attack_num(x):
  if x == 1: return 1
  else: return 2*f(x // 2) + 1
  
print(attack_num(H))
Problem p02910 (python)

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

# 1,3,...文字目が'R'でも'U'でも'D'でもない、または、2,4,...文字目が'L'でも'U'でも'D'でもないとき、'No'を出力する
ans = 'Yes'
for i in range(N):
  if (i % 2 == 0 and S[i] != 'R' and S[i] != 'U' and S[i] != 'D') or (i % 2 == 1 and S[i] != 'L' and S[i] != 'U' and S[i] != 'D'):
    ans = 'No'
    break
    
print(ans)

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

N = len(S)
# Sの各文字は'L', 'R', 'U', 'D'のいずれかであることに注意する
# 1,3,...文字目が'L'でなく、偶数文字目が'R'でないとき 'Yes'とする
for i in range(N):
  if (i % 2 == 0 and S[i] == 'L') or (i % 2 == 1 and S[i] == 'R'):
    ans = 'No'
    break
    
print(ans)
Problem p02922 (python)

Fixed submission:
import math
A, B = map(int, input().split())
 
# A*x-(x-1) >= B
# (A-1)*x >= B-1
# x >= ceil((B-1)/(A-1))
print(math.ceil((B-1)/(A-1)))

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

# 電源タップの個数をa, 差込口の個数をnumとおく 
a = 0
num = 1
while num < B:
  num -= 1
  num += a
  ans += 1

print(a)
Problem p02923 (python)

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

a = 0
ans = 0
for i in range(N-1):
  if H[i] >= H[i+1]: a += 1
  else: 
    a = 0
  ans = max(ans, a)
print(ans)

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

a = 0
l = [0]*(N-1)
for i in range(N-1):
  if H[i] >= H[i+1]: a += 1
  else: a = 0
  l[i] = a

print(max(l))
Problem p02947 (python)

Fixed submission:
from collections import Counter 
N = int(input())
s = [input() for _ in range(N)]
 
# N=10^5より、O(N)で解く
for i in range(N):
  s[i] = sorted(s[i])
  s[i] = ''.join(s[i])

s = Counter(s).most_common()
ans = 0
for t in s:
  ans += t[1]*(t[1]-1)//2
  
print(ans)

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

for i in range(N):
  s[i] = list(set(s[i]))
  
print(len(set(s)))
Problem p02953 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
 
# 左から順にやるとうまくいかない => [1, 4, 3, 2, 1] みたいな場で失敗
# 右から順に考えよ！
ans = 'Yes'
for i in range(N-1, 0, -1):
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
 
ans = 'Yes'
for i in range(N-1, 0, -1):
  if A[i] > A[i-1]: A[i-1] -= 1
    if A[i] > A[i-1]:
      ans = 'No'
      break

print(ans)
Problem p02957 (python)

Fixed submission:
A, B = map(int, input().split())
 
if (A+B) %2 == 0: print((A+B) // 2)
else: print('IMPOSSIBLE')

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

if (A+B) %2 == 0: print((A+B) // 2)
else: print('IMPOSSIBLE')
Problem p02971 (python)

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

M = max(A)
M_index = A.index(M)
sub_M = 0
for i in range(N):
  if i != M_index: sub_M = max(sub_M, A[i])

for i in range(N):
  if i == M_index: print(sub_M)
  else: print(M)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
 
# 前から最適に配置せよ
# 一人目は, 1,...,D, D+1, D+2,...,2D+1 を監視
# 二人目は, 2D+2,..., 3D+2, ...,4D+2 を監視
# x人まで繰り返すと、1,...,x(2D+1)まで監視できる
 
# x(2D+1) > N を満たす最小のxは？
# x_min = ceil(N/(2D+1))
 
# ceil(B/A) = floor((A+B-1)/A)
print((N+2*D) // (2*D+1))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]
 
# M_list = index(max(A_1,...,A_N))
# M = max(A)
# sub_M = sub_max(A)

# iがM_listに含まれるときにはsub_Mを出力
# それ以外ではMを出力

M = max(A)
sub_M = 0
for i in range(N):
  if i not in M_list:
    sub_M = max(sub_M, A[i])
    
M_list = []
for i in range(N):
  if A[i] == M: M_list.append(i)
    
for i in range(N):
  if i in M_list: print(sub_M)
  else: print(M)

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

ans = 'Yes'
for i in range(N-1, 0, -1):
  if A[i] > A[i-1]: A[i-1] -= 1
    if A[i] > A[i-1]:
      ans = 'No'
      break

print(ans)

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

# max(A_2,A_3,...,A_N)
# max(A_1,A_3,...,A_N)
# max(A_1,A_2,...,A_(N-1))

M_1 = max(A)
M_2 = max(A.replace(M_1, 0))

for i in range(N):
  if A[i] != M_1: print(M_1)
  else: print(M_2)

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

A = sorted(A)
print(sum(A[1:])
Problem p02981 (python)

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

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

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

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
 
ans = 0
for i in range(1, n-1):
  M = max(p[i-1], p[i], p[i+1])
  m = min(p[i-1], p[i], p[i+1])
  if p[i] != M and p[i] != m: ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
 
ans = 0
for i in range(1, n-1):
  if p[i] >= p[i-1] and p[i] =< p[i+1]: ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input()))

ans = 0
for i in range(1, n-1):
  if p[i] > p[i-1] and p[i] < p[i+1]: ans += 1

print(ans)