Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    count = 1
    for i in range(1, len(p_list)):
        if min(p_list[:i+1]) == p_list[i]:
            count += 1

    print(count)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    count = 1
    tmp_min = p_list[0]
    for i in range(1, len(p_list)):
        tmp_min = min(tmp_min, p_list[i])
        if tmp_min == p_list[i]:
            count += 1

    print(count)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    count = 1
    for i in range(1, len(p_list)):
      flag = True
      for j in range(i):
          if p_list[i] > p_list[j]:
              flag = False
              break

      if flag:
          count += 1

    print(count)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    count = 1
    tmp_min = p_list[0]
    for i in range(1, len(p_list)):
        tmp_min = min(tmp_min, p_list[i])
        if tmp_min == p_list[i]:
            count += 1

    print(count)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
l, r = list(map(int, input().split()))

ans = 2018

for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    if ((i * j) % 2019) < ans:
      ans = (i * j) % 2019

print(ans)


Fixed submission:
import sys

l, r = list(map(int, input().split()))

ans = 2018

for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    if ((i * j) % 2019) < ans:
      ans = (i * j) % 2019
    if ans == 0:
      print(ans)
      sys.exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import scipy.linalg as linalg

n = int(input())
b = [[int(i)] for i in input().split()]

diag = [.5 for i in range(n)]

A = np.diag(diag)
for i in range(n-1):
  A[i][i+1] = .5

A[n-1][0] = .5

invA = np.linalg.pinv(A)
x = np.dot(invA, b)

tmp = [str(int(round(i[0], 0))) for i in x]
print(' '.join(tmp))


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

all_ = sum(a)

x1 = all_ - 2 * (sum([a[i] for i in range(1, n, 2)]))
x = [x1]

for i in range(1, n):
  x_i = 2 * a[i-1] - x[i-1]
  x.append(x_i)

print(' '.join(list(map(str, x))))

Buggy python submission (verdict: Runtime Error):
import numpy as np
import scipy.linalg as linalg

n = int(input())
b = [[int(i)] for i in input().split()]

diag = [.5 for i in range(n)]

A = np.diag(diag)
for i in range(n-1):
  A[i][i+1] = .5

A[n-1][0] = .5

LU = linalg.lu_factor(A)
x = linalg.lu_solve(LU, b)

tmp = [str(int(round(i[0], 0))) for i in x]
print(' '.join(tmp))


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

all_ = sum(a)

x1 = all_ - 2 * (sum([a[i] for i in range(1, n, 2)]))
x = [x1]

for i in range(1, n):
  x_i = 2 * a[i-1] - x[i-1]
  x.append(x_i)

print(' '.join(list(map(str, x))))

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

n = int(input())
b = [[int(i)] for i in input().split()]

diag = [.5 for i in range(n)]

A = np.diag(diag)
for i in range(n-1):
  A[i][i+1] = .5

A[n-1][0] = .5

x = np.linalg.solve(A, b)
tmp = [str(int(round(i[0], 0))) for i in x]
print(' '.join(tmp))


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

all_ = sum(a)

x1 = all_ - 2 * (sum([a[i] for i in range(1, n, 2)]))
x = [x1]

for i in range(1, n):
  x_i = 2 * a[i-1] - x[i-1]
  x.append(x_i)

print(' '.join(list(map(str, x))))

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

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

diag = [.5 for i in range(n)]

A = np.diag(diag)
for i in range(n-1):
  A[i][i+1] = .5

A[n-1][0] = .5

b = []
for i in range(n):
  b.append([a_list[i]])

x = np.linalg.solve(A, b)
tmp = [str(int(i[0])) for i in x]
print(' '.join(tmp))


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

all_ = sum(a)

x1 = all_ - 2 * (sum([a[i] for i in range(1, n, 2)]))
x = [x1]

for i in range(1, n):
  x_i = 2 * a[i-1] - x[i-1]
  x.append(x_i)

print(' '.join(list(map(str, x))))
Buggy python submission (verdict: Runtime Error):
#prep
n = int(input())
m = list(map(int, input().split())) #initial values
asmt = [0]*n
cnt = 0

#assessment 
while True:
    a = list(map(lambda x: x*(1/2)**(cnt+1), m))
    for i in range(n):
        asmt[i] = a[i].is_integer() 
        
    if all(asmt) == False:
        break 
    else: cnt = cnt+1

print(cnt)

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Runtime Error):
info_A = input().split()
info_B = input().split()
T = int(input())
win = ''

