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

Fixed submission:
import re
# 盤面の状態
s = input()

# Aマッチする数を数える
w = re.findall(r'[W]+', s)
# Bにマッチする数を数える
b= re.findall(r'[B]+', s)

# 全部Wなら入れ替える必要なし
if s.count("W") == len(s):
    print(0)
else:
    print(len(w)+len(b)-1)

Buggy submission (verdict: Runtime Error):
import re
# 盤面の状態
s = input()

cnt = 0

while True:
    print(s)
    
    # 全部Wになるまで or 1文字残しまで繰り返す
    if s.count("W") == len(s):
        break

    # Bがどちらにあるか調べる
    if s[0] != "B":
        # 逆向きにする
        s = s[::-1]
        
    # 先頭を置換する
    if s[0] == "B":
        s = re.sub(r'[B]+', "", s,1)
        cnt +=1
    elif s[0] == "W":
        s = re.sub(r'[W]+', "", s,1)
        cnt +=1

print(cnt)

Buggy submission (verdict: Runtime Error):
import re
# 盤面の状態
s = input()

cnt = 0

while True:
    print(s)
    
    # 全部Wになるまで or 1文字残しまで繰り返す
    if s.count("W") == len(s):
        break

    # Bがどちらにあるか調べる
    if s[len(s)-1] == "B":
        # 逆向きにする
        s = s[::-1]
        
    # 先頭を置換する
    if s[0] == "B":
        s = re.sub(r'[B]+', "", s,1)
        cnt +=1
    elif s[0] == "W":
        s = re.sub(r'[W]+', "", s,1)
        cnt +=1

print(cnt)

Buggy submission (verdict: Runtime Error):
import re
# 盤面の状態
s = input()

cnt = 0

while True:
    print(s)
    
    # 全部Wになるまで or 1文字残しまで繰り返す
    if s.count("W") == len(s):
        break

    # Bがどちらにあるか調べる
    if s[len(s)-1] == "B":
        # 逆向きにする
        s = s[::-1]
    else:
        # Bが末尾に見つからなければ、何もしない
        pass
        
    # 先頭を置換する
    if s[0] == "B":
        s = re.sub(r'[B]+', "", s,1)
        cnt +=1
    elif s[0] == "W":
        s = re.sub(r'[W]+', "", s,1)
        cnt +=1

print(cnt)

Buggy submission (verdict: Runtime Error):
import re
# 盤面の状態
s = input()

cnt = 0

while True:
    # 全部Wになるまで or 1文字残しまで繰り返す
    if s.count("W") == len(s) or len(s)==1:
        break
    else:
        print(s)

    # 先頭を置換する
    if s[0] == "W":
        s = re.sub(r'[W]+', "", s,1)
        cnt +=1
    elif s[0] == "B":
        s = re.sub(r'[B]+', "", s,1)
        cnt +=1

print(cnt)
Problem p04031 (python)

Fixed submission:
import sys

# N個の整数
N = int(input())

a = list(map(int, input().split()))

