TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
from functools import lru_cache

@lru_cache(None)
def dp(N,A,i,k):
    if k<=0:
        return 0
    tmp=N-i
    if k>(tmp//2)+(tmp%2):
        return -float('inf')
    return max(A[i]+dp(N,A,i+2,k-1),dp(N,A,i+1,k))

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    print(dp(N,A,0,N//2))

main()


from math import ceil
INF=float('inf')

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    def dp(i,k):
        print(i,k)
        if k<=0:
            return 0
        tmp=N-i
        if k>ceil(tmp/2):
            return -INF
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))

    print(dp(0,N//2))

main()

from math import ceil

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]

    def dp(i,k):
        print(i,k)
        if k<=0:
            return 0
        tmp=N-i
        if k>ceil(tmp/2):
            return -float('inf')
        return max(A[i]+dp(i+2,k-1),dp(i+1,k))

    print(dp(0,N//2))

main()

def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    for d in dp:
        print(d)
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()


def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
n=int(input())
arr=list(map(int,input().split()))
lim=n%2+2
dp=[[0]*lim for _ in range(n+100)]
for i in range(n):
  dp[i+1][0]=dp[i-1][0]+arr[i]
  dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
  if lim==3:
    dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
print(max(dp[-1][:lim]))

n=int(input())
arr=list(map(int,input().split()))
acum1=[0]
acum2=[0]
for i in range(n):
  if i%2==0:
    acum1.append(acum1[-1]+arr[i])
    acum2.append(acum2[-1]+0)
  else:
    acum1.append(acum1[-1]+0)
    acum2.append(acum2[-1]+arr[i])
if n%2==0:
  ans=max(acum1[n-1]-acum1[0],acum2[n]-acum2[1])
  for i in range(1,n+1,2):
    if i+3>n:
      continue
    tmp=(acum1[i]-acum1[0])+(acum2[n]-acum2[i+2])
    ans=max(ans,tmp)
else:
  ans=max(acum1[n-2]-acum1[0],acum2[n-1]-acum2[1],acum1[n]-acum1[2])
  for i in range(1,n+1,2):
    if i+3>n-1:
      continue
    tmp=(acum1[i]-acum1[0])+(acum2[n-1]-acum2[i+2])
    ans=max(ans,tmp)
  for i in range(2,n+1,2):
    if i+3>n:
      continue
    tmp=(acum2[i]-acum2[1])+(acum1[n]-acum1[i+2])
    ans=max(ans,tmp)
  for i in range(1,n+1,2):
    if i+4>n:
      continue
    tmp=(acum1[i]-acum1[0])+(acum1[n]-acum1[i+3])
    ans=max(ans,tmp)
  acummax=[-10**18]
  for i in range(1,n+1):
    if i+2>n:
      acummax.append(-10**18)
    else:
      if i%2==0:
        acummax.append(acum2[i]+acum1[n]-acum1[i+2])
      else:
        acummax.append(-10**18)
  for i in range(n-1,-1,-1):
    acummax[i]=max(acummax[i],acummax[i+1])
  for i in range(1,n+1,2):
    if i+6>n:
      continue
    tmp=(acum1[i]-acum1[0]-acum2[i+2])+acummax[i+3]
    ans=max(ans,tmp)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
n,*l=open(0);n=int(n);l=list(map(int,l.split()))
p=[0]*n;d=[0]*n
for i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if(i&1)else d[i-1],l[i]+d[i-2])
print(d[-1])

n,*l=open(0);n=int(n);l=list(map(int,l))
p=[0]*n;d=[0]*n
for i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if(i&1)else d[i-1],l[i]+d[i-2])
print(d[-1])

n=int(input());l=list(map(int,input().split()));p=[0]*n;d=[0]*n
for i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]*(i&1)+d[i-1]*(i&1),l[i]+d[i-2])
print(d[-1])

n=int(input());l=list(map(int,input().split()));p=[0]*n;d=[0]*n
for i in range(n):p[i]=l[i]+p[i-2];d[i]=max(p[i-1]if i&1else d[i-1],l[i]+d[i-2])
print(d[-1])

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
dp = [{} for _ in range(N+1)]
INF = -float('inf')
for i in range(1,N+1):
    mid = i//2
    dp[i][mid-2],dp[i][mid-1],dp[i][mid],dp[i][mid+1],dp[i][mid+2]=INF,INF,INF,INF,INF
dp[1][1] = A[0]
dp[2][1] = max(A[1],dp[1][1])
dp[1][0],dp[2][0]=0,0

for i in range(2,N):
  a = A[i]
  ma = (i+2)//2
  mi = i//2
  dp[i+1][ma] = max(dp[i][ma],dp[i-1][ma-1]+a)
  dp[i+1][mi] = max(dp[i][mi],dp[i-1][mi-1]+a)