A = int(info_A[0]) #A（鬼）の開始位置
V = int(info_A[1]) #A（鬼）の速度
B = int(info_B[0]) #B（逃げる側）の開始位置
W = int(info_B[1]) #B（逃げる側）の速度

# 逃げる側の速度が同じか速ければ追いつけない
if W >= V:
    win = 'B'

else:
# T秒後までに同じ座標にいればAが勝つ
    k = (B-A)/(V-W)
    if k <= T and 0 < k and (k*10)%10 == 0
        win = 'A'

if win == 'A':
    print('YES')
else:
    print('NO')

Fixed submission:
info_A = input().split()
info_B = input().split()
T = int(input())
win = ''

A = int(info_A[0]) #A（鬼）の開始位置
V = int(info_A[1]) #A（鬼）の速度
B = int(info_B[0]) #B（逃げる側）の開始位置
W = int(info_B[1]) #B（逃げる側）の速度

# 逃げる側の速度が同じか速ければ追いつけない
if W >= V:
    win = 'B'

else:
# T秒後までに同じ座標にいればAが勝つ
    k = (B-A)/(V-W)
    if A>B:
        k = -k
    
    if k <= T and 0 < k:
        win = 'A'
    else:
        win = 'B'


if win == 'A':
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
input = raw_input

def isprime(n):
    if n == 1: return True
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

A,B = map(int, input().split(" "))

a = []
for i in range(1,int(math.sqrt(A))+1):
    if A % i == 0:
        a.append(i)
        if i != A / i:
            a.append(A/i)

b = []
for i in range(1,int(math.sqrt(B))+1):
    if B % i == 0:
        b.append(i)
        if i != B / i:
            b.append(B/i)
c = 0
for i in a:
    if i in b and isprime(i):
        c += 1
print(c)


Fixed submission:
import math

input = raw_input

def isprime(n):
    if n == 1: return True
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

A,B = map(int, input().split(" "))

a = []
for i in range(1,int(math.sqrt(A))+1):
    if A % i == 0:
        a.append(i)
        if i != A / i:
            a.append(A/i)

b = []
for i in range(1,int(math.sqrt(B))+1):
    if B % i == 0:
        b.append(i)
        if i != B / i:
            b.append(B/i)
c = 0
for i in a:
    if i in b and isprime(i):
        c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
def lsum(x):
    return A[x[0]] + B[x[1]] + C[x[2]]

def nextlist():
    global lx
    idx = 0
    m = lsum(lx[0])
    for i in range(len(lx)):
        s = lsum(lx[i])
        if m < s:
            m = s
            idx = i
    p = lx.pop(idx)
    wa.append(lsum(p))
    if p[0] > 0:
        if not [p[0]-1, p[1], p[2]] in lx:
            lx.append([p[0]-1, p[1], p[2]])
    if p[1] > 0:
        if not [p[0], p[1]-1, p[2]] in lx:
            lx.append([p[0], p[1]-1, p[2]])
    if p[2] > 0:
        if not [p[0], p[1], p[2]-1] in lx:
            lx.append([p[0], p[1], p[2]-1])

l1 = list(map(int, input().split(" ")))

X,Y,Z,K = l1[0],l1[1],l1[2],l1[3]
A = sorted(list(map(int, input().split(" "))))
B = sorted(list(map(int, input().split(" "))))
C = sorted(list(map(int, input().split(" "))))

wa = []
lx = [[X-1,Y-1,Z-1]]

for i in range(K):
    nextlist()

for l in wa:
    print(l)


Fixed submission:
a=[]
for i in range(5):
    a.append(int(input()))
k = int(input())
for i in range(5):
    for j in range(i+1,5):
        if abs(a[i]-a[j]) > k:
            print(":(")
            exit()
print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
input = raw_input
N,K = map(int, input().strip().split(" "))
H = list(map(int, input().strip().split(" ")))

dp = [[0]*K for i in range(N)]

for i in range(1,N):
    for j in range(1, K+1):
        jj = max(0, i-j)
        dp[i][j-1] = min(dp[jj]) + abs(H[i]-H[jj])
print(min(dp[N-1]))


Fixed submission:
input = raw_input
N,K = map(int, input().strip().split(" "))
H = list(map(int, input().strip().split(" ")))

dp = [[0]*K for i in range(N)]

for i in range(1,N):
    for j in range(1, K+1):
        jj = max(0, i-j)
        dp[i][j-1] = dp[jj][0] + abs(H[i]-H[jj])
    dp[i][0] = min(dp[i])
