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

Fixed submission:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(50):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(42):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(40):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if x == 1:
  ans = 1

print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(40):
  if x < H and x*2 >= H:
    ans = x*2 - 1
    break
  x = x*2

print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
x = 2
for i in range(40):
  if x < H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
    
print(ans)
Problem p02983 (python)

Fixed submission:
tmp = list(map(int,input().split()))
L = tmp[0] % 2019
R = tmp[1] % 2019
l = tmp[0]//2019
r = tmp[1]//2019
if l == r:
  if tmp[1] - tmp[0] > 673:
    print(0)
  else:
    num_list = []
    for i in range(tmp[0],tmp[1]+1,1):
      for k in range(i+1,tmp[1]+1,1):
        num_list.append((i*k) % 2019)
    print(min(num_list))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
tmp = list(map(int,input().split()))
L = tmp[0] % 2019
R = tmp[1] % 2019
l = tmp[0]//2019
r = tmp[1]//2019
if l == r:
  num_list = []
  for i in range(tmp[0],tmp[1]+1,1):
    for k in range(i+1,tmp[1],1):
      num_list.append((i*k) % 2019)
  print(min(num_list))
else:
  print(0)
Problem p02999 (python)

Fixed submission:
X,A = map(int,input().split(' '))
if X < A:
  print('0')
else:
  print('10')

Buggy submission (verdict: Runtime Error):
N,K = input().split(' ')
N = int(N)
K = int(K)
num_list = list(map(int,input().split(' ')))
pivot = 0
ans = 0
while (pivot < len(num_list)):
  flag = 0
  tmp_num = 0
  for i in range(pivot, len(num_list), 1):
    tmp_num += num_list[i]
    if tmp_num >= K:
      ans += (N - i)
      pivot += 1
      break
    elif tmp_num < K and i == len(num_list)-1:
      flag = 1
      break
      
  if flag == 1:
    break
    
for i in range(pivot, len(num_list), 1):
  sum_num = sum(num_list[pivot + 1:])
  if sum_num < K:
    break
  ans += 1
      
print(ans)
Problem p02787 (python)

Fixed submission:
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    amax = max(a for a, b in ab)
    dp = [0] + [0] * (h + amax)
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)
    print(dp[h])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    dp = [0] + [0] * h
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)
    print(dp[h])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    dp = [0] + [0] * h
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)


if __name__ == '__main__':
    main()
Problem p03160 (python)

Fixed submission:
import math

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

dp = list([math.inf for i in range(N)])  # dpテーブル
dp[0] = 0
for i in range(N):
    a = dp[i]
    b = dp[i - 1] + abs(h[i] - h[i - 1])
    if a > b:
        dp[i] = b
    else:
        dp[i] = a
    a = dp[i]
    if i > 1:
        b2 = dp[i - 2] + abs(h[i] - h[i - 2])
        if a > b2:
            dp[i] = b2
        else:
            dp[i] = a

print(dp[N - 1])

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


