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

Fixed submission:
import math

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

tmp = -10
li = [a,b,c,d,e]
for i in li:
  tmp += math.ceil(i/10)*10
if a%10 + b%10 + c%10 + d%10 + e%10 == 0:
  print(int(tmp +10))
else:
  li_1 = [a%10,b%10,c%10,d%10,e%10]
  for i in range(5):
    try:
      li_1.remove(0)
    except:
      break
  print(int(tmp + min(li_1)))

Buggy submission (verdict: Runtime Error):
import math

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

tmp = -10
li = [a,b,c,d,e]
for i in li:
  tmp += math.ceil(i/10)*10
li_1 = [a%10,b%10,c%10,d%10,e%10]
for i in range(5):
  try:
    li_1.remove(0)
  except:
    break
print(int(tmp + min(li_1)))
Problem p03145 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input(),split())
print(a*b/2)
Problem p03369 (python)

Fixed submission:
s = input()
print(700 + s.count("o")*100)

Buggy submission (verdict: Runtime Error):
xxx
Problem p03399 (python)

Fixed submission:
a = int(input())
b = min(a,int(input()))
c = int(input())
d = min(c,int(input()))
print(b+d)

Buggy submission (verdict: Runtime Error):
n = int(input())
d,x = map(int,input().split())
li = [int(input()) for i in range(n)]

choco = x
for i in range(n):
  choco += 1 + (d-1)//li[i]
print(choco)
Problem p03457 (python)

Fixed submission:
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
 
if li[0][0] - abs(li[0][1]) - abs(li[0][2]) < 0:
  print("No")
  exit()
elif li[0][0] - abs(li[0][1]) - abs(li[0][2]) > 0:
  if (li[0][0] - abs(li[0][1]) - abs(li[0][2])) % 2 != 0:
    print("No")
    exit()
else:
  for k in range(1,n):
    t = li[k][0]
    x = li[k][1]
    y = li[k][2]
    tt = li[k-1][0]
    xx = li[k-1][1]
    yy = li[k-1][2]
    if t - tt - abs(x - xx) - abs(y - yy) <0:
      print("No")
      exit()
    elif t - tt - abs(x - xx) - abs(y - yy) <0:
      if (t - tt - abs(x - xx) - abs(y - yy)) % 2 != 0:
        print("No")
        exit()
print("Yes")

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

if li[1][1] - abs(li[1][2]) - abs(li[1][3]) < 0:
  print("NO")
  exit()
elif li[1][1] - abs(li[1][2]) - abs(li[1][3]) > 0:
  if (li[1][1] - abs(li[1][2]) - abs(li[1][3])) % 2 != 0:
    print("NO")
    exit()
else:
  for k in range(1,n):
    t = li[k][1]
    x = li[k][2]
    y = li[k][3]
    tt = li[k-1][1]
    xx = li[k-1][2]
    yy = li[k-1][3]
    if t - tt - abs(x - xx) - abs(y - yy) <0:
      print("NO")
      exit()
    elif t - tt - abs(x - xx) - abs(y - yy) <0:
      (t - tt - abs(x - xx) - abs(y - yy)) % 2 != 0:
        print("NO")
        exit()
print("YES")
Problem p03493 (python)

Fixed submission:
S = input()
li = list(S)
 
ans = 0
for i in range(3):
  if li[i] == "1":
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
print(int(s.count("1"))

Buggy submission (verdict: Runtime Error):
s = input()
print(int(s.count(1))
Problem p03494 (python)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
 
lians = [0]*n
for i in range(n):
  while li[i]%2 == 0:
    li[i] /= 2
    lians[i] += 1
print(min(lians))

Buggy submission (verdict: Runtime Error):
n = int(input())
li = input().split()

lians = [0]*n
for i in range(n):
  while li[i]%2 == 0:
    li[i] /= 2
    lians[i] += 1
print(max(lians))
Problem p02882 (python)

Fixed submission:
import math

a,b,x=map(int,input().split())

if (a*a*b/2<=x):
    print(math.degrees(math.atan((2*(a*a*b-x))/(a*a*a))))
else:
    print(math.degrees(math.atan((a*b*b)/(2*x))))

Buggy submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())

print(90 - math.degrees(math.atan( a*a*a / (2*(a*a*b - x)) )))
Problem p02995 (python)

Fixed submission:
A, B, C, D = map(int, input().split())

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B, C, D = map(int, input().split())

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / np.gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))

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

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / math.gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))
Problem p03103 (python)

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