print(min(dp[N-1]))

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().strip().split(" "))
H = list(map(int, input().strip().split(" ")))

dp = [[0]*K for i in range(N)]

for i in range(1,N):
    for j in range(1, K+1):
        jj = max(0, i-j)
        dp[i][j-1] = min(dp[jj]) + abs(H[i]-H[jj])
print(min(dp[N-1]))


Fixed submission:
input = raw_input
N,K = map(int, input().strip().split(" "))
H = list(map(int, input().strip().split(" ")))

dp = [[0]*K for i in range(N)]

for i in range(1,N):
    for j in range(1, K+1):
        jj = max(0, i-j)
        dp[i][j-1] = dp[jj][0] + abs(H[i]-H[jj])
    dp[i][0] = min(dp[i])
print(min(dp[N-1]))

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().strip().split(" "))
H = list(map(int, input().strip().split(" ")))

dp = [[0]*K for i in range(N)]

for i in range(1,N):
    for j in range(1, K+1):
        jj = max(0, i-j)
        dp[i][j-1] = min(dp[jj]) + abs(H[i]-H[jj])
print(min(dp[N-1]))


Fixed submission:
input = raw_input
N,K = map(int, input().strip().split(" "))
H = list(map(int, input().strip().split(" ")))

dp = [[0]*K for i in range(N)]

for i in range(1,N):
    for j in range(1, K+1):
        jj = max(0, i-j)
        dp[i][j-1] = dp[jj][0] + abs(H[i]-H[jj])
    dp[i][0] = min(dp[i])
print(min(dp[N-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

def chk(x):
    s = "{0:b}".format(x)
    s = s[-1::-1]
    w = 0
    v = 0
    for i in range(len(s)):
        if s[i] == '1':
            w += oj[i][0]
            v += oj[i][1]
    return w,v

ans = 0
for i in range(0, 2**N):
    w,v = chk(i)
    if w <= W and v > ans:
        ans = v
print(ans)


Fixed submission:
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

dp = [[0] * (W+1) for i in range(N)]
for i in range(W+1):
    dp[0][i] = oj[0][1] if oj[0][0] <= i else 0

for i in range(1,N):
    for j in range(W+1):
        if j < oj[i][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-oj[i][0]] + oj[i][1])
print(max(dp[N-1]))

Buggy python submission (verdict: Runtime Error):
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

def chk(x):
    s = f"{x:b}"
    s = s[-1::-1]
    w = 0
    v = 0
    for i in range(len(s)):
        if s[i] == '1':
            w += oj[i][0]
            v += oj[i][1]
    return w,v

ans = 0
for i in range(0, 2**N):
    w,v = chk(i)
    if w <= W and v > ans:
        ans = v
print(ans)


Fixed submission:
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

dp = [[0] * (W+1) for i in range(N)]
for i in range(W+1):
    dp[0][i] = oj[0][1] if oj[0][0] <= i else 0

for i in range(1,N):
    for j in range(W+1):
        if j < oj[i][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-oj[i][0]] + oj[i][1])
print(max(dp[N-1]))

Buggy python submission (verdict: Runtime Error):
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

def chk(x):
    s = f"{x:b}"
    s = s[-1::-1]
    w = 0
    v = 0
    for i in range(len(s)):
        if s[i] == '1':
            w += oj[i][0]
            v += oj[i][1]
    return w,v

ans = 0
for i in range(0, 2**N):
    w,v = chk(i)
    if w <= W and v > ans:
        ans = v
print(ans)


Fixed submission:
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

dp = [[0] * (W+1) for i in range(N)]
for i in range(W+1):
    dp[0][i] = oj[0][1] if oj[0][0] <= i else 0

for i in range(1,N):
    for j in range(W+1):
        if j < oj[i][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-oj[i][0]] + oj[i][1])
