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

Fixed submission:
S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())

from collections import deque
def operate(i):
    global count, str_list
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                str_list.appendleft(Q_list[i][2])
            else:
                str_list.append(Q_list[i][2])
        else:
            if Q_list[i][1] == '1':
                str_list.append(Q_list[i][2])
            else:
                str_list.appendleft(Q_list[i][2])

check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1

S_list = [i for i in S]
if check % 2 == 1:
    S_list = list(reversed(S_list))

S_n = ''.join(S_list)

str_list = deque()
str_list.append(S_n)
count = check%2
for i in range(Q):
    operate(i)
print(''.join(str_list))

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())
 
from collections import deque
def operate(i):
    global count, str_list
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                str_list.appendleft(Q_list[i][2])
            else:
                str_list.append(Q_list[i][2])
        else:
            if Q_list[i][1] == '1':
                str_list.append(Q_list[i][2])
            else:
                str_list.appendleft(Q_list[i][2])
 
check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1
 
if check % 2 == 1:
    S_list = list(reversed(S_list))
 
str_list = deque()
str_list.append(S)
count = check%2
for i in range(Q):
    operate(i)
print(''.join(str_list))

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())
  
from collections import deque
def operate(i):
    global count, str_list
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                str_list.appendleft(Q_list[i][2])
            else:
                str_list.append(Q_list[i][2])
        else:
            if Q_list[i][1] == '1':
                str_list.append(Q_list[i][2])
            else:
                str_list.appendleft(Q_list[i][2])

check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1

if check % 2 == 1:
    S_list = list(reversed(S_list))

str_list = deque()
str_list.append(S)
count = 0
for i in range(Q):
    operate(i)
print(''.join(str_list))
Problem p02767 (python)

Fixed submission:
import math
N = int(input())
X = list(map(int, input().split()))
 
def sutamina(P, X):
    return (X-P)**2
  
sutamina_min = float('inf')
for i in range(100):
    sutamina_souwa = 0
    for k in X:
        sutamina_souwa += sutamina(i, k)
    if sutamina_souwa < sutamina_min:
        sutamina_min = sutamina_souwa

print(sutamina_min)

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

def sutamina(P, X):
    return (X-P)**2
  
sutamina_min = math.inf
for i in range(100):
    sutamina_souwa = 0
    for k in X:
        sutamina_souwa += sutamina(i, k)
    if sutamina_souwa < sutamina_min:
        sutamina_min = sutamina_souwa

print(sutamina_min)
Problem p02783 (python)

Fixed submission:
H,A = map(int,input().split())
if H%A == 0:
    count = H//A
else:
    count = H//A + 1
print(count)

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split())
magic = list()
for _ in range(N):
    magic.append(list(map(int, input().split())))
 
magic_min = [0 for _ in range(H+1)]
for i in range(H+1):
    if i != 0 and magic_min[i] == 0:
        continue
    for A, B in magic:
        Index = i + A
        value = magic_min[i] + B
        try:
            if magic_min[Index] == 0:
                magic_min[Index] = value
            elif value < magic_min[Index]:
                magic_min[Index] = value
        
        except:
            if magic_min[-1] == 0:
                magic_min[-1] = value
            elif value < magic_min[-1]:
                magic_min[-1] = value
                
print(magic_min[-1])
Problem p02801 (python)

Fixed submission:
C = input()

Alphabet = 'abcdefghijklmnopqrstuvwxyz'
Alphabet_list = [i for i in Alphabet]
print(Alphabet_list[Alphabet_list.index(C)+1])

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

S = []
for e in sys.stdin:
    S.append(e.rstrip())

H, M = map(int, S[0].split())

meiro = []
for i in range(H):
    meiro.append([])
    for k in S[i + 1]:
        if k == '.':
            meiro[i].append(1)
        else:
            meiro[i].append(0)
meiro_array = np.array(meiro)
susumikata = [[1, 0], [-1, 0], [0, 1], [0, -1]]


def BFS(y, x):
    global max_distance
    if meiro_array[x, y] == 1:
        max_distance = 0
        reached = {(x, y): 0}
        for i in range(H * M):
            zahyous = [k for k, v in reached.items() if v == i]
            for zahyou in zahyous:
                for susumi in susumikata:
                    new_zahyou = tuple([zahyou[0] + susumi[0], zahyou[1] + susumi[1]])
                    if not(0 <= new_zahyou[0] < H and 0 <= new_zahyou[1] < M):
                        a = 0
                    elif new_zahyou not in reached.keys() and meiro_array[new_zahyou] == 1:
                        reached[new_zahyou] = i + 1
                        max_distance = i + 1

    return max_distance