ans = 10**18
# 最小値から最大値の間の値のどれに書き換えるかをループで調べる
for i in range(min(a),max(a)+1):
    tmp=0
    # 試しに入れ替えてみる
    for j in range(N): 
        # 入れ替えたときのコスト計算
        tmp += (a[j]-i)**2
    # 最小値を記録する
    ans=min(ans,tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

# N個の整数
N = int(input())

a = list(map(int, input().split()))

ans = 10**18
# いくつに書き換えるか
for i in range(min(a),max(a)):
    tmp=0
    for j in range(N):    
        # 書き換える or 書き換えない
        tmp += (a[j]-i)**2
    ans=min(cost,tmp)

print(ans)
Problem p04032 (python)

Fixed submission:
import sys
s = input()

# ２文字だった時の判定
if len(s) == 2:
    if s[0] == s[1]:
        print("1 2")
    else:
        print("-1 -1")

# 2文字以上の時の判定
else:
    # 比較
    for i in range(len(s) - 2):
        # ３文字比較すれば、アンバランスかわかる
        # 3文字全部ばらばらならOK
        # 1:2に別れたらアンバランス
        t = s[i:i + 3]
        # tの中で、１文字目の出現回数が１より上、もしくは、2文字目の出現回数が1より上
        # ２文字出た時点でアンバランス
        if t.count(t[0]) > 1 or t.count(t[1]) > 1:
            print(i + 1, i + 3)
            sys.exit()

    print("-1 -1")

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

# ２文字だった時の判定
if len(s) == 2:
    if s[0] == s[1]:
        print("1 2")
    else:
        print("-1 -1")

# 2文字以上の時の判定
else:
    # 比較
    for i in range(len(s) - 2):
        # ３文字比較すれば、アンバランスかわかる
        # 3文字全部ばらばらならOK
        # 1:2に別れたらアンバランス
        t = s[i:i + 3]
        # tの中で、１文字目の出現回数が１より上、もしくは、2文字目の出現回数が1より上
        # ２文字出た時点でアンバランス
        if t.count(t[0]) > 1 or t.count(t[1]) > 1:
            exit()

    print("-1 -1")
Problem p03000 (python)

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

pos = 0
cnt = 1

for l in L:
    pos += l
    if pos <= X:
        cnt += 1
    else:
        break
print(cnt)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = 0
i = 0
count = 0
while D<=X:
    count += 1
    D += L[i]
    i += 1
print(count)
Problem p02811 (python)

Fixed submission:
K,X=map(int,input().split())
if 500*K>=X:
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
n=input()
s=input()

print(s.count("ABC"))

Buggy submission (verdict: Runtime Error):
K,X=map(int,input().split())
if 500*K>=X:
	print("Yes")
  else:
  	print("No")

Buggy submission (verdict: Runtime Error):
K,X=map(int,input().split())
if 500*K>=X
	print("Yes")
  else
  	print("No")
Problem p02817 (python)

Fixed submission:
S, T = input().split()
print (T+S)

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

if K>=A + B:
	print ("0 0")
elif K>=A:
	print (str(0) + ' ' + str(B-(K-A)))
else:
  	print (str(A-K) + ' ' +str(B))
Problem p02660 (python)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
import sys     
N = int(input())
if N == 1:
    print(0)
    sys.exit()

fact = factorization(N)
fact_num = []
fact_num2 = []
 

for i in range(len(fact)):
    fact_num.append(fact[i][0])
    fact_num2.append(fact[i][1])

cnt=0

for j in range(max(fact_num2)+1):
    for i in range(len(fact)):
        if N%fact_num[i]==0 and N%(fact_num[i]**(j+1))==0:
            N = N/(fact_num[i]**(j+1))
            cnt+=1

            if N==1:
                print(cnt)
                sys.exit()
print(cnt)

Buggy submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
import sys     
N = int(input())
if N == 1:
    print(0)
    sys.exit()

fact = factorization(N)
fact_num = []
fact_num2 = []
 

for i in range(len(fact)):
    fact_num.append(fact[i][0])
    fact_num2.append(fact[i][1])

cnt=0

for j in range(max(fact_num2)**2):
    for i in range(len(fact)):
        if N%fact_num[i]==0 and N%(fact_num[i]**(j+1))==0:
            N = N/(fact_num[i]**(j+1))
            cnt+=1
            if N==1:
                print(cnt)
                sys.exit()
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys     
N = int(input())
if N == 1:
    print(0)
    sys.exit()
# if isPrime(N)==True:
#     print(0)
fact = factorization(N)
fact_num = []
fact_num2 = []

    
for i in range(len(fact)):
    fact_num.append(fact[i][0])
    fact_num2.append(fact[i][1])

cnt=0

for j in range(1000000):
    for i in range(len(fact)):
        if N%fact_num[i]==0 and N%(fact_num[i]*(j+1))==0:
            N = N/(fact_num[i]*(j+1))
            cnt+=1

print(cnt)

Buggy submission (verdict: Runtime Error):

N = int(input())
fact = factorization(N)
fact_num = []
fact_num2 = []

    
for i in range(len(fact)):
    fact_num.append(fact[i][0])
    fact_num2.append(fact[i][1])

cnt=0

for j in range(1000000):
    for i in range(len(fact)):
        if N%fact_num[i]==0 and N%(fact_num[i]*(j+1))==0:
            N = N/(fact_num[i]*(j+1))
            cnt+=1

print(cnt)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if S==T[:-1] and len(S)+1==len(T):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = []
cnt = 0
next_town = 0

l = len(a) + 1
for j in range(l):
    if j==0:
        b.append(a[0])
        next_town = a[0]
        continue
    
    b.append(a[next_town - 1])
    next_town = a[next_town -1]
for i in range(l):
    if b.count(i+1)==2:
        k -= b.index(i+1)
        indexes = [p for p, x in enumerate(b) if x == i+1]
        roop_list = b[indexes[0]:indexes[1]]
        roop_num = indexes[1]-indexes[0]
        last = k %roop_num
        

        print(roop_list[last-1])
        sys.exit()

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

A = [1]*A
B = [0]*B
C = [-1]*C

all_data = A+B+C

print(sum(all_data[:K]))

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

A = [1]*A
B = [0]*B
C = [-1]*C

all_data = A+B+C

print(sum(all_data[:K]))
Problem p02700 (python)

Fixed submission:
A,B,C,D = map(int, input().split())
i = 0
while True:
    C -= B
    if C<=0:
        print("Yes")
        break
    if C>0:
        A -= D
        if A<=0:
            print("No")
            break
    i += 1

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

while True:
    C -= B
    if C<=0:
        print("Yes")
        break
    if C>0:
        A -= D
        if A<=0:
            print("No")
            break
    i += 1
Problem p02733 (python)

Fixed submission:
# https://atcoder.jp/contests/abc159/tasks/abc159_e
import sys

ans = sys.maxsize
H, W, K = map(int, input().split())
s = [input() for _ in range(H)]

for h in range(1 << (H - 1)):
    g = 0
    ids = [-1 for _ in range(H)]
    for i in range(H):
        ids[i] = g
        if (h >> i) & 1:
            g += 1

    g += 1
    c = [[0 for _ in range(W)] for _ in range(g)]
    for i in range(H):
        for j in range(W):
            c[ids[i]][j] = c[ids[i]][j] + (s[i][j] == '1')

    num = g - 1
    now = [0 for _ in range(g)]


    def add(j):
        for i in range(g):
            now[i] += c[i][j]

        for i in range(g):
            if now[i] > K:
                return False

        return True

    if num >= ans:
        continue

    for j in range(W):
        if not add(j):
            num += 1
            if num >= ans:
                continue
            now = [0 for _ in range(g)]
            if not add(j):
                num = sys.maxsize
                break

    ans = min(ans, num)

print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc159/tasks/abc159_e
import sys

ans = sys.maxsize
H, W, K = map(int, input().split())
s = [input() for _ in range(H)]

for h in range(1 << (H - 1)):
    g = 0
    ids = [-1 for _ in range(H)]
    for i in range(H):
        ids[i] = g
        if (h >> i) & 1:
            g += 1

    g += 1
    c = [[[0] * W] for _ in range(g)]
    for i in range(H):
        for j in range(W):
            c[ids[i]][j] = c[ids[i]][j] + (s[i][j] == '1')

    num = g - 1
    now = [0 for _ in range(g)]


    def add(j):
        for i in range(g):
            now[i] += c[i][j]

        for i in range(g):
            if now[i] > K:
                return False

        return True


    if num >= ans:
        continue

    for j in range(W):
        if not add(j):
            num += 1
            if num >= ans:
                continue
            now = [0 for _ in range(g)]
            if not add(j):
                num = sys.maxsize
                break

    ans = min(ans, num)

print(ans)
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().strip().split())
s_list = [input() for _ in range(n)]
s_list.sort()
 