def recursive(i):
    if i == 0:
        return 0
    res = math.inf
    res = min(res, recursive(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, recursive(i - 2) + abs(h[i] - h[i - 2]))
    return res


print(recursive(N - 1))

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


def recursive(i):
    if i == 0:
        return 0
    res = math.inf
    res = min(res, recursive(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, recursive(i - 2) + abs(h[i] - h[i - 2]))
    return res


print(recursive(N - 1))

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

dp = list([math.inf for i in range(N + 10)])  # dpテーブル


def recursive(i):
    res = math.inf
    if dp[i] < math.inf:
        return dp[i]

    if i == 0:
        return 0
    res = min(res, recursive(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, recursive(i - 2) + abs(h[i] - h[i - 2]))
    dp[i] = res
    return res


print(recursive(N - 1))

Buggy submission (verdict: Runtime Error):
import math
"""再帰的な解(メモ化つき)"""
N = int(input())
h = list(map(int, input().split()))

dp = list([math.inf for i in range(N)])  # dpテーブル


def recursive(i):
    res = math.inf
    if dp[i] < math.inf:
        return dp[i]
    if i == 0:
        return 0
    if i > 0:
        res = min(res, recursive(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, recursive(i - 2) + abs(h[i] - h[i - 2]))
    dp[i] = res
    return res


print(recursive(N - 1))

Buggy submission (verdict: Runtime Error):
import math


"""再帰的な解(メモ化つき)"""
N = int(input())
h = list(map(int, input().split()))

dp = list([math.inf for i in range(N)])  # dpテーブル


def recursive(i):
    if dp[i] < math.inf:
        return dp[i]
    if i == 0:
        return 0

    if i > 0:
        res = math.inf
        res = min(res, recursive(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, recursive(i - 2) + abs(h[i] - h[i - 2]))
    dp[i] = res
    return res


print(recursive(N - 1))

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

dp = list([math.inf for i in range(N)])  # dpテーブル


def recursive(i):
    if dp[i] < math.inf:
        return dp[i]
    if i == 0:
        return 0
    res = math.inf
    res = min(res, recursive(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, recursive(i - 2) + abs(h[i] - h[i - 2]))
    dp[i] = res
    return res


print(recursive(N - 1))
Problem p03161 (python)

Fixed submission:
import math

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [math.inf] * n
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i))
print(dp[n - 1])

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [math.inf] * n
dp[0] = 0
for i in range(1, n):
    for j in range(max(0, i - k), k):
        dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))
print(dp[n - 1])
Problem p03163 (python)

Fixed submission:
def main():
    n, w = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(n)]

    dp = [0] * (w + 1)
    for wi, vi in wv:
        for sum_w in range(w, wi - 1, -1):
            v = dp[sum_w - wi] + vi
            if dp[sum_w] < v:
                dp[sum_w] = v

    print(dp[w])


if __name__ == '__main__':
    main()

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

dp = [0] * (w + 1)
for wi, vi in wv:
    for sum_w in range(w, wi - 1, -1):
        v = dp[sum_w - wi] + vi
        if dp[sum_w] < v:
            dp[sum_w] = vi

print(max(dp[w]))

Buggy submission (verdict: Runtime Error):

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [0] * (w + 1)
for wi, vi in wv:
    for sum_w in range(w, wi - 1, -1):
        v = dp[sum_w - wi] + vi
        if dp[sum_w] < v:
            dp[sum_w] = vi

print(max(dp[w]))
Problem p03493 (python)

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

Buggy submission (verdict: Runtime Error):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = Counter(a)
a = sorted(a.values())
print(sum[a[:len(a) - k]])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = Counter(A)
A = sorted(A.values())
print(sum[A[:len(A) - k]])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split(',')]

is_all_even = True
counter = 0
while True:
    for i, v in enumerate(A):
        if v % 2 == 0:
            A[i] = A[i] // 2
        else:
            is_all_even = False
    if is_all_even:
        counter += 1
    else:
        break
print(counter)

Buggy submission (verdict: Runtime Error):

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

N = int(input())
A = [int(i) for i in input().split(',')]

is_all_even = True
counter = 0
while True:
    for i in range(len(A)):
        if A[i] % 2 == 0:
            A[i] = int(A[i] // 2)
        else:
            is_all_even = False
    if is_all_even:
        counter += 1
    else:
        break
print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split(',')]

is_all_even = True
counter = 0
while True:
    for i in range(len(A)):
        if A[i] % 2 == 0:
            A[i] = int(A[i] / 2)
        else:
            is_all_even = False
    if is_all_even:
        counter += 1
    else:
        break
print(counter)

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

is_all_odd = True
counter = 0
while True:
    for i in range(len(A)):
        if A[i] % 2 == 0:
            A[i] = int(A[i] / 2)
        else:
            is_all_odd = False
    if is_all_odd:
        counter += 1
    else:
        break
print(counter)
Problem p03494 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

is_all_even = True
counter = 0
while True:
    for i, v in enumerate(A):
        if v % 2 == 0:
            A[i] = A[i] // 2
        else:
            is_all_even = False
    if is_all_even:
        counter += 1
    else:
        break
print(counter)

Buggy submission (verdict: Runtime Error):
"""Shift Only
【問題概要】
黒板に N 個の正の整数 A1,…,AN が書かれています。
すぬけ君は，黒板に書かれている整数がすべて偶数であるとき，次の操作を行うことができます。

黒板に書かれている整数すべてを，2 で割ったものに置き換える。
すぬけ君は最大で何回操作を行うことができるかを求めてください。

【制約】

1≤N≤2001≤N≤200
1≤Ai≤1091≤Ai≤109
【数値例】
1)
　N=3
　A=(16,12,24)
"""
N = int(input())
A = list(map(int, input().split(',')))

