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

Fixed submission:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
 
if M <= sum(s):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
s1 = sorted(s)

if M <= s1[-1] + s1[-2]:
    print("Yes")
else:
    print("No")
Problem p02797 (python)

Fixed submission:
N,K,S = map(int,input().split())
t = [999999999]*N
for i in range(K):
    t[i] = S
print(*t)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [0]*N
t = [0]*N
for i in range(N):
    s[i],t[i] = input().split()
s = [int(x) for x in s]
t = [int(x) for x in t]
def sel(a,b):
    u = []
    c = 0
    for i in range(len(a)-3):
        if abs(a[i+1] - a[i]) < b[i+1] + b[i]:
            c = c + 1
            a.pop(i)
            b.pop(i)
            a1 = a
            b1 = b
            sel(a1,b1)
            c = 0
    if c == 0:
        u.append(len(a))
    return u
u1 = sorted(sel(s,t))
print(u1[-1])
Problem p02802 (python)

Fixed submission:
N,M = [int(x) for x in input().split()]
s = []
for i in range(M):
    array = list(map(str,input().split()))
    s.append(array)

answer = 0
penalty = 0

WA = [0 for i in range(N)]
#print(t)
for i in range(M):
    if WA[int(s[i][0])-1] != "AC":
        if s[i][1] == "WA":
            WA[int(s[i][0])-1] += 1
        else:
            penalty += WA[int(s[i][0])-1]
            answer += 1
            WA[int(s[i][0])-1] = "AC"
    #print(WA)
print(answer,penalty)

Buggy submission (verdict: Runtime Error):
N,M = [int(x) for x in input().split()]
s = []
for i in range(M):
    array = list(map(str,input().split()))
    s.append(array)
a = 0
b = 0
for i in range(M):
    if s[i][0] == s[i+1][0]:
        if s[i][1] == "WA":
            b = b + 1
        else:
            a = a + 1
            break
    else:
        if s[i][1] == "AC":
            a = a + 1
        else:
            b = b + 1
print(str(a) + " " + str(b))
Problem p02811 (python)

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

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

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

Fixed submission:
from collections import defaultdict

params = input().split()
n = int(params[0])
m = int(params[1])

penaltyCount = dict()
penaltyCount = defaultdict(lambda: 0, penaltyCount)

correct = 0
penalty = 0

for i in range(m):
    submission = input().split()
    p = int(submission[0]) - 1
    status = submission[1]

    if penaltyCount[p] == -1:
        continue
    if status == "WA":
        penaltyCount[p] += 1
    else:
        penalty += penaltyCount[p]
        penaltyCount[p] = -1
        correct += 1

print(str(correct) + " " + str(penalty))

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

params = input().split()
n = int(params[0])
m = int(params[1])

penaltyCount = dict()
penaltyCount = defaultdict(lambda: 0, penaltyCount)

correct = 0
penalty = 0

for i in range(m):
    submission = input.split()
    p = int(submission[0]) - 1
    status = submission[1]

    if penaltyCount[p] == -1:
        continue
    if status == "WA":
        penaltyCount[p] += 1
    else:
        penalty += penaltyCount[p]
        penaltyCount[p] = -1
        correct += 1

print(str(correct) + " " + str(penalty))

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

lines = []
while True:
    line = input()
    if line:
        lines.append(line)
    else:
        break

correct = 0
penalty = 0
d = dict()
d = defaultdict(lambda: 0, d)

for line in lines[1:]:
    n = line.split()[0]
    m = line.split()[1]

    if d[n] == -1:
        continue
    if m == "WA":
        d[n] += 1
    else:
        penalty += d[n]
        d[n] = -1
        correct += 1

print(str(correct) + " " + str(penalty))

Buggy submission (verdict: Runtime Error):
lines = []
while True:
    line = input()
    if line:
        lines.append(line)
    else:
        break

c = 0
p = 0
curr_no = -1
for line in lines[1:]:
    curr = line.split()
    if(curr_no != curr[0]):
        curr_no = curr[0]
        curr_flag = True
    if(curr_flag):
        if(curr[1] == "AC"):
            c += 1
            curr_flag = False
        else:
            p += 1

