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

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = ['' for i in range(n)]
maxd = len(bin(10 ** 12 + 1))-2
bink = bin(k)[2:]
digitk = len(bink)
bink1 = bin(k+1)[2:]
digitk1 = len(bink1)
bink = bink.zfill(maxd)[::-1]
bink1 = bink1.zfill(maxd)[::-1]
for i in range(n):
    b[i] = format(a[i], 'b').zfill(maxd)[::-1]
#print(b)

s = [0 for i in range(maxd)]
c = [0 for i in range(maxd)]
for i in range(maxd):
    c[i] = sum(list(map(lambda x: int(x[i]), b)))
for i in range(digitk1):
    if bink1[i] == '1':
        for j in range(i):
            if c[j] <= n/2:
                s[i] += (n-c[j]) * 2 ** j
            else:
                s[i] += c[j] * 2 ** j

        s[i] += c[i] * 2 ** i

        for j in range(i+1, digitk1):
            if bink1[j] == '1':
                s[i] += (n-c[j]) * 2 ** j
            else:
                s[i] += c[j] * 2 ** j

    for j in range(digitk1, maxd):
        s[i] += c[j] * 2 ** j
print(max(s))

Buggy submission (verdict: Runtime Error):
for i in range(n):
    b[i] = format(a[i], 'b').zfill(maxd)[::-1]
#print(b)

s = [0 for i in range(maxd)]
c = [0 for i in range(maxd)]
for i in range(maxd):
    c[i] = sum(list(map(lambda x: int(x[i]), b)))
for i in range(digitk1):
    for j in range(i):
        count = c[j]
        if count <= n/2:
            s[i] += (n - count) * 2 ** j
        else:
            s[i] += count * 2 ** j
    count = c[i]

    if int(bink[i]) == 0:
        s[i] = count * 2**i
        pass
    else:
        s[i] += count * 2 ** i

    for j in range(i+1, digitk):
        count = c[j]
        if int(bink[j]) == 0:
            s[i] += count * 2 ** j

        else:
            s[i] += (n-count) * 2 ** j

    for j in range(digitk1, maxd):
        count = c[j]
        s[i] += count * 2 ** j
print(max(s))
Problem p03212 (python)

Fixed submission:
n = int(input())
count = 0
stack = [0]
def check(n):
  s = str(n)
  if "3" in s and "5" in s and "7" in s:
    return True
  else:
    return False
while len(stack)>0:
  now = stack.pop()
  if check(now) and now <= n:
    count += 1
  if now < n:
    stack.append(now*10+3)
    stack.append(now*10+5)
    stack.append(now*10+7)
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [True]*(10**9+1)
count = 0
stack = [3, 5, 7]
def check(n, k):
  s = str(n)
  if "3" in s and "5" in s and "7" in s:
    return True
  else:
    return False
while len(stack)>0:
  now = stack.pop()
  if l[now]:
    l[now] = False
    if check(now):
      count += 1
    if now < n:
      stack.append(now*10+3)
      stack.append(now*10+5)
      stack.append(now*10+7)
      stack.append(3*10**len(str(now))+now)
      stack.append(5*10**len(str(now))+now)
      stack.append(7*10**len(str(now))+now)
print(count)
Problem p03263 (python)

Fixed submission:
h, w = map(int, input().split())
mat = []
for i in range(h):
  mat.append(list(map(int, input().split())))
sousa = []
for y in range(h):
  if y % 2 == 0:
    x = -1
    for x in range(w-1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x+1] += 1
        sousa.append((y+1, x+1, y+1, x+1+1))
    x += 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))
  if y % 2 == 1:
    x = w
    for x in range(w-1, 0, -1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x-1] += 1
        sousa.append((y+1, x+1, y+1, x+1-1))
    x -= 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))

print(len(sousa))
for y,x,y1,x1 in sousa:
  print(y,x,y1,x1)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
mat = []
for i in range(h):
  mat.append(list(map(int, input().split())))
