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

Fixed submission:
n = input()
number = []
count = 0
flag = False

number = list(map(int, input().split()))
while flag != True:
    tmp = []
    for n in number:
        if n % 2 == 0:
            tmp.append(n / 2)

        else:
            flag = True
            break

    if flag:
        print(count)
        break

    number = tmp
    count += 1

Buggy submission (verdict: Runtime Error):
n: int = input()
number: int = []
count: int = 0
flag: bool = False

number = list(map(int, input().split()))
while flag != True:
    tmp: int = []
    for n in number:
        if n % 2 == 0:
            tmp.append(n / 2)

        else:
            flag = True
            break

    if flag:
        print(count)
        break

    number = tmp
    count += 1

Buggy submission (verdict: Runtime Error):
n: int = input()
number: int = [input().split()]
count: int = 0
flag: bool = False

while flag != True:
    tmp: int = []
    for n in number:
        if n % 2 == 0:
            tmp.append(n / 2)

        else:
            flag = True
            break

    if flag:
        print(count)
        break

    number = tmp
    count += 1
Problem p02953 (python)

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


w = 1
for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        w = 0

for j in range(n-2):
    if h[j] - h[j+1]  == 1:
        for k in range(j,n-2):
            if h[k+1] - h[k+2] == 0:
                continue
            if h[k+1] - h[k+2] == 1:
                w = 0
                break
            break


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

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
w = 1
for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        w = 0
for j in range(n-2):
    if h[j] - h[j+1]  == 1:
        if h[j+1] - h[j+2] == 1:
            w = 0
if h[n-3] == h[n-2] and h[n-2] == h[n-1] +1:
    w = 0
        
if w == 0:
    print("No")
else:
    print("Yes")

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


w = 1
for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        w = 0

for j in range(n-2):
    if h[j] - h[j+1]  == 1:
        
        if h[j+1] - h[j+2] == 1:
            w =0
        else:
            count += 1
    elif h[j] - h[j+1] == 0:
        continue
        
if w == 0:
    print("No")
else:
    print("Yes")
Problem p02958 (python)

Fixed submission:
a = int(input())
 
p = list(map(int, input().split()))
 
d = 0
for i in range(a):
  if not p[i] == i+1:
    d += 1
      
 
  
if d  ==0 or d ==2:
  print("YES")
  
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [int(i) for i in input().split()]
score == 0
for i in range(N):
    if list[i] != i+1:
        score += 1
if score == 0 or 2:
    print("YES")
else:
    print("NO")

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

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

d = 0
for i in range(a):
  if not p[i] == a-i:
    d += 1
      
print(d)
    
  
if d == 0 or d == 2:
  print("YES")
  