print(str(c) + " " + str(p))

Buggy submission (verdict: Runtime Error):
lines = []
while True:
    line = input()
    if line:
        lines.append(line)
    else:
        break

c = 0
p = 0
curr_no = -1
for line in lines[1:]:
    curr = line.split()
    if(curr_no != curr[0]):
        curr_no = curr[0]
        curr_flag = True
    if(curr_flag):
        if(curr[1] == "AC"):
            c += 1
            curr_flag = False
        else:
            p += 1

print(c, p)
Problem p03160 (python)

Fixed submission:
n = int(input())
costs = list(map(int, input().split()))
a, b = 0, abs(costs[1]-costs[0])
i = 2
while i < n:
	a, b = b, min(abs(costs[i] - costs[i-1]) + b, abs(costs[i] - costs[i-2]) + a)
	i += 1
print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
costs = map(int, input().split())
a, b = cost[0], cost[0] + abs(costs[1]-cost[0])
i = 2
while i < n:
  a, b = b, min(abs(cost[i] - cost[i-1]) + b, abs(cost[i] - cost[i-2]) + a)
  i += 1
print(b)
Problem p02732 (python)

Fixed submission:
import copy
from scipy.misc import comb
n = int(input())
#x, y, a, b, c = map(int, input().split())
#s= list(input())
a = list(map(int, input().split()))
an = [0] * n
for i in range(n):
    an[a[i]-1] += 1

ac2 = []
ac2_diff = []
for i in range(n):
    ac2.append(comb(an[i], 2, exact=True))
    ac2_diff.append(ac2[i]-comb(an[i]-1, 2, exact=True))
sum = sum(ac2)
for i in range(n):
    print(sum - ac2_diff[a[i]-1])

Buggy submission (verdict: Runtime Error):
import copy
from scipy.special import comb
n = int(input())
#x, y, a, b, c = map(int, input().split())
#s= list(input())
a = list(map(int, input().split()))
an = [0] * n
for i in range(n):
    an[a[i]-1] += 1

ac2 = []
ac2_diff = []
for i in range(n):
    ac2.append(comb(an[i], 2, exact=True))
    ac2_diff.append(ac2[i]-comb(an[i]-1, 2, exact=True))
sum = sum(ac2)
for i in range(n):
    print(sum - ac2_diff[a[i]-1])
Problem p02756 (python)

Fixed submission:
import copy
import itertools

s = input()
q = int(input())
#s= list(input())

ct = 0
ls = []
rs = []
for i in range(q):
    qtmp = input().split()
    #qtmp = [2,1,'c']
    t = int(qtmp[0])
    if(t == 1):
        ct += 1
        ct = ct % 2
    else:
        f = int(qtmp[1])
        if(ct+1 == f):
            ls.append( qtmp[2])
        else:
            rs.append( qtmp[2])
if(ct == 1):
    tmp = rs
    rs = ls
    ls = tmp
    s = s[::-1]
for i in range(len(ls)):
    print(ls[len(ls)-i-1], end='')
print(s, end='')
for i in range(len(rs)):
    print(rs[i], end='')
print("")

Buggy submission (verdict: Runtime Error):
import copy
import itertools

s = input()
q = int(input())
#s= list(input())

ct = 0
ls = []
rs = []
for i in range(q):
    qtmp = input().split()
    "qtmp = [2,1,'c']
    t = int(qtmp[0])
    if(t == 1):
        ct += 1
        ct = ct % 2
    else:
        f = int(qtmp[1])
        if(ct == f):
            rs.append( qtmp[2])
        else:
            ls.append( qtmp[2])
if(ct == 1):
    tmp = rs
    rs = ls
    ls = tmp
for i in range(len(ls)):
    print(ls[len(ls)-i-1], end='')
print(s, end='')
for i in range(len(rs)):
    print(rs[i], end='')
print("")
Problem p02813 (python)

Fixed submission:
from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

allp = p.copy()
allp.sort()
allperms = list(map(list, permutations(allp)))
print(abs(allperms.index(p) - allperms.index(q)))

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