for s in s_list:
    print(s, end='')
print()

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

s_list = [input() for _ in range(N)]
s_list.sort()

for ele in s_list: 
    print(ele, end = '')

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

s_list = [input() for _ in range(N)]

for ele in sorted(s_list): 
    print(ele, end = '')

Buggy submission (verdict: Runtime Error):
N   =   int(input())
L   =   int(input())
a   =   []
for i in range(N):
    a.append(input())
for ele in sorted(a): 
    print(ele, end = '')
Problem p02658 (python)

Fixed submission:
import numpy as np
N = int(input())
A = list(input().split())

Af =  np.array(A,dtype='float64')
Afans = np.prod(Af,dtype='float64')

if Afans == 0.:
    print('0')
elif Afans >=2e18:
    print('-1')
else:
    Ai =  np.array(A,dtype='int64')
    Aians = np.prod(Ai,dtype='int64')
    if Aians <=np.int64(1e18) and Aians >=np.int64(0):
        print(Aians)
    else:
        print("-1")

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(input().split())
B = np.array(A,dtype='float64')
B = np.max(B)
if B>=2e18 :
    print("-1")
else:
    A=np.array(A,dtype='int64')
    ans=np.prod(A,dtype='int64')
    if ans >=np.int64(1e18) : flg = 1
    if ans<=np.int64(0)  : flg = 1
    if flg ==1:
        print(ans)
    else:
        print("-1")
