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

Fixed submission:
H, W, D = list(map(int, input().split()))
 
dic = {}
for i in range(H):
    for j,v in enumerate(list(map(int, input().split()))):
        dic[v] = (i,j)
 
Q = int(input())
 
Qs = []
mi = 100000
ma = 1
for i in range(Q):
    l,r = list(map(int, input().split()))
    Qs.append((l,r))
    mi = min(mi, l)
    ma = max(ma, r)
 
S = [0 for i in range(100000)]
acm = 0
pi, pj = dic[mi]
for start in range(1, D+1):
    for i in range(start, ma+1, D):
        x,y = dic[i]
        acm += abs(x-pi) + abs(y-pj)
        S[i] = acm
        pi,pj = x,y

for i in Qs:
    l,r = i
    print(S[r] - S[l])

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

dic = {}
for i in range(H):
    for j,v in enumerate(list(map(int, input().split()))):
        dic[v] = (i,j)

Q = int(input())

Qs = []
mi = 1000000
ma = 1
for i in range(Q):
    l,r = list(map(int, input().split()))
    Qs.append((l,r))
    mi = min(mi, l)
    ma = max(ma, r)

S = [0 for i in range(100000)]
acm = 0
pi, pj = dic[mi]
for i in range(mi, ma+D, D):
    x,y = dic[i]
    acm += abs(x-pi) + abs(y-pj)
    S[i] = acm
    pi,pj = x,y

for i in Qs:
    l,r = i
    print(S[r] - S[l])

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

A = [[0 for i in range(W)] for j in range(H)]
dic = {}
for i in range(H):
    for j,v in enumerate(list(map(int, input().split()))):
        A[i][j] = v
        dic[v] = (i,j)

Q = int(input())

Qs = []
mi = 10000000
ma = 1
for i in range(Q):
    l,r = list(map(int, input().split()))
    Qs.append((l,r))
    mi = min(mi, l)
    ma = max(ma, r)

S = [0 for i in range(100000)]
acm = 0
pi, pj = dic[mi]
for i in range(mi, ma+D, D):
    x,y = dic[i]
    acm += abs(x-pi) + abs(y-pj)
    S[i] = acm
    pi,pj = x,y

for i in Qs:
    l,r = i
    print(S[r] - S[l])
Problem p03329 (python)

Fixed submission:
#! /usr/bin/env python3

import copy
import sys

def solve(n, actions, offset):

    res = 0
    val = 1000000
    if n == 0 or len(actions) == 0:
        return(offset)
    while (val > n):
        val = actions.pop()
    if val == 1:
        return(n + offset)
    while n >= val * 3:
        res += 1
        n -= val
    tmp = 1000000
    i = 0
    while n >= 0:
        tmp = min(tmp, solve(copy.copy(n), copy.copy(actions), copy.copy(i)))
        i += 1
        n -= val
    return(tmp + res + offset)


n = int(input())

res = 0

actions = [1]

for i in range(1, 6 + 1):
    actions.append(6 ** i)
    actions.append(9 ** i)

print(solve(n, actions, 0))

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python3

import copy

def solve(n, actions, offset):

    res = 0
    val = 100000
    if n == 0 or len(actions) == 0:
        return(offset)
    while (val > n):
        val = actions.pop()
    if val == 1:
        return(n + offset)
    while n >= val * 3:
        res += 1
        n -= val
    tmp = 100000
    i = 0
    while n >= 0:
        tmp = min(tmp, solve(copy.copy(n), copy.copy(actions), copy.copy(i)))
        i += 1
        n -= val
    return(tmp + res + offset)


n = int(input())

res = 0

actions = [1]

for i in range(1, 6 + 1):
    actions.append(6 ** i)
    actions.append(9 ** i)

print(solve(n, actions, 0))
Problem p03272 (python)

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

a=(N-i+1)

print(a)

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

a=(N-i+1)

print(a)
Problem p03805 (python)

Fixed submission:
N, M = map(int, input().split())
edgelist = []
for i in range(M):
    edgelist.append(set(map(int, input().split())))