else:
  print("NO)
Problem p02969 (python)

Fixed submission:
a = int(input())

b = 3*a**2

print(b)

Buggy submission (verdict: Runtime Error):
a = map(int.input())
print(3*a**2)
Problem p02981 (python)

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

c = a * n
if c > b:
  print(b)
  
else:
  print(c)

Buggy submission (verdict: Runtime Error):
n,a,b =open(0)


c = int(int(a) * int(n))
b = int(b)

if c > b:
  print(b)
  
else:
  print(c)
Problem p02995 (python)

Fixed submission:
import fractions

def lcm(p,q):
    return (p*q) // fractions.gcd(p,q)

def g(x,k):
    return x // k

def f(x,c,d):
    return x - (g(x,c)+g(x,d)-g(x,lcm(c,d)))

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

print(f(b,c,d)-f(a-1,c,d))

Buggy submission (verdict: Runtime Error):
import math

def lcm(p,q):
    return (p*q) // math.gcd(p,q)

def g(x,k):
    return x // k

def f(x,c,d):
    return x - (g(x,c)+g(x,d)-g(x,lcm(c,d)))

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

print(f(b,c,d)-f(a-1,c,d))
Problem p03455 (python)

Fixed submission:
a,b=(int(x) for x in input().split())

if (a*b) % 2 == 0:
  print("Even")
  
else:
  print("Odd")

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

if (a*b) % == 0:
  print("Even")
  
else:
  print("Odd")

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

c = a*b

if c % 2 ==0:
  print(even)

else:
  print(odd)
Problem p03478 (python)

Fixed submission:
def sumall(a):
    n = 0
    while a > 0:
        n += a % 10 
        a = a // 10
    return n
 
 
n, a, b = map(int, input().split())
 
c = [0 for i in range(n)]
for i in range(n):
    c[i] = sumall(i+1)
    
d = 0
for i in range(n):

    if a <= c[i] <= b:
        d += i+1
        
print(d)

Buggy submission (verdict: Runtime Error):
def sumall(a):
    n = 0
    while a > 0:
        n += a % 10 
        a = a // 10
    return n


n,a,b = open(0)

n = int(n)
a = int(a)
b = int(b)

c = [0 for i in range(n)]
for i in range(n):
    c[i] = sumall(i+1)
    
d = 0

for i in range(n):

    if a <= c[i] <= b:
        d += i+1
        
print(d)
Problem p02717 (python)

Fixed submission:
l = input().split(' ')

print(str(l[2])+' '+str(l[0])+' '+str(l[1]))

Buggy submission (verdict: Runtime Error):
l = input()
m = input()
z = l.split(' ')
M = int(z[1])
N = int(z[0])
F = m.split(' ')
X = []

for item in F:
  votes = int(item)
  X.append(votes)
print("Yes")

Buggy submission (verdict: Runtime Error):
l = input()
m = input()
z = l.split(' ')
M = int(z[1])
N = int(z[0])
C = (1/(4*M))*N
F = m.split(' ')
X = []
print("No")

for item in F:
	votes = int(item)
	X.append(votes)
X.sort(reverse = True)
for i in range(M):
	if X[i]<C:
		print("No")
		return
print("Yes")
Problem p02719 (python)

Fixed submission:
NK = input().split(' ')
N = int(NK[0])
K = int(NK[1])

while N>K:
  N = N%K
  
print(min([N,K-N]))

Buggy submission (verdict: Runtime Error):
l = input()
m = l.split(" ")
n = int(m[0])
k = int(m[1])
if n > k:
  n = n//k
  if k = 1:
    n = 0
if n < k:
  n = n
  if n > k/2
  n = n-k
print(n)

Buggy submission (verdict: Runtime Error):
l = input()
m = l.split(" ")
n = int(m[0])
k = int(m[1])
while a < n:
  a = abs(n-k)
  n = a
print(n)

Buggy submission (verdict: Runtime Error):
l = input()
m = l.split(" ")
n = int(m[0])
k = int(n[1])
a = abs(n-k)
while a < n:
  n = a
  a = abs(n-k)
print(n)

Buggy submission (verdict: Runtime Error):
l = input()
m = l.split(" ")
n = int(m[0])
k = int(n[1])
a = abs(n)-abs(k)
while a < n:
  n = a
  a = abs(n) - abs(k)
while a > n:
  n = n
print(n)
Problem p02724 (python)

Fixed submission:
m = int(input())
print(1000*(m//500)+5*((m%500)//5))

Buggy submission (verdict: Runtime Error):
X = input()
print((X//500)*1000+((X-X//500)//5)*5)
Problem p02730 (python)

Fixed submission:
s = input()

def check(s):
  if len(s) == 1 or len(s) == 0:
    return True
  if s[0]!=s[-1]:
    return False
  return check(s[1:-1])

mid = len(s)//2

if check(s) and check(s[0:mid]) and check(s[mid+1:]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(0,len(s)//2):
  if (s[i]!=s[-i-1]):
    print("No")
    break
  if (i == len(s)//2-1)
    print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(1,len(s)/2):
  if (s[i-1]!=s[-i]):
    print("No")
print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
if s == s.reverse():
  print("Yes")
else:
  print("No")
Problem p02731 (python)

Fixed submission:
s = int(input())
side = s/3
ans = pow(side,3)
print(ans)

Buggy submission (verdict: Runtime Error):
l = input().split()
m = int(l)
N = m/3
v = pow(N,3)
print(v)

Buggy submission (verdict: Runtime Error):
s = int(input())
side = s/3

print(side^3)

Buggy submission (verdict: Runtime Error):
print(((int(input()))/3)^3)

Buggy submission (verdict: Runtime Error):
print((int(input())/3)^3)
Problem p02713 (python)

Fixed submission:
mod = 10**9 + 7
import math 
from bisect import bisect_left 
from collections import Counter
from itertools import combinations
 
def ain():
    return map(int, input().split())
def fain():
    return map(float, input().split())
 
def mc2(s):
    return (s*(s-1))//2 + s
    
# for tc in range(int(input())):
#     n = int(input())
    
#     print(ans)

k = int(input())
sum=0
for a in range(1,k+1):
    for b in range(1,k+1):
        g1 = math.gcd(a,b)
        for c in range(1,k+1):
            sum += math.gcd(g1,c)
print(sum)
# python3 pan3.py

Buggy submission (verdict: Runtime Error):
k = int(input())
sum=0
for a in range(1,k+1):
    for b in range(1,k+1):
        g1 = math.gcd(a,b)
        for c in range(1,k+1):
            sum += math.gcd(g1,c)
print(sum)
Problem p03469 (python)

Fixed submission:
s = input()
s = s.replace('2017','2018')
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s[3]='8'
print(s)
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
flg = 0
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            a = i
            b = j
            c = n-i-j
            flg = 1
            break
        else: 
            pass
if flg == 1:
    print(a,b,c)
else:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
n, m =map(int,input().split())
flg=0
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j+1000*(n-i-j)==m:
            flg = 1
            x = i
            y = j
            z = k
            break
        else:
            continue
        break
            
if flg==0:
    print(-1,-1,-1)
else:
    print(x,y,z)
Problem p03486 (python)

Fixed submission:
s = sorted(list(str(input())))
t = reversed(sorted(list(str(input()))))
S = str()
T = str()
for i in s:
    S += i
for k in t:
    T += k
print('Yes' if S<T else 'No')

Buggy submission (verdict: Runtime Error):
s = sorted(list(str(input())))
t = reversed(sorted(list(str(input())))
S = str()
T = str()
for i in s:
    S += i
for k in t:
    T += k
print('Yes' if S<T else 'No')
Problem p03644 (python)

Fixed submission:
n = int(input())
data = [i*2 for i in range(1,n//2+1)]
def f(x):
    cnt = 0
    flg = 0
    while flg==0:
        if x%2==0:
            cnt += 1
            x = x/2
        else:
            flg = 1
    return cnt 
aim = 0
for i in data:
    if aim < f(i):
        aim = f(i)
        num = i
    else:
        continue
if n==1:
    print(1)
else:    
    print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
data = [i*2 for i in range(1,n//2+1)]
def f(x):
    cnt = 0
    flg = 0
    while flg==0:
        if x%2==0:
            cnt += 1
            x = x/2
        else:
            flg = 1
    return cnt 
aim = 0
for i in data:
    if aim < f(i):
        aim = f(i)
        num = i
    else:
        continue
print(num)
Problem p02713 (python)

Fixed submission:
from math import gcd
K = int(input())
r = range(1,K+1)
print(sum(gcd(gcd(a,b),c)for a in r for b in r for c in r))

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

gcd = lambda a,b : a if b == 0 else gcd(b, a % b)
gcd3 = lambda a,b,c = gcd(c, gcd(a,b))

print(sum(list(map(lambda: x,y,z: gcd3(x,y,z), list(range(1,K+1))))))
Problem p02724 (python)

Fixed submission:
x = int(input())
happy500 = (x // 500) * 1000
happy5 = ((x % 500) // 5) * 5
print(happy500 + happy5)

Buggy submission (verdict: Runtime Error):
x = input()
happy500 = (x % 500) * 1000
happy5(500 - (x % 500) * x) % 5 * 5
print(happy500 + happy5)

Buggy submission (verdict: Runtime Error):
X = input()
happier = (X % 500) * 1000
happy = ((X % 500) % 5) * 5
print(happier + happy)
Problem p02888 (python)

Fixed submission:
N = int(input())

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

count = 0 
L.sort()

for i in range(N-2):
    k = i + 2
    for j in range(i+1,N):
        while (k<N and L[i] + L[j] > L[k]):
            k += 1

        if k > j:
            count += k - j - 1


print(count)

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

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

count = 0 
L.sort()

for i in range(N-2):
    k = i + 2
    for j in range(i+1,n):
        while (k<n and L[i] + L[j]):
            k += 1

        if k > j:
            count += k - j - 1


print(count)
Problem p03359 (python)

Fixed submission:
a, b = map(int, input().split())
print(a - 1 + (a <= b))

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

a = []

def is_prime(n):
    if (n % 2 == 0):
        return False

    for i in range(n - 2,1,-2):
        if (n % i == 0):
            return False

    return True

start = 5
for n in range(N):
    for i in range(start,555555,5):
        if (is_prime(i + 1)):
            a.append(i + 1)
            start = i + 5
            break

print(a)
Problem p02898 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
out = 0
for i in h:
 if i >= k:
  out = out + 1
print(out)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
out = 0
for i in h:
 if h >= k:
  out = out + 1
print(out)
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
L = []
for i in range(N):
 L.append(0)
for i in range(Q):
 a = int(input()) - 1
 L[a] += 1
for i in range(N):
 print("Yes" if K - Q + L[i] > 0 else "No")

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
L = []
for i in range(N):
 L.append(0)
for i in range(Q)
 a = int(input()) - 1
 L[a] += 1
for i in range(N):
 print("Yes" if K - Q + L.count(i+1) > 0 else "No")
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())
n = 0
while b > n*(a-1) + 1:
  n = n + 1
else:
  print(n)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = 0
 while ( n < (b-1)/(a-1) ):
  n = n + 1

print(n)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = 0
 while n < (b-1)/(a-1):
  n = n + 1
  
print(n)
Problem p03555 (python)

Fixed submission:
c1 = input()
c2 = input() 
if c1 == c2[::-1]:
 print("YES")
else:
 print("NO")

Buggy submission (verdict: Runtime Error):
c11, c12, c13 = map(int, input())
c21, c22, c23 = map(int, input())
if (c11 == c23) and (c12 == c22) and (c13 == c21):
 print("YES")
else:
 print("NO")

Buggy submission (verdict: Runtime Error):
c11, c12, c13 = map(int, input())
c21, c22, c23 = map(int, input())
if (c11 == c23) and (c12 == c22) and (c13 == c21):
 print("YES")
else:
 print("NO")
Problem p03635 (python)

Fixed submission:
n, m = map(int,input().split())
print((n - 1) * (m - 1))

Buggy submission (verdict: Runtime Error):
n, m = map(int(input().split()))
print((n - 1) * (m - 1))
Problem p03796 (python)

Fixed submission:
n = int(input())
import math
print(math.factorial(n)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
import math
print(math.factorial(n)/(10**9+7))
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())

r = N % 500
if r > A:
    print("No")
else:
    print("Yes")

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

r = n % 500
if r > a:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n, a = map(int,input().split())
 
r = n%500
if r > a:
  print("No")
else:
  print("Yes")

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

r = N%500
if r > A:
  print("No")
else:
  print("Yes")
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
data = input().split()
a = int(data[0])
b = int(data[1])

if (a*b)%2==0:
  print(Even)
else:
  print(Odd)

Buggy submission (verdict: Runtime Error):
data = input().split()
a = int(data[0])
b = int(data[1])

if a*b%2==0:
  print(Even)
else:
  print(Odd)

Buggy submission (verdict: Runtime Error):
data = input().split()
a = int(data[0])
b = int(data[1])

if a*b%2==0:
  print(Even)
else:
  print(Odd)
Problem p03719 (python)

Fixed submission:
print((lambda a,b,c: "Yes" if a<=c and c<=b else "No")(*[int(_) for _ in input().split()]))

Buggy submission (verdict: Runtime Error):
print((lambda a,b,c: "YES" if a<=c&&c<=b else "NO")(*[int(_) for _ in input().split()]))
Problem p02732 (python)

Fixed submission:
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
a = Counter(res)

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
res2 = res.copy()
a = Counter(res)
b = set()
for i in range(len(res)):
    if res[i] not in b:
        b.add(res[i])
        a[res[i]] -= 1
        sums = 0
        for j in a.values():
            sums += j * (j - 1) // 2
        a[res[i]] += 1
        res2 = [sums if x == res[i] else x for x in res2]
for k in res2:
    print(k)
Problem p02747 (python)

Fixed submission:
s = input()
ans = False
if len(s) < 1 or len(s) >10:
    ans = False
if len(s) >= 1 or len(s) <= 10:
    if s == 'hi' or s == 'hihi' or s == 'hihihi' or s == 'hihihihi' or s == 'hihihihihi':
        ans =True
    else:
        ans =False
if ans:
    print ('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
flag = True
ans = True
if len(s) == 1 || len(s)>10:
        ans = False
if len(s) != 1 and len(s) <=10:
    while s :
        if flag:
            if s.pop() == 'i':
                ans = True
                flag = False
            else:
                ans = False
                break
        else:
            if s.pop() == 'h':
                ans = True
                flag = True
            else:
                ans = False
                break
if ans:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
flag = True
ans == True
if len(s) == 1:
        ans = False
if len(s) != 1:
    while s :
        if flag:
            if s.pop() == 'i':
                ans = True
                flag = False
            else:
                ans = False
                break
        else:
            if s.pop() == 'h':
                ans = True
                flag = True
            else:
                ans = False
                break
if ans:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
flag = True
ans == True
if len(s) == 1:
        ans = False
if len(s) != 1:
    while s :
        if flag:
            if s.pop() == 'i':
                ans = True
                flag = False
            else:
                ans = False
                break
        else:
            if s.pop() == 'h':
                ans = True
                flag = True
            else:
                ans = False
                break
if ans:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
flag = True
ans == True
if len(s) == 1:
        ans = False
if len(s) != 1:
    while s :
        if flag:
            if s.pop() == 'i':
                ans = True
                flag = False
            else:
                ans = False
                break
        else:
            if s.pop() == 'h':
                ans = True
                flag = True
            else:
                ans = False
                break
if ans:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
flag =True
for i in range(len(s)):
  if s[i] == 'h':
    if s[i+1] == 'i':
      flag =True
    else:
      flag =False
  else if s[i] == 'i':
    if s[i+1] == 'h':
      flag =True
    else:
      flag =False
  else:
    flag =False
if flag:
  print('Yes')
else:
  print('No')
Problem p02756 (python)

Fixed submission:
from collections import deque
 
s = input()
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(f[2])
            else:
                ans.append(f[2])
        else:
            if cnt % 2 == 0:
                ans.append(f[2])
            else:
                ans.appendleft(f[2])
if cnt % 2 != 0:
    ans.reverse()
print(''.join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
from collections import deque
 
s = input()
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(f[2])
            else:
Problem p02716 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 9)
def solve(pick, idx):

    if pick == 0: return 0
    if idx >= n: return -float('inf')
    if (pick, idx) in dp: return dp[pick, idx]
    if n-idx+2 < pick*2: return -float('inf')
    total = max(A[idx] + solve(pick-1, idx+2), solve(pick, idx+1))

    dp[(pick, idx)] = total
    return total

n = int(input())
A = list(map(int, input().split()))
dp = {}
pick = n//2

print(solve(pick, 0))

Buggy submission (verdict: Runtime Error):
def solve(pick, idx):

    if pick == 0: return 0
    if idx >= n: return -float('inf')
    if (pick, idx) in dp: return dp[pick, idx]
    if n-idx+2 < pick*2: return -float('inf')
    total = max(A[idx] + solve(pick-1, idx+2), solve(pick, idx+1))

    dp[(pick, idx)] = total
    return total

n = int(input())
A = list(map(int, input().split()))
dp = {}
pick = n//2

print(solve(pick, 0))
"""
@lru_cache(None)
def F(index, n):
    if index >= N:
        return -INF
    if N - index + 2 < 2 * n:
        return -INF
    if n == 0:
        return 0
    elif n == 1:
        return max(A[index:])
    ret = max(A[index] + F(index+2, n-1), F(index+1, n))
    return ret
"""

Buggy submission (verdict: Runtime Error):
def solve(pick, idx):

    if pick == 0: return 0
    if idx >= n: return -float('inf')
    if (pick, idx) in dp: return dp[pick, idx]
    # if n-idx+2 < pick*2: return -float('inf')
    total = max(A[idx] + solve(pick-1, idx+2), solve(pick, idx+1))

    dp[(pick, idx)] = total
    return total

n = int(input())
A = list(map(int, input().split()))
dp = {}
pick = n//2

print(solve(pick, 0))

Buggy submission (verdict: Runtime Error):
def solve(pick, idx):

    if pick == 0: return 0
    if idx >= n: return -float('inf')

    if n-idx+2 < pick*2: return -float('inf')
    total = max(A[idx] + solve(pick-1, idx+2), solve(pick, idx+1))

    dp[(pick, idx)] = total
    return total

n = int(input())
A = list(map(int, input().split()))
dp = {}
pick = n//2

print(solve(pick, 0))

Buggy submission (verdict: Runtime Error):
def solve(pick, idx):

    if pick == 0: return 0
    if idx >= n: return -float('inf')

    total = max(A[idx] + solve(pick-1, idx+2), solve(pick, idx+1))

    dp[(pick, idx)] = total
    return total

n = int(input())
A = list(map(int, input().split()))
dp = {}
pick = n//2

print(solve(pick, 0))

Buggy submission (verdict: Runtime Error):
def solve(pick, idx, sum):

    if pick == 0: 
        return sum
    if idx >= n: return -float('inf')

    if (pick, idx) in dp: return dp[(pick, idx)]

    total = 0
    for i in range(idx, n):
        total = max(total, solve(pick-1, i+2, sum+A[i]))

    dp[(pick, idx)] = total
    return total

n = int(input())
A = list(map(int, input().split()))
dp = {}
pick = n//2+1
total = -float('inf')
for i, val in enumerate(A):
    total = max(total, solve(pick-1, i+2, val))
print(total)
Problem p02899 (python)

Fixed submission:
n = int(input())
p_list = list(map(int, input().split()))
p_dict = {}
for i, p in enumerate(p_list):
    p_dict[p] = i
res_list = []
for key in sorted(list(p_dict.keys())):
    res_list.append(str(p_dict[key]+1))
print(' '.join(res_list))

Buggy submission (verdict: Runtime Error):
n = int(input())
a_l = list(map(int, input().split()))
a_d = {}
for i, p in enumerate(a_l):
    a_d[p] = i
res_l = []
for k in sorted(list(a_d.keys())):
    res_l.append(str(a_dt[k]+1))
print(' '.join(res_l))