Problem p02813 (python)

Fixed submission:
import math

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
per = math.factorial(n - 1)
r = 0
r2 = 0
for k in range(1, n)[::-1]:
    t = p[0]
    c = sum([t > x for x in p])
    r += per * c
    p.remove(t)
    t = q[0]
    c = sum([t > x for x in q])
    r2 += per * c
    q.remove(t)
    per = int(per / k)

print(int(abs(r - r2)))

Buggy submission (verdict: Runtime Error):
from scipy.special import perm

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
per = perm(n - 1, n - 1, exact=True)
r = 0
r2 = 0
for k in range(1, n)[::-1]:
    t = p[0]
    c = sum([t > x for x in p])
    r += per * c
    p.remove(t)
    t = q[0]
    c = sum([t > x for x in q])
    r2 += per * c
    q.remove(t)
    per = int(per / k)

print(int(abs(r - r2)))
Problem p03067 (python)

Fixed submission:
a, b, c = map(int, input().split())
if (a <= c and c <= b) or (a >= c and c >= b):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
a = 0
f = 0
for i in range(n-1):
    if s[i] == '#' and s[i + 1] =='.':
        a += 1
        f = 1
    if s[i] == '.' and s[i + 1] == '.' and f == 1:
        a += 1
    if s[i] == '.' and s[i + 1] == '#':
        f = 0
print(a)
Problem p03846 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
if n % 2 == 0:
    l = n ** 2
else:
    l = (n - 1) * (n + 1)
if sum(A) == l // 2:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
A = map(int, input().split())
c = collections.Counter(A)
if n % 2 == 0:
    for k, v in c.items():
        if v % 2 != 0:
            print(0)
            break
    else:
        print(int((2 ** (n / 2)) % (10 ** 9 + 7)))
else:
    if c[0] != 1:
        print(0)
    else:
        for k, v in c.items():
            if v % 2 != 0 and k != 0:
                print(0)
                break
        else:
            print(int((2 ** ((n - 1) / 2)) % (10 ** 9 + 7)))

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
A = map(int, input().split())
c = collections.Counter(A)
if n % 2 == 0:
    for k, v in c.items():
        if v % 2 != 0:
            break
    else:
        print(int((2 ** (n / 2)) % (10 ** 9 + 7)))