keiro_max = []
for x in range(H):
    for y in range(M):
        keiro_max.append(BFS(x, y))

print(max(keiro_max))
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())

if 500 * K >= X:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
K, X = map(int, input())

if 500 * X >= X:
    print('Yes')
else:
    print('No')
Problem p02813 (python)

Fixed submission:
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [i for i in range(1,N+1)]
conbination = list(itertools.permutations(N_list, N))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [i for i in range(1,N)]
conbination = list(itertools.permutations(N_list, N))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [i for i in range(1,N)]
conbination = list(itertools.permutations(N_list, 8))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [1, 2, 3, 4, 5, 6, 7, 8]
conbination = list(itertools.permutations(N_list, 8))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))
Problem p02882 (python)

Fixed submission:
import math

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

sakaime = a * a * b / 2

if x > sakaime:
    try:
        tan = a / (2 * (b - (x / (a ** 2))))
    except:
        tan = float('inf')
else:
    tan = 2 * x / (a * (b**2))

ans = math.degrees(math.atan(tan))

if ans >= 0:
    print(90-ans)

Buggy submission (verdict: Runtime Error):
import math

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

sakaime = a * a * b / 2

if x > sakaime:
    tan = a / (2 * (b - (x / (a ** 2))))
else:
    tan = 2 * x / (a * (b**2))

ans = math.degrees(math.atan(tan))

if ans >= 0:
    print(90-ans)
Problem p02646 (python)

Fixed submission:
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if v<=w:
    print("NO")
else:
    if abs(b-a)<=t*(v-w):
        print("YES")
    else:
        print("NO")

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

if v<=w:
    print("NO")
else:
    if abs(b-a)<=(v-w):
    if abs(b-a)%(v-w)==0 and abs(b-a)//(v-w)<=t:
        print("YES")
    else:
        print("NO")

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

if v<=w:
    print("NO")
else:
    if abs(b-a)<=(v-w)
    if abs(b-a)%(v-w)==0 and abs(b-a)//(v-w)<=t:
        print("YES")
    else:
        print("NO")
Problem p02675 (python)

Fixed submission:
N=int(input())%10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
if N==3:
    print("bon")
elif N in hon:
    print("hon")
else:
    print("pon")

Buggy submission (verdict: Runtime Error):
N=int(input())%10

if n ==3:
  print("bon")
Problem p02681 (python)

Fixed submission:
N=input()
NN=input()

if len(NN)==len(N)+1:
    if NN[:len(N)]==N:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
L=list(map(int,input().split()))
cnt=0
i=0
SET=set()
S=[]
while not(L[i] in SET):
    S.append(i+1)
    SET.add(i+1)
    i=L[i]-1

    
S.append(i+1)
SS=S


S=S[S.index(L[i]):]

cnt=len(S)



print(SS[K%(cnt)])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
L=list(map(int,input().split()))
cnt=0
i=0
SET=set()
S=[]
while not(L[i] in SET):
    S.append(i+1)
    SET=set(S)
    i=L[i]-1

    
S.append(i+1)
SS=S


S=S[S.index(L[i]):]

cnt=len(S)



print(SS[K%(cnt)])
Problem p04043 (python)

Fixed submission:
A,B,C=map(int,input().split())
if A*B*C==(5*5*7) :
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
if A+B+C==5*5*7 :
  print("YES")
  else:
    print("NO")
Problem p02796 (python)

Fixed submission:
n = int(input())
d = []
left = []
right = []
for i in range(n):
    x,l = map(int, input().split())
    # num , left , right
    d.append([x-l,x+l])