res = M
n = 0
cnt = 0


while(AB[n][1] < res):
    cnt += AB[n][0] * AB[n][1]
    res -= AB[n][1]
    n += 1

cnt += res * AB[n][0]

print(cnt)

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

res = M
n = 0
cnt = 0

if N == 1:
    cnt = res * AB[0][1]
else:
    while(AB[n][1] <= res):
        cnt += AB[n][0] * AB[n][1]
        res -= AB[n][1]
        n += 1

    cnt += res * AB[n][0]

print(cnt)
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())
s = a-2*b if a-2*b >= 0 else 0
print(s)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a-2b if a-2b >= 0 else 0
print(s)
Problem p02887 (python)

Fixed submission:
n = int(input())
s = input()
a = ''
ans = 0
for i in range(n):
  if s[i] != a:
    a = s[i]
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(str(input()))
a = ''
ans = 0
for i in s:
  if s[i] != a:
    a = s[i]
    ans += 1
print(ans)
Problem p02888 (python)

Fixed submission:
from  bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
ans = 0

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left

n = int(input())
l = list(map(int, input()))
ans = 0

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)
Problem p02899 (python)

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

for i in range(n):
  s = a[i]
  ans[s-1] = i+1
print(*ans)

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

for i in range(n):
  s = a[i]
  ans[s-1] = i + 1
print(ans*)

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

for i in range(n):
  s = a[i]
  ans[s-1] = i+1
print(*ans)
Problem p02910 (python)