is_all_odd = True
counter = 0
while True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] / 2
        else:
            is_all_odd = False
    if is_all_odd:
        counter += 1
    else:
        break
print(counter)
Problem p03164 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N, W = map(int, input().rstrip().split())
    item_list = []
    for _ in range(N):
        w, v = map(int, input().rstrip().split())
        item_list.append((w, v))

    # dp[i][v] = i番目まで見て価値vを達成できる最小の重さ
    dp = [[float("inf")] * (100001) for _ in range(N+1)]
    dp[0][0] = 0

    max_value = 0
    for i, item in enumerate(item_list, 1):
        for v in range(100001):
            # もし品物iが入れられる
            if dp[i-1][v] + item[0] <= W:
                dp[i][v+item[1]] = min(dp[i][v+item[1]], dp[i-1][v]+item[0])
                max_value = max(max_value, v+item[1])
            # 入れないパターン
            dp[i][v] = min(dp[i][v], dp[i-1][v])
    print(max_value)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N, W = map(int, input().rstrip().split())
    item_list = []
    for _ in range(N):
        w, v = map(int, input().rstrip().split())
        item_list.append((w, v))

    # dp[i][v] = i番目まで見て価値vを達成できる最小の重さ
    dp = [[float("inf")] * (10001) for _ in range(N+1)]
    dp[0][0] = 0

    max_value = 0
    for i, item in enumerate(item_list, 1):
        for v in range(10001):
            # もし品物iが入れられる
            if dp[i-1][v] + item[0] <= W:
                dp[i][v+item[1]] = min(dp[i][v+item[1]], dp[i-1][v]+item[0])
                max_value = max(max_value, v+item[1])
            # 入れないパターン
            dp[i][v] = min(dp[i][v], dp[i-1][v])
    print(max_value)

if __name__ == '__main__':
    main()
Problem p03289 (python)

Fixed submission:
inp = input()
count = 0
index = 0
for i in range(len(inp[2:-1])):
  if inp[2:-1][i] == "C":
      count += 1
      index = i
if inp[0] == "A" and count == 1 and (inp[1:2+index]+inp[3+index:]).islower():
  print("AC")
else: 
  print("WA")

Buggy submission (verdict: Runtime Error):
inp = input()
remain = inp[1:-2] + inp[-1]
if inp[0] == "A" && inp[-2] == "C":
  if remain.islower():
    return "AC"
return "WC"
Problem p03078 (python)

Fixed submission:
import sys

input = sys.stdin.readline

X, Y, Z, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
AB = []
ABC = []

for a in A:
    for b in B:
        AB.append(a+b)

AB.sort(reverse=True)
for i in range(min(len(AB), 3000)):
    for c in C:
        ABC.append(AB[i]+c)
        
ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

Buggy submission (verdict: Runtime Error):
import sys
import heapq

input = sys.stdin.readline

X, Y, Z, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

q = [[(A[0]+B[0]+C[0])*(-1),0,0,0]]
heapq.heapify(q)
count = 0
x, y, z = 0, 0, 0
alr = [[1,1,1]]

while count < K:
    poped = heapq.heappop(q)
    ans = poped[0]*(-1)
    print(ans)
    i, j, k = poped[1], poped[2], poped[3]
    if i+1 < X and not [i+1,j,k] in alr:
        heapq.heappush(q, [(A[i+1]+B[j]+C[k])*(-1), i+1, j, k])
        alr.append([i+1,j,k])
    if j+1 < Y and not [i,j+1,k] in alr:
        heapq.heappush(q, [(A[i]+B[j+1]+C[k])*(-1), i, j+1, k])
        alr.append([i,j+1,k])
    if k+1 < Z and not [i,j,k+1] in alr:
        heapq.heappush(q, [(A[i]+B[j]+C[k+1])*(-1), i, j, k+1])
        alr.append([i,j,k+1])
    count += 1
Problem p03131 (python)

Fixed submission:
k, a, b = map(int,input().split())

if a >= b:
    print(1+k)
