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

Fixed submission:
n,a=map(int,input().split())
if n>=a:
    print(10)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=1
D=0
for i in range(n):
    if D>x:
        print(count)
        break
    else:
        D=D+L[i]     
        count+=1

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=0
D=0
for i in range(n+1):
    if D>x:
        print(count)
        break
    else:
        D=D+L[i]     
        count+=1
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=1
D=0
for i in L:
    D=D+i
    if D<=x:
        count+=1
    else:
        break
 
print(count)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=0
D=0
for i in range(n+2):
    if D<=x:
        D=D+L[i]     
        count+=1
    else:
        print(count)
        break

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=0
D=0
for i in range(n+1):
    if D<=x:
        D=D+L[i]     
        count+=1
    else:
        print(count)
        break

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=0
D=0
for i in range(n):
    if D>x:
        print(count)
        break
    elif D=0:
        count+=1
        print(count)
        break
    else:
        D=D+L[i]     
        count+=1

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=0
D=0
for i in range(n+1):
    if D>x:
        print(count)
        break
    else:
        D=D+L[i]     
        count+=1

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=0
D=0
for i in range(n+1):
    if D>x:
        print(count)
        break
    else:
        D=D+L[i]     
        count+=1
Problem p03005 (python)

Fixed submission:
n,k=map(int,input().split())
if k==1:
    print(0)
else:
    print(n-k)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
if k=0:
    print(0)
else:
    print(n-k)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
if(k=0){
print(0)
}
print(n-k)
Problem p03448 (python)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
total = 0
cnt = 0
 
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      total = 500*a+100*b+50*c
      if total==X:
        cnt +=1
             
print(cnt)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
X=input()
total = 0
cnt = 0
 
for a in A+1:
  for b in B+1:
    for c in C+1:
      total = 500*a+100*b+50*c
      if total=X:
        cnt +=1
        
        
print(cnt)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
x=input()
total = 0
cnt = 0

for i in a+1:
  for i in b+1:
    for i in c+1:
      total = 500*a+100*b+50*c
      if total=x:
        cnt +=1
        
        
print(cnt)
Problem p03493 (python)

Fixed submission:
s=input()
print(s.count("1"))

Buggy submission (verdict: Runtime Error):
s=input().splitlines()
count = 0
if(s[0]==1):
    count+=1
if(s[1]==1):
    count+=1
if(s[2]==2):
    count+=1

print(count)
Problem p03494 (python)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
cnt = 0

while all(i%2==0 for i in li):
  for i in range(n):
    li[i]/=2
  cnt+=1

print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
li = list(map(int,input().split())
cnt = 0
print(n)
print(li)

while True:
    for i in range(n):
        if li[i]%2 ==0:
            pass
        else:
            break

    for j in range(n):
        li[j]/=2

    cnt += 1

print(cnt)

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

while True:
    for i in range(n):
        if li[i]%2 ==0:
            li[i]=li[i]/2
        else:
            break
        if(i==n-1):
            cnt += 1

print(cnt)
Problem p02795 (python)

Fixed submission:
h = int(input())
w=  int(input())
n = int(input())


sum = 0
if h > w:
    for i in range(h):
        sum = sum + h
        if n <= sum:
            print(int(sum/h))
            break
else:
    for i in range(w):
        sum = sum + w
        if n <= sum:
            print(int(sum/w))
            break

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


sum = 0
if h > w:
    for i in range(h):
        sum = sum + h
        if n <= sum:
            print(int(sum/h))
            break
else
    for i in range(w):
        sum = sum + w
        if n <= sum:
            print(int(sum/w))
            break
Problem p02853 (python)

Fixed submission:
n = input().split(' ')
third = 100000
second = 200000
first = 300000
sum = 0
for i in n:
    if int(i) == 3:
        sum = sum + third
    elif  int(i) == 2:
        sum = sum + second
    elif  int(i) == 1:
        sum = sum + first

if int(n[0]) == 1 and int(n[1]) == 1:
    sum = sum + 400000

print(sum)

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

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + array[i]
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

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

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    return list.index(min(diffList))

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )
Problem p02854 (python)

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

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

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

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    return list.index(min(diffList))

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )
Problem p02717 (python)

Fixed submission:
x,y,z = input().split()

a = z
b = x
c = y

print(str(a)+" "+str(b)+" "+str(c))

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())
z = int(input())

a = z
b = x
c = y

print(str(a)+" "+str(b)+" "+str(c))

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())
z = int(input())

a = z
b = y
c = x

print("%i %i %i" %(a,b,c))

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())
z = int(input())

a = z
b = y
c = x

print("%i %i %i" %(a,b,c))
Problem p02999 (python)