d.sort()
p = d[0][1]
ans = n
for i in range(1,n):
    if d[i][0] < p:
        ans -= 1
        p = min(p,d[i][1])
    else:
        p = d[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
def find_dex(list,dex):
    for j in range(len(list)):
        if list[j][0] == dex:
            return j
    return 0
n = int(input())
a = np.zeros((10**9))
d = []
left = []
right = []
for i in range(n):
    x,l = map(int, input().split())
    # num , left , right
    left.append([i,x-l+1,x+l-1])
    right.append([i,x-l+1,x+l-1])

left.sort(key=lambda x:x[1],reverse=False)
right.sort(key=lambda x:x[2],reverse=False)

flag = True
p = 10**9 + 1
ans = 0
while len(left) > 0:
    if flag:
        i,l,r = left.pop(-1)
        right.pop(find_dex(right,i))
        flag = False
        if r >= p:
            ans += 1
        p = l

    else:
        i,l,r = right.pop(-1)
        left.pop(find_dex(left,i))
        flag = True
        if r >= p:
            ans += 1
        p = l

    #print(i,l,r)
    #print(left)
    #print(right)

print(n-ans)

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

def find_dex(list,dex):
    for j in range(len(list)):
        if list[j][0] == dex:
            return j

    return 0

n = int(input())
a = np.zeros((10**9))
d = []
left = []
right = []
for i in range(n):
    x,l = map(int, input().split())
    # num , left , right
    left.append([i,x-l+1,x+l-1])
    right.append([i,x-l+1,x+l-1])

left.sort(key=lambda x:x[1],reverse=False)
right.sort(key=lambda x:x[2],reverse=False)

flag = True
p = 10**9 + 1
ans = 0
while len(left) > 0:
    if flag:
        i,l,r = left.pop(-1)
        right.pop(find_dex(right,i))
        flag = False
        if r >= p:
            ans += 1
        p = l

    else:
        i,l,r = right.pop(-1)
        left.pop(find_dex(left,i))
        flag = True
        if r >= p:
            ans += 1
        p = l


    #print(i,l,r)
    #print(left)
    #print(right)

print(n-ans)
Problem p02972 (python)

Fixed submission:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))
b = [0] * (n+1)
for i in range(n):
    b[i+1] = a[i]

#print(b)

#print('p',n//2)
for i in reversed(range(1,n//2 + 1)):
    j = 2
    b_sum = 0
    #print(i)
    while i * j <= n:
        #print(i,j)
        b_sum += b[i*j]
        j += 1
    if (b_sum % 2) == a[i-1]:
        b[i] = 0
    else:
        b[i] = 1

#print(b)

s = sum(b)

print(s)
if s > 0:
    sl = ''
    for i in range(len(b)):
        if b[i] == 1:
            sl += str(i) + ' '

    print(sl[:-1])

Buggy submission (verdict: Runtime Error):

import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))

b = np.zeros((n))




from numpy.linalg import solve

c = np.zeros((n,n))
for i in range(n):

    j = 1
    while (i+1) * j <= n:
        c[i][(i+1) * j-1] = 1
        j += 1

#print(c)
b = solve(c,a)
#print(b)

'''
for i in range(n):
    b[i] = a[i]

#print(b)

if n % 2 == 0:
    p = int(np.ceil(n/2))
else:
    p = int(np.ceil(n/2)-1)
#print(p)

for i in reversed(range(p+1)):
    for j in reversed(range(1,int(n/(i+1)))):
        #print(i,j)
        b[i] -= b[(i+1)*(j+1)-1]

'''


b = b.astype(int)

#print(b)

flag = True
for i in range(n):
    if b[i] < 0:
        flag = False
        break

if flag:
    print(str(b).replace('[','').replace(']','').replace(' 0',''))

else:
    print(-1)
Problem p02995 (python)

Fixed submission:
a,b,c,d = map(int, input().split())
def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y%x, x)
def lcm(x,y):
    return x * y // gcd(x,y)
l = lcm(c,d)
ans_b = b - b//c - b//d + b//l
ans_a = (a-1) - (a-1)//c - (a-1)//d + (a-1)//l
print(ans_b - ans_a)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())



g = c * d / math.gcd(c, d)

b_c = int(b / c)
b_d = int(b / d)

l_b = int(b / g)

ans_b = b - b_c - b_d + l_b

a_c = int((a-1) / c)
a_d = int((a-1) / d)

l_a = int((a-1) / g)

ans_a = (a - 1) - a_c - a_d + l_a

print(ans_b - ans_a)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
a,b,c,d = map(int, input().split())

cs = math.ceil(a / c)
ds = math.ceil(a / d)

w = np.zeros((b + 1))

x = int(c * cs)
while x <= b:
    w[x] = 1
    x += c