else:
    p1 = [1,1]
    p2 = [b-a,2]
    proc = [p1,p2]
    proc.sort(key=lambda x:x[0]/x[1])
    proc.reverse()
    if proc[0] == p1:
        print(1+k)
    elif proc[0] == p2:
        if a-1 > k:
            print(1+k)
        else:
            print(a+((k-a+1)//2)*(b-a)+(k-a+1)%2)

Buggy submission (verdict: Runtime Error):
4 2 6
Problem p03161 (python)

Fixed submission:
import numpy as np

n, k = map(int, input().split())
h = np.array([0] + list(map(int, input().split()))) # index調整
dp = np.zeros(n+1,dtype=np.int)

for i in range(2,n+1):
    start = 1 if i - k < 1 else i - k
    dp[i] = min((dp[start:i]+np.abs(h[i]-h[start:i])))            
print(dp[n])

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

n, k = map(int, input().split())
h = np.array([0] + list(map(int, input().split()))) # index調整
dp = np.zeros(n+1,dtype=np.int)

for i in range(2,n+1):
    start = max(1,i-k)
    dp[i] = min((dp[start:i]+np.abs(h[i]-h[start:i]))            
print(dp[n])
Problem p03195 (python)

Fixed submission:
N = int(input())
all1 = True
goukei = 0
existodd = False
for i in range(N):
    tmp = int(input())
    if tmp != 1:
        all1 = False
    if tmp % 2 == 1:
        existodd = True
    goukei += tmp
    
    
if(goukei%2==1 or all1 or existodd):
    print("first")
else:
    print("second")

Buggy submission (verdict: Runtime Error):
N = int(input())
all1 = True
goukei = 0
existodd = False
for i in range(N):
    tmp = int(input())
    if tmp != 1:
        all1 = False
    if tmo % 2 == 1:
        existodd = True
    goukei += tmp
    
    
if(goukei%2==1 or all1 or existodd):
    print("first")
else:
    print("second")
Problem p03240 (python)

Fixed submission:
import numpy as np
n = int(input())
origin = []
modified = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    origin.append([tx, ty, th])
    if th != 0:
        modified.append([tx, ty, th])
origin = np.array(origin).T
modified = np.array(modified).T
for cx in range(0,101):
    for cy in range(0,101):
        tmp = modified[2] + np.abs(modified[0] - cx) + np.abs(modified[1] - cy)
        if np.max(tmp) == np.min(tmp):
            height = np.max(tmp)
            # print("cx = ", cx, "cy = ", cy, "height =", height)
            # print(origin[0])
            # print(origin[1])
            # print(origin[2])
            # print(np.maximum(height - np.abs(origin[0] - cx) - np.abs(origin[1] - cy), np.zeros(origin[0].size)))
            if (origin[2] == np.maximum(height - np.abs(origin[0] - cx) - np.abs(origin[1] - cy), np.zeros(origin[0].size))).all():
                print(cx, cy, height)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
x = []
y = []
h = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    if th != 0:
        x.append(tx)
        y.append(ty)
        h.append(th)
x = np.array(x)
y = np.array(y)
h = np.array(h)
else:
    for cx in range(0,101):
        for cy in range(0,101):
            tmp = h + np.abs(x - cx) + np.abs(y - cy)
            if np.max(tmp) == np.min(tmp):
                print(cx, cy, np.max(tmp))
Problem p03262 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

n, x = map(int, input().split())
xlist = list(map(int, input().split()))
for i in range(n):
    xlist[i] = abs(xlist[i]-x)
    
if len(xlist)==1:
    print(xlist[0])
else:
    maxgcd = gcd(xlist[0], xlist[1])
    for i in range(2,n):
        maxgcd = gcd(maxgcd, xlist[i])
    print(maxgcd)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

n, x = map(int, input().split())
xlist = list(map(int, input().split()))
for i in range(n):
    xlist[i] = abs(xlist[i]-x)
    
if len(xlist)==1:
    print(xlist[0])
else:
    maxgcd = gcd(xlist[0], xlist[1])
    for i in range(2,n):
        maxgcd = gcd(maxgcd, xlist[i])
    
    
print(maxgcd)

Buggy submission (verdict: Runtime Error):
import math
import functools

n, x = map(int, input().split())
xlist = list(map(int, input().split()))
for i in range(n):
    xlist[i] = abs(xlist[i]-x)
    
gcd = functools.reduce(math.gcd, xlist)
    
print(gcd)
Problem p03263 (python)

Fixed submission:
h, w = map(int,input().split())
grid = [list(map(int,input().split())) for i in range(h)]
out = []
for i in range(h):
    for j in range(w):
        ii, ij, nii, nij = 0, 0, 0, 0
        ii = i
        ij = j if i%2==0 else w-1-j
        if (i%2==0 and ij==w-1) or (i%2==1 and ij==0): nii = i+1
        else: nii = i
        if i%2==0 and ij<w-1: nij = ij+1
        elif i%2==1 and ij>0: nij = ij-1
        else: nij = ij
        if grid[ii][ij]%2==1 and nii<h:
            grid[ii][ij] -= 1
            grid[nii][nij] += 1
            out.append([ii+1,ij+1,nii+1,nij+1])
print(len(out))
for i in out:
    print(i[0],i[1],i[2],i[3])

Buggy submission (verdict: Runtime Error):
h, w = map(int,input().split())
grid = [list(map(int,input().split())) for i in range(h)]
out = []
for i in range(h):
    for j in range(w):
        ii, ij, nii, nij = 0, 0, 0, 0
        ii = i
        ij = j if i%2==0 else w-1-j
        if (i%2==0 and ij==w-1) or (i%2==1 and ij==0): nii = i+1
        else: nii = i
        if i%2==0 and ij<w-1: nij = ij+1
        elif i%2==1 and ij>0: nij = ij-1
        else: nij = ij
        if grid[ii][ij]%2==1 and nii<w:
            grid[ii][ij] -= 1
            grid[nii][nij] += 1
            out.append([ii+1,ij+1,nii+1,nij+1])
print(len(out))
for i in out:
    print(i[0],i[1],i[2],i[3])

Buggy submission (verdict: Runtime Error):
h, w = map(int,input().split())
grid = [list(map(int,input().split())) for i in range(h)]
for i in range(h):
    for j in range(w):
        ii, ij, nii, nij = 0, 0, 0, 0
        ii = i
        ij = j if i%2==0 else w-1-j
        if (i%2==0 and ij==w-1) or (i%2==1 and ij==0): nii = i+1
        else: nii = i
        if i%2==0 and ij<w-1: nij = ij+1
        elif i%2==1 and ij>0: nij = ij-1
        else: nij = ij
        if grid[ii][ij]%2==1 and nii<w:
            grid[ii][ij] -= 1
            grid[nii][nij] += 1
            print(ii+1,ij+1,nii+1,nij+1)
Problem p03282 (python)

Fixed submission:

s = input()
k = int(input())

slist = list(s)
i = 0
count = 0
while slist[i] == "1":
    count += 1
    i += 1
    if i >= len(slist):
        break
    
if count >= k:
    print(1)
else:
    print(slist[i])

Buggy submission (verdict: Runtime Error):

s = input()
k = int(input())

slist = list(s)
i = 0
count = 0
while slist[i] == "1":
    count += 1
    i += 1
    
if count >= k:
    print(1)
else:
    print(slist[i])
Problem p03340 (python)

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

f = [i for i in range(N)]
left, right = 0, 0
ans = 0
nowxor = 0
nowsum = 0
for left in range(N):
    while right < N and nowxor ^ A[right] == nowsum + A[right]:
        nowsum += A[right]
        nowxor = nowxor ^ A[right]
        right += 1
    ans += right - left
    if left == right:
        right += 1
    else:
        nowsum -= A[left]
        nowxor = nowxor ^ A[left]
print(ans)

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

f = [i for i in range(N)]
left, right = 0, 0
nowxor = A[0]
nowsum = A[0]
while True:
    if right+1 < N:
        if nowxor ^ A[right+1] == nowsum + A[right+1]:
            nowxor = nowxor ^ A[right+1]
            nowsum = nowsum + A[right+1]
            right += 1
        else:
            if left == right:
                nowxor = A[left+1]
                nowsum = A[left+1]
                left, right = left+1, right+1
            else:
                nowxor = nowxor ^ A[left]
                nowsum = nowsum - A[left]
                left += 1
    else:
        nowxor = nowxor ^ A[left]
        nowsum = nowsum - A[left]
        left += 1
    f[left] = right
    if left == N-1 and right == N-1:
        break
ans = 0
for i in range(N):
    ans += f[i]-i+1
print(ans)
Problem p03407 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A+B >= C:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A+B >= C:
  print('Yes')
else:
  print('No)