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

Fixed submission:
a=list(input())
b=list(input())
c=list(input())
#print(a,b,c)


card=a.pop(0)
#print(card)
flag=0
for i in range(301):
    if card=='a' and len(a)==0 and flag==0:
        ans='A'
        flag=1
    elif card=='b' and len(b)==0 and flag==0:
        ans='B'
        flag=1
    elif card=='c' and len(c)==0 and flag==0:
        ans='C'
        flag=1
    elif flag==0:
        if card=='a':
            card=a.pop(0)
        elif card=='b':
            card=b.pop(0)
        elif card=='c':
            card=c.pop(0)
    
print(ans)

Buggy submission (verdict: Runtime Error):
a=list(input())
b=list(input())
c=list(input())
#print(a,b,c)

card=a.pop(0)
#print(card)

flag=0
for i in range(len(a)+len(b)+len(c)):
    if card=='a' and len(a)==0 and flag==0:
        ans='A'
        flag=1
    elif card=='b' and len(b)==0 and flag==0:
        ans='B'
        flag=1
    elif card=='c' and len(c)==0 and flag==0:
        ans='C'
        flag=1
    else:
        if card=='a':
            card=a.pop(0)
        elif card=='b':
            card=b.pop(0)
        elif card=='c':
            card=c.pop(0)
    
print(ans)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()

sizea=len(a)
sizeb=len(b)
sizec=len(c)
print(sizea,sizeb,sizec)

flag=1
x=0
y=0
z=0
for i in range(301):
  if flag==1:
    if sizea==0:
      ans='A'
      break
    else:
      if a[x]=='a':
        flag=1
      elif a[x]=='b':
        flag=2
      elif a[x]=='c':
        flag=3
      sizea-=1
      x+=1
      print(sizea,a[x])
  elif flag==2:
    if sizeb==0:
      ans='B'
      break
    else:
      if b[y]=='a':
        flag=1
      elif b[y]=='b':
        flag=2
      elif b[y]=='c':
        flag=3
      sizeb-=1
      y+=1
      print(sizeb,b[y])
  elif flag==3:
    if sizec==0:
      ans='C'
      break
    else:
      if c[z]=='a':
        flag=1
      elif c[z]=='b':
        flag=2
      elif c[z]=='c':
        flag=3
      sizec-=1
      z+=1
      print(sizec,c[z])

print(ans)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()

cnta=len(a)
cntb=len(b)
cntc=len(c)

print(a,b,c)
print(cnta,cntb,cntc)

numa=0
numb=0
numc=0

flag=1
if flag==1:
  numa+=1  
elif flag==2:
  numb+=1
elif flag==3:
  numc+=1

if a[numa]=='a':
  flag=1
elif a[numa]=='b':
  flag=2
elif a[numa]=='c':
  flag=3

if flag==1:
  numa+=1  
elif flag==2:
  numb+=1
elif flag==3:
  numc+=1

print(a[numa])
if a[numa]=='a':
  flag=1
elif a[numa]=='b':
  flag=2
elif a[numa]=='c':
  flag=3
  
numa+=1
Problem p03999 (python)

Fixed submission:
n=input()
size=len(n)
#print(n,size)

ans=0
for i in range(2**(size-1)):
    z=format(i,'b').zfill(size-1)
#    print(z)
    string=n[0]
    for j in range(size-1):
        if z[j]=='1':
            string+='0'+n[j+1]
        elif z[j]=='0':
            string+=n[j+1]
    string=string.replace('0','+')
    ans+=eval(string)

print(ans)

#12656242944

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

mynum=2**(len(n)-1)
#print(mynum)
data=['','+']
x=['0']*10000
#print(x)

for i in range(mynum):
  y=format(i, 'b')
  z=y.zfill(len(n)-1)
  x[i]=n[0]
  for j in range(len(z)):
    x[i]+=data[int(z[j])]+n[j+1]
#  print(x[i])           
x=[eval(i) for i in x]

print(n if len(n)==1 else sum(x))
#12656242944