s = [1]
count = 0
L = [[i for i in edgelist if (len(i&set([1]))!=0)]]
while s != []:
    if len(s) == N:
        count = count + 1
        L.pop()
        s.pop()
    elif L[-1] == []:
        L.pop()
        s.pop()
    else:
        p = L[-1].pop()
        r = list(p - set([s[-1]]))
        L.append([i for i in edgelist if (len(i&set(r))!=0)*(len(i&set(s))==0)])
        s.append(r[0])
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
edgelist = []
for i in range(N):
    edgelist.append(set(map(int, input().split())))

s = [1]
count = 0
L = [[i for i in edgelist if (len(i&set([1]))!=0)]]
while s != []:
    if len(s) == M:
        count = count + 1
        L.pop()
        s.pop()
    elif L[-1] == []:
        L.pop()
        s.pop()
    else:
        p = L[-1].pop()
        r = list(p - set([s[-1]]))
        L.append([i for i in edgelist if (len(i&set(r))!=0)*(len(i&set(s))==0)])
        s.append(r[0])
print(count)
Problem p03803 (python)

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

if A  == 1:
  if A < B:
    print('Alice')
  else:
    print('Draw')
elif B == 1:
  if B < A:
    print('Bob')
else:
  if A > B:
    print('Alice')
  elif A == B:
    print('Draw')
  else:
    print('Bob')

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

if A  == 1:
  if A < B:
    print('Alice')
  else:
    print('Draw')
if B == 1:
  if B < A:
    print('Bob')
  else:
    print(Draw)
else:
  if A > B:
    print('Alice')
  elif A == B:
    print('Draw')
  else:
    print('Bob')
Problem p03327 (python)

Fixed submission:
n = int(input())
 
if n > 999:
    print('ABD')
else:
    print('ABC')

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