Fixed submission:
# coding: utf-8
# Your code here!

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

if X<A:
    print(0)
    
else:
    print(10)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

W,H,x,y =  list(map(float,input().split()))


if(W%x==0 and H%y==0):
    print (W*H/2,1)

else:
    print (W*H/2,0)
Problem p03289 (python)

Fixed submission:
S = input()

if S[2:-1].count('C') != 1:
  print('WA')
else:
    if S[0] != 'A':
      print('WA')
    else:
        S = list(map(lambda x: x, S))
        S[0] = 'a'
        S[S[2:-1].index('C')+2] = 'c'
        if ''.join(S).islower():
          print('AC')
        else:
          print('WA')

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

if S[2:-2].count('C') != 1:
  print('WA')

if S[0] != 'A':
  print('WA')

S[0] == 'a'
S[S[2:-2].index('C')] == 'c'

if S.islower():
  print('AC')
else:
  print('WA')
Problem p03296 (python)

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

count=0
for i in range(len(l)-1):
    if i == len(l)-2:
        if l[i] == l[i+1]:
            l[i] = l[i]+1
            count=count+1
            break
    if l[i] == l[i+1]:
        if l[i+1]+l[i+2]< 10000:
            l[i+1] = l[i]+l[i+2]
        elif l[i+1] - l[i+2] > 0:
            l[i+1] = l[i]-l[i+2]
        else:
            l[i+1] = l[i]+1
        count=count+1
print(count)

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

count=0
for i in range(len(l)-1):
    if i == len(l)-1:
        break
    if l[i] == l[i+1]:
        if l[i+1]+l[i+2]< 10000:
            l[i+1] = l[i]+l[i+2]
        else:
            l[i+1] = l[i]-l[i+2]
        count=count+1
print(count)
Problem p02765 (python)

Fixed submission:
a, b = input().split()
if int(a) <= 9:
  ans = int(b) + 100 * (10 - int(a))
  print(ans)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
if int(a) =< 9:
  ans = int(b) + 100 * (10 - int(a))
  print(ans)
else:
  print(b)
Problem p02791 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
 
cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, N + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if len(A) < j:
            continue
        if not (A[i] <= A[j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, N + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if not (A[i] <= A[j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)

Buggy submission (verdict: Runtime Error):
fast_list = list(map(int, input().split())) 
correct_answer_count = 0
bat_answer_count = 0
for i in range(1, fast_list[0] + 1):
    for j in range(1, i+1):
        if not (fast_list[1][i] <= fast_list[1][j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)

Buggy submission (verdict: Runtime Error):
fast_list = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, fast_list[0] + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if not (fast_list[1][i] <= fast_list[1][j]):
            bat_answer_count += 1

if bat_answer_count == 0:
    correct_answer_count += 1

print(correct_answer_count)
Problem p02811 (python)

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

Buggy submission (verdict: Runtime Error):
    def twoSum(self, k, x) -> str:        
        if k * 500 >= x:
          return "Yes"
        else:
          return "No"
Problem p03455 (python)

Fixed submission:
a, b= map(int, input().split())
if a*b%2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
print(sum([int(i) for i in input()]))

Buggy submission (verdict: Runtime Error):
a, b= map(int, input().split())
if a*b/2 % 0:
    print("Even")
else:
    print("Odd")
Problem p03493 (python)

Fixed submission:
print(sum([int(i) for i in input()]))

Buggy submission (verdict: Runtime Error):
s1, s2, s3 = map(str, input().split())
list = [s1, s2, s3]
bidama_num = 0
for item in list:
  if item == "1":
    bidama_num += 1
 
print(str(bidama_num))

Buggy submission (verdict: Runtime Error):
s1, s2, s3 = map(int, input().split())
list = [s1, s2, s3]
bidama_num = 0
for item in list:
  if item == 1:
    bidama_num += 1
Problem p02720 (python)

Fixed submission:
from collections import deque

k = int(input())

q = deque()

for i in range(1, 10):
    q.append(i)

for _ in range(k):
    temp = q.popleft()
    if temp % 10 != 0:
        q.append(temp*10+int(str(temp)[-1])-1)
    
    q.append(temp*10+int(str(temp)[-1]))

    if temp % 10 != 9:
        q.append(temp*10+int(str(temp)[-1])+1)

print(temp)

Buggy submission (verdict: Runtime Error):
from collections import deque

k = int(input())

q = deque()

if k > 9:
    for i in range(1, 10):
        q.append(i)

for _ in range(k):
    temp = q.popleft()
    if temp % 10 != 0:
        q.append(temp*10+int(str(temp)[-1])-1)
    
    q.append(temp*10+int(str(temp)[-1]))

    if temp % 10 != 9:
        q.append(temp*10+int(str(temp)[-1])+1)

print(temp)
Problem p02791 (python)

Fixed submission:
n = int(input())
num_list = [int(i) for i in input().split()]

k = 0
for i in range(len(num_list)):
    if i == 0:
        temp_min = num_list[i]
    else:
        temp_min = min(temp_min, num_list[i])
        
    if i != len(num_list)-1:
        if temp_min == num_list[i]:
            k += 1
    else:
        if temp_min == num_list[i]:
            k += 1
    
print(k)

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

k = 0
for i in range(len(num_list)):
  if min(num_list[:i+1]) == num_list[i]:
    k += 1
    
print(k)
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
ps_list = [[i for i in input().split()] for j in range(m)]

ac_list = []
wa_list = [0 for i in range(n)]
num_wa = 0
num_ac = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and wa_list[p-1] != -1:
        ac_list.append(p)
        num_wa += wa_list[p-1]
        num_ac += 1
        wa_list[p-1] = -1
    elif wa_list[p-1] != -1:
        wa_list[p-1] += 1
        
print(num_ac, num_wa)

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

ac_list = []
wa_dict = {}
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC':
        ac_list.append(p)
        num_wa += wa_dict[p]
    elif p not in ac_list:
        if p not in wa_dict.keys():
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
            
num_ac = len(ac_list)
        
print(num_ac, num_wa)

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

ac_list = []
wa_dict = {}
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC':
        ac_list.append(p)
        num_wa += wa_dict[p]
    elif p not in ac_list:
        if p not in wa_dict.keys():
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
         
print(num_ac, num_wa)
Problem p03147 (python)

Fixed submission:
n = int(input())
inp_h = [int(i) for i in input().split()]

h_max = max(inp_h)
h_len = len(inp_h)

ind = [0]*h_len

h_bool = [True if ind[i] == inp_h[i] else False for i in range(h_len)]

def make_index(h_bool):
    try:
        index = h_bool.index(False)
    except:
        index = -1
    return index

num = 0
while True:
    index = make_index(h_bool)
    index_list = []
    if index != -1:
        while True:
            if index < h_len:
                if h_bool[index] == False:
                    index_list.append(index)
                    index += 1
                elif h_bool[index] == True:
                    ind = [ind[i]+1 if i in index_list else ind[i] for i in range(h_len)]
                    h_bool = [True if ind[i] == inp_h[i] else False for i in range(h_len)]
                    num += 1
                    break
            elif index >= h_len:
                ind = [ind[i]+1 if i in index_list else ind[i] for i in range(h_len)]
                h_bool = [True if ind[i] == inp_h[i] else False for i in range(h_len)]
                num += 1
                break
    else:
        break
    
print(num)

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

k = 0
while sum(h_list)>0:
  bool_list = [True if i==max(h_list) else False for i in h_list]
  indexes = []
  true_index = bool_list.index(True)
  indexes.append(true_index)
  while bool_list(true_index):
    true_index += 1
    indexes.append(true_index)
  h_list = [h_list[i]-1 for i in indexes]
  k += 1
  
print(k)
Problem p03106 (python)

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

num_list = []

for i in range(1,min(a,b)+1):
    if a % i == 0 and b % i == 0:
        num_list.append(i)


print(num_list[-k])

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

num_list = []

for i in range(1,100):
    if a % i == 0 & b % i == 0:
        num_list.append(i)

print(num_list[k])
Problem p03206 (python)

Fixed submission:
D = int(input())

if D == 25:
    print("Christmas")

elif D == 24:
    print("Christmas Eve")

elif D == 23:
    print("Christmas Eve Eve")

elif D == 22:
    print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
bager = []
bager.append("P")

for i in range(1, N+1):
    bagernow = "B" + bager[i-1] + "P" + bager[i-1] + "B"
    bager.append(bagernow)

bagerN = str(bager[N])

runbager = bagerN[:(X)]

Ans = runbager.count("P")

print(Ans)
Problem p03212 (python)

Fixed submission:
from itertools import product

N = int(input())
num_list = ["3", "5", "7"]
count = 0

for i in range(3, 10):
    for t in (product(num_list, repeat=i)):
        check = t.count("3")*t.count("5")*t.count("7")
        if int("".join(t)) <= N and check:
            count += 1


print(count)

Buggy submission (verdict: Runtime Error):
from itertools import product

N = int(input())
num_list = ["3", "5", "7"]
count = 0

for i in range(2,10):
    for t in product(num_list, repeat=i):
        check = t.count("3")*t.count("5")*t.count("7")
        if int("".join(t)): <= N and check:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
from itertools import product

N = int(input())
num_list = ["3", "5", "7"]
count = 0

for i in range(2,10):
    for t in product(num_list, repeat=i):
        check = t.count("3")*t.count("5").t.count("7")
        if int("".join(t)): <= N and check:
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
from itertools import product

N = int(input())
num_list = ["3", "5", "7"]
count = 0

for i in range(2,10):
    for t in product(num_list, repeat=i):
        check = t.count("3")*t.count("5").t.count("7")
        
        if int("".join(t)): <= N and check:
            count += 1

print(count)
Problem p03251 (python)

Fixed submission:
N, M, X, Y = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))

if X < max(xlist):
    xmax = max(xlist)
else:
    xmax = X

if Y > min(ylist):
    ymin = min(ylist)
else:
    ymin = Y

if xmax + 1 <= ymin:
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))