Buggy submission (verdict: Runtime Error):
n=input()
#print(n)
mynum=2**(len(n)-1)
#print(mynum)
data=['','+']
x=['0']*10000
#print(x)

for i in range(mynum):
  y=format(i, 'b')
  z=y.zfill(len(n)-1)
  x[i]=n[0]
  for j in range(len(z)):
    x[i]+=data[int(z[j])]+n[j+1]
#  print(x[i])           
x=[eval(i) for i in x]

print(sum(x))
#12656242944

Buggy submission (verdict: Runtime Error):
n=input()
#print(n)
data=['','+']
x=['0']*10000
#print(x)
for i8 in range(2):
  for i7 in range(2): 
    for i6 in range(2): 
      for i5 in range(2): 
        for i4 in range(2): 
          for i3 in range(2): 
            for i2 in range(2): 
              for i1 in range(2): 
                for i0 in range(2):
                  x[i0+2*i1+4*i2+8*i3+16*i4+32*i5+64*i6+128*i7+256*i8]=(n[0]+data[i0]+n[1]
                         +data[i1]+n[2]
                         +data[i2]+n[3]
                         +data[i3]+n[4]
                         +data[i4]+n[5]
                         +data[i5]+n[6]
                         +data[i6]+n[7]
                         +data[i7]+n[8]
                         +data[i8]+n[9])        
        
x=[eval(i) for i in x]

print(sum(x))
#12656242944
Problem p04001 (python)

Fixed submission:
import itertools
s=input()
length=len(s)

ans=0
mylist=list(itertools.product('01',repeat=length-1))

for j in range(len(mylist)):
    tmp=s[0]
    for i in range(length-1):
        if mylist[j][i]=='1':
            tmp+="+"+s[i+1]
        else:
            tmp+=s[i+1]
    tmp=eval(tmp)
    ans+=tmp
print(ans)

Buggy submission (verdict: Runtime Error):
#import itertools
list1=[k for k in input()]
#print(list1)
num1=len(list1)
#print(num1)
list00=[format(int(k), 'b') for k in range(2**(num1-1))]
#print(list00)

list0=['','+']

list01=[]
for count1 in range(num1):
  x=list00[count1]
  list01.extend(x)
#print(list01)
total=0

for step1 in range(2):
  for step2 in range(2):
    list2=[list0[step2],list0[step1]]
    num = min(len(list1), len(list2))
    result = [None]*(num*2)
    result[::2] = list1[:num]
    result[1::2] = list2[:num]
    result.extend(list1[num:])
    result.extend(list2[num:])
    result1 = ''.join(result)
#    print(result1)
    total+=eval(result1)

print(total)
#176

Buggy submission (verdict: Runtime Error):
#import itertools
list1=[k for k in input()]
print(list1)
num1=len(list1)
print(num1)
list00=[format(int(k), 'b') for k in range(2**(num1-1))]
print(list00)

list0=['','+']

list01=[]
for count1 in range(num1):
  x=list00[count1]
  list01.extend(x)
print(list01)
total=0

for step1 in range(2):
  for step2 in range(2):
    list2=[list0[step2],list0[step1]]
    num = min(len(list1), len(list2))
    result = [None]*(num*2)
    result[::2] = list1[:num]
    result[1::2] = list2[:num]
    result.extend(list1[num:])
    result.extend(list2[num:])
    result1 = ''.join(result)
    print(result1)
    total+=eval(result1)

print(total)
#176
Problem p02971 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
a_unique = list(sorted(set(a), reverse=True))
max_value = a_unique[0]
max_value_count = a.count(max_value)

if max_value_count == 1:
    for i in range(n):
        if a[i] == max_value:
            print(a_unique[1])
        else:
            print(max_value)
else:
    for i in range(n):
        print(max_value)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
max = max(a)
for i in range(n):
    index = a.pop(i)
    if index == max:
        print(max(a))
    else:
        print(max)
    a.insert(i, index)
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
id = [list(map(int, input().split())) for _ in range(M)]
L = []
R = []
for i in range(M):
    L.append(id[i][0])
    R.append(id[i][1])