print(max(dp[N-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
oj=[]
for i in range(N):
  oj.append(list(map(int,input().split())))
M=100*1001
dp=[10**10]*M
dp[0]=0
for i in range(N):
  for j in range(M,-1,-1):
    if j+oj[i][1]<M:
      k=j+oj[i][1]
      dp[k]=min(dp[k],dp[j]+oj[i][0])
v=0
for i in range(M):
  if dp[i]<=W:v=i
print(v)


Fixed submission:
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

#dp = [0] * (W+1)
M = 100 * 1001
dp = [10**10] * M

dp[oj[0][1]] = oj[0][0]

for i in range(1,N):
    for j in range(M, -1, -1):
        if j + oj[i][1] < M:
            dp[j + oj[i][1]] = min(dp[j + oj[i][1]], dp[j] + oj[i][0])
    dp[oj[i][1]] = min(dp[oj[i][1]], oj[i][0])

v = 0
for i in range(M):
    if dp[i] <= W:
        v = i
print(v)

Buggy python submission (verdict: Runtime Error):
N,W=map(int,input().split())
oj=[]
for i in range(N):
  oj.append(list(map(int,input().split())))
M=100*1001
dp=[10**10]*M
dp[0]=0
for i in range(N):
  for j in range(M,-1,-1):
    if j+oj[i][1]<M:
      k=j+oj[i][1]
      dp[k]=min(dp[k,dp[j]+oj[i][0])
v=0
for i in range(M):
  if dp[i]<=W:v=i
print(v)


Fixed submission:
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

#dp = [0] * (W+1)
M = 100 * 1001
dp = [10**10] * M

dp[oj[0][1]] = oj[0][0]

for i in range(1,N):
    for j in range(M, -1, -1):
        if j + oj[i][1] < M:
            dp[j + oj[i][1]] = min(dp[j + oj[i][1]], dp[j] + oj[i][0])
    dp[oj[i][1]] = min(dp[oj[i][1]], oj[i][0])

v = 0
for i in range(M):
    if dp[i] <= W:
        v = i
print(v)

Buggy python submission (verdict: Runtime Error):
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

dp = [0] * (W+1)
for i in range(W+1):
    dp[i] = oj[0][1] if oj[0][0] <= i else 0

for i in range(1,N):
    for j in range(W,-1,-1):
        if j < oj[i][0]:
            dp[j] = dp[j]
        else:
            dp[j] = max(dp[j], dp[j-oj[i][0]] + oj[i][1])
print(max(dp))


Fixed submission:
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

#dp = [0] * (W+1)
M = 100 * 1001
dp = [10**10] * M

dp[oj[0][1]] = oj[0][0]

for i in range(1,N):
    for j in range(M, -1, -1):
        if j + oj[i][1] < M:
            dp[j + oj[i][1]] = min(dp[j + oj[i][1]], dp[j] + oj[i][0])
    dp[oj[i][1]] = min(dp[oj[i][1]], oj[i][0])

v = 0
for i in range(M):
    if dp[i] <= W:
        v = i
print(v)
Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
t = input().strip()

NS = len(s)
NT = len(t)

dp = [[0] * (NT+2) for i in range(NS+2)]
dp2 = [[""] * (NT+2) for i in range(NS+2)]

for i in range(1,NS+1):
    for j in range(1,NT+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1])
            if dp[i-1][j-1]+1 > dp[i-1][j] and dp[i-1][j-1]+1 > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j-1] + s[i-1]
            elif dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
            if dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
print(dp2[NS][NT])


Fixed submission:
input = raw_input
s = input().strip()
t = input().strip()

NS = len(s)
NT = len(t)

dp = [[0] * (NT+2) for i in range(NS+2)]
dp2 = [[""] * (NT+2) for i in range(NS+2)]

for i in range(1,NS+1):
    for j in range(1,NT+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1])
            if dp[i-1][j-1]+1 > dp[i-1][j] and dp[i-1][j-1]+1 > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j-1] + s[i-1]
            elif dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
            if dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
print(dp2[NS][NT])
Buggy python submission (verdict: Runtime Error):
import fileinput
 
lines = list(fileinput.input())
 
for x in lines():
	print(x[:3])

Fixed submission:
import fileinput
 
lines = list(fileinput.input())
 
for x in lines:
	print(x[:3])

Buggy python submission (verdict: Runtime Error):
import fileinput
 
lines = list(fileinput.input())
 
for x in lines():
	print(x[-3:])

Fixed submission:
import fileinput
 
lines = list(fileinput.input())
 
for x in lines:
	print(x[:3])

Buggy python submission (verdict: Runtime Error):
import sys
from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
if K > 41:
    print(*([N]*N))
else:
    for _ in range(K):
        imos = [0] * N
        ruiseki = [0] * (N+1)
        for i, ai in enumerate(current_arr):
            imos[max([0, i-ai])] += 1
            if i+ai+1 < N:
                imos[i+ai+1] -= 1
        for j, im in enumerate(imos):
            ruiseki[j+1] = ruiseki[j] + im
        current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
    print(*current_arr)


Fixed submission:
S = input()
print(S[:3])
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = [int(x) for x in input().split()]
a = [K]*N
for _ in range(Q):
    ai = int(input())
    for i,aa in enumerate(a):
        if i != ai-1:
            a[i] -= 1