else:
    if c[0] != 1:
        print(0)
    else:
        for k, v in c.items():
            if v % 2 != 0 and k != 0:
                print(0)
                break
        else:
            print(int((2 ** ((n - 1) / 2)) % (10 ** 9 + 7)))
Problem p02681 (python)

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
if s == T[:-1]:
    print("Yes")
else:
    print("No")
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = int(input().split())
print(a*b)
Problem p02657 (python)

Fixed submission:
b = [int(x) for x in input().split()]
print(b[0]*b[1])

Buggy submission (verdict: Runtime Error):
a = int(input())
b = [int(x) for x in input().split()]
summ = 1
for i in range(a):
    summ*=b[i]
    if(summ>1000000000000000000):
        summ=-1
        break
print(summ)
Problem p02657 (python)

Fixed submission:
a, b = [*map(int, input().split(" "))]
print(a * b)

Buggy submission (verdict: Runtime Error):
a, b = [*map(input().split(" "), int)]
print(a * b)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

def gcd(*nums):
  return reduce(math.gcd, nums)


input_num = int(input()) + 1
result = 0
for a in range(1, input_num):
  for b in range(1, input_num):
    for c in range(1, input_num):
        result += gcd(a, b, c)

print(result)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
from numba import jit

@jit
def gcd(*nums):
  return reduce(math.gcd, nums)


input_num = int(input()) + 1
result = 0
for a in range(1, input_num):
  for b in range(1, input_num):
    for c in range(1, input_num):
        result += gcd(a, b, c)
print(result)
Problem p02658 (python)

Fixed submission:
n = input()
A = list(map(int,input().split()))
s = 1
A.sort()
for a in A:
  s *= a
  if s > 10**18:
    s = -1
    break
print(s)

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

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

if k > 10**(18):
    print(-1)
else:
    print(int(np.prod(A)))
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = [int(input()) for i in range(2)]

print(a*b)
Problem p02783 (python)

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