if X < max(xlist):
    xmax = max(xlist)
else:
    xmax = X

if Y > min(ylist):
    ymax = min(ylist)
else:
    ymin = Y

if xmax + 1 <= ymin:
    print("No War")
else:
    print("War")
Problem p03260 (python)

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

if A % 2 == 1 and B % 2 == 1:
    print("Yes")

else:
    print("No")

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

if A % 2 == 1 and B % 2 == 1:
    print("Yes")

else:
    print("No")
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N, X = map(int, input().split())

clist = [X]
diff = []

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

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd_list(diff))

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N, X = map(int, input().split())

clist = [X]
diff = []

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

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd_list(diff))

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

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


N, X = map(int, input().split())

clist = [X]
diff = []

for i in range(N):
    clist.append(list(map(int, input().split)))

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd(*diff))
Problem p03281 (python)

Fixed submission:
N = int(input())
con = []
counter = 0

for i in range(1, N+1):
    if i % 2 == 1:
        for s in range(1, i+1):
            if i % s == 0:
                counter += 1
            
        con.append(counter)
        counter = 0


print(con.count(8))

Buggy submission (verdict: Runtime Error):
N = int(input())
con = []
conter = 0

for i in range(1, 105):
    if i % 2 == 1:
        for s in range(1, i/2):
            if i % s == 0:
                counter += 1
            
        con.append(counter)


print(con.count(8))
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())

ans = 0
n1 = 0

for i in S:
    if i != "1":
        s = int(i)
        break
    
    else:
        n1 += 1

if n1 >= K:
    print(1)

else:
    print(s)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
i = 0
ans = 0

while K > 0:
    K = K - S[i]**(5*10**16 + 1)
    ans = S[i]
    i += 1

print(ans)
Problem p02953 (python)

Fixed submission:

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

count = 0
diff = 0

if N == 1:
    print("Yes")
else:
    minn = 1
    tmp = 0
    for i in range (0, N):
        if minn <= H[i] - 1:
            H[i] -= 1
            minn = H[i]
        elif minn <= H[i]:
            minn = H[i]
        else:
            tmp = 1

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

Buggy submission (verdict: Runtime Error):

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

count = 0
diff = 0

if N == 1:
    print("Yes")
    exit(1)

for i in range(0, N-1):
    if H[i] <= H[i+1]:
        continue
    else:
        count += 1
        if diff < H[i+1] - H[i]:
            diff = H[i+1] - H[i]


if count <= 1 and diff <= 1:
    print("yes")
else:
    print("No")
Problem p02958 (python)

Fixed submission:

N = int(input())

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

dis = True
count = 0
for i in range(0, N-1):
    if A[i] > A[i+1]:
        count += 1
        dis = False
        if count == 1:
            tmp1 = i
        elif count == 2:
            tmp2 = i+1

if dis == False and count > 1:
    tmp = A[tmp1]
    A[tmp1] = A[tmp2]
    A[tmp2] = tmp

    count = 0
    for i in range(0, N-1):
        if A[i] > A[i + 1]:
            count += 1
            dis = False
            if count == 1:
                tmp1 = i
            elif count == 2:
                tmp2 = i + 1
    if count == 0:
        dis = True

if dis == True:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):

N = int(input())

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

dis = True
count = 0
for i in range(0, N-1):
    if A[i] > A[i+1]:
        count += 1
        dis = False
        if count == 1:
            tmp1 = i
        elif count == 2:
            tmp2 = i+1

if dis == False:
    tmp = A[tmp1]
    A[tmp1] = A[tmp2]
    A[tmp2] = tmp

    count = 0
    for i in range(0, N - 1):
        if A[i] > A[i + 1]:
            count += 1
            dis = False
            if count == 1:
                tmp1 = i
            elif count == 2:
                tmp2 = i + 1
    if count == 0:
        dis = True

if dis == True:
    print('YES')
else:
    print('NO')