sousa = []
for y in range(h):
  if y % 2 == 0:
    for x in range(w-1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x+1] += 1
        sousa.append((y+1, x+1, y+1, x+1+1))
    x += 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))
  if y % 2 == 1:
    for x in range(w-1, 0, -1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x-1] += 1
        sousa.append((y+1, x+1, y+1, x+1-1))
    x -= 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))

print(len(sousa))
for y,x,y1,x1 in sousa:
  print(y,x,y1,x1)

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

for y in range(h):
  if y % 2 == 0:
    for x in range(w-1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x+1] += 1
        print(y+1, x+1, y+1, x+1+1)
    x += 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        print(y+1, x+1, y+1+1, x+1)
  if y % 2 == 1:
    for x in range(w-1, 0, -1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x-1] += 1
        print(y+1, x+1, y+1, x+1-1)
    x -= 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        print(y+1, x+1, y+1+1, x+1)

count = 0        
for y in range(h):
  for x in range(w):
    if mat[y][x] % 2 == 0:
      count += 1
print(count)
Problem p03273 (python)

Fixed submission:
h,w = map(int,input().split())
mat = []
for i in range(h):
  g = list(input())
  if g.count(".") != w:
    mat.append(g)


for i in range(w-1, -1, -1):
  count = 0
  for j in range(len(mat)):
    if mat[j][i] == ".":
      count += 1
  if count == len(mat):
    for j in range(len(mat)):
      mat[j].pop(i)

for h in range(len(mat)):
  print("".join(mat[h]))

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
mat = []
for i in range(h):
  g = list(input().split())
  if g.count(".") != w:
    mat.append(g)

for i in range(w-1, -1, -1):
  count = 0
  for j in range(len(mat)):
    if mat[j][i] == ".":
      count += 1
  if count == len(mat):
    for j in range(len(mat)):
      mat[j].pop(i)

for h in range(len(mat)):
  print(" ".join(mat[h]))
Problem p03289 (python)

Fixed submission:
s = input()
ac = True
c = True
if s[0] != "A":
  ac = False
if not ord("a") <= ord(s[1]) <= ord("z"):
  ac = False
if not ord("a") <= ord(s[-1]) <= ord("z"):
  ac = False
for i in range(2, len(s)-1):
  if s[i] == "C":
    if c:
      c = False
    else:
      ac = False
  else:
    if not ord("a") <= ord(s[i]) <= ord("z"):
      ac = False
if c:
  ac = False
if ac:
  print("AC")
else:
  print("WA")

Buggy submission (verdict: Runtime Error):
s = input()
ac = True
c = True
if s[0] != "A":
  ac = False
if not ord("a") <= ord(s[1]) <= ord("z"):
  ac = False
if not ord("a") <= ord(s[-1]) <= ord("z"):
  ac = False
for i in range(2, len(s)-1):
  if s[i] == "C":
    if c:
      c = False
    else:
      ac = False
  else:
    if not ord("a") <= ord(s[i]) <= ord("z"):
    ac = False
if ac:
  print("AC")
else:
  print("WA")
Problem p03363 (python)

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

count_list = {}
s = 0
for i in range(n):
  s += a[i]
  count_list[s] = count_list.get(s, 0) + 1

count = 0
count += count_list.get(0, 0) * (count_list.get(0, 0)+1)
for i in count_list.keys():
  if i!=0:
    #count+= count_list[i] * count_list.get(-i, 0)
    count += count_list[i] * (count_list[i]-1)