print(dp[-1][N//2])
print(dp)

N = int(input())
A = list(map(int,input().split()))
dp = [{} for _ in range(N+1)]
INF = -float('inf')
for i in range(1,N+1):
    mid = i//2
    dp[i][mid-2],dp[i][mid-1],dp[i][mid],dp[i][mid+1],dp[i][mid+2]=INF,INF,INF,INF,INF
dp[1][1] = A[0]
dp[2][1] = max(A[1],dp[1][1])
dp[1][0],dp[2][0]=0,0

for i in range(2,N):
  a = A[i]
  ma = (i+2)//2
  mi = i//2
  dp[i+1][ma] = max(dp[i][ma],dp[i-1][ma-1]+a)
  dp[i+1][mi] = max(dp[i][mi],dp[i-1][mi-1]+a)

print(dp[-1][N//2])

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):


n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(-1 * 10**9, 10**9) for i in range(n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	odd = [0]
	even = [0]
	for i in range(n // 2):
		odd.append(odd[-1] + a[2*i])
		even.append(even[-1] + a[2*i+1])
	if n % 2 == 1:
		odd.append(odd[-1] + a[-1])

	print(odd)
	print(even)
	answer = -1 * 10**9 * n
	if n % 2 == 0:
		for i in range(n // 2 + 1):
			answer = max(answer, odd[i] - even[i] + even[-1])
	else:
		for i in range(n // 2 + 2):
			if i < n // 2 + 1:
				for j in range(i+1):
					answer = max(answer, odd[j] - even[j] + even[i] - odd[i+1] + odd[-1])
			else:
				for j in range(i):
					answer = max(answer, odd[j] - even[j] + even[-1])
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)




n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(-1 * 10**9, 10**9) for i in range(n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	odd = [0]
	even = [0]
	for i in range(n // 2):
		odd.append(odd[-1] + a[2*i])
		even.append(even[-1] + a[2*i+1])
	if n % 2 == 1:
		odd.append(odd[-1] + a[-1])

	answer = -1 * 10**9 * n
	if n % 2 == 0:
		for i in range(n // 2 + 1):
			answer = max(answer, odd[i] - even[i] + even[-1])
	else:
		even_range = [even[0] - odd[1]]
		for i in range(n // 2):
			add = a[2*i+1] - a[2*i+2]
			min = - a[2*i] + add
			even_range.append(max(even_range[-1] + add, min))
		answer = odd[-1] + max(even_range)
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
input()
aa = map(int, input().split())

bb = [0] * len(aa)
bb[0] = aa[0]
bb[1] = aa[1]
for i in range(2,len(aa)):
    bb[i] = bb[i-2] + aa[i]

sum0 = bb[len(aa)-2]
sum1 = bb[len(aa)-1]
ret = sum1
if len(aa)%2 == 0:
    ret = max(ret, sum0)
if len(aa)%2:
    sum0 = bb[len(aa)-1]
    sum1 = bb[len(aa)-2]
    for i in range(len(aa)//2):
        ret = max(ret, sum0 - aa[2*i])

# 0 -> 1
for i in range(0,len(aa)//2):
    try:

        ret = max(ret, bb[i] - bb[i+3] + sum1 + aa[i+3] )
    except:
        0
# 1 -> 0
for i in range(0,len(aa)//2):
    try:

        ret = max(ret, bb[2*i+1] - bb[2*i+4] + sum0 + aa[2*i+4] )
    except:
        0
print(ret)

bb = [0] * len(aa)
bb[0] = aa[0]
bb[1] = aa[1]
for i in range(2,len(aa)):
    bb[i] = bb[i-2] + aa[i]

sum0 = bb[len(aa)-2]
sum1 = bb[len(aa)-1]
ret = sum1
if len(aa)%2 == 0:
    ret = max(ret, sum0)
if len(aa)%2:
    sum0 = bb[len(aa)-1]
    sum1 = bb[len(aa)-2]
    for i in range(len(aa)//2):
        ret = max(ret, sum0 - aa[2*i])

# 0 -> 1
for i in range(0,len(aa)//2):
    try:

        ret = max(ret, bb[i] - bb[i+3] + sum1 + aa[i+3] )
    except:
        0
# 1 -> 0
for i in range(0,len(aa)//2):
    try:

        ret = max(ret, bb[2*i+1] - bb[2*i+4] + sum0 + aa[2*i+4] )
    except:
        0
print(ret)

input()
aa = list(map(int, input().split()))
state = {(0,False)}
skipmax = len(aa)%2 + 1
state_all = {(i, True) for i in range(skipmax+1)}.union({(j, False) for j in range(skipmax+1)})
dp_0 = {a:None for a in state_all }
dp_0[(0,False)] = 0
skipcount = 0

def getmax(a, b):
    if a is None:
        return b
    if b is None:
        return a
    return max(a,b)

for i,a in enumerate(aa):
    dp_1 = {}
    for s in state_all:
        if s[1] & (dp_0[(s[0], False)] is not None):
            dp_1[s] = dp_0[(s[0], False)] + a
            continue
        dp_1[s] = getmax(dp_0[(s[0], True)], dp_0.get((s[0]-1, False), None))
    dp_0 = dp_1.copy()
if len(aa)%2:
    print(getmax(dp_0[(2,True)], dp_0[(1,False)]))
else:
    print(getmax(dp_0[(1,True)], dp_0[(0,False)]))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
import collections
import math

N, *A = map(int, open(0).read().split())
a = dict(enumerate(A, 1))
dp = collections.defaultdict(int)
dp[1, 1] = a[1]

for i in range(2, N + 1):
    jj = range(math.floor(i // 2 - 1), math.ceil((i + 1) // 2) + 1)
    debug(jj)
    for j in jj:
        x = dp[i - 2, j - 1] + a[i]
        y = dp[i - 1, j]
        dp[i, j] = max(x, y)

print(dp[N, N // 2])

#!/usr/bin/env python3
# coding: utf-8
import collections
def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)

def main():
    pass
    N, *A = map(int, open(0).read().split())
    a = dict(enumerate(A, 1))
    dp = collections.defaultdict(lambda: -float("inf"))
    dp[0, 0] = 0 
    dp[1, 0] = 0 
    dp[1, 1] = a[1]
    for i in range(2, N + 1):
        jj = range(max(i // 2 - 1, 1), (i + 1) // 2 + 1)
        for j in jj:
            x = dp[i - 2, j - 1] + a[i]
            y = dp[i - 1, j]
            dp[i, j] = max(x, y)
    print(dp[N, N // 2])

if __name__ == "__main__":
    main()

Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
N = int(input())
*A, = map(int,input().split())

if N%2==0:
    1/0
    ans = max(sum(A[::2]),sum(A[1::2]))
    print(ans)
else:
    INF = 2* 10**9
    dp = [[-INF]*N for _ in [0]*3]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    for i in range(2,N,2):
        a = A[i]
        dp[0][i] = dp[0][i-2] + a
    for i in range(3,N):
        a = A[i]
        dp[1][i] = max(dp[1][i-2],dp[0][i-3]) + a
    for i in range(4,N,2):
        a = A[i]
        dp[2][i] = max(dp[2][i-2],dp[1][i-3],dp[0][i-4]) + a
    print(dp[2][-1])

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

if N%2==0:
    INF = 2* 10**9
    dp = [[-INF]*N for _ in [0]*2]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    for i in range(2,N,2):
        a = A[i]
        dp[0][i] = dp[0][i-2] + a
    for i in range(3,N):
        a = A[i]
        dp[1][i] = max(dp[1][i-2],dp[0][i-3]) + a
    print(max(dp[1][-1],dp[0][-2]))
else:
    INF = 2* 10**9
    dp = [[-INF]*N for _ in [0]*3]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    for i in range(2,N,2):
        a = A[i]
        dp[0][i] = dp[0][i-2] + a
    for i in range(3,N):
        a = A[i]
        dp[1][i] = max(dp[1][i-2],dp[0][i-3]) + a
    for i in range(4,N,2):
        a = A[i]
        dp[2][i] = max(dp[2][i-2],dp[1][i-3],dp[0][i-4]) + a
    print(max(dp[2][-1],dp[1][-2],dp[0][-3]))

Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
INF = 10**18

dp0 = [-INF] * (N + 2)
dp1 = [-INF] * (N + 2)
dp2 = [-INF] * (N + 2)
dp0[0] = 0
dp0[1] = 0

for i, a in enumerate(A, start=2):
    dp0[i] = dp0[i - 2] + a
    dp1[i] = max(dp1[i - 2] + a, dp0[i - 1])
    dp2[i] = max(dp2[i - 2] + a, dp1[i - 1], dp0[i - 2])

if N % 2 == 1:
    print(dp2[-1])
else:
    print(max(dp1[-1], dp0[-2]))


N = int(input())
A = list(map(int, input().split()))
INF = 10**18

dp0 = [-INF] * (N + 2)
dp1 = [-INF] * (N + 2)
dp2 = [-INF] * (N + 2)
dp0[0] = 0
dp1[0] = 0

for i, a in enumerate(A, start=2):
    dp0[i] = dp0[i - 2] + a
    dp1[i] = max(dp1[i - 2] + a, dp0[i - 1])
    dp2[i] = max(dp2[i - 2] + a, dp1[i - 1], dp0[i - 3])

if N % 2 == 1:
    print(dp2[-1])
else:
    print(max(dp1[-1], dp0[-1]))


N = int(input())
A = list(map(int, input().split()))
INF = 10**18

dp0 = 0
dp1 = -INF
dp2 = -INF

for i, a in enumerate(A):
    if i % 2 == 0:
        dp1 = max(dp1, dp0)
        dp0 += a
        dp2 += a
    else:
        dp2 = max(dp2, dp1)
        dp1 += a

if N % 2 == 1:
    print(max(dp1, dp2))
else:
    print(max(dp0, dp1))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))

DP = [0,0,0]
m = N//2*2
if N%2 == 0:
    for i in range(0,m,2):
        DP[0] += A[i]
        DP[1] += A[i+1]
        DP[1] += max(DP[0],DP[1])

    print(DP[1])

else:
    for i in range(0,m,2):
        DP[0] += A[i]
        DP[1] += A[i+1]
        DP[2] += A[i+2]

        DP[1] = max(DP[0],DP[1])
        DP[2] = max(DP[1],DP[2])

    print(DP[2])


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

DP = [0,0,0]
m = N//2*2
if N%2 == 0:
    for i in range(0,m,2):
        DP[0] += A[i]
        DP[1] += A[i+1]
        DP[1] = max(DP[0],DP[1])

    print(DP[1])

else:
    for i in range(0,m,2):
        DP[0] += A[i]
        DP[1] += A[i+1]
        DP[2] += A[i+2]

        DP[1] = max(DP[0],DP[1])
        DP[2] = max(DP[1],DP[2])

    print(DP[2])


Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

macro_rules! max {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: max ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: max ($ a , max ! ($ ($ rest ) ,+ ) ) } } ; }


fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut dp = vec![vec![0; 3]; n+4];
    for i in 0..n{
        dp[i + 4][0] = dp[i + 2][0] + a[i];
        dp[i + 4][1] = max!(dp[i+2][1], dp[i+1][0]) + a[i];
        if n & 1 > 0 {
            dp[i + 4][2] = max!(dp[i + 2][2], dp[i + 1][1], dp[i][0]) + a[i];
        }
    }
    if n & 1 > 0 {
        println!("{}", max!(dp[n+1][0], dp[n+2][1], dp[n+3][2]));
    } else {
        println!("{}", max!(dp[n+2][0], dp[n+3][1]));
    }
}

import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = nl()
dp = [[0]*3 for _ in range(n+5)]
t = n%2
for i in range(n):
    dp[i][0] = dp[i-2][0] + a[i]
    dp[i][1] = max(dp[i-2][1], dp[i-3][0]) + a[i]
    if t:
        dp[i][2] = max(dp[i-2][2], dp[i-3][1], dp[i-4][0]) + a[i]
if t:
    print(max(dp[n-3][0], dp[n-2][1], dp[n-1][2]))
else:
    print(max(dp[n-2][0], dp[n-1][1]))


Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
n = int(input())
a = [int(i) for i in input().split()]

    
b = a[:4]
e = [True]*4

for i in range(1, n // 2):
    c = [0] * 4
    f = [False]*4
    d = -10**24
    for j in range(4):
        if 2 * i + j >= n:
            continue
        if not e[j]:
            continue
        d = max(d, b[j])
        c[j] = d + a[2 * i + j]
        f[j] = True
    e = f.copy()
    b = c.copy()
ans = -10 ** 24
for i in range(4):
    if e[i]:
        ans = max(ans, b[i])
print(e)
print(ans)

n = int(input())
a = [int(i) for i in input().split()]

if n // 2 == 1:
    print(max(a))
    exit()
if n < 20:
    d = a.copy()
    
    for i in range(1, n // 2):
        b = [0] * n
        c = -10 ** 24
        ans = -10 ** 24
        for j in range(i * 2, n):
            c = max(c, a[j - 2])
            b[j] = c + d[j]
            ans = max(ans, c + d[j])

        a = b.copy()
    print(ans)
    exit()

b = a[:10]
e = [True]*10

for i in range(1, n // 2):
    c = [0] * 10
    f = [False]*10
    d = -10**24
    for j in range(10):
        if 2 * i + j >= n:
            continue
        if not e[j]:
            continue
        d = max(d, b[j])
        c[j] = d + a[2 * i + j]
        f[j] = True
    e = f.copy()
    b = c.copy()
ans = -10 ** 24
for i in range(10):
    if e[i]:
        ans = max(ans, b[i])
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
N=int(input())
A=list(map(int, input().split()))
if N==2 or N==3:
  print(max(A))
  exit() 
  
dp=[[0,0,0] for i in range(N)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]
for i in range(N):
  if i>1:
    dp[i][0]=dp[i-2][0]+A[i]
  if i>2:
    dp[i][1]=max(dp[i-3][0],dp[i-2][1])+A[i]
  if i>3 :
    dp[i][2]=max(dp[i-4][0],dp[i-3][1],dp[i-2][2])+A[i]
if N%2==1:
  ans=max(dp[-1][2],dp[-2][1],dp[-3][0])
else:
  ans=max(dp[-1][2],dp[-2][1])
print(ans)

N=int(input())
A=list(map(int, input().split()))
if N==2:
  print(max(A))
  exit() 
  
dp=[[0,0,0] for i in range(N)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]
for i in range(N):
  if i>1:
    dp[i][0]=dp[i-2][0]+A[i]
  if i>2:
    dp[i][1]=max(dp[i-3][0],dp[i-2][1])+A[i]
  if i>3 :
    dp[i][2]=max(dp[i-4][0],dp[i-3][1],dp[i-2][2])+A[i]
if N%2==1:
  ans=max(dp[-1][2],dp[-2][1],dp[-3][0])
else:
  ans=max(dp[-1][1],dp[-2][0])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
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)

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))

Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
# coding: utf-8
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()

INF = 10 ** 17

@lru_cache(None)
def F(index, n):
    if index >= N:
        return -INF
    if N - index < 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

answer = F(0, N//2)
print(answer)


# coding: utf-8
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 17

@lru_cache(None)
def F(index, n):
    
    if index >= N: 
        return -INF
    if N - index < 2 * n - 1:  
        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

answer = F(0, N//2)
print(answer)


Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
import numpy as np

n = int(input())
a = np.array(input().split(), dtype=np.int)

if n % 2 == 0:
  print(max(a[::2].sum(), a[1::2].sum()))
else:
  half = n // 2
  dp = a[:3]
  for i in range(half - 1):
    index_ = 2 * i + 2
    dp[:] = (
      dp[0] + a[index_],
      max(dp[0] + a[index_ + 1], dp[1] + a[index_ + 1]),
      max(dp[0] + a[index_ + 2], dp[1] + a[index_ + 2], dp[2] + a[index_ + 2])
    )
  print(dp.max())

import numpy as np

n = int(input())
a = np.array(input().split(), dtype=np.int)

if n % 2 == 0:
  print(max(a[::2].sum(), a[1::2].sum()))
else:
  dp = a[:3]
  for i in range(1, n // 2):
    dp = dp[0] + a[2*i], dp[:2].max() + a[2*i+1], dp.max() + a[2*i+2]
  print(dp.max())

import numpy as np

n = int(input())
a = np.array(input().split(), dtype=np.int)

if n % 2 == 0:
  print(max(a[::2].sum(), a[1::2].sum()))
else:
  half = n // 2
  dp = a[:3]
  for i in range(half - 1):
    index_ = 2 * i + 2
    dp[0] += a[index_]
    dp[1] = max(dp[0] + a[index_ + 1], dp[1] + a[index_ + 1])
    dp[2] = max(dp[0] + a[index_ + 2], dp[1] + a[index_ + 2], dp[2] + a[index_ + 2])
  print(dp.max())

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

if n % 2 == 0:
  dp = a[:2]
  for i in range(1, n // 2):
    dp = dp[0] + a[2*i], max(dp) + a[2*i+1]
else:
  dp = a[:3]
  for i in range(1, n // 2):
    dp = dp[0] + a[2*i], max(dp[:2]) + a[2*i+1], max(dp) + a[2*i+2]

print(max(dp))

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
import numpy as np
n=int(input())
a=list(map(int,input().split()))


dp=np.full((n+1,n+1),-1e+9)
dp[1,1]=a[0]
for i in range(2,n+1): 
      for j in range(i//2-1,(i+1)//2+1):
            dp[i,j]=max(dp[i-2,j-1]+a[i-1],dp[i-1,j])
print(int(dp[n,n//2]))

n=int(input())
a=list(map(int,input().split()))
import numpy as np
dp=np.full((3,n+1),-pow(10,15))
dp[:,0]=0
dp[1,1]=a[0]
for i in range(2,n+1):
    #l,r=max(1,n//2-(n-i+1)//2),(i+1)//2+1
    l,r=max(1,i//2-1),(i+1)//2+1
    if i%3==2:
        now,pre,prepre=2,1,0
    elif i%3==0:
        now,pre,prepre=0,2,1
    elif i%3==1:
        now,pre,prepre=1,0,2
    dp[now,l:r]=np.maximum(dp[pre,l:r],dp[prepre,l-1:r-1]+a[i-1])
print(dp[now,n//2])

Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
N,K = [int(x) for x in input().split()]
count = [0]*(K+1)
ans = 0
mod = 1000000007
for i in range(K,0,-1):
    kosuu = pow(K//i,N,mod)
    if K // i >= 2:
        for j in range(K//i,1,-1):
            kosuu -= count[j*i]
    ans += i*kosuu
    count[i] = kosuu
print(ans%mod)

import sys
sys.setrecursionlimit(2000000000)
N = int(input())
import math
l = [int(x) for x in input().split()]
tobi = [0]*(math.ceil(N/2))
tobi[0] = l[0]
for i in range(1,math.ceil(N/2)):
    tobi[i] = tobi[i-1] + l[i*2]
from functools import lru_cache
@lru_cache(maxsize=1000000000)
def motomeru(x,y):
    if y == 0 or x == 0 or x == 1:
        return 0
    elif x % 2 == 0:
        return max(motomeru(x-2,y-1)+l[x-1],tobi[math.floor((x-1)/2)])
    else:
        return max(motomeru(x-2,y-1)+l[x-1],motomeru(x-1,y))
print(motomeru(N,N//2))

Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

DP_odd = [0, 0, A[0]]
DP_even = [0, max(A[0], A[1])]

if N >= 3:
    DP_odd = [DP_even[0], max(DP_odd[1] + A[i], DP_even[1]), DP_odd[2] + A[2]]

for i in range(3, N):
    if (i + 1) % 2 == 1:    
        DP_odd = [max(DP_odd[0] + A[i], DP_even[0]), max(DP_odd[1] + A[i], DP_even[1]), DP_odd[2] + A[i]]
        print(DP_odd)
    else:
        DP_even = [max(DP_even[0] + A[i], DP_odd[1]), max(DP_even[1] + A[i], DP_odd[2])]
        print(DP_even)

if N % 2 == 1:
    ans = DP_odd[1]
else:
    ans = DP_even[1]

print(ans)

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

DP_odd = [0, A[0]]
DP_even = [0, max(A[0], A[1])]

for i in range(2, N):
    if (i + 1) % 2 == 1:    
        DP_odd = [max(DP_odd[0] + A[i], DP_even[1]), DP_odd[1] + A[i]]
    else:
        DP_even = [max(DP_even[0] + A[i], DP_odd[0]), max(DP_even[1] + A[i], DP_odd[1])]

if N % 2 == 1:
    ans = DP_odd[0]
else:
    ans = DP_even[1]

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()

def odd(A):
    oddi=np.array(A[::2],dtype=np.int64)
    eveni=np.array(A[1::2],dtype=np.int64)
    left=np.cumsum(oddi[:-1]-eveni)
    left=np.insert(left,0,0)
    left=np.append(left,0)
    right=np.cumsum(oddi[:0:-1]-eveni[::-1])[::-1]
    right=np.insert(right,0,0)
    right=np.append(right,0)
    tmp=np.max(np.maximum.accumulate(left)+right)
    return tmp+np.sum(eveni)

def even(A):
    left=np.array([0]+A[::2],dtype=np.int64)
    right=np.array(A[1::2]+[0],dtype=np.int64)
    return np.max(left.cumsum()+right.cumsum())

def main():
    n=int(input())
    A=list(map(int, input().split()))
    if n%2==1:
        print(odd(A))
    else:
        print(even(A))


if __name__ == '__main__':
    main()

import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()

def odd(A):
    oddi=np.array(A[::2],dtype=np.int64)
    eveni=np.array(A[1::2],dtype=np.int64)
    left=np.cumsum(oddi[:-1]-eveni)
    left=np.insert(left,0,0)
    right=np.cumsum(oddi[:0:-1]-eveni[::-1])[::-1]
    right=np.append(right,0)
    tmp=np.max(np.maximum.accumulate(left)+right)
    return tmp+np.sum(eveni)

def even(A):
    left=np.array([0]+A[::2],dtype=np.int64)
    right=np.array(A[1::2]+[0],dtype=np.int64)[::-1]
    return np.max(left.cumsum()+right.cumsum()[::-1])

def main():
    n=int(input())
    A=list(map(int, input().split()))
    if n%2==1:
        print(odd(A))
    else:
        print(even(A))


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    a0, a1, a2, b0, b1, b2 = 0, 0, 0, 0, 0, 0
    for i, a in enumerate(A):
        a0, a1, a2, b0, b1, b2 = (
                b0,
                max(b1, a0),
                max(b2, a1),
                a0 + a,
                a1 + a if i >= 1 else a1,
                a2 + a if i >= 2 else a2)
        print(a0, a1, a2, b0, b1, b2)

    if N & 1:
        return max(a2, b1)
    else:
        return max(a1, b0)


print(main())


def main():
    N = int(input())
    A = list(map(int, input().split()))
    a0, a1, a2, b0, b1, b2 = A[0], 0, 0, A[1], 0, 0
    for a in A[2:]:
        a0, a1, a2, b0, b1, b2 = (
                b0,
                max(b1, a0),
                max(b2, a1),
                a0 + a,
                a1 + a,
                a2 + a)

    if N & 1:
        return max(b2, a1)
    else:
        return max(a0, b1)


print(main())


def main():
    N = int(input())
    A = list(map(int, input().split()))
    a0, a1, a2, b0, b1, b2 = 0, 0, 0, 0, 0, 0
    for i, a in enumerate(A):
        a0, a1, a2, b0, b1, b2 = (
                b0,
                max(b1, a0),
                max(b2, a1),
                a0 + a,
                a1 + a if i >= 1 else a1,
                a2 + a if i >= 2 else a2)

    if N & 1:
        return max(b2, a1)
    else:
        return max(b1, a0)


print(main())


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
n = int(input())
nums = list(map(int,input().split()))
dp = [[0,0,0] for _ in range(n)]
dp[0][0] = nums[0]
dp[1][0],dp[1][1],dp[1][2] = nums[1],nums[0],-float("inf")
dp[2][0],dp[2][1],dp[2][2] = nums[2],nums[1],nums[0]
for i in range(3,n):
    if i%2 == 0:
        dp[i][0] = max(dp[i-2]) + nums[i]
        dp[i][1] = max(dp[i-3]) + nums[i-1]
        dp[i][2] = sum(nums[0:i-1:2])
    else:
        dp[i][0] = max(dp[i-2]) + nums[i]
        dp[i][1] = sum(nums[0:i-2:2]) + nums[i-1]
        dp[i][2] = -float("inf")
print(max(dp[n-1]))
print(dp)

n = int(input())
nums = list(map(int,input().split()))
if n == 2:
    print(max(nums[0],nums[1]))
else:
    temp =[0]
    for i in range(n):
        if i%2 == 0:
            temp += [temp[-1]+nums[i]]
    dp = [[0,0,0] for _ in range(n)]
    dp[0][0] = nums[0]
    dp[1][0],dp[1][1],dp[1][2] = nums[1],nums[0],-float("inf")
    dp[2][0],dp[2][1],dp[2][2] = nums[2],nums[1],nums[0]
    for i in range(3,n):
        if i%2 == 0:
            dp[i][0] = max(dp[i-2]) + nums[i]
            dp[i][1] = max(dp[i-3]) + nums[i-1]
            dp[i][2] = temp[i//2]
        else:
            dp[i][0] = max(dp[i-2]) + nums[i]
            dp[i][1] = temp[(i-1)//2] + nums[i-1]
            dp[i][2] = -float("inf")
    print(max(dp[n-1]))

Verdicts: Runtime Error

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
from itertools import accumulate
n,*a = [int(i) for i in open(0).read().split()]
a1 = list(accumulate([0]+a[::2]))
a2 = list(accumulate([0]+a[n-1::-2]))[::-1]
ans = max(x+y for x,y in zip(a1,a2[1:]))
if n&1: ans = max(ans, max(x+y+mid for x,y,mid in zip(a1,a2[2:],a[1::2])))
print(ans)

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = [int(i) for i in read().split()]

from itertools import accumulate
if n%2==0:
    a1 = list(accumulate([0]+a[::2]))
    a2 = list(accumulate([0]+a[n-1::-2]))[::-1]
    #print(a1,a2)
    print(max(x+y for x,y in zip(a1,a2)))
#elif n==3: print(max(a))
else:
    dp0 = [0]*(n+9)
    dp1 = [0]*(n+9)
    dp2 = [0]*(n+9)
    for i in range(n):
        if i%2==0:
            dp0[i] = dp0[i-2]+a[i]
            if i >= 2:
                dp2[i] = max(dp2[i-2],dp1[i-3],dp0[i-4]) + a[i]
        else:
            dp1[i] = max(dp1[i-2],dp0[i-3]) + a[i]
    #print(dp0)
    #print(dp1)
    #print(dp2)
    print(max(dp2[n-1],dp1[n-2],dp0[n-3]))





Verdicts: Wrong Answer

Accepted
Problem: Given is an integer sequence A_1, ..., A_N of length N.  We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.  Find the maximum possible sum of the chosen elements.  Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Submission attempts (in order):
n = int(input())
*A, = map(int, input().split())
inf = 10**18


DP = [(None, None) for i in range(n)]
DP[0] = (0, A[0])
DP[1] = (0, max(A[0], A[1]))
for i in range(2, n):
    if i % 2 == 0:
        DP[i][0] = max(DP[i-2][0]+A[i], DP[i-1][1])
        DP[i][1] = DP[i-2][1]+A[i]
    else:
        DP[i][0] = max(DP[i-2][0]+A[i], DP[i-1][0])
        DP[i][1] = max(DP[i-2][1]+A[i], DP[i-1][1])
if n % 2 == 0:
    print(DP[n-1][1])
else:
    print(DP[n-1][0])


n = int(input())
*A, = map(int, input().split())
inf = 10**18


DP = [[-inf]*2 for i in range(n)]
DP[0][0] = 0
DP[0][1] = A[0]
DP[1][0] = 0
DP[1][1] = max(A[0], A[1])
for i in range(2, n):
    if i % 2 == 0:
        DP[i][0] = max(DP[i-2][0]+A[i], DP[i-1][1])
        DP[i][1] = DP[i-2][1]+A[i]
    else:
        DP[i][0] = max(DP[i-2][0]+A[i], DP[i-1][0])
        DP[i][1] = max(DP[i-2][1]+A[i], DP[i-1][1])
if n % 2 == 0:
    print(DP[n-1][1])
else:
    print(DP[n-1][0])


Verdicts: Runtime Error

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
X,Y,Z = map(int,input().split())
X = Z
Y = X
Z = Y
print(X,Y,Z)

X,Y,Z = map(int,input().split())

print(Z,X,Y)

Verdicts: Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
p,x,y=map(int,input().split())
print(y,x,p)
  

x,y,z = map(int, input().split())
print(z,x,y)

Verdicts: Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
A = list(map(int, input().split()))
print(A[2])
print(A[1])
print(A[0])

x,y,z=map(int, input().split())
print(z,x,y)

Verdicts: Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
a,b,c=map(int,input().split())
print(a,b,c)


a,b,c=map(int,intput().split())
print(a," ",b," ",c)

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


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
def calc():
    d = a
    a = b
    b = d

    d = a
    a = c
    c = d

    list = [a,b,c]
    return list

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

def calc():
    d = a
    a = b
    b = d

    d = a
    a = c
    c = d

    mytuple = (a,b,c)
    return mytuple

a, b, c = map(int, input().split())
ans = calc()
print(*ans)

def calc():
    d = a
    a = b
    b = d

    d = a
    a = c
    c = d

    print(a,b,c)

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


def calc():
    d = a
    a = b
    b = d

    d = a
    a = c
    c = d
    return a, b, c

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

def calc():
    x, y, z = c, a, b

    print(x, y, z)

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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
a, b, c = map(int, input().split())

a, b = b, a
a, c = c, a

print(a + " " + b + " " + c)

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

a, b = b, a
a, c = c, a

print(a, b, c)

Verdicts: Runtime Error

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
A = list(map(int,input().split()))
B = []
B.append(A[2])
B.append(A[0])
B.append(A[1])
print(B)

A = list(map(int,input().split()))
B = []
B.append(A[2])
B.append(A[0])
B.append(A[1])
print(B[0],B[1],B[2])



Verdicts: Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
# -*- coding: utf-8 -*-
BOX = list(map(int, input().split()))
print([BOX[2], BOX[0], BOX[1]])

# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for Ai in A:
    k = 1/(4*M)
    if (sum(A))*k <= Ai:
        cnt += 1
if cnt >= M:
    print("Yes")
else:
    print("No")

# -*- coding: utf-8 -*-
BOX = list(map(int, input().split()))
print(BOX[2], BOX[0], BOX[1])

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
x,y,z = map(int,input().split())
print(z,x,y,sep=",")

x,y,z = map(int,input().split())
print(z,x,y)

Verdicts: Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
a,b,c=map(int, input().split())  
temp = b
b = c
c = temp
print(a,b,c)

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


temp = b
b = a
a =temp


temp = c
c = a
a =temp


print(a,b,c)

Verdicts: Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
a, b, c = map(int, input().split())
list = [a, b, c]
list.sort()
print("{} {} {}".format(list[0], list[1], list[2]))

a, b, c = map(int, input().split())
a, b = b, a
a, c = c, a
print("{} {} {}".format(a, b, c))

Verdicts: Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
a, b, c = [int(x) for x in input().split()
a, b = b, a
a, c = c, a
print (a,b,c)

a, b, c = [int(x) for x in input().split()]
a, b =b, a
a, c = c, a
print (a,b,c)

Verdicts: Runtime Error

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
k = input().split()
s = int(k[0])
j = int(k[1])
v = 10000000000
while v > s:
    v = s
    s = abs(s - j)
     
print(s)

s = input().split()
i = s[0]
m = int(s[1])
j = 0
el = input().split()
for p in el:
    if int(p) < 1 / (4 * m):
      j = 1 
if j == 0:
    print("Yes")
else:
    print("No")


s = input().split()
i = s[0]
m = int(s[1])
j = 0
el = input().split()
for p in el:
    if int(p) < (1 / (4 * m)):
      j = 1 
if j == 0:
    print("Yes")
else:
    print("No")

s = input().split()
i = s[0]
m = int(s[1])
j = 0
el = input().split()
for p in el:
    if int(p) < 1 / (4 * m):
      j = 1 
if j == 0:
    print("Yes")
else:
    print("No")

k = input().split()
s = int(k[0])
j = int(k[1])
v = s + 1
while v > s:
    v = s
    s = abs(s - j)

v = s
s = abs(s-j)
if v > s:
  print(s)
else:
  print(v)

el = input().split()
print("{} {} {}".format(el[2],el[0],el[1]))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
N,K = map(int, input().split())
print(min(N%K,abs(N%K-K)))


x,y,z = map(int, input().split())
print(z,x,y)


Verdicts: Runtime Error

Accepted
Problem: We have three boxes A, B, and C, each of which contains an integer.   Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.   We will now do the operations below in order. Find the content of each box afterward.    * Swap the contents of the boxes A and B   * Swap the contents of the boxes A and C

Submission attempts (in order):
from sys import stdin
#n = int(stdin.readline().rstrip())
l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
a=l[0]
b=l[1]
c=l[2]

print("c a b")

from sys import stdin
A, B, C = map(int, stdin.readline().rstrip().split())


print(C,A,B)

Verdicts: Wrong Answer

Accepted