if n > 999:
    print('ABD)
else:
    print('ABC')
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2=[int(s) for s in input().split()]
(dx,dy)=(x2-x1,y2-y1)
print(x2-dy,y2+dx,x1-dy,y1+dx)

Buggy submission (verdict: Runtime Error):
1,y1,x2,y2=[int(s) for s in input().split()]
(dx,dy)=(x2-x1,y2-y1)
print(x2-dy,y2+dx,x1-dy,y1+dx)
Problem p03272 (python)

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


num = N-i+1
print(num)

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

print(N-i+1)
Problem p03804 (python)

Fixed submission:
import itertools

_N, _M = input().split()
N=int(_N)
M=int(_M)
A=[]
for i in range(0,N):
    A.append(input())
B=[]
for j in range(0,M):
    B.append(input())

ref_tuple = itertools.product(range(0,N-M+1),range(0,N-M+1))
t=False
for ref_row_a, ref_col_a in ref_tuple:
    for row_b, col_b in itertools.product(range(0,M),range(0,M)):
        if not A[ref_row_a+row_b][ref_col_a+col_b]==B[row_b][col_b]:
            break
        if (row_b, col_b)==(M-1,M-1):
            t=True
            break
    if t:
        break

if t:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N, M = input().split()
A=[]
for i in range(0,N):
    A.append(input())
B=[]
for j in range(0,M):
    B.append(input())

ref_tuple = zip(range(0,N-M+1),range(0,N-M+1))
t=False
for ref_row_a, ref_col_a in ref_tuple:
    for row_b, col_b in zip(range(0,M),range(0,M)):
        if not A[ref_row_a+row_b][ref_col_a+col_b]==B[row_b][col_b]:
            break
        if (row_b, col_b)==(M-1,M-1):
            t=True
            break
    if t:
        break

if t:
    print('Yes')
else:
    print('No')
Problem p03805 (python)

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

graph = [ [False] * 8 for _ in range(8) ]
visited = [False] * n

def dfs(a, N, visited):
    finish = True
    for i in range(N):
        if not visited[i]:
            finish = False
    if finish:
        return 1
    ans = 0
    for i in range(N):
        if not graph[a][i] or visited[i]:
            continue
        visited[i] = True
        ans += dfs(i,N,visited)
        visited[i] = False
    return ans

for i in range(m):
    graph[ab[i][0]-1][ab[i][1]-1], graph[ab[i][1]-1][ab[i][0]-1] = True, True

visited[0] = True
print(dfs(0,n,visited))

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

graph = [ [False] * 8 for _ in range(8) ]
visited = [False] * n

def dfs(a, N, visited):
    finish = True
    for i in range(N):
        if not visited[i]:
            finish = False
    if finish:
        return 1
    ans = 0
    for i in range(N):
        if not graph[a][i] or visited[i]:
            continue
        visited[i] = True
        ans += dfs(i,N,visited)
        visited[i] = False

for i in range(m):
    graph[ab[i][0]-1][ab[i][1]-1], graph[ab[i][1]-1][ab[i][0]-1] = True, True

visited[0] = True
print(dfs(0,n,visited))
Problem p03307 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(N * 2)

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

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

print(max(A) - min(A))
Problem p03315 (python)

Fixed submission:
seq = input()
print(seq.count('+') - seq.count('-'))

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

index_of_1 = A.index(1)

if index_of_1 == 0:
    first = 0
else:
    first = math.ceil((index_of_1 + 1) / K)

if index_of_1 == N - 1:
    latter = 0
else:
    latter = math.ceil((N - index_of_1 + 1) / K)

print(first + latter)
Problem p03307 (python)

Fixed submission:
m = int(input())
if m %2 == 1:res = m*2
else:res = m
print(res)

Buggy submission (verdict: Runtime Error):
m = int(input())
a = list( map( int, input().split() ) )
b1 = a[0]
b2 = a[0]
for i in range(m):
  if a[i] > b1:
    b1 = a[i]
  elif a[i] < b2:
    b2 = a[i]
print(b1-b2)
Problem p03317 (python)

Fixed submission:
N,K = map(int, input().split())
print(-(-(N-1)//(K-1)))

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

print(-(-(N-1)//(K-1)))
Problem p03834 (python)

Fixed submission:
s = input().split(',')
s = ' '.join(s)
print(s)

Buggy submission (verdict: Runtime Error):
a,b,c=input().split(,)
print(a+" "+b+" "+c)
Problem p03329 (python)

Fixed submission:
N=int(input())
dp=[float('inf')]*100010
dp[0]=0
base=[1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049]


for i in range(N+1):
    for power in base:
        dp[i]=min(dp[i],dp[i-power]+1)

print(dp[N])

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[float("inf")]*100010
dp[0]=0

for i in range(n+1):
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 6
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 9

print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[float("inf")]*100010
dp[0]=0

for i in range(n):
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 6
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 9

print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[float("inf")]*100000
dp[0]=0

for i in range(n):
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 6
    power = 1
    while power <= n:
        dp[i + power] = min(dp[i + power],dp[i] + 1)
        power *= 9

print(dp[n])
Problem p03272 (python)

Fixed submission:
N,i=input().split()
N=int(N)
i=int(i)
print (N-i+1)

Buggy submission (verdict: Runtime Error):
a
Problem p03272 (python)

Fixed submission:
s=input().split()
N=int(s[0])
i=int(s[1])
j = N - i +1
print(j)

Buggy submission (verdict: Runtime Error):
N=int(input())
i=int(input())
j = N - i +1
print(j)
Problem p03272 (python)

Fixed submission:
N,i= map(int,input().split())
print (N-i+1)

Buggy submission (verdict: Runtime Error):
N= int(input())
i=int(input())
print (i if i==N else N-i+1)
Problem p03315 (python)

Fixed submission:
input_list = list(input())

print(input_list.count("+")-input_list.count("-"))

Buggy submission (verdict: Runtime Error):
input_list = input().split()

print(input_list.count("+")-input_list.cout("-"))
Problem p03272 (python)

Fixed submission:
n, i = map(int, input().split())
print(n-i+1)

Buggy submission (verdict: Runtime Error):
There is an N-car train.

You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
Problem p03803 (python)

Fixed submission:
a, b = input().split()
a, b = int(a), int(b)
if a == 1:
  a += 13
if b == 1:
  b += 13
print("Alice" if a > b else "Draw" if a == b else "Bob")

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a, b = int(a), int(b)
print("Draw" if a == b elif a < b "Bob" else "Alice")
Problem p03307 (python)

Fixed submission:
import math

n = int(input())
if n%2 == 0:
    print(n)
else:
    print(2*n)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
ans = (2*n) // math.gcd(2, n)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
ans = (2*n) // math.gcd(2, n)
print(ans)
Problem p03775 (python)

Fixed submission:
import math


def f(a, b):
    return max(len(str(a)), len(str(b)))


def main():
    n = int(input())

    i = 1
    minv = 100000000000
    while i <= int(math.sqrt(n)):
        if n%i == 0 and f(i, n//i) < minv:
            minv = f(i, n//i)
        i += 1
    print(minv)
    

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>


using namespace std;


long long f(long long a, long long b)
{
  string x=to_string(a), y=to_string(b);
  return max(x.length(), y.length());
}


int main()
{
  long long n, i, minv=100000000000;

  cin >> n;
  i = 1;
  while (i <= (long long)sqrt((long long)n)){
    if (n%i == 0 && f(i, n/i) < minv) minv = f(i, n/i);
    i++;
  }
  cout << minv << endl;
  
  return 0;
}
Problem p03272 (python)

Fixed submission:
l = input().split()
N = int(l[0])
i = int(l[1])
print(N + 1 - i)

Buggy submission (verdict: Runtime Error):
l = raw_input().split()
N = l[0]
i = l[1]
print(N + 1 - i)
Problem p03804 (python)

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

A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
                    break
            if not flag:
                break
        
        if flag:
            print('Yes')
            exit()

print('No')

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

A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
                    break
            if not flag:
                break
        
        if flag:
            print('Yes')
            exit()

print('No')
Problem p03806 (python)

Fixed submission:
INF = float('inf')

def solve():
    N, Ma, Mb = map(int, input().split())
    l = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        l.append((a, b, c))
 
    dp = [[[INF] * 401 for _ in range(401)] for _ in range(N + 1)]
    dp[0][0][0] = 0
    for i in range(len(l)):
        for a in range(len(dp[0])):
            for b in range(len(dp[0][0])):
                if dp[i][a][b] != INF:
                    dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
                    dp[i + 1][a + l[i][0]][b + l[i][1]] = min(dp[i + 1][a + l[i][0]][b + l[i][1]], dp[i][a][b] + l[i][2])
 
    ans = INF
    for i in range(len(dp)):
        for a in range(1, len(dp[0])):
            for b in range(1, len(dp[0][0])):
                if dp[i][a][b] != INF:
                    if Ma * b == Mb * a:
                        ans = min(ans, dp[i][a][b])
 
    print(-1 if ans == INF else ans)
 
 
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    
    INF = float('inf')
    
    N, Ma, Mb = map(int, input().split())
    
    l = []
    for _ in range(N):
        a,b,c = map(int, input().split())
        l.append((a,b,c))
        
    #dp table: dp[i][ca][cb] 
    dp = [[[INF] * 401 for _ in range(401)] for _ in range(N+1)]
    dp[0][0][0] = 0
    
    for i in range(N):
        for ca in range(401):
            for cb in range(401):
                if dp[i][a][b] != INF:
                    dp[i+1][a][b] = min(dp[i][a][b], dp[i+1][a][b]) #薬品iを加えない場合
                    dp[i+1][a+l[i][0]][b+l[i][1]] = min(dp[i+1][a+l[i][0]][b+l[i][1]], dp[i][a][b] + l[i][2]) #薬品iを加える場合
                    
    ans = INF
    for i in range(N):
        for ca in range(401):
            for cb in range(401):
                if dp[i][a][b] != INF:
                    if a * Mb == b * Ma:
                        ans = min(ans, dp[i][a][b])
    
    print(-1 if ans == INF else ans)

if __name__ == '__main'__:
    solve()
Problem p03272 (python)

Fixed submission:
# -*- coding: utf-8 -*-
f, r = map(int, raw_input().split())
print(f - r + 1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 f, r = map(int, raw_input().split())
print(f - r + 1)

Buggy submission (verdict: Runtime Error):
    l = raw_input().split()
    f = int(l[0])
    r = int(l[1])

    a = f-r+1

    print(a)
Problem p03272 (python)

Fixed submission:
n,i=map(int,input().split(" "))
print(n-i+1)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
X=list(map(int,input().split()))
hidari=0
migi=N-1
if N-K!=0:
    for i in range(N-K):
      if abs(X[hidari])>=abs(X[migi]):
        hidari=hidari+1
      else:
        migi=migi-1

if X[hidari]<0 and X[migi]>0:
  if abs(X[hidari])>=abs(X[migi]):
    print(2*abs(X[migi])+abs(X[hidari]))
  else:
    print(2*abs(X[hidari])+abs(X[migi]))
else:
  if abs(X[hidari])>=abs(X[migi]):
    print(abs(X[hidari]))
  else:
    print(abs(X[migi]))
Problem p03272 (python)

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

def findJ(num):
    return n+1-num;

print(findJ(i))

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

def findMedian(nums):
    size=len(nums)
    mIndex = (size*(size+1)//2) + 1
    gap=0
    mValue=0
    while mIndex>0 and gap<size:
        start=0
        end=start+gap
        while end<size and mIndex>0:
            mIndex-=1
            mValue=nums[(start+end+1)//2]
            start+=1
            end+=1
        gap+=1
    return mValue

print(findMedian(nums))
Problem p03286 (python)

Fixed submission:
a=int(input())
sum=0
s=''

if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a=int(input())
sum=0
s=''
'''if a<0:
    b = abs(a)
    if b%2==1:
        b=b+1
        print(str(bin(b))[2:-1]+'1')
    else:
        print(str(bin(b))[2:-1])''
if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)
Problem p03307 (python)

Fixed submission:
n = int(input())

if n % 2 == 0:
  print(n)
else:
  print(2*n)

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

if n % 2 == 0:
  print(n)
else:
  print(2*n)
Problem p03272 (python)

Fixed submission:
def main():
    N, i = list(map(int, input().split(" ")))
    output = solve(N, i)
    print(output)
    return

#________________________________________
#  Solve
#________________________________________
def solve(N, i):
    """
    解答のコード
    """
    return N - i + 1
#________________________________________


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    i = int(input())
    output = solve(N, i)
    print(output)
    return

#________________________________________
#  Solve
#________________________________________
def solve(N, i):
    """
    解答のコード
    """
    return N - i + 1
#________________________________________


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

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
n = int(input())
print(lcm(2,n))

Buggy submission (verdict: Runtime Error):
n = int(input())
an = [int(i) for i in input().split()]
print(sum(an)-n)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n = int(input())
print(lcm(2,n))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
n = int(input())
print(lcm_base(2,n))
Problem p03307 (python)

Fixed submission:
n = int(input())

if n % 2 == 0:
    print(n)
else:
    print(n*2)

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

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

a_d = []
for i in range(1, n+1):
    a_d.append(a[i-1]-i)

d = (list(np.absolute(a_d)))
d.sort()
m = d[int(n/2)]

print(abs(sum(d-m)))

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

a_d = []
for i in range(1, n+1):
    a_d.append(a[i-1]-i)

d = (list(np.absolute(a_d)))
d.sort()
m = d[int(n/2)]

print(abs(sum(d-m)))
Problem p03295 (python)

Fixed submission:
def main():
    n = [int(i) for i in input().split()]
    bridge = set()
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    prefix = 0
    
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge.clear()
            counter += 1
        for j in range(prefix, len(reqs)):
            if reqs[j][0] == i:
                bridge.add(reqs[j][1])
            else:
                prefix = j
                break
    
    print(counter)
 
main()

Buggy submission (verdict: Runtime Error):
def main():
    n = [int(i) for i in input().split()]
    bridge = []
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    prefix = 0
    
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge = []
            counter += 1
        for j in range(len(prefix, reqs)):
            if reqs[j][0] == i:
                bridge.append(reqs[j][1])
            else:
                prefix = j + 1
                break
    
    print(counter)
 
main()
Problem p03631 (python)

Fixed submission:
n = input()
if n[0] == n[2]:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
n = input()
if n == n[::-1]:
	print('Yes')
else:
	print('No')
Problem p03803 (python)

Fixed submission:
a, b = map(int, input().split())
if a == b:
	print('Draw')
elif a == 1:
	print('Alice')
elif b == 1:
	print('Bob')
elif a > b:
	print('Alice')
else:
	print('Bob')

Buggy submission (verdict: Runtime Error):
a, b = map(int(input().split()))
if a == b:
	print('Draw')
elif a == 1:
	print('Alice')
elif b == 1:
	print('Bob')
elif a > b:
	print('Alice')
else:
	print('Bob')
Problem p03307 (python)

Fixed submission:
a = int(input())

if a % 2 == 0:
    print(a)
else:
    print(a*2)

Buggy submission (verdict: Runtime Error):
if a%2 == 0:
    print(a)
else:
    print(a*2)