if(h%a == 0):
    print(h//a)
else: 
    print(h//a + 1)

Buggy submission (verdict: Runtime Error):
h,n=map(int,input().split())
A = list(map(int,input().split()))
if h >sum(A):
    print('No')
else:
    print('Yes')
Problem p02786 (python)

Fixed submission:
import math 
 
h=int(input())
x =math.floor(math.log(h,2))
print( sum([2**y for y in range(x+1)]))

Buggy submission (verdict: Runtime Error):
import math 
 
h=int(input())
x =math.floor(math.log2(h))
print( sum([2**y for y in range(x+1)]))

Buggy submission (verdict: Runtime Error):
import math 

h=int(input())
x =math.ceil(math.log2(h))
print( sum([2**y for y in range(x+1)]))
Problem p02789 (python)

Fixed submission:
n, m = [int(x) for x in input().split()]

if n==m :
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
P = [int(x) for x in input().split()]

counter = 1
for i in range(1,n):
    if any( x< P[i] for x in  P[0:i] ):
            break
    else:
        counter +=1

print(counter)

Buggy submission (verdict: Runtime Error):
n = int(input())
P = [int(x) for x in input().split()]

counter = 1
for i in range(1,n):
    if [x for x in P[0:i] if P[i]>x ] == []:
        counter +=1

print(counter)
Problem p02993 (python)

Fixed submission:
a,b,c,d = input()
print('Bad' if a==b or b==c or c==d else 'Good')

Buggy submission (verdict: Runtime Error):
a,b,c,d = input()
print('Bad'
Problem p03076 (python)

Fixed submission:
import math
A = [int(input()) for _ in range(5)]
print(sum([math.ceil(i/10)*10 for i in A])  -max([10-i for i in [ (i % 10) for i in A] if i != 0] +[0]))

Buggy submission (verdict: Runtime Error):
import math
A = [int(input()) for _ in range(5)]
print(sum([math.ceil(i/10)*10 for i in A])  -max([10-i for i in [ (i % 10) for i in A] if i != 0]))

Buggy submission (verdict: Runtime Error):
import math
A = [int(input()) for _ in range(5)]
A.sort()
print([(i//10+1)*10 for i in A])
print(sum([math.ceil(i/10)*10 for i in A])  -max([10-i for i in [ (i % 10) for i in A] if i != 0]))

Buggy submission (verdict: Runtime Error):
import numpy as np, math
A = [int(input()) for _ in range(5)]
A.sort()
print([(i//10+1)*10 for i in A])
print(sum([math.ceil(i/10)*10 for i in A])  -max([10-i for i in [ (i % 10) for i in A] if i != 0]))
Problem p03239 (python)

Fixed submission:
n,t = map(int, input().split())
a = []
for i in range(n):
    aa = list(map(int, input().split()))
    a.append(aa)

cost = float(10000)
for a in a:
    if a[1] <= t and a[0] < cost:
        cost = a[0]

if cost == 10000:
    cost = 'TLE'
print(cost)

Buggy submission (verdict: Runtime Error):
n,t = map(int, input().split())
a = []
cost = float(10000)
for i in range(n):
    a,b = list(map(int, input().split()))
    if b <= t:
        cost = min(cost, a)

print('TLE' if cost == 10000 else co
Problem p03447 (python)

Fixed submission:
a,b,c = [int(input()) for _ in range(3) ]
print((a-b)%c)

Buggy submission (verdict: Runtime Error):
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
A, B, C, X = map(int, [input() for i in  range(4)])
counter = 0
numA=min(X//500, A)
for a in range(0,numA+1):
    numB=min((X-500*a)//100,B)
    for b in range(0, numB+1):
        for c in range(0, C+1):
            if (X-500*a-100*b)-50*c==0:
                counter+=1
                print(a,b,c)
print(counter)
Problem p03457 (python)

Fixed submission:
flag = False
n = int(input())
t = [[0,0,0]]
for i in range(n):
    t.append( [int(x) for x in input().split()])
 
for  i in range(n):
    if (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2])) /  (t[i+1][0]-t[i][0]) > 1:
            flag = False
            break
    elif (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))   / ( t[i+1][0]-t[i][0])  == 1:
            flag = True
            continue
    else:
            if not (( t[i+1][0]-t[i][0]) - (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))  )  &1:
                flag = True
                continue
            else:
                flag = False
                break
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
flag = False
n = int(input())
t = [[0,0,0]]
for i in range(n):
    t.append( [int(x) for x in input().split()])
 
for  i in range(n):
    if (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2])) /  (t[i+1][0]-t[i][0]) > 1:
      		flag = False
            break
    elif (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))   / ( t[i+1][0]-t[i][0])  == 1:
            flag = True
            continue
    else:
            if not (( t[i+1][0]-t[i][0]) - (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))  )  &1:
                flag = True
                continue
            else:
              	flag = False
                break
if flag:
    print('Yes')
else:
    print('No')
Problem p03471 (python)

Fixed submission:
n, y = list(map(int,input().split()))
flag = 0
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n - i - j )==y:
            print(i, j, n-i-j)
            flag = 1
            break
    if flag == 1:
        break
        
if flag == 0:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
n, y = list(map(int,input().split()))
flager = 0
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n - i - j )==y:
            print(i, j, n-i-j)
            flag = 1
            break
    if flag == 1:
        break
        
if flag == 0:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
n, y = list(map(int,input().split()))
flager = 0
for i in range(n+1):
    print('i'+str(i))
    for j in range(n-i+1):
        print('j'+str(j))
        
        if 10000*i + 5000*j + 1000*(n - i - j )==y:
            print(i, j, n-i-j)
            flag = 1
            break
    if flag == 1:
        break
        
if flag == 0:
    print(-1,-1,-1)
Problem p03477 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('Right')

Buggy submission (verdict: Runtime Error):
n, a , b = map(int, input().split())
counter=0
for i in range(1, n+1):
    sum1 =  sum(int(x) for x in str(i))
    if(a<=sum1<=b):
        counter+=i
print(counter)