n = int(input)
p = list(map(int, input().split()))
q = list(map(int, input().split()))

allp = p.copy()
allp.sort()
allperms = list(map(list, permutations(allp)))
print(abs(allperms.index(p) - allperms.index(q)))
Problem p02717 (python)

Fixed submission:
input = input().split(" ")
print(input[2] + " " + input[0] + " " + input[1])

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

Fixed submission:
i = str(input()).split(" ")
print(i[1] + i[0])

Buggy submission (verdict: Runtime Error):
s = str(input())
t = str(input())
print(t + s)

Buggy submission (verdict: Runtime Error):
st = str(input())
s, t = st.split('')
print t + s
Problem p02818 (python)

Fixed submission:
a,b,k = map(int, input().split())
x = 0 if k > a else a - k
y = b if (k - a) <= 0 else (0 if (k - a) > b else b - (k - a))
print("{} {}".format(x,y))

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
a[0] = int(a[0])
a[1] = int(a[1])
a[2] = int(a[2])
if a[0] > 0 and a[1] > 0:
  print("0 0")
else:
  if a[2] > a[0]:
    a[0] = 0
  a[2] = a[2] - a
  if a[2] > a[1]:
    a[1] = 0
  else: 
    a[1] = a[1] - a[2]
  print(str(a[0]) + " " + str(a[1]))

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
a[0] = int(a[0])
a[1] = int(a[1])
a[2] = int(a[2])
if a[0] > 0 and a[1] > 0:
  print("0 0")
  return
else:
  if a[2] > a[0]:
    a[0] = 0
  a[2] = a[2] - a
  if a[2] > a[1]:
    a[1] = 0
  else: 
    a[1] = a[1] - a[2]
print(str(a[0]) + " " + str(a[1]))

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
a[0] = int(a[0])
a[1] = int(a[1])
if a[0] > 0 and a[1] > 0:
  for i in range(0, int(a[2])):
    if a[0] > 0:
      a[0] -= 1
    else:
      if a[0] == 0 and a[1] == 0:
  	  	break
  	  else:
        a[1] -= 1
print(str(a[0]) + " " + str(a[1]))
Problem p02934 (python)

