Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
answer=0
i = list(map(int, input().split()))
f=i[0]+1
for a in range(f):
    for b in range(f):
        for c in range(f):
            sum=a+b+c
            if sum==i[1]:
                answer+=1
print(answer)

Fixed submission:
answer=0
i = list(map(int, input().split()))
f=i[0]+1
for a in range(f):
    for b in range(f):
        sum=a+b
        if 0 <= i[1]-sum <= i[0] :
                answer+=1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    half = N // 2
    for i in range(N // 2):
        length = half - i
        for i in range(N - length * 2 + 1):
            org = S[i:length + i]
            rest = S[length + i:N]
            #print(org, rest)
            if org in rest:
                print(length)
                return
    print('0')
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import re
import sys


def solve(N: int, S: str):
    max_length = 1
    found = False
    for i in range(N):
        is_break = False
        if i + max_length > N:
            break
        while not is_break:
            org = S[i:i + max_length]
            rest = S[i + max_length:N]
            # print(org, rest)
            if org in rest:
                max_length += 1
            else:
                is_break = True
    print(max_length - 1)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

result = 0
for i in range(N):
    result += i
print(result)


Fixed submission:
N = int(input())

print(N * (N-1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10 ** 7)

n, m = input().split(' ')
N = int(n)
M = int(m)

sorted_ab = sorted([list(map(int, input().split())) for i in range(N)])

# 報酬がi日後までにもらえるタスクの中(pool)で報酬が最大ものを選んでいく。
# 最大 M-1 回働ける
index = 0
pool = []
rewords = 0
for i in range(M):
    day = i + 1

    while index < N and day >= int(sorted_ab[index][0]):
        pool.append(int(sorted_ab[index][1]))
        index += 1
    # pool の中にある仕事の中から最大の報酬のものを選ぶ
    if pool:
        max_reword = max(pool)
        rewords += max_reword
        pool.remove(max_reword)

print(rewords)


Fixed submission:
import sys
from heapq import heappop, heappush

sys.setrecursionlimit(10 ** 7)

n, m = input().split(' ')
N = int(n)
M = int(m)

sorted_ab = sorted([list(map(int, input().split())) for i in range(N)])

# 報酬がi日後までにもらえるタスクの中(pool)で報酬が最大ものを選んでいく。
# 最大 M-1 回働ける
index = 0
pool = []
rewords = 0
for i in range(M):
    day = i + 1

    while index < N and day >= int(sorted_ab[index][0]):
        heappush(pool, -sorted_ab[index][1])
        index += 1
    # pool の中にある仕事の中から最大の報酬のものを選ぶ
    if pool:
        rewords += -heappop(pool)

print(rewords)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
uvw = [list(map(int, input().split(' '))) for _ in range(N - 1)]

# 適当に最初の色を決める
# その点を親として、
# 親からの距離が偶数だったら親と同じ色
# 親からの距離が奇数だったら親と違う色

pool = [1]

result = [0 for i in range(N)]  # 頂点1は白くする

while pool:
    top = pool.pop()
    copy_uvw = copy.deepcopy(uvw)
    for e in copy_uvw:
        if top == e[0]:
            uvw.remove(e)
            pool.append(e[1])
            if e[2] % 2 == 0:
                # 親と同じ色を入れる
                result[e[1] - 1] = 0 if result[e[0] - 1] == 0 else 1
            else:
                # 親と違う色を入れる
                result[e[1] - 1] = 1 if result[e[0] - 1] == 0 else 0
        elif top == e[1]:
            uvw.remove(e)
            pool.append(e[0])
            if e[2] % 2 == 0:
                # 親と同じ色を入れる
                result[e[0] - 1] = 0 if result[e[1] - 1] == 0 else 1
            else:
                # 親と違う色を入れる
                result[e[0] - 1] = 1 if result[e[1] - 1] == 0 else 0

for i in result:
    print(i)


Fixed submission:
import copy
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
uvw = [list(map(int, input().split(' '))) for _ in range(N - 1)]

# 適当に最初の色を決める
# その点を親として、
# 親からの距離が偶数だったら親と同じ色
# 親からの距離が奇数だったら親と違う色

children = [[] for _ in range(N + 1)]

for e in uvw:
    children[e[0]].append([e[1], e[2]])
    children[e[1]].append([e[0], e[2]])

pool = [1]
result = [0 for i in range(N + 1)]  # 頂点1は白くする

marked = set()
marked.add(1)

while pool:
    top = pool.pop()
    for child in children[top]:
        child_edge = child[0]
        length = child[1]

        if child_edge not in marked:
            pool.append(child_edge)
            marked.add(child_edge)
        if length % 2 == 0:
            result[child_edge] = 0 if result[top] == 0 else 1
        else:
            result[child_edge] = 1 if result[top] == 0 else 0

for i in result[1:]:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

if len(A) > 1:
    result = sorted(A)[1]
else:
    result = min(A)

while True:
    counter = 0
    should_continue = False
    for e in A:
        if e % result != 0:
            counter += 1
            if counter > 1:
                should_continue = True
                break
    if should_continue:
        continue
    if counter <= 1:  # 1つは書き換えられる
        break
    else:
        result -= 1

print(result)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

if len(A) > 1:
    result = sorted(A)[1]
else:
    result = min(A)

while True:
    counter = 0
    should_continue = False
    for e in A:
        if e % result != 0:
            counter += 1
            if counter > 1:
                should_continue = True
                break
    if should_continue:
        result -= 1
        continue
    if counter <= 1:  # 1つは書き換えられる
        break
    else:
        result -= 1

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

if len(A) > 1:
    result = sorted(A)[1]
else:
    result = min(A)

while True:
    counter = 0
    for e in A:
        if e % result != 0:
            counter += 1
    if counter <= 1:  # 1つは書き換えられる
        break
    else:
        result -= 1

print(result)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

if len(A) > 1:
    result = sorted(A)[1]
else:
    result = min(A)

while True:
    counter = 0
    should_continue = False
    for e in A:
        if e % result != 0:
            counter += 1
            if counter > 1:
                should_continue = True
                break
    if should_continue:
        result -= 1
        continue
    if counter <= 1:  # 1つは書き換えられる
        break
    else:
        result -= 1

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
x = int(input())

candidates = [0]

for i in range(1, x + 1):
    # print(candidates)
    new_candidates = []
    for c in copy.deepcopy(candidates):
        new_candidates.append(c)
        new_candidates.append(c+i)
        new_candidates.append(c-i)

    if x in new_candidates:
        print(i)
        break

    candidates = copy.deepcopy(new_candidates)


Fixed submission:
import copy
x = int(input())

m = 0

for i in range(1, x + 1):
    m += i
    if x <= m:
        print(i)
        break

Buggy python submission (verdict: Time Limit Exceeded):
import copy
x = int(input())

candidates = [0]

for i in range(1, x + 1):
    # print(candidates)
    for c in copy.deepcopy(candidates):
        candidates.append(c+i)
        candidates.append(c-i)

    if x in candidates:
        print(i)
        break


Fixed submission:
import copy
x = int(input())

m = 0

for i in range(1, x + 1):
    m += i
    if x <= m:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
import bisect as bs
import collections

n = int(input())
alist = [0]*n
for i in range(n):
    alist[i] = int(input())

col = collections.deque()
min_ = 10000000000

for a in alist:
    if a <= min_:
        col.appendleft(a)
        min_ = a
    else:
        index = bs.bisect(col, a) - 1
        ind = bs.bisect_left(col, col[index])+1
        col[ind] = a

print(len(col))


Fixed submission:
import bisect as bs
import collections

n = int(input())
alist = [0]*n
for i in range(n):
    alist[i] = int(input())

col = collections.deque()
min_ = 10000000000

for a in alist:
    if a <= min_:
        col.appendleft(a)
    else:
        index = bs.bisect_left(col, a) - 1
        col[index] = a
    min_ = col[0]

print(len(col))
Buggy python submission (verdict: Runtime Error):
n = input()
h = input()
w = input()
print((n-h+1)*(n-w+1))

Fixed submission:
n = int(input())
h = int(input())
w = int(input())
print((n-h+1)*(n-w+1))
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
printf('Yes' if a in (b*2) else 'No')

Fixed submission:
a=input()
b=input()
print('Yes' if a in (b*2) else 'No')
Buggy python submission (verdict: Runtime Error):
a = []
al, ar = 1, n
for _ in xrange(m):
    l, r = [int(x) for x in raw_input().split()]
    a.append((l, r))
a.sort()
for (l, r) in a:
    al = max(l, al)
    ar = min(r, ar)
ans = max(ar - al + 1, 0)
print ans


Fixed submission:
n, m = [int(x) for x in raw_input().split()]
a = []
al, ar = 1, n
for _ in xrange(m):
    l, r = [int(x) for x in raw_input().split()]
    a.append((l, r))
a.sort()
for (l, r) in a:
    al = max(l, al)
    ar = min(r, ar)
ans = max(ar - al + 1, 0)
print ans
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(x) for x in raw_input().split()]
a = map(int, raw_input().split())
a.sort()
bc = []
for _ in xrange(m):
    bc.append([int(x) for x in raw_input().split()][::-1])
bc.sort(reverse=True)
for i in xrange(n):
    if len(bc) == 0:
        break
    if bc[0][1] == 0:
        bc = bc[1:]
    if len(bc) == 0:
        break
    if a[i] < bc[0][0]:
        a[i] = bc[0][0]
        bc[0][1] -= 1
    else:
        bc = bc[1:]
print sum(a)


Fixed submission:
n, m = [int(x) for x in raw_input().split()]
a = map(int, raw_input().split())
a.sort()
bc = []
for _ in xrange(m):
    bc.append([int(x) for x in raw_input().split()][::-1])
bc.sort(reverse=True)
j = 0
for i in xrange(n):
    if j == m:
        break
    if bc[j][1] == 0:
        j += 1
    if j == m:
        break
    if a[i] < bc[j][0]:
        a[i] = bc[j][0]
        bc[j][1] -= 1
    else:
        break
print sum(a)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : a.py
# Author            : recurze
# Date              : 22:46 18.01.2019
# Last Modified Date: 22:46 18.01.2019

print int(raw_input()) + int(raw_input()) >> 1


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : a.py
# Author            : recurze
# Date              : 22:46 18.01.2019
# Last Modified Date: 22:49 18.01.2019

a, b = [int(x) for x in raw_input().split()]
print a + (b>>1)
Buggy python submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
res = 1
max_res = m//n
for i in range(2, math.ceil(math.sqrt(m)) + 1):
  if m % i == 0:
     if i <= max_res:
        res = max(res, i)
     x = m//i
     if x <= max_res:
        res = max(res, x)
print(res)

Fixed submission:
n = int(input())
if n == 1:
  print('Hello World\n')
else:
  a = int(input())
  b = int(input())
  print(a + b)

Buggy python submission (verdict: Runtime Error):
import math
n, m = map(int, input.split())
res = 1
max_res = m//n
for i in range(2, math.ceil(math.sqrt(m)) + 1):
  if m % i == 0:
     if i <= max_res:
        res = max(res, i)
     x = m//i
     if x <= max_res:
        res = max(res, x)
print(res)

Fixed submission:
n = int(input())
if n == 1:
  print('Hello World\n')
else:
  a = int(input())
  b = int(input())
  print(a + b)

Buggy python submission (verdict: Runtime Error):
n, T = map(input().split(), int)
res = 2000
for _ in range(n):
  c, t = map(input().split(), int)
  if t > T: continue
  res = min(res, c)
if res == 2000:
  print('TLE')
else:
  print(res)

Fixed submission:
n = int(input())
if n == 1:
  print('Hello World\n')
else:
  a = int(input())
  b = int(input())
  print(a + b)

Buggy python submission (verdict: Runtime Error):
n, T = map(input.split(), int)
res = 2000
for _ in range(n):
  c, t = map(input.split(), int)
  if t > T: continue
  res = min(res, c)
if res == 2000:
  print('TLE')
else:
  print(res)

Fixed submission:
n = int(input())
if n == 1:
  print('Hello World\n')
else:
  a = int(input())
  b = int(input())
  print(a + b)
Buggy python submission (verdict: Runtime Error):
n, T = map(int, input.split())
res = 2000
for _ in range(n):
  c, t = map(int, input.split())
  if t > T: continue
  res = min(res, c)
if res == 2000:
  print('TLE')
else:
  print(res)

Fixed submission:
n, T = map(int, input().split())
res = 2000
for _ in range(n):
  c, t = map(int, input().split())
  if t > T: continue
  res = min(res, c)
if res == 2000:
  print('TLE')
else:
  print(res)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [[] for i in range(m)]
for i in range(m):
    t = list(map(int, input().split()))
    a[i] = t[1:]

p = list(map(int, input().split()))
ans = 0
for i in range(1<<n):
    p_ = p[:]
    for j in range(n):
        if not (i & (1<<j)):
            continue
        for k in range(m):
            if j+1 in a[k]:
                p_[k] ^= 1
    ans += (max(p_) == 0):
print(ans)



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

p = list(map(int, input().split()))
ans = 0
for i in range(1<<n):
    p_ = p[:]
    for j in range(n):
        if not (i & (1<<j)):
            continue
        for k in range(m):
            if j+1 in a[k]:
                p_[k] ^= 1
    ans += (max(p_) == 0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf8 -*-

n,k,q = map(int, input().split())
a = [int(input()) for _ in range(q)]
if k > q:
    for _ in range(n):
        print('Yes')
else:
    d = q - k + 1
    for i in range(1, n + 1):
        if a.count(i) >= d > 0:
            print('Yes')
        else:
            print('No')

Fixed submission:
# -*- coding:utf8 -*-
from collections import Counter

n,k,q = map(int, input().split())
a = Counter([int(input()) for _ in range(q)])
if k > q:
    for _ in range(n):
        print('Yes')
else:
    d = q - k + 1
    for i in range(1, n + 1):
        if not a[i]:
            print('No')
        else:
            if a[i] >= d:
                print('Yes')
            else:
                print('No')

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf8 -*-

n,k,q = map(int, input().split())
a = [int(input()) for _ in range(q)]
pb = k - q
for i in range(1, n + 1):
    p = pb + a.count(i)
    if p > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
# -*- coding:utf8 -*-
from collections import Counter

n,k,q = map(int, input().split())
a = Counter([int(input()) for _ in range(q)])
if k > q:
    for _ in range(n):
        print('Yes')
else:
    d = q - k + 1
    for i in range(1, n + 1):
        if not a[i]:
            print('No')
        else:
            if a[i] >= d:
                print('Yes')
            else:
                print('No')
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

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

ans = 0
for i in range(n):
    ans += b[a[i - 1]]
    if i != 0 and a[i] == a[i - 1] + 1:
        ans += c[a[i - 1] - 1]
print(ans)

Fixed submission:
# -*- coding:utf8 -*-

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

ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i != 0 and a[i] == a[i - 1] + 1:
        ans += c[a[i - 1] - 1]
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

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

ans = 0
for i in range(n):
    ans += b[a[i]]
    if i != 0 and a[i] == a[i - 1] + 1:
        ans += c[a[i - 1] - 1]
print(ans)

Fixed submission:
# -*- coding:utf8 -*-

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

ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i != 0 and a[i] == a[i - 1] + 1:
        ans += c[a[i - 1] - 1]
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

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

ans = 0
for i in range(n):
        ans += b[a[i]]
        if i != 0 and a[i] == a[i - 1] + 1:
                ans += c[a[i - 1]]
print(ans)

Fixed submission:
# -*- coding:utf8 -*-

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

ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i != 0 and a[i] == a[i - 1] + 1:
        ans += c[a[i - 1] - 1]
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

n = int(input())
l = list(map(int, input().split()))
c,p = 0,0
t = []
for i,n in enumerate(l):
    if p == 0:
        pass
    elif n <= p:
        c += 1
        if i == len(l) - 1:
            t.append(c)
    else:
        t.append(c)
        c = 0
    p = n
ans = max(t)
print(ans)



Fixed submission:
# -*- coding:utf8 -*-

n = int(input())
l = list(map(int, input().split()))
c,p = 0,0
t = [0]
for i,n in enumerate(l):
    if p == 0:
        pass
    elif n <= p:
        c += 1
        if i == len(l) - 1:
            t.append(c)
    else:
        t.append(c)
        c = 0
    p = n
ans = max(t)
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

n = int(input())
l = list(map(float, 1 / input().split()))
print(a/sum(l))


Fixed submission:
# -*- coding:utf8 -*-

n = int(input())
l = list(map(int, input().split()))
f = [1/i for i in l]
print(1/sum(f))
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [list(range(i)) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(t))

Fixed submission:
# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf8 -*-

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = [list(range(s.count(i))) for i in set(s) if s.count(i) != 1]
t = [sum(i) for i in c]
print(sum(t))

Fixed submission:
# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf8 -*-

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = [list(range(s.count(i))) for i in set(s)]
t = [sum(i) for i in c if i != 1]
print(sum(t))

Fixed submission:
# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-
import math

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = [math.factorial(s.count(i)) for i in set(s) if s.count(i) != 1]
ans = 0 if not c else sum(c)/2 
print(ans)

Fixed submission:
# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-
import math

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = [math.factorial(s.count(i)) for i in set(s) if s.count(i) != 1]
print(sum(c)/2)

Fixed submission:
# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-
import math

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = [math.factorial(s.count(i)) for i in set(s)]
print(sum(c)/2)

Fixed submission:
# -*- coding:utf8 -*-
import collections

n = int(input())
s = [input() for _ in range(n)]
s = [''.join(sorted(i)) for i in s]
c = collections.Counter(s)
t = [range(i) for i in list(c.values()) if i != 1]
a = [sum(i) for i in t]
print(sum(a))
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

n = int(input())
h = list(map(int, input().split()))
p = h[0]
l = [p]
for i in range(1,n):
    c = h[i]
    if i == 1 and p - 1 == c:
        l[0] == c
    if p < c:
        C -= 1
    l.append(c)
    p = c
ans = 'Yes' if l == sorted(l) else 'No'
print(ans)

Fixed submission:
# -*- coding:utf8 -*-

n = int(input())
h = list(map(int, input().split()))
p = h[0]
l = [p]
for i in range(1,n):
    c = h[i]
    if i == 1 and p - 1 == c:
        l[0] == c
    if p < c:
        c -= 1
    l.append(c)
    p = c
ans = 'Yes' if l == sorted(l) else 'No'
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
p, pp = 0, 0
for i in h:
    if p == 0:
        p = i
    d =  p - i
    if d < -1 or (d == -1 and pp == -1):
        ans  'No'
        break
    else:
        pp = p
        p = d
print(ans)

Fixed submission:
# -*- coding:utf8 -*-

n = int(input())
h = list(map(int, input().split()))
p = h[0]
l = [p]
for i in range(1,n):
    c = h[i]
    if i == 1 and p - 1 == c:
        l[0] == c
    if p < c:
        c -= 1
    l.append(c)
    p = c
ans = 'Yes' if l == sorted(l) else 'No'
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf8 -*-

n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
t = h[0]
a = 0
for n in h[1:]:
    d = t - n
    if d < -1 or (d == -1 and a == -1):
        ans  'No'
        break
    else:
        t = i
        a = d
print(ans)

Fixed submission:
# -*- coding:utf8 -*-

n = int(input())
h = list(map(int, input().split()))
p = h[0]
l = [p]
for i in range(1,n):
    c = h[i]
    if i == 1 and p - 1 == c:
        l[0] == c
    if p < c:
        c -= 1
    l.append(c)
    p = c
ans = 'Yes' if l == sorted(l) else 'No'
print(ans)