for aa in a:
    if aa > 0:
        print('Yes')
    else:
        print('No')


Fixed submission:
N,K,Q = [int(x) for x in input().split()]
AI = [0]*N
for _ in range(Q):
    ai = int(input())
    AI[ai-1] += 1
sum_a = sum(AI)

for ai in AI:
    if sum_a - ai >= K:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N,M = [ int(x) for x in input().split()]

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

allaw = 1
result = 0
for _ in range(M, 0, -1):
    memo = []
    for i, x in enumerate(array):
        limit, reward = x
        if limit <= allaw:
            memo.append([i, reward])
    if memo:
        m = -1
        mi = None
        for i, r in memo:
            if r > m:
                m = r
                mi = i
        result += m
        array.pop(mi)
    allaw += 1
print(result)


Fixed submission:
import heapq
N,M = [ int(x) for x in input().split()]

AB = [ list(map(int, input().split())) for _ in range(N)]
AB.sort()
result = 0
# sort したABを押し上げるindex
i = 0
memo = []
# 制約のきついM-1日後(余裕日数1日)から数える
for x in range(M-1, -1, -1):
    allaw = M - x
    while i < N:
        ab = AB[i]
        limit, reward = ab
        if limit > allaw:
            # AB は sort してあるので、制約を超えたらそれ以上は見ない
            break
        else:
            # 日数制約を満たした仕事は全て heapq に入れられる
            heapq.heappush(memo, -reward)
            i += 1
    if memo:
        # heapq の特性により自動的に最小のもの（-を掛けているので最大のもの）から取り出される
        result += -heapq.heappop(memo)
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0

limit = max(B) + 1

for i in range(N):
  Pb = B.index(min(B))
  if time + A[Pb] <= B[Pb]:
    endflg[Pb] = 1
    B[Pb] = limit
    time = time + A[Pb]
  else:
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")
  

Fixed submission:
S = input()
A = [int(S[0]),int(S[1]),int(S[2]),int(S[3])]

flg = 0
for i in range(len(A) - 1):
  if A[i] == A[i + 1]:
    flg = 1
    break

if flg:
  print("Bad")
else:
  print("Good")

Buggy python submission (verdict: Runtime Error):
def GCD(a,b):
  if a<b:
    tmp = a
    a = b
    b = tmp
 
  r = a % b
  while (r!=0): 
    a = b
    b = r
    r = a % b
  return b


A,B,C,D = map(int,input().split())
A = A - 1
upperC = int(B // C)
upperD = int(B // D)
lowerC = int(A // C)
lowerD = int(A // D)

numC = upperC - lowerC
numD = upperD - lowerD

gcd = GCD(C,D)

lcm = C * D / gcd
upperL = int(B / lcm)
lowerL = int(A / lcm)
numL = upperL - lowerL

print(str(B - A - (numC + numD - numL)))

Fixed submission:
S = input()
A = [int(S[0]),int(S[1]),int(S[2]),int(S[3])]

flg = 0
for i in range(len(A) - 1):
  if A[i] == A[i + 1]:
    flg = 1
    break

if flg:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
N,L = map(int,input().split())
taste = [None for _ in range(N)]
for i in range(N):
  taste[i] = L + i
taste_abs = [abs(taste[i]) for i in range(N)] 
  
p = taste.index(min(taste_abs))
taste[p] = 0
print(str(sum(taste)))

Fixed submission:
N,L = map(int,input().split())
taste = [(L+i) for i in range(N)]
taste_abs = [abs(taste[i]) for i in range(N)] 
p = taste_abs.index(min(taste_abs))
taste[p] = 0
print(str(sum(taste)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0
 
z = zip(B,A)
s = sorted(z)
for i in range(N):
  if time + s[i][1] <= s[i][0]:
    time = time + = s[i][1]
    endflg[i] = 1
  else :
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0
 
z = zip(B,A)
s = sorted(z)
for i in range(N):
  if time + s[i][1] <= s[i][0]:
    time = time +  s[i][1]
    endflg[i] = 1
  else :
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0

limit = max(B) + 1

for i in range(N):
  Pb = B.index(min(B))
  if time + A[Pb] <= B[Pb]:
    endflg[Pb] = 1
    B[Pb] = limit
    time = time + A[Pb]
  else:
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")
  

Fixed submission:
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0
 
z = zip(B,A)
s = sorted(z)
for i in range(N):
  if time + s[i][1] <= s[i][0]:
    time = time +  s[i][1]
    endflg[i] = 1
  else :
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")