print(count//2)

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

count_list = {}
s = 0
for i in range(n):
  s += a[i]
  count_list[s] = count_list.get(s, 0) + 1

count = 0
count += count_list.get(0, 0) * (count_list.get(0, 0)+1)
for i in count_list.keys():
  if i!=0:
    count+= counta_list[i] * count_list.get(-i, 0)
    count += count_list[i] * (count_list[i]-1)
print(count//2)

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

count_list = {}
s = 0
for i in range(n):
  s += a[i]
  count_list[s] = count_list.get(s, 0) += 1

count = 0
# count += count_list.get(0, 0) * (count_list.get(0, 0)+1) // 2
for i in count_list.keys():
  count+= count_list[i] * count_list.get(-i, 0)
print((count + count_list.get(0, 0))//2)

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

count_list = [[0,0]]*(n*10**9+1)
s = 0
for i in range(n):
  s += a[i]
  if s > 0:
    count_list[s][0] += 1
  elif s < 0:
    count_list[-s][1] += 1
  else:
    count_list[s][0] += 1
count = 0
count += count_list[0][0] * (count_list[0][0] + 1) // 2
for i in range(1, len(count_list)):
  count+= count_list[i][0] * count_list[i][1]
print(count)

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

count_list = [[0,0]]*(n*10**9+1)
s = 0
for i in range(n):
  s += a[i]
  if s > 0:
    count_list[s][0] += 1
  elif s < 0:
    count_list[s][1] += 1
  else:
    count_list[s][0] += 1
count = 0
count += count_list[0][0] * (count_list[0][0] + 1) // 2
for i in range(1, len(count_list)):
  count+= count_list[i][0] * count_list[i][1]
print(count)
Problem p03371 (python)

Fixed submission:
a, b, c, x, y = map(int, input().split())
if a+b<2*c:
    print(a*x+b*y)
else:
    if x > y:
        amari = x - y
        if a > 2*c:
            print(2*c*y + amari*2*c)
        else:
            print(2*c*y + amari*a)
    else:
        amari = y - x
        if b > 2*c:
            print(2*c*x + amari*2*c)
        else:
            print(2*c*x + amari*b)

Buggy submission (verdict: Runtime Error):
a, b, c, x, y = map(int, input().split())
if a+b<2*c:
    print(a*x+b*y)
else:
    if x > y:
        amari = x - y
        if a > 2*c:
            print(2*c*y + amari*2*c)
        else:
            print(2*c*y + amari*a)
    else:
        amari = y - x
        if b > 2*c:
            print(2*c*x + amari*2*c)
        else:
            print(2*c*x +
Problem p03385 (python)

Fixed submission:
s = list(input())
if "".join(sorted(s)) == "abc":
  print("Yes")
else:
  print("No")

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

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]

d_1 = []
for i in range(1, n+2):
  d_1.append(abs(a[i]-a[i-1]))
d_2 = []
for i in range(1, n+1):
  d_2.append(abs(a[i+1]-a[i-1]))

s_d = sum(d_1)
for i in range(1, n+1):
  print(s_d - d_1[i-1] - d_1[i] + d_2[i-1])

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

d_1 = []
for i in range(1, n+2):
  d_1.append(abs(a[i]-a[i-1]))
d_2 = [0]
for i in range(1, n+1):
  d_2.append(abs(a[i+1]-a[i-1]))

s_d = sum(d_1)
for i in range(1, n+1):
  print(s_d - d_1[i] - d_1[i+1] + d_2[i])

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

d_1 = []
for i in range(1, n+2):
  d_1.append(abs(a[i]-a[i-1]))
d_2 = []
for i in range(1, n+1):
  d_2.append(abs(a[i+1]-a[i-1]))

s_d = sum(d_1)
for i in range(1, n+1):
  print(s_d - d_1[i] - d_1[i+1] + d_2[i])
Problem p03416 (python)

Fixed submission:
a, b = map(int, input().split())
c = 0
for i in range(a, b+1):
    i = str(i)
    if i[0] == i[4] and i[1] == i[3]:
        c += 1
print(c)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
c = 0
for i in range(int(a), int(b)+1):
  if i[0] == i[4] and i[1] == i[3]:
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
c = 0
for i in range(a, b+1):
  if i[0] == i[4] and i[1] == i[3]:
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = 0
for i in range(a, b+1):
  if i[0] == i[4] and i[1] == i[3]:
    c += 1
print(c)
Problem p03472 (python)

Fixed submission:
n, h = map(int, input().split())
h2 = h
l = []
for i in range(n):
  l.append(list(map(int,input().split())))

l_b = sorted(l, key=lambda x: x[1])
l = sorted(l_b, reverse=True, key=lambda x: x[0])
c_a = 0
c_b = 0
b_sum = 0

for i in range(n-1, -1, -1):
  if l_b[i][1] >= l[0][0]:
    b_sum += l_b[i][1]
    h -= l_b[i][1]
    c_b += 1
    if h <= 0:
      print(c_b)
      exit()
import math
c_a = math.ceil((h2 - b_sum) / l[0][0])


print(c_a+c_b)

Buggy submission (verdict: Runtime Error):
n, h = map(int, input().split())
l = []
for i in range(n):
  l.append(list(map(int,input().spplit())))

l = sorted(l, reverse=True)
c = 0
for i in range(1, n):
  if l[i][1] > l[0][0]:
    h -= l[i][1]
    c += 1
    if h <= 0:
      print(c)
      exit()

while h > l[0][1]:
  h -= l[0][0]
  c += 1

print(c+1)
Problem p03476 (python)

Fixed submission:
data = sorted(list(range(10**5+1)))
prime_bool = [True]*(10**5+1)
prime_bool[0] = False
prime_bool[1] = False
for i in range(2, len(data)):
  p = data[i]
  if prime_bool[p]:
    k = 2
    while k*p <= 10**5:
      prime_bool[k*p] = False
      k += 1

count_list = [0]*(10**5+1)
for i in range(1, 10**5+1):
  count_list[i] = count_list[i-1]
  if prime_bool[i] and prime_bool[(i+1)//2]:
    count_list[i] += 1

q = int(input())
for i in range(q):
  l,r=map(int, input().split())
  print(count_list[r]-count_list[l-1])

Buggy submission (verdict: Runtime Error):
data = sorted(list(range(10**5+1)))
prime_bool = [True]*(10**5+1)
prime_bool[0] = False
 
for i in range(len(data)):
  p = data[i]
  if prime_bool[p]:
    k = 2
    while k*p <= max(a):
      prime_bool[k*p] = False
      k += 1

count_list = [0]*(10**5+1)
for i in range(1, 10**5+1):
  count_list[i] = count_list[i-1]
  if prime_bool[i] and prime_bool[(i+1)//2]:
    count_list[i] += 1

q = int(input())
for i in range(q):
  l,r=map(int, input().split())
  print(count_list[r]-count_list[l-1])
Problem p03495 (python)

Fixed submission:
n, k = map(int, input().split())
a =list(map(int, input().split()))
ball = 0
count = [0]*(n+1)
for i in range(n):
    count[a[i]] += 1

count.sort(reverse=True)
for i in range(k):
    ball += count[i]

print(n - ball)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a =list(map(int, input().split()))
ball = 0
count = [0]*(n+1)
for i in range(n):
    count[a[i]] += 1

count = count.sorted(reverse=True)
for i in range(k):
    ball += count[i]

print(n - ball)
Problem p03547 (python)

Fixed submission:
x, y = input().split()
if x > y:
    print(">")
elif x < y:
    print("<")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
s = 0
p = [0.0]
k = 1
s_old = -1.0
while s - s_old >= 0.0000001:
    pr = (1 - sum(p)) / (2**m)
    p.append(pr)
    s_old = s
    s += (1900 * m + 100 * (n - m)) * k * pr
    k += 1
print(math.ceil(s))
Problem p03565 (python)

Fixed submission:
s = input()
t = input()
if len(s) < len(t):
  print("UNRESTORABLE")
  exit()

start = -1
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j] != "?" and s[i+j] != t[j]:
      break
  else:
    start = i

if start == -1:
  print("UNRESTORABLE")
else:
  ans_list = list(s)
  for i in range(len(ans_list)):
    if start <= i < start+len(t):
      ans_list[i] = t[i-start]
    elif ans_list[i] == "?":
      ans_list[i] = "a"
  print("".join(ans_list))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
if len(s) < len(t):
  print("UNRESTORABLE")
  exit()

start = -1
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j] != "?" and s[i+j] != t[j]:
      break
  else:
    start = i

if start == -1:
  print("UNRESTORABLE")
else:
  ans_list = list(s)
  for i in range(len(ans_list)):
    if start <= i <= start+len(t):
      ans_list[i] = t[i-start]
    elif ans_list[i] == "?":
      ans_list[i] = "a"
  print("".join(ans_list))
Problem p03598 (python)

Fixed submission:
n = int(input())
k = int(input())
x = list(map(int, input().split()))
d = 0
for i in x:
    d += min(i, k-i) * 2

print(d)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = list(map(int, input()))
d = 0
for i in x:
    d += min(i, k-i) * 2

print(d)
Problem p03721 (python)

Fixed submission:
n,k=map(int,input().split())
l = []
for i in range(n):
  a,b=map(int,input().split())
  l.append((a,b))
l = sorted(l)
c = 0
i = 0
while c < k:
  c += l[i][1]
  i += 1

print(l[i-1][0])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l = []
for i in range(n):
  a,b=map(int,input().split())
  l.append((a,b))
l = sorted(l)
c = 0
i = 0
while c < k:
  c += l[i][1]
  i += 1

print(l[i][1])
Problem p03730 (python)

Fixed submission:
a,b,c=map(int,input().split())
for i in range(1, b+1):
  if a%b * i % b == c:
    print("YES")
    break
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
for i in range(1, b+1):
  a%b * i % b == c:
    print("YES")
    break
else:
  print("NO")
Problem p03761 (python)

Fixed submission:
n=int(input())
d = {}
for i in range(26):
  d[chr(ord("a")+i)]=10**9
for i in range(n):
  s=input()
  for j in range(26):
    d[chr(ord("a")+j)]=min(d[chr(ord("a")+j)], s.count(chr(ord("a")+j)))

ans = ""
for e in d.items():
  ans+=e[0]*e[1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d = {}
for i in range(26):
  d[chr(ord("a")+i)]=10**9
for i in range(n):
  s=input()
  for j in range(26):
    d[chr(ord("a")+i)]=min(d[chr(ord("a")+i)], s.count(chr(ord("a")+i)))

ans = ""
for e in d.items():
  ans+=e[0]*e[1]
print(ans)
Problem p02582 (python)

Fixed submission:
A = input()
if A == "SSS":
	print(0)
elif A == "RRR":
  print(3)  
elif A ==  "SRR" or A == "RRS":
  print(2)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
A = input()
if A == "S"
	print("天気が雨である日が連続していた最大の日数を出力せよ。")
if A = "SSS"
	print(0)
if A == "RSS" or "SRS" or "SSR" or "RSR":
  print(1)
if A == "SRR" or "RRS":
  print(2)
if A == "RRR":
  print(3)

Buggy submission (verdict: Runtime Error):
A = input("")
if A == "S"
	print("天気が雨である日が連続していた最大の日数を出力せよ。")
if A = "SSS"
	print(0)
if A == "RSS" or "SRS" or "SSR" or "RSR":
  print(1)
if A == "SRR" or "RRS":
  print(2)
if A == "RRR":
  print(3)
Problem p02993 (python)

Fixed submission:
S = input()

if S[0] == S[1] or S[1] == S[2] or S[2] ==S[3]:
    print('Bad')
else:
    print('Good')

Buggy submission (verdict: Runtime Error):
S1,S2,S3,S4=list(map(int,input().split()))

if S1 == S2 or S2 == S3 or S3 == S4:
    print('Bad')
else:
    print('Good')
Problem p03061 (python)

Fixed submission:
from fractions import gcd as GCD

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

# GCD_LtoR[i] = GCD(A0, A1, ... , A(i-1))
GCD_LtoR = [None] * N
# GCD_LtoR[i] = GCD(Ai, A(i+1), ... , AN)
GCD_RtoL = [None] * N

GCD_LtoR[0] = A[0]
for i in range(1, N):
    GCD_LtoR[i] = GCD(A[i], GCD_LtoR[i-1])

GCD_RtoL[N-1] = A[N-1]
for i in range(N-2, -1, -1):
    GCD_RtoL[i] = GCD(A[i], GCD_RtoL[i+1])

GCD_max = GCD_RtoL[1]
for i in range(0, N-1):
    # Aに含まれるAi以外の要素のGCDを計算する
    GCD_ex_i = GCD(GCD_LtoR[i-1], GCD_RtoL[i+1])
    GCD_max = max(GCD_ex_i, GCD_max)
GCD_max = max(GCD_LtoR[N-2], GCD_max)
print(GCD_max)

Buggy submission (verdict: Runtime Error):
import math
print(math.gcd(2, 5))

Buggy submission (verdict: Runtime Error):
from math import gcd as GCD

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

# GCD_LtoR[i] = GCD(A0, A1, ... , A(i-1))
GCD_LtoR = [None] * N
# GCD_LtoR[i] = GCD(Ai, A(i+1), ... , AN)
GCD_RtoL = [None] * N

GCD_LtoR[0] = A[0]
for i in range(1, N):
    GCD_LtoR[i] = GCD(A[i], GCD_LtoR[i-1])

GCD_RtoL[N-1] = A[N-1]
for i in range(N-2, -1, -1):
    GCD_RtoL[i] = GCD(A[i], GCD_RtoL[i+1])

GCD_max = GCD_RtoL[1]
for i in range(0, N-1):
    # Aに含まれるAi以外の要素のGCDを計算する
    GCD_ex_i = GCD(GCD_LtoR[i-1], GCD_RtoL[i+1])
    GCD_max = max(GCD_ex_i, GCD_max)
GCD_max = max(GCD_LtoR[N-2], GCD_max)
print(GCD_max)
Problem p03081 (python)

Fixed submission:
def can_reach_to_0(s, comm, pos):
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos < 0:
            return True
        if pos >= N:
            return False
    return False

def can_reach_to_N(s, comm, pos):
    N = len(s)
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos >= N:
            return True
        if pos < 0:
            return False
    return False

N, Q = list(map(int, input().split()))
s = input()
comm = [input().split() for _ in range(Q)]

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_0(s, comm, mid):
        l = mid + 1
    else:
        r = mid - 1
left = r # いける右端index

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_N(s, comm, mid):
        r = mid - 1
    else:
        l = mid + 1
right = l # いける左端index
print(right-left-1)

Buggy submission (verdict: Runtime Error):
def can_reach_to_0(s, comm, pos):
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos < 0:
            return True
    return False

def can_reach_to_N(s, comm, pos):
    N = len(s)
    for t, d in comm:
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
        if pos >= N:
            return True
    return False

N, Q = list(map(int, input().split()))
s = input()
comm = [input().split() for _ in range(Q)]

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_0(s, comm, mid):
        l = mid + 1
    else:
        r = mid - 1
left = r # いける右端index

l = 0
r = N-1
while l <= r:
    mid = int((l+r)/2)
    if can_reach_to_N(s, comm, mid):
        r = mid - 1
    else:
        l = mid + 1
right = l # いける左端index
print(right-left-1)
Problem p02582 (python)

Fixed submission:
s = input()
cnt = 0
ans = [0]
for i in range(3):
  if s[i] == 'R':
    cnt+=1
    ans.append(cnt)
  else:
    cnt = 0
print(max(ans))

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
ans = []
for i in range(3):
  if s[i] == 'R':
    cnt+=1
    ans.append(cnt)
  else:
    cnt = 0
print(max(ans))
Problem p02641 (python)

Fixed submission:
x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(-10,102):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(len(ans)):
        if MIN == abs(ans[i]-x):
            print(ans[i])
            break

Buggy submission (verdict: Runtime Error):
x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(1,101):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(len(ans)):
        if MIN == abs(ans[i]-x):
            print(ans[i])
            break

Buggy submission (verdict: Runtime Error):
x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(1,101):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(len(ans)):
        if MIN == abs(ans[i]-x):
            print(ans[i])

Buggy submission (verdict: Runtime Error):
x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(1,101):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(0,len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(n):
        if MIN == abs(ans[i]-x):
            print(ans[i])
Problem p02664 (python)

Fixed submission:
t = input()
ans=t.replace('P?','PD')
ans=ans.replace('?D','PD')
ans=ans.replace('??','PD')
ans=ans.replace('?','D')
print(ans)

Buggy submission (verdict: Runtime Error):
t = input()
ans=ans.replace('P?','PD')
ans=t.replace('?D','PD')
ans=ans.replace('??','PD')
ans=ans.replace('?','D')
print(ans)