Fixed submission:
s = list(str(input()))
for i in range(len(s)):
  if ((i+1)%2 and s[i]=='L') or ((i+1)%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
s = list(str(input()))
for i in range(1, len(s)+1):
  if ((i+1)%2 and s[i]=='L') or ((i+1)%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
s = list(str(input()))
for i in range(1, len(s)+1):
  if (i%2 and s[i]=='L') or (i%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
s = list(str(input()))
for i in range(1, len(s)+1):
  if (i%2 and s[i]=='L') or (i%2==0 and s[i]=='R'):
    print('No')
 	exit()
print('Yes')
Problem p02911 (python)

Fixed submission:
n, k, q = map(int, input().split())
a = list(map(int, [input() for i in range(q)]))
p = [k-q] * n
for i in range(q):
  p[a[i]-1] += 1
for i in range(n):
  print('Yes' if p[i] > 0 else 'No')

Buggy submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
a = list(map(int, [input() for i in range(q)]))
p = [k-q] * n
for i in range(q):
  p[a[i]] += 1
for i in range(n):
  print('Yes' if p[i] > 0 else 'No')
Problem p02917 (python)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
ans = 0
ans = b[0] + b[n-2]
for i in range(1, n-1):
  ans += min(b[i-1], b[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().split()))
ans = 0
ans = b[0] + b[n-2]
for i in range(1, n-1):
  ans += min(b[i], b[i+1])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map, input().split())
print(sum(b) + b[0])
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
a = 0
list = []
if n == 1:
  print(0)
  exit()
for i in range(1, n):
  if h[i] <= h[i-1]:
    a += 1
  else:
    a = 0
  list.append(a)
print(max(list))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
a = 0
list = []
for i in range(1, n):
  if h[i] <= h[i-1]:
    a += 1
  else:
    a = 0
  list.append(a)
print(max(list))
Problem p02924 (python)

Fixed submission:
# 例： 1 - 8 までの数列
# 1 2 3 4 5 6 7 8

# 余りを最大化するには、Nに対する N-1 の余り。つまり１ずつ減じた値の余りをとる。最初の値は N
# 8 1 2 3 4 5 6 7

#  (8 % 1) + (1 % 2) + (2 % 3) + .... + (7 % 8)
#   0 + 1   2 + ... + 7

N = int(input())
print(N * (N-1) // 2)

Buggy submission (verdict: Runtime Error):
# 例： 1 - 8 までの数列
# 1 2 3 4 5 6 7 8

# 余りを最大化するには、Nに対する N-1 の余り。つまり１ずつ減じた値の余りをとる。最初の値は N
# 8 1 2 3 4 5 6 7

#  (8 % 1) + (1 % 2) + (2 % 3) + .... + (7 % 8)
#   0 + 1   2 + ... + 7

N = int(input())
print(sum(list(range(N))))
Problem p02953 (python)

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

if N == 1:
    print("Yes")
else:
    for i in range(N-1, 0, -1):
        #print(H[i-1], H[i])
        if H[i-1] <= H[i]:
            #print("@")
            continue
        elif (H[i-1] - 1) == H[i]:
            #print("#")
            H[i-1] = H[i]
        else:
            #print("=")
            break
    
    if i == 1:
        print("Yes")
    else:
        print("No")

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

above = H[N-1]
for i in range(N-2, -1, -1):
    cur = H[i]
    #print(cur, above)
    if cur <= above:
        above = cur
        continue
    elif cur - 1 == above:
        continue
    else:
        break

if i == 0:
    print("Yes")
else:
    print("No")

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

for i in range(N-1, 0, -1):
    #print(H[i-1], H[i])
    if H[i-1] <= H[i]:
        #print("@")
        continue
    elif (H[i-1] - 1) == H[i]:
        #print("#")
        H[i-1] = H[i]
    else:
        #print("=")
        break

if i == 1:
    print("Yes")
else:
    print("No")
Problem p02982 (python)

Fixed submission:
N, D = map(int, input().split())
arX = [list(map(int, input().split()))[:D] for n in range(N)]

import math

count = 0
for x in range(len(arX)):
    xp = arX[x]
    for y in range(x, len(arX)):
        if x == y:
            continue
        
        yp = arX[y]
        
        powSum = 0
        for d in range(D):
            powSum += (xp[d] - yp[d]) ** 2
        
        #print(x, y, sqPowSum)
            
        sqPowSum = math.sqrt(powSum)
        if sqPowSum == int(sqPowSum):
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
arX = [list(map(int, input().split()))[:D] for n in range(N)]

import math

count = 0
for x in range(len(arX)):
    xp = arX[x]
    for y in range(x, len(arX)):
        if x == y:
            continue
        
        yp = arX[y]
        
        powSum = 0
        for d in range(D):
            powSum += (xp[d] - yp[d]) ** 2
        
        if debug:
            print(x, y, sqPowSum)
            
        sqPowSum = math.sqrt(powSum)
        if sqPowSum == int(sqPowSum):
            count += 1

print(count)
Problem p02995 (python)

Fixed submission:
from fractions import gcd

def lcm(x, y):
    return ((x * y) // gcd(x, y))


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

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = (B // C) - ((A - 1) // C)

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = (B // D) - ((A - 1) // D)

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    div, _ = divmod(x * y, math.gcd(x, y))
    return div


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

# 変数C の倍数が A, B 区間内に存在しうる数
#Ccount = (B // C) - ((A - 1) // C)
divBC, _ = divmod(B, C)
divA1C, _ = divmod(A-1, C)
Ccount = divBC - divA1C

# 変数D の倍数が A, B 区間内に存在しうる数
#Dcount = (B // D) - ((A - 1) // D)
divBD, _ = divmod(B, D)
divA1D, _ = divmod(A-1, D)
Dcount = divBD - divA1D

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
#CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))
divBlcmCD, _ = divmod(B, lcm(C, D))
divA1lcmCD, _ = divmod(A-1, lcm(C, D))
CDcross =divBlcmCD - divA1lcmCD

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return ((x * y) // math.gcd(x, y))


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

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = (B // C) - ((A - 1) // C)

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = (B // D) - ((A - 1) // D)

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = B // C - (A - 1) // C

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = B // D - (A - 1) // D

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = B // lcm(C, D) - (A - 1) // lcm(C, D)

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))
Problem p03049 (python)

Fixed submission:
N = int(input())
s = [input() for n in range(N)]

# 先頭が B ではなく、末尾が A な文字列
TxBA = [s[n] for n in range(N) if s[n][0] != "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A な文字列
TBBA = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A ではない文字列
TBBx = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] != "A"]

# 上記を除き中に "AB" が存在する文字列
kouho = TxBA + TBBA + TBBx
ss = s.copy()
for k in kouho:
    ss.remove(k)
    
str = ""
while (len(TxBA)):
    str += TxBA.pop()
    while (len(TBBA)):
        str += TBBA.pop()
    if (len(TBBx)):
        str += TBBx.pop()

while (len(TBBA)):
    str += TBBA.pop()
if (len(TBBx)):
    str += TBBx.pop()

while (len(TBBx)):
    str += TBBx.pop()

while (len(ss)):
    str += ss.pop()

print(str.count("AB"))

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

# 先頭が B ではなく、末尾が A な文字列
TxBA = [s[n] for n in range(N) if s[n][0] != "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A な文字列
TBBA = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A ではない文字列
TBBx = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] != "A"]

str = ""

while (len(TxBA)):
    str += TxBA.pop()
    while (len(TBBA)):
        str += TBBA.pop()
    if (len(TBBx)):
        str += TBBx.pop()

while (len(TBBx)):
    str += TBBx.pop()

while (len(ss)):
    str += ss.pop()

print(str.count("AB"))
Problem p03145 (python)

Fixed submission:
AB, BC, CA = map(int, input().split())

print( int(AB * BC / 2) )

Buggy submission (verdict: Runtime Error):
a = [0 for i in range(3 * 1000000 + 1)]

s = int(input().rstrip())

a[s] = 1

for i in range(2, 1000000+1):
    if s % 2 == 0:
        s = int(s / 2)
    else:
        s = int(3 * s + 1)
    #print(s)
    
    if a[s] == 1:
        break
    a[s] = 1
        
print(i)
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())
x = 1
ans = 0
while x < b:
    x += a - 1
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
print(ans)
Problem p02960 (python)

Fixed submission:
s = input()
dp = [[0 for i in range(13)]]
if s[-1] != "?":
    dp[0][int(s[-1]) % 13] += 1
else:
    for k in range(10):
        dp[0][k % 13] += 1
        
d = [1]   
for i in range(1,len(s)):
    dp.append([0]*13)
    d.append(d[i-1]*10 % 13)
    for r in range(13):
        if s[-(i+1)] == "?":
            for k in range(10): 
                dp[i][(k * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)
                
        else:
            dp[i][(int(s[-(i+1)]) * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)

print(dp[len(s)-1][5]%(10**9+7))

Buggy submission (verdict: Runtime Error):
s = input()
dp = [[0 for i in range(13)] for i in range(len(s))]
if s[-1] != "?":
    dp[0][int(s[-1]) % 13] += 1
else:
    for k in range(10):
        dp[0][k % 13] += 1

for i in range(1,len(s)):
    for r in range(13):
        if s[-(i+1)] == "?":
            for k in range(10): 
                dp[i][(k * (10**i) % 13 + r) % 13] += dp[i-1][r]
                
        else:
            dp[i][(int(s[-(i+1)]) * (10**i) % 13 + r) % 13] += dp[i-1][r]
    for r in range(13)    
        dp[i][r]  %= 10**9 + 7
print(dp[len(s)-1][5]%(10**9+7))

Buggy submission (verdict: Runtime Error):
s = input()
dp = [[0 for i in range(13)] for i in range(len(s))]
if s[-1] != "?":
    r_0 = int(s[-1]) % 13
    dp[0][r_0] += 1
else:
    for k in range(10):
        r_0 = k % 13
        dp[0][r] += 1

for i in range(1,len(s)):
    for r in range(13):
        if s[-(i+1)] != "?":
            j = (int(s[-(i+1)]) * (10**i) + r) % 13
            dp[i][j] += dp[i-1][r]
        else:
            for k in range(10):
                j = (k * (10**i) + r) % 13
                dp[i][j] += dp[i-1][r]
print(dp[len(s)-1][5]%(10**9+7))

Buggy submission (verdict: Runtime Error):
s = input()
dp = [[0 for i in range(13)] for i in range(len(s))]
r_0 = int(s[-1]) % 13
dp[0][r_0] = 1

for i in range(1,len(s)):
    for r in range(13):
        if s[-(i+1)] != "?":
            j = (int(s[-(i+1)]) * (10**i) + r) % 13
            dp[i][j] += dp[i-1][r]
        else:
            for k in range(10):
                j = (k * (10**i) + r) % 13
                dp[i][j] += dp[i-1][r]
print(dp[len(s)-1][5]%(10**9+7))

Buggy submission (verdict: Runtime Error):
s = input()
count = 0
k = 0
for i in s:
    if i == "?":
        k += 1
    else:
        break
for i in range(10**(len(s)-k-1), 10**(len(s))):
    if i % 13 == 5:
        flag = True
        i_str = str(i)
        if len(i_str) < len(s):
            i_str = "0" * (len(s) - len(i_str)) + i_str
        for j in range(len(s)):
            if s[j] == "?" or i_str[j] == s[j]:
                continue
            else:
                flag = False
                break
        if flag == True:
            count += 1
print(count % (10**9 + 7))
Problem p02969 (python)

Fixed submission:
a = int(input())
print(3*a**2)

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

for i in range(n-1, n//2 - 1, -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range(n//2 - 1, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)
Problem p02972 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0 #ボールが入ってる箱の数
index = [] #ボールが入ってる番号

for i in range(n-1, -1, -1):
    balls = 0
    j = i
    while j +(i+1) < n:
        j += i + 1
        balls += ball[j]
    
    if a[i] != balls%2:
        ball[i] = 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0 #ボールが入ってる箱の数
index = [] #ボールが入ってる番号

for i in range(n-1, -1, -1):
    balls = 0
    j = i
    while j < n:
        j += i + 1
        balls += ball[j]
    
    if a[i] != balls%2:
        a[i] = 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

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

for i in range(n-1, (n+1)//2 -1, -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range((n+1)//2, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

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

for i in range(n-1, (n+1)//2 +1 , -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range((n+1)//2, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

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

for i in range(n-1, (n-1)//2, -1):
    ball.insert(0, a[i])
for i in range((n-1)//2, -1, -1):
    for j in range(len(ball)):
        if (j+1) % (i+1) == 0:
            s += ball[j]

    s = s % 2
    if a[i] == s:
        ball.insert(0, 0)
    else:
        ball.insert(0, 1)
ans = ""
for i in range(n):
    if ball[i] == 1:
        ans += " " + str(i)
    elif i == 1 and ans == "":
        print("0")
Problem p02994 (python)

Fixed submission:
n,l = map(int,input().split())
apple = [l + i -1 for i in range(1, n+1)]
org = sum(apple)

for i in range(n):
    if i == 0:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[i+1:])
    elif abs(sum(apple[:i]+apple[i+1:]) - org) < dif:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[:i]+apple[i+1:])
print(ans)

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
apple = [l + i -1 for i in range(1, n+1)]
org = sum(apple)
dif = org
for i in range(n):
    if abs(sum(apple[:i]+apple[i+1:]) - org) < dif:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[:i]+apple[i+1:])
print(ans)

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
apple = [l + i -1 for i in range(1, n+1)]
org = sum(apple)
dif = org
for i in range(n):
    if abs(sum(apple[:i]+apple[i+1:]) - org) < dif:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[:i]+apple[i+1:])
print(ans)