y = int(d * ds)
while y <= b:
    w[y] = 1
    y += d

print(int(len(w) - a - w.sum()))
Problem p03085 (python)

Fixed submission:
b = input()

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'G':
    print('C')
elif b == 'C':
    print('G')

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

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'G':
    print('C')
elif b == 'C':
    print('G')
Problem p03469 (python)

Fixed submission:
s = str(input())
print("2018" + s[4:])

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

flag = True
while (flag):
	input_line = sys.stdin.readline()
    if not input_line:
      break

    input_line[0:3] = '2018'
	print(input_line)
Problem p03470 (python)

Fixed submission:
#coding : utf-8
 
n = int(input())
d = []
for i in range(n):
    d.append(int(input()))
print(len(list(set(d))))

Buggy submission (verdict: Runtime Error):
N = input()
d = []
for i in range(N):
    d.append(input())
print(len(list(set(d)))

Buggy submission (verdict: Runtime Error):
N = input()
d = []
for i in range(N):
    a.append(input())
print(len(list(set(li)))
Problem p02642 (python)

Fixed submission:
import sys
from collections import deque
import copy
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    MAX = (10 ** 6) + 5
    prime = [True] * MAX
    ans = 0
    for i in range(1, N):
        if A[i] == A[i - 1] and prime[A[i]]:
            prime[A[i]] = False
            for j in range(A[i] * 2, MAX, A[i]):
                prime[j] = False
    for i in range(N):
        now = A[i]
        if prime[now]:
            ans += 1
            for j in range(now * 2, MAX, now):
                prime[j] = False
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
import copy
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    MAX = 2 * (10 ** 5) + 1
    prime = [True] * MAX
    ans = 0
    for i in range(1, N):
        if A[i] == A[i - 1]:
            prime[A[i]] = False
    for i in range(N):
        now = A[i]
        if prime[now]:
            ans += 1
            for j in range(now * 2, MAX, now):
                prime[j] = False
    print(ans)


if __name__ == '__main__':
    main()
Problem p02647 (python)

Fixed submission:
import sys
from collections import deque
import copy
import math
def main():
    N, K = map(int, input().split())
    a = [int(i) for i in input().split()]
    A = [0] * (N + 1)
    if K >= 41:
        for i in range(1, N+1):
            if i > 1:
                print(' ', end='')
            print(N, end='')
        print()
        sys.exit()
    for i in range(1, N+1):
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        for i in range(1, N+1):
            left_d = max(math.ceil(i - A[i]), 1)
            right_d = min(math.floor(i + A[i]), N)
            count[left_d] += 1
            if right_d + 1 <= N:
                count[right_d + 1] -= 1
        for i in range(1, N+1):
            count[i] += count[i - 1]
        A = copy.copy(count)
    
    for i in range(1, N+1):
        if i > 1:
            print(' ', end='')
        print(A[i], end='')
    print()


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
import copy
import math
def main():
    N, K = map(int, input().split())
    a = [float(i) for i in input().split()]
    A = [0] * (N + 1)
    if K >= N:
        for i in range(1, N+1):
            if i > 1:
                print(' ', end='')
            print(N, end='')
        print()
        sys.exit()
    for i in range(1, N+1):
        if a[i - 1] > N:
            a[i - 1] = N
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        for i in range(1, N+1):
            if A[i] == N:
                left_d = 1
                right_d = N
                count[1:] += 1
            else:
                left_d = math.ceil(i - A[i] - 0.5)
                right_d =  math.floor(i + A[i] + 0.5)
                if left_d < 1:
                    left_d = 1
                if right_d > N:
                    right_d = N
                for j in range(left_d, right_d+1):
                    count[j] += 1
        A = copy.copy(count)
        flag = True
        for i in range(1, N+1):
            if A[i] != N:
                flag = False
                break
        if flag:
            break
    for i in range(1, N+1):
        if i > 1:
            print(' ', end='')
        print(A[i], end='')
    print()


if __name__ == '__main__':
    main()
Problem p02657 (python)

Fixed submission:
import sys
from collections import deque
import copy
def main():
    A, B = map(int, input().split())
    print(A * B)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
import copy
def main():
    A,B = map(int, input())
    print(A * B)

if __name__ == '__main__':
    main()
Problem p02696 (python)

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

if B > N:
    x = N
else:
    x = B - 1

m = int(A * x / B) - A * int(x / B)

print(m)

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

if B > N:
    x = N
else:
    X = B - 1

m = int(A * x / B) - A * int(x / B)

print(m)
Problem p02732 (python)

Fixed submission:
import collections
import math

def nC2(n):
    return n * (n - 1) / 2

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

c = collections.Counter(A)
sum_values = sum(map(nC2, c.values()))

for n in range(N):
    if c[A[n]] == 1:
        print(int(sum_values))
    else:
        print(int(sum_values - (c[A[n]] - 1)))

Buggy submission (verdict: Runtime Error):
import collections
import math

def nC2(n):
    if n == 1:
        return 0
    return nCr(n, 2)

def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

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

c = collections.Counter(A)
sum_values = sum(map(nC2, c.values()))

for n in range(N):
    print(int(sum_values - (nC2(c[A[n]]) - nC2(c[A[n]] - 1))))

Buggy submission (verdict: Runtime Error):
import collections
import math

def nC2(n):
    if n == 1:
        return 0
    return nCr(n, 2)

def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

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

c = collections.Counter(A)
sum_values = sum(map(nC2, c.values()))

for n in range(N):
    if c[A[n]] == 1:
        print(int(sum_values))
    else:
        print(int(sum_values - (nC2(c[A[n]]) - nC2(c[A[n]] - 1))))
Problem p02756 (python)

Fixed submission:
from collections import deque

S = input()
Q = int(input())

ANS = deque(S)

rev = 0

for _ in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        rev = rev ^ 1
    else:
        f, c = int(query[1]), query[2]
        if (f - 1) ^ rev:
            ANS.append(c)
        else:
            ANS.appendleft(c)

if rev:
    ANS.reverse()

print(''.join(ANS))

Buggy submission (verdict: Runtime Error):
S: str = input()
Q = int(input())

ANS = S

for _ in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        ANS = ANS[::-1]
    else:
        f, c = query[1:]
        if f == '1':
            ANS = c + ANS
        else:
            ANS = ANS + c

print(ANS)
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split(' '))

N = 2019


ans = 2019

for i in range(L, R):
    for j in range(i + 1, R + 1):
        mod = (i * j) % N
        if ans > mod:
            ans = mod
        if ans == 0:
            print(ans)
            exit(0)

print(ans)

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

N = 2019


ans = 2019

for i in range(L, R):
    for j in range(i + 1, R + 1):
        mod = (i * j) % N
        if ans > mod:
            ans = mod
        if ans = 0:
            print(ans)
            exit(0)

print(ans)
Problem p03219 (python)

Fixed submission:
x,y=map(int,input().split())
ans=x+int(y/2)
print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
y=int(input())
ans=x+int(y/2)
print(ans)
Problem p02923 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
startpt=0
indexer=0
maxi=0
i=1
while(i<n):
    if(a[i]>a[i-1]):
        maxi=max(i-startpt-1,maxi)
        startpt=i
        
    i+=1
maxi=max(i-startpt-1,maxi)
print(maxi)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def findMax(a):
    l=len(a)
    if(l==0):
        return 0
    elif(l==1):
        return 0
    else:
        i=1
        while(i<l):
            if(a[i]>a[i-1]):
                return(max(i-1,findMax(a[i:])))
            i+=1
        return l-1

print(findMax(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def findMax(a):
    l=len(a)
    if(l==0):
        return 0
    else:
        i=1
        while(i<l):
            if(a[i]>a[i-1]):
                return(max(i,findMax(a[i:])))
            i+=1
        return l

print(findMax(a)-1)
Problem p02971 (python)

Fixed submission:
n=int(input())
i=0
b=[]
pos=0
maxi=0
while(i<n):
  k=int(input())
  b.append(k)
  if(k>maxi):
    pos=i
    maxi=k
  i+=1
b.sort()
ns=b[n-2]
i=0
while(i<n):
  if(i==pos):
  	print(ns)
  else:
    print(b[n-1])
  i+=1

Buggy submission (verdict: Runtime Error):
n=int(input())
i=0
b=[]
pos=0
maxi=0
while(i<n):
  k=int(input())
  b.append(k)
  if(k>maxi):
    pos=i
    maxi=k
  i+=1
b.sort()
ns=b[n-2]
i=0
while(i<n):
  if(i==posi)
  	print(ns)
  else:
    print(b[i])
  i+=1