Fixed submission:
n=int(input())
print(1/sum([1/float(i) for i in input().split()]))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print((b-2)//(a-1)+1)
Problem p03997 (python)

Fixed submission:
a,b,h=[int(input()) for _ in range(3)]
print(((a+b)*h)//2)

Buggy submission (verdict: Runtime Error):
a,b,h=map(int,input().split())
print((((a+b)*h)//2)

Buggy submission (verdict: Runtime Error):
a,b,h=map(int,input().split())
print(((a+b)*h)/2)
Problem p02811 (python)

Fixed submission:
if __name__ == "__main__":
    m, n = map(int, input().split())
    if m * 500 >= n:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    x = int(input())
    m, n = map(int, input().split())
    if m * 500 >= n:
        print("Yes")
    else:
        print("No")
Problem p02817 (python)

Fixed submission:
inputStrings = input().split()
print(inputStrings[1] + inputStrings[0])

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
print(T + S)
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
slist = []
clist = []

def check(numlist, slist, clist):
    for i in range(m):
        if int(numlist[slist[i]]) != clist[i]:
            return False
    return True

for i in range(m):
    s,c = map(int, input().split())
    slist.append(s-1)
    clist.append(c)

start = 10**(n-1)
end = 10**n
if n == 1:
    start = 0
flag = 0
for num in range(start, end):
    numstring = str(num)
    numlist = list(numstring)
    if check(numlist, slist, clist):
        print(num)
        flag = 1
        break
if not flag:
    print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
slist = []
clist = []

def check(numlist, slist, clist):
    for i in range(m):
        if int(numlist[slist[i]]) != clist[i]:
            return False
    return True

for i in range(m):
    s,c = map(int, input().split())
    slist.append(s-1)
    clist.append(c)
flag = 0
# if m > n:
#     print(-1)
# else:
    for num in range(10**(n-1), 10**n):
        numstring = str(num)
        numlist = list(numstring)
        if check(numlist, slist, clist):
            print(num)
            flag = 1
            break
    if not flag:
        print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
slist = []
clist = []

def check(numlist, slist, clist):
    for i in range(m):
        if int(numlist[slist[i]]) != clist[i]:
            return False
    return True

for i in range(m):
    s,c = map(int, input().split())
    slist.append(s-1)
    clist.append(c)
flag = 0
# if m > n:
#     print(-1)
# else:
    for num in range(10**(n-1), 10**n):
        numstring = str(num)
        numlist = list(numstring)
        if check(numlist, slist, clist):
            print(num)
            flag = 1
            break
    if not flag:
        print(-1)
Problem p02845 (python)

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

def count(n, list1):
    num0 = list1.count(0)
    statuslist = []
    answer = 1
    if num0 >= 4:
        return 0
    else:
        for i in range(len(list1)):
            if list1[i] == 0:
                    statuslist.append(0)
            else:
                pos = statuslist.count(list1[i]-1)
                answer *= pos
                try:
                    statuslist.remove(list1[i]-1)
                except ValueError:
                    return answer
                statuslist.append(list1[i])
        if num0 == 2 or num0 == 3:
            answer *= 6
        elif num0 == 1:
            answer *= 3  
        return (answer % 1000000007)
    # else:
    #     return 3
        

print(count(n, list1))

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

def count(n, list1):
    num0 = list1.count(0)
    if num0 == 2 or num0 == 3:
        statuslist = []
        answer = 1
        for i in range(len(list1)):
            if list1[i] == 0:
                statuslist.append(0)
            else:
                pos = statuslist.count(list1[i]-1)
                answer *= pos
                statuslist.remove(list1[i]-1)
                statuslist.append(list1[i])
        answer *= 6
        return (answer % 1000000007)
    else:
        return 3
        

print(count(n, list1))
Problem p02717 (python)

Fixed submission:
arvud = input()

arvu=arvud.split(" ")
arv1=arvu[0]
arv2=arvu[1]
arv3=arvu[2]

print(arv3+ " "+ arv1+ " "+ arv2)

Buggy submission (verdict: Runtime Error):
num1 = int(input()) 
num2 = int(input())
num3=int(input())
print(num3 + " "+ num1 + " "+ num2)
Problem p02717 (python)

Fixed submission:
x, y, z = map(int, input().split())
print('{} {} {}'.format(z, x, y))

Buggy submission (verdict: Runtime Error):
x, y, z = map(int, input().split())
print(f"{z} {x} {y}")
Problem p02717 (python)

Fixed submission:
X, Y, Z = map(int, input().split())
print(str(Z) + " " + str(X) + " " + str(Y))

Buggy submission (verdict: Runtime Error):
k = int(input())
lunlun = [0] * 100
lunlun[1] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = 1

for i in range(9):
    n = len(lunlun[i])
    lunlun[i+1] = []
    for x in lunlun[i]:
        r = x%10
        if r > 0:
            lunlun[i+1].append(10*x + r-1)
        lunlun[i+1].append(10*x + r)
        if r < 9:
            lunlun[i+1].append(10*x + r+1)
    i += 1

for i in range(1, 11):
    for j in range(len(lunlun[i])):
        k -= 1
        if k == 0:
            print(lunlun[i][j])
            exit()

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

N = [1,2,3,4,56,7,8,9]

for x in range(a):
  tmp = N[x]
  if tmp%10 != 0:
    N.append(tmp*10+tmp%10-1)
  N.append(tmp*10+tmp%10)
  if tmp%10 != 9:
    N.append(tmp*10+tmp%10+1)
print(N[a-1])
Problem p02719 (python)

Fixed submission:
N,K = map(int,input().split())
ans1 = N % K
ans2 = abs(ans1-K)
print(min(ans1,ans2))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans1 = N % K
ans2 = abs(ans1 - K )
print(min(ans1,ans2)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans1 = N - K
ans2 = abs(ans1 - K)
print(min(ans1,ans2)
Problem p02720 (python)

Fixed submission:
k = int(input())
lunlun = [0] * 100
lunlun[1] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = 1

for _ in range(9):
    n = len(lunlun[i])
    lunlun[i+1] = []
    for x in lunlun[i]:
        r = x%10
        if r > 0:
            lunlun[i+1].append(10*x + r-1)
        lunlun[i+1].append(10*x + r)
        if r < 9:
            lunlun[i+1].append(10*x + r+1)
    i += 1

for i in range(1, 11):
    for j in range(len(lunlun[i])):
        k -= 1
        if k == 0:
            print(lunlun[i][j])
            exit()

Buggy submission (verdict: Runtime Error):
k = int(input())
lunlun = [0] * 100
lunlun[1] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = 1

for i in range(9):
    n = len(lunlun[i])
    lunlun[i+1] = []
    for x in lunlun[i]:
        r = x%10
        if r > 0:
            lunlun[i+1].append(10*x + r-1)
        lunlun[i+1].append(10*x + r)
        if r < 9:
            lunlun[i+1].append(10*x + r+1)
    i += 1

for i in range(1, 11):
    for j in range(len(lunlun[i])):
        k -= 1
        if k == 0:
            print(lunlun[i][j])
            exit()

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

N = [1,2,3,4,5,6,7,8,9]

For  x  in  range(a):
  tmp = N[x]
  if tmp%10 != 0:
    N.append(tmp*10+tmp%10-1)
  N.append(tmp*10+tmp%10)
  if tmp%10 != 9:
    N.append(tmp*10+tmp%10+1)
print(N[a-1])
Problem p03109 (python)

Fixed submission:
S = input().split("/")
if int(S[1])==4 and int(S[2])<=30:
    print("Heisei")
elif int(S[1])>4:
    print("TBD")
else:
    print("Heisei")

Buggy submission (verdict: Runtime Error):
S = input().split("/")
if S[1]==4 and S[2]<=30:
    print("Heisei")
elif S>4:
    print("TBD")
else:
    print("Heisei")
Problem p02844 (python)

Fixed submission:
n=int(input())
s=input()
list=["" for _ in range(1000)]
ans=0
for i in range(1000):
  t=str(i)
  u="0"*(3-len(t))+t
  j=0
  exi=0
  p=u[0]
  for x in s:
    if x==p:
      j+=1
      if j==3:
        ans+=1
        break
      p=u[j]
    
print(ans)

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

cnt = 0
for i in range(1000):
    
    t = str(i)
    u = '0'*(3-len(t))+t
    
    j = 0
    p = u[0]
    for x in s:
        if x == p:
            j += 1
            if j == 3:
                cnt += 1
                break
            p = u[j]
            
print(ans)
Problem p03086 (python)

Fixed submission:
s =input()
s += ' '
ACGT = ['A', 'C', 'G', 'T']

cnt_list = []
cnt = 0
for i in s:
    if i in ACGT:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 0
print(max(cnt_list))

Buggy submission (verdict: Runtime Error):
s =input()
ACGT = ['A', 'C', 'G', 'T']

cnt_list = []
cnt = 0
for i in s:
    if i in ACGT:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 0
print(max(cnt_list))

Buggy submission (verdict: Runtime Error):
# ABC122_B
s = input()
ACGT = ['A', 'C', 'G', 'T']

cnt_list = []
cnt = 0
for i in s:
    for k in ACGT:
        if i == k:
            cnt += 1
            continue
    if all([i != k for k in ACGT]):
        cnt_list.append(cnt)
        cnt = 0
print(max(cnt_list))

Buggy submission (verdict: Runtime Error):
# ABC122_B
s = input()
ACGT = ['A', 'C', 'G', 'T']

cnt_list = []
cnt = 0
for i in s:
    for k in ACGT:
        if i == k:
            cnt += 1
        if all([i != k for k in ACGT]):
            cnt_list.append(cnt)
            cnt = 0
print(max(cnt_list))
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, split(input()))
print(c, a, b)
Problem p02843 (python)

Fixed submission:
x = int(input())

n = x // 100
f = 0

for j in range(n+1):
    if j*100 <= x <= j*105:
        f = 1

if f:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import itertools as it

x = int(input())
f = 0

c = x // 100

l = list(it.combinations(range(100,106),c))

for i in l:
    if x % sum(i) == 0:
        f = 1

if f:
    print(1)
else:
    print(0)
Problem p02882 (python)

Fixed submission:
import math as m

a, b, x = map(int,input().split())

z = a ** 2 * b

if z / 2 >= x:
  ap = x * 2 / a / b
  at = m.degrees(m.atan(b/ap))
  print(at)
else:
  bp = b - x / (a ** 2)
  bt = m.degrees(m.atan(bp*2/a))
  print(bt)

Buggy submission (verdict: Runtime Error):
import math as m

a, b, x = map(int,input().split())

z = a ** 2 * b

if z / 2 >= x:
  ap = x * 2 / a / b
  at = m.degrees(m.atan(b/ap))
  print(at)
else:
  bp = b - x / (a ** 2)
  bt =　m.degrees(m.atan(bp*2/a))
  print(bt)
Problem p02921 (python)

Fixed submission:
s = str(input())
t = str(input())
st = tuple(s)
tt = tuple(t)

cnt = 0

for i in range(len(st)):
  if st[i] == tt[i]:
    cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
ans = (pow(n,2) - n) / 2
if not n == 2:
  print(int(ans))
else:
  print(2)
Problem p02924 (python)

Fixed submission:
n = int(input())
ans = 0
ans = (pow(n,2) - n) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
ans = (pow(n,2) - n) / 2
if not n 2:
  print(int(ans))
else:
  print(2)
Problem p02952 (python)

Fixed submission:
n = int(input())

cnt = 0

for i in range(1,n+1):
    ln = len(str(i))
    if ln % 2 == 1:
        cnt += 1

print(cnt)

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

for i in range(1,n):
    a = h[i-1] - h[i]
    if a > 1:
        break
    elif a == 1:
        if f == 1:
            break
        f = 1
    else:
        f = 0

    if i == n - 1:
        f = 2

if f == 2 or n == 1:
    print('Yes')
else:
    print('No')
Problem p02953 (python)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
f = 0

for i in range(1,n):
    a = h[i-1] - h[i]
    if a > 1:
        break
    elif a == 1:
        if f == 1:
            break
        f = 1
    elif a == 0:
        pass
    else:
        f = 0

    if i == n - 1:
        f = 2

if f == 2 or n == 1:
    print('Yes')
else:
    print('No')

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

for i in range(1,n):
    a = h[i-1] - h[i]
    if a > 1:
        break
    elif a == 1:
        if f == 1:
            break
        f = 1
    elif a == 0:
        pass
    else:
        f = 0
else:
    if i == n - 1:
        f = 2

if f == 2 or n == 1:
    print('Yes')
else:
    print('No')
Problem p02971 (python)

Fixed submission:
n = int(input())
a = []
b = []

for i in range(n):
    t = int(input())
    a.append(t)
    b.append(t)

b.sort()

for i in range(n):
    if a[i] != b[-1]:
        print(b[-1])
        continue
    else:
        print(b[-2])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
b = []

for i in range(n):
    t = int(input())
    a.append(t)
    b.append(t)

b.sort()
m = 0
l = n+1

for i in range(n):
    m = 0
    l = n+1
    if a[i] != b[-1]:
        print(b[-1])
        continue
    while a[i] != b[(m+l)//2]:
        if a[i] < b[(m+l)//2]:
            l //= 2
        else:
            m = i
    tmp = b[(m+l)//2]
    b[(m+l)//2] = 0
    print(max(b))
    b[(m+l)//2] = tmp
Problem p03361 (python)

Fixed submission:
H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag=1
print("Yes" if flag==0 else "No")

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

shw = [list(map(str, input())) for _ in range(W)]

        

for i in range(1,H-1):
    for j in range(1,W-1):
        if shw[i][j] == str('#'):
            if shw[i][j] != shw[i+1][j] and shw[i][j] != shw[i][j+1] and shw[i][j] != shw[i-1][j] and shw[i][j] != shw[i][j-1]:
                print("No")
                exit()
print("Yes")