if max(L) <= min(R):
    print(min(R) - max(L) + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
id = [list(map(int, input().split())) for _ in range(M)]
ans = 0
for i in range(1, N+1):
    a = id[0]
    b = id[1]
    if a[0] <= i <= a[1] and b[0] <= i <= b[1]:
        ans = ans + 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
id = [list(map(int, input().split())) for _ in range(M)]
ans = 0
for i in range(1, N+1):
    a = id[0]
    b = id[1]
    if a[0] <= i <= a[1] and b[0] <= i <= b[1]:
        ans = ans + 1
print(ans)
Problem p02621 (python)

Fixed submission:
# １変数の標準入力
a = int(input())
# フォーマット関数
print("{}".format(a + a**2 + a**3))

Buggy submission (verdict: Runtime Error):
a = input()
print('a + a**2 + a**3)

Buggy submission (verdict: Runtime Error):
a = input()
print(a + a**2 + a**3)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(a + '+' + a**2  + '+' + a**3)
Problem p02675 (python)

Fixed submission:
a=input()
s = str(a)
if(s[-1] in ('2','4','5','7','9')):
	print('hon')
elif(s[-1] in ('0','1','6','8')):
	print('pon')
elif(s[-1] == '3'):
	print('bon')

Buggy submission (verdict: Runtime Error):
k = input()
s = input()
if(len(s) <= int(k)):
  print(s)
else:
  print(s[:int(k)]+'...')

Buggy submission (verdict: Runtime Error):
a=input()
s = str(a)
	if(s[-1] in ('2','4','5','7','9')):
		print('hon')
	elif(s[-1] in ('0','1','6','8')):
		print('pon')
	elif(s[-1] == '3'):
		print('bon')

Buggy submission (verdict: Runtime Error):
a=input()
	s=str(a)
	if(s[-1] in ('2','4','5','7','9')):
		print('hon')
	elif(s[-1] in ('0','1','6','8')):
		print('pon')
	elif(s[-1] == '3'):
		print('bon')

Buggy submission (verdict: Runtime Error):
a=input()
if(a >0):
	s=str(a)
	if(s[-1] in ('2','4','5','7','9')):
		print('hon')
	elif(s[-1] in ('0','1','6','8')):
		print('pon')
	elif(s[-1] == '3'):
		print('bonn')

Buggy submission (verdict: Runtime Error):
a=input()
s=str(a)
if(s[-1] in ('2','4','5','7','9')):
	print('hon')
elif(s[-1] in ('0','1','6','8')):
	print('pon')
elif(s[-1] in 3):
	print('bonn')
Problem p02612 (python)

Fixed submission:
N = int(input())
minn=1000
if N <1 or N>10000:
	print(' ')
elif N%1000==0:
	print(0)
else:
	for i in range(1000,10001,1000):
		if N<i:
			print(i-N)
			break

Buggy submission (verdict: Runtime Error):
N = int(input())
minn=1000
if N <1 or N>10000
	print(' ')
elif N%1000==0:
	print(0)
else:
	for i in range(1000,10001,1000):
		if N<i:
			print(i-N)
			break
Problem p02683 (python)

Fixed submission:
from itertools import combinations

n, m, x = list(map(int, input().split()))
c = []
a = []

# c, aにデータを用意
for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append([])
    
    for j in range(1, m + 1):
        a[i].append(tmp[j])

money_min = -1
comb = []
# 組み合わせを用意
for l in range(n):
    tmp = combinations(range(n), l + 1)
    for i in tmp:
        comb.append(i)
    
# 組み合わせごとに考える
for el in comb:
    ables = []
    money = 0        
    scores = []

    # scoreに0をいれる
    for i in range(m):
        scores.append(0)

    # 組み合わせを足し合わせる
    for n in el:
        money += c[n] # 金
        for i in range(m):
            scores[i] += a[n][i] # 習得度

    # 判定
    for i in range(m):
        ables.append(scores[i] >= x)

    # 良ければ金額更新
    if all(ables):
        money_min = money if money_min < 0 or money_min > money else money_min

print(money_min)

Buggy submission (verdict: Runtime Error):
n, m, x = list(map(int, input().split()))
c = []
a = []

for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append([])
    
    for j in range(m):
        a[i].append(tmp[j])

ab = []
for i in range(m):
    sum = 0
    for j in range(n):
        sum += a[j][i]
    ab.append(bool(sum > x))

print(all[ab])
Problem p02713 (python)

Fixed submission:
from math import gcd

v = int(input())
sum = 0

for i in range(1, v + 1):
    for j in range(1, v + 1):
        for k in range(1, v + 1):
            sum += gcd(gcd(i, j), k)

print(sum)

Buggy submission (verdict: Runtime Error):
import math

v = int(input())
sum = 0

for i in range(v):
    i += 1
    for j in range(v):
        j += 1
        for k in range(v):
            k += 1
            sum += math.gcd(i, j, k)

print(sum)
Problem p02630 (python)

Fixed submission:
from collections import Counter


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    C = Counter(A)
    ANS = 0
    for i in C:
        ANS += i * C[i]

    for _ in range(Q):
        B, X = map(int, input().split())
        ANS += X * C[B]
        C[X] += C[B]

        ANS -= B * C[B]
        del(C[B])
        print(ANS)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    C = Counter(A)
    ANS = 0
    for i in C:
        ANS += i * C[i]

    for _ in range(Q):
        B, X = map(int, input().split())
        ANS += X * C[B]
        C[X] += C[B]

        ANS -= B * C[B]
        del(C[B])
        print(ANS)

resolve()

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


def resolve():
    N = int(input())
    A = list(input().split())
    Q = int(input())

    C = Counter(A)
    ANS = 0
    for i in C:
        ANS += i * C[i]

    for _ in range(Q):
        B, X = map(int, input().split())
        ANS += X * C[B]
        C[X] += C[B]

        ANS -= B * C[B]
        del(C[B])
        print(ANS)

resolve()
Problem p02681 (python)

Fixed submission:
import re

def resolve():
    S = input()
    T = input()

    if 1 <= len(S) and len(S) <= 10:
        if re.match(S + '.', T):
            print('Yes')
            return

    print('No')


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    S = input()
    T = input()

    if re.match(r'[a-z]{1,10}', S) and re.match(S + '.', T):
        print('Yes')
        return

    print('No')

resolve()
Problem p02702 (python)

Fixed submission:
from collections import defaultdict


def resolve():
    s = input()

    cnt = defaultdict(int)
    cnt[0] += 1
    tmp = 0
    for i, c in enumerate(s[::-1]):
        c = int(c)
        tmp = (tmp + c * pow(10, i, 2019)) % 2019
        cnt[tmp] += 1

    ans = sum(c * (c - 1) // 2 for c in cnt.values())
    print(ans)


resolve()

Buggy submission (verdict: Runtime Error):
def retry(list_S, ans, start_ii=0):
    if start_ii > len(list_S) - 3:
        return ans

    for start_i in range(start_ii, len(list_S) - 3):
        for last_i in range(start_i + 3, len(list_S)):
            tmp = ''.join(list_S[start_i:last_i + 1])

            if (int(tmp) % 2019) == 0:
                ans += 1
                return retry(list_S, ans, last_i)

    return ans


def resolve():
    S = input()
    list_S = list(S)
    ans = 0

    print(retry(list_S, ans))


resolve()

Buggy submission (verdict: Runtime Error):
def retry(list_S, ans, start_ii=0):
    if start_ii > len(list_S) - 3:
        return ans

    for start_i in range(start_ii, len(list_S) - 3):
        for last_i in range(start_i + 3, len(list_S)):
            tmp = ''.join(list_S[start_i:last_i + 1])

            if (int(tmp) % 2019) == 0:
                ans += 1
                retry(list_S, ans, last_i)

    return ans


def resolve():
    S = input()
    list_S = list(S)
    ans = 0

    print(retry(list_S, ans))


resolve()

Buggy submission (verdict: Runtime Error):
def retry(list_S, ans, start_ii=0):
    for start_i in range(start_ii, len(list_S) - 3):
        for last_i in range(start_i + 3, len(list_S)):
            tmp = ''.join(list_S[start_i:last_i + 1])

            if (int(tmp) % 2019) == 0:
                ans += 1
                retry(list_S, ans, last_i)

    return ans


def resolve():
    S = input()
    list_S = list(S)
    ans = 0

    if len(list_S) <= 3:
        print(ans)
        return

    ans = retry(list_S, ans)

    print(ans)


resolve()
Problem p02705 (python)

Fixed submission:
import math

from decimal import Decimal, getcontext

getcontext().prec = 99


def resolve():
    R = int(input())

    print(R * 2 * math.pi)


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    R = int(input())

    print(R * 2 * math.pi)


resolve()

Buggy submission (verdict: Runtime Error):
from decimal import Decimal, getcontext

getcontext().prec = 99


def resolve():
    R = int(input())

    print(Decimal(R * 2 * math.pi))


resolve()
Problem p02732 (python)

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

from collections import Counter
C=Counter(A)
ANS=0
for i in C.values():
    ANS+=i*(i-1)//2

for a in A:
    k=C[a]

    print(ANS-(k*(k-1)//2)+((k-1)*(k-2)//2))

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    A = sorted(map(int, input().split()))

    counter = collections.Counter(A)
    ans = 0

    for i in counter.values():
        ans += i * (i - 1) // 2

    for a in A:
        count = counter[a]
        print(ans - (count * (count - 1) // 2) +
              ((count - 1) * (count - 2) // 2))

resolve()
Problem p02787 (python)

Fixed submission:
from functools import lru_cache
import sys

sys.setrecursionlimit(1000000)

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

AB = []
for i in range(N):
    A, B = map(int, input().split())
    AB.append((A, B))

AB.sort(key=lambda ab: (ab[0] / ab[1], -ab[0]), reverse=True)


@lru_cache(maxsize=None)
def solve(h):
    if h <= 0:
        return 0
    best = float("inf")
    for a, b in AB:
        val = b + solve(h - a)
        if val < best:
            best = val
        else:
            break
    return best


print(solve(H))

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


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

AB.sort()

ans = 0
dp = np.zeros(H, dtype=int)
for a, b in AB:
    ans = max(ans, dp.max() + b)
    np.max(dp[:-a] + b, dp[a:], out=dp[a:])

print(ans)
Problem p02802 (python)

Fixed submission:
# import itertools
# import math

# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_s[P] == 0:
        ans_p[P] += 1

for i in range(len(ans_p)):
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0

print(str(sum(ans_s)) + " " + str(sum(ans_p)))

Buggy submission (verdict: Runtime Error):
import itertools
# import math

MOD = 10 ** 9 + 7


def solve(N, K, A):
    A.sort()
    ans = 0

    for group in list(itertools.combinations(A, K - 1)):
        ans += max(group) - min(group)

    return ans % MOD


# N = int(input())
# S = input()
N, K = map(int, input().split())
A = list(map(int, input().split()))

print(solve(N, K, A))

Buggy submission (verdict: Runtime Error):
# import itertools
# import math

# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_s[P] == 0:
        ans_p[P] += 1

for i in ans_p:
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0


print(str(sum(ans_s)) + " " + str(sum(ans_p)))

Buggy submission (verdict: Runtime Error):
# import itertools
# import math

# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_p[P] == 0:
        ans_p[P] += 1

for i in ans_p:
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0


print(str(sum(ans_s)) + " " + str(sum(ans_p)))

Buggy submission (verdict: Runtime Error):
# import itertools
# import math

# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_p[P] == 0:
        ans_p[P] += 1

for i in range(ans_p):
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0


print(str(sum(ans_s)) + " " + str(sum(ans_p)))
Problem p02899 (python)

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

index = 1
dic = {}

for i in A:
    dic[i] = index
    index += 1

sort_dic = sorted(dic.items(), key=lambda x:x[0])

for i in sort_dic:
    print(i[1], end = ' ')

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


def solve(A):
    dict_A = {key: val for key, val in zip(A, range(N))}
    score_sorted = sorted(dict_A.items(), key=lambda x : x[1])
    score_sorted = dict(score_sorted)

    return ' '.join(list(score_sorted.keys()))


print(solve(A))
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]


def winner_or_loss(point):
    return 'Yes' if point > 0 else 'No'


def solve():
    point = [K-Q] * N

    for answer_id in A:
        answer_id -= 1
        point[answer_id] += 1

    return '\n'.join(list(map(winner_or_loss, point)))


print(solve())

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


def winner_or_loss(point):
    return 'Yes' if point > 0 else 'No'


def solve():
    point = [K-Q] * N

    for answer_id in A:
        answer_id -= 1
        point[answer_id] += 1

    return '\n'.join(list(map(winner_or_loss, point)))


print(solve())
Problem p02924 (python)

Fixed submission:
def solve(n):
    return n * (n - 1) // 2


N = int(input())

print(solve(N))

Buggy submission (verdict: Runtime Error):

def solve(n):
    n = list(range(1, n))
    return sum(n)


N = int(input())

print(solve(N))
Problem p02953 (python)

Fixed submission:
# import itertools
# import math


def solve(N, H):
    for i in range(N - 1):
        if H[i] < H[i+1]:
            H[i+1] -= 1
        elif H[i] > H[i+1]:
            return 'No'
    return 'Yes'


N = int(input())
# S = input()
# A, B = map(int, input().split())
H = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, H))

Buggy submission (verdict: Runtime Error):
# import itertools
# import math


def solve(N, H):
    for i in range(1, N):
        if H[i] < H[i+1]:
            H[i+1] -= 1
        elif H[i] > H[i+1]:
            return 'No'
    return 'Yes'


N = int(input())
# S = input()
# A, B = map(int, input().split())
H = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, H))
Problem p02958 (python)

Fixed submission:
# import itertools
# import math

import sys
input = sys.stdin.readline


def solve(N, P):
    PP = sorted(P)
    cnt = 0
    for l1, l2 in zip(P, PP):
        if l1 != l2:
            cnt += 1

    return 'YES' if cnt <= 2 else 'NO'


N = int(input())
# S = input()
# A, B = map(int, input().split())
P = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, P))

Buggy submission (verdict: Runtime Error):
# import itertools
# import math

import sys
input = sys.stdin.readline


def solve(N, P):
    NN = sorted(N)
    cnt = 0
    for l1, l2 in zip(N, NN):
        if l1 != l2:
            cnt += 1

    return 'YES' if cnt <= 2 else 'NO'


N = int(input())
# S = input()
# A, B = map(int, input().split())
P = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, P))
Problem p02971 (python)

Fixed submission:
# import itertools
# import math

import sys
input = sys.stdin.readline


def solve(N, A):
    max_idx = A.index(max(A))
    s = sorted(A, reverse=True)

    for i in range(N):
        if i == max_idx:
            print(s[1])
        else:
            print(s[0])


N = int(input())
# S = input()
# A, B = map(int, input().split())
# A = list(map(int, input().split()))


A = []
for i in range(N):
    aa = int(input())
    A.append(aa)


solve(N, A)

Buggy submission (verdict: Runtime Error):
# import itertools
# import math

import sys
input = sys.stdin.readline


def solve(N, A):
    for i in range(N):
        tmp = A
        tmp.pop(i)
        print(max(tmp))


N = int(input())
# S = input()
# A, B = map(int, input().split())
# A = list(map(int, input().split()))


A = []
for i in range(N):
    aa = int(input())
    A.append(aa)


solve(N, A)