Problem:


Score : 600 points

Problem Statement

We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.

Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.

It can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.

You are given an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.

Constraints

0 ≤ K ≤ 50 \times 10^{16}

Input

Input is given from Standard Input in the following format:

K

Output

Print a solution in the following format:

N
a_1 a_2 ... a_N

Here, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.

Sample Input 1

0

Sample Output 1

4
3 3 3 3

Sample Input 2

1

Sample Output 2

3
1 0 3

Sample Input 3

2

Sample Output 3

2
2 2

The operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].

Sample Input 4

3

Sample Output 4

7
27 0 0 0 0 0 0

Sample Input 5

1234567894848

Sample Output 5

10
1000 193 256 777 0 1 1192 1234567891011 48 425



Sample input:
0


Sample output:
4
3 3 3 3

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
K = int(input())

N = 50
As = [N-1 for _ in range(N)]
ind = 0

modk = K % 50
L = K // 50
base = 49 + L - modk

ans = []

if modk != 0:
    for i in range(N):
        if i >= N - modk:
            ans.append(base + N + 1)
        else:
            ans.append(base)
    # for i in range(0,modk,1):
    #     ans.append(base + N + 1)
    # for i in range(modk,N,1):
    #     ans.append(base)
else:
    for i in range(N):
        ans.append(49 + L)
# for k in range(K):
#     for i in range(N):
#         As[i] -= 1
#     As[ind] += N + 1
#     ind += 1
#     ind = ind % N
# print(N)
# print(*As)
print(N)
print(*ans)

Submission status: Accepted

Solution code:
k = int(input())

if k == 0:
    print("2\n1 1")
    exit(0)

if k == 1:
    print("2\n2 0")
    exit(0)

n = min(50,k)
a = [i for i in range(n)]
c = k // n

for i in range(n):
    a[i] += c

for i in range(k % n):
    a[i] += n
    for j in range(n):
        if i != j:
            a[j] -= 1

print(n)
for i in a:
    print(i, end=' ')
print()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    K = int(input())
    N = 50
    result = list(range(N))
    for x in range(N):
        result[x] += K // N
    K %= N

    for x in range(K):
        result[x] += N + 1
        for i in range(N):
            result[i] -= 1
    print (len(result))
    print (" ".join(map(str, result)))

Submission status: Accepted

Solution code:
k = input()
epoch = k / 50
tweak = 50 - k % 50

ans = [50 + epoch for _ in range(50)]
for i in range(50):
    if i < tweak:
        ans[i] += -50 + tweak - 1
    else:
        ans[i] += tweak

ans_st = " ".join(map(str, ans))
print 50
print ans_st

Submission status: Accepted

Solution code:
K = int(input())

b = K % 50
a = K // 50
	
list = [0] * 50
j = 0

while (j <= 49 - b) :
	list[j] = 49 + a - b
	j += 1

while (j <= 49):
	list[j] = 2 * 50 + a - b
	j += 1

list = map(str, list)
print('50')
print(' '.join(list))

Submission status: Accepted

Solution code:
k = int(input())
d, m = divmod(k, 50)
b = 49 + d
print(50)
print(*map(str, [b + 1] * m + [b - m] * (50 - m)))

Submission status: Accepted

Solution code:
b=int(input());a=b//50+49;b%=50;c=50-b;print(50,*[a-b]*c+[a+c]*b)

Submission status: Accepted

Solution code:
b=input();a=b/50+49;b%=50;c=50-b;print 50,(`a-b`+" ")*c+(`a+c`+" ")*b

Submission status: Accepted

Solution code:
b=input();a=b/50+49;b%=50;c=50-b;print"50\n"+(`a-b`+" ")*c+(`a+c`+" ")*b

Submission status: Accepted

Solution code:
k = input()
n = 50
print n
a = (k / 50) + n-1
b = k % 50
print " ".join(map(str, [a - b]*(n-b) + [a + (n-b)]*b))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    K = int(input())
    N = 50
    ans = [i for i in range(0, N)]

    modulo = K % N
    for i in range(0, modulo):
        ans[i] += N
        for j in range(0, N):
            if i != j:
                ans[j] -= 1

    divide = K // N

    ans = [str(divide + i) for i in ans]
    print(N)
    print(" ".join(ans))

Submission status: Accepted

Solution code:
K = int(input())
N = 50

base = K // N
resi = K % N

A = [49 + base] * N

for i in range(N):
    if i < resi:
        A[i] += N - resi + 1
    else:
        A[i] -= resi

print(N)
print(' '.join(map(str,A)))

Submission status: Accepted

Solution code:
K=int(input())
R=K%50
L=K//50
a=[49+L]*50#50*L回掛かるモード
if R!=0:
  a=[49+L+50-R]*50
  a[0]+=1
  for i in range(50-R):
    a[i]-=51
print(50)
print(' '.join(map(str, a)))

Submission status: Accepted

Solution code:
K=int(input())
R=K%50
L=K//50
a = [49 - R + L for i in range(50)]
for i in range(R):
    a[i] += 51
print(50)
print(' '.join(map(str, a)))

Submission status: Accepted

Solution code:
K=int(input())
R=K%50
L= K // 50
a = [49 - R + L for i in range(50)]
for i in range(R):
    a[i] += 51
print(50)
print(' '.join(map(str, a)))

Submission status: Accepted

Solution code:
import sys
k=int(raw_input())
n=k

if n<50:
    if n%2==0:
        print 2
        print "%d %d" %( n/2+1,n/2+1)
    else:
        print 2
        print "%d %d" % ((n-1)/2,(n-1)/2+3)
    sys.exit(0)


def proc(ls):
    ls.sort()
    ls[-1]-=len(ls)
    for i in range(len(ls)-1):
        ls[i]+=1
    return ls
if k%5==0:
    print 50
    ans= [k/50+49]*50
    for i in range(49):
        sys.stdout.write(str(ans[i])+" ")
    sys.stdout.write(str(ans[49]))
    sys.stdout.write("\n")
else:
    print 50
    k+=50
    ans=[k/50+49]*50
    for i in range(50-k%50):
        ans=proc(ans)
    for i in range(49):
        sys.stdout.write(str(ans[i])+" ")
    sys.stdout.write(str(ans[49]))
    sys.stdout.write("\n")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

K = int(input())

a = np.ones(50).astype(np.int64)*(49) + (K)//50


if K%50 != 0:
    a[:K%50] += 51 - (K%50)
    a[K%50:] -= (K%50)
else:
    pass
                
result = "50\n{}".format(a[0])
for a_ in a[1:]:
    result += (" {}".format(int(a_)))
print(result)

Submission status: Accepted

Solution code:
import sys
state_size = 50
#generate states
init = [0] + [state_size - 1] * (state_size - 1)
states = [init]
for i in xrange(1,state_size):
    topush = []
    for j in xrange(state_size):
        if i-1 == j:
            topush.append(states[-1][j] + state_size)
        else:
            topush.append(states[-1][j] - 1)
    states.append(topush)

K = int(sys.stdin.readline())

P = K/state_size
Q = K%state_size

ret = states[Q]
ret = [x+P for x in ret]

print state_size
print ' '.join(map(str,ret))

Submission status: Accepted

Solution code:
k=int(input())
n=50
q,r=k//n,k%n
a=[n-1-k+q*(n+1)]*n
a=list(map(lambda x:x+n+1,a[:r]))+a[r:n]
print(n)
print(' '.join(map(str,a)))

Submission status: Accepted

Solution code:
def main():
    k = int(input())

    if k == 0:
        print(4)
        print(3, 3, 3, 3)
        return
    if k == 1:
        print(3)
        print(1, 0, 3)
        return
    if k <= 50:
        print(k)
        print(' '.join([str(k)]*k))
        return
    print(50)
    res = [50+k//50-k%50-1]*50
    for i in range(k%50):
        res[i] += 51
    print(' '.join([str(i) for i in res]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
K = int(input())

def solve(K):
    if K == 0:
        return [3, 3, 3, 3]
    if K == 1:
        return [1, 0, 3]
    if K == 2:
        return [2, 2]
    if K <= 2 * 10**16 - 10:
        if K % 2 == 0:
            return [K//2 + 1, K//2 + 1]
        else:
            return [K//2, K//2 + 3]
    N, R = divmod(K, 10**16)
    if R != 0:
        N = N + 1
    if N <= 2:
        N = 3
    a = K//N
    r = K - N * a
    if r == 0:
        return [N - 1 + a] * N
    ret = [N + a] * N
    for i in range(N - r):
        ret[i] -= (N + 1)
        for j in range(N):
            ret[j] += 1
    return ret


ans = solve(K)
print(len(ans))
print(*ans)

Submission status: Accepted

Solution code:
K = int(input())

n = 50

b = K // n

if b == 0:
    a = [0 for i in range(n)]
    a[n - 1] = n * (K % n)
else:
    a = [(n - 1) + b for i in range(n)]
    for i in range(n - (K % n)):
        a[i] -= K % n
    for i in range(n - (K % n), n):
        if K % n > 0:
            a[i] += n - (K % n - 1)

print(len(a))
print(' '.join(str(s) for s in a))

Submission status: Accepted

Solution code:
k = int(raw_input())
n = 50

ai = k/n + (n-1)
a = [ai] * n
r = k%n
b = n - r + 1
cq = (b * r) / (n-r)
cr = (b * r) % (n-r)
for i in range(n):
  if i < r:
    a[i] += b
  else:
    a[i] -= cq
    if cr > 0:
      a[i] -= 1
      cr -= 1

a = map(str, a)

print n
print " ".join(a)

Submission status: Accepted

Solution code:
K = int(input())

N = 50
a = [0] * N

m = K // N
mod = K % N

for i in range(0, mod):
    a[i] = N * (m + 2) - K + m

for i in range(mod, N):
    if m != 0:
        a[i] = N * (m + 1) - K + m - 1

print(N)
print(' '.join([str(x) for x in a]))

Submission status: Accepted

Solution code:
k = int(input())
if k <= 100 * 1000:
    if k % 2:
        print(2)
        print(k // 2, 2 + k // 2)
    else:
        print(2)
        print(1 + k // 2, 1 + k // 2)
else:
    mn = k // 50
    md = k % 50
    print(50)
    ok = 49 + mn
    for i in range(50):
        if i < md:
            print(ok + 50 - (md - 1), end=" ")
        else:
            print(ok - md, end= " ")

Submission status: Accepted

Solution code:
x = int(input())
if x == 0:
    print(4)
    print(3, 3, 3, 3)
    exit()

x-= 1
phase = x//50
subphase = x%50
pstart = phase*50

left = 99+phase-(x-pstart)
right = 48+phase-(x-pstart)
ans = [left]*(1+subphase)+[right]*(49-subphase)
print(50)
print(*ans)

Submission status: Accepted

Solution code:
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    K = II()
    return (K,)


def solve(K):
    N = 50
    a = [49] * N
    div, mod = divmod(K, N)
    for i in range(N):
        a[i] += div
    if mod != 0:
        for i in range(mod):
            a[i] += N - (mod - 1)
        for i in range(mod, N):
            a[i] += -mod

    ans = "50\n" + " ".join(map(str, a))

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
K = int(input())
N = 50

q,r = K//N, K%N

A = [N-1-K + q*(N+1)]*N

for i in range(r):
  A[i] += N+1

print(N)
print(' '.join(map(str,A)))

Submission status: Accepted

Solution code:
K = int(input())
N = 50
a = K // N
b = K % N

l = a-b+N*2
m = a-b+N-1
L = [l for _ in range(b)]
M = [m for _ in range(N-b)]

print(N)
print(" ".join(map(str, L+M)))

Submission status: Accepted

Solution code:
k = int(input())
if k % 50 == 0:
    ans = [50 + (k // 50) - 1] * 50
else:
    mm = k % 50
    base = 50 + 50 - mm
    k -= mm
    k = k // 50
    lul = 50 - mm - 1 + k
    k += base
    ans = [k] * mm + [lul] * (50 - mm)

print(50)
print(' '.join([str(x) for x in ans]))

Submission status: Accepted

Solution code:
def show1(n, ans):
    for i in xrange(n):
        print ans[i],
    print

def show2(n, m, l, ans):
    for i in xrange(l):
        print ans[i] + m + 1,
    for i in xrange(l, n):
        print ans[i] + m ,
    print

k = int(raw_input())
n = 50
ans = [0] * n
print n
if k <= n:
    for i in xrange(k):
        ans[i] = n - i
    show1(n, ans)
else:
    ans = range(50, 0, -1)
    m = k / 50 - 1
    l = k % 50
    show2(n, m, l, ans)

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

K = ri()
X = K // 50
mod = K % 50
a = [49 - mod + X for i in range(50)]
for i in range(mod):
    a[i] += 51
print(50)
print(plis(a))

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math

K, = list(map(int, sys.stdin.readline().rstrip().split()))

N = 50

As = [0 for _ in range(50)]
if K > 50:
    bias = K // 50
    K = K - bias * 50


    # for i in range(50):
    #     if i < K:
    #         As[i] += (50 + 1 - i + bias * 50)
    #
    if bias > 0:
        for i in range(50):
            As[i] += (50 - i + bias -1 )

    # for i in range(50):
    #     if i < K:
    #         As[N - 1 - i] += (50 - i + bias)
    for i in range(50):
        if i < K:
            As[i] += 1
            # As[i] += (50 - i + bias)
else:
    for i in range(50):
        if i < K:
            As[i] += (50 - i)
print(50)
print(" ".join(map(str, As)))

exit(0)

Submission status: Accepted

Solution code:
k = int(input())

if k <= 2 * 10**16:
    n = 2
    if k % 2 == 0:
        a = [k // 2 + 1, k // 2 + 1]
    else:
        a = [k // 2 + 3, k // 2]
else:
    n = 50
    a = [k // n + n - 1 for _ in range(50)]
    for i in range(k % n):
        for j in range(n):
            if j == i:
                a[j] += n
            else:
                a[j] -= 1
print(n)
print(' '.join(map(str, a)))

Submission status: Accepted

Solution code:
K = int(input())
L = 50
N = K // L + L - 1
res = K - (N - L + 1) * L
assert(res < 50)
ans = [N] * L
for i in range(res):
    ans[i] += L - res + 1
for i in range(res, L):
    ans[i] -= res
print(L)
print(*ans)

Submission status: Accepted

Solution code:
def main():
    K = int(input())
    a = [K//50 + 49] * 50
    kp = K % 50
    for i in range(50):
        if i < kp:
            a[i] += 51 - kp
        else:
            a[i] -= kp
    print(50)
    print(" ".join(map(str, a)))

main()

Submission status: Accepted

Solution code:
K = int(input())


def check(lst):
    for i in range(K):
        maxv = max(lst)
        if maxv <= N - 1:
            return False
        flg = False
        for j in range(N):
            if lst[j] == maxv and not flg:
                lst[j] -= N
                flg = True
            else:
                lst[j] += 1

    for i in range(N):
        if lst[i] >= N:
            return False
    return True



N = 50
mod = K % N
ans = []
for i in range(N):
    if i < mod:
        ans.append(N - i)
    else:
        ans.append(N - mod - 1)

for i in range(N):
    if i < mod:
        ans[i] = ans[i] + K // N + 1
    else:
        ans[i] = ans[i] + K // N
print(N)
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    k = read_int()
    n = 50
    q, r = divmod(k, n)
    a = [n - 1 + q] * n
    for i in range(r):
        a[i] += n - r + 1
    for i in range(r, n):
        a[i] += -r
    return n, a


def main():
    n, a = solve()
    print(n)
    print(*a)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
  N = 50
  K = int(raw_input())
  A = [N - 1 + (K / N)] * N
  K %= N
  for i in xrange(K):
    for j in xrange(N):
      A[j] -= 1
    A[i] += N + 1
  print N
  print ' '.join(map(str, A))

main()

Submission status: Accepted

Solution code:
k = int(input())
n = 50
d = k // n
a = [d + i for i in range(n)]  # d*n operations
k = k % n
for i in range(k):
    a[i] += n
    for j in range(n):
        if j != i:
            a[j] -= 1
print(n)
print(' '.join(map(str, a)))

Submission status: Accepted

Solution code:
k = int(raw_input())

n = 50
a = [n - 1 + k // n] * n
j = 0
s = 0
c = 0
for i in xrange(k % n):
    a[j] += n + 1
    s += 1
    c += 1
    if c == 15:
        j += 1
        c = 0
for i in xrange(n):
    a[i] -= s
print n
print " ".join(str(x) for x in a)

Submission status: Accepted

Solution code:
# D
K = int(input())

N = 50

L = K // 50
R = K % 50

a_list = []

if R != 0:
    for i in range(50):
        if i >= 50 - R:
            a_list.append(str(99 - R + 1 + L))
        else:
            a_list.append(str(49 - R + L))
else:
    for i in range(50):
        a_list.append(str(49 + L))
        
print(len(a_list))
print(" ".join(a_list))

Submission status: Accepted

Solution code:
k = int(raw_input())
n = 50
a = [49] * n
c = k // n
for i in range(n):
	a[i] += c
c = k % n
for _ in range(c):
	mp = 0
	for i in range(n):
		if a[i] < a[mp]:
			mp = i
	for i in range(n):
		if i == mp:
			a[i] += n
		else:
			a[i] -= 1
print n
for i in range(n):
	print a[i],

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    K = I()
    N = 50
    a = [49] * 50
    k = K // 50
    kp = K % 50
    for i in range(N):
        t = k
        if i < kp:
            t += 1
        for j in range(N):
            if i == j:
                continue
            a[j] -= t
        a[i] += t * 50
    return '{}\n{}'.format(N, ' '.join(map(str,a)))



print(main())

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
void calc(vector<int>& a,int i,int n){
    rep(j,n){
        if(j==i)a[i]+=n;
        else a[j]-=1;
    }
}
signed main(){
    int k;cin>>k;
    int n=50;
    vector<int> a(n,n-1);
    int buf=k/n;
    rep(i,n){
        a[i]+=buf;
    }
    k%=n;
    rep(i,k){
        calc(a,i,n);
    }
    rep(i,n){
        cout<<a[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
K=int(input())
if K%2==0:
    A0=K//2+1
    A1=K//2+1
else:
    A0=(K+1)//2-2
    A1=(K+1)//2+1
print(N)
print(A0,A1)

Submission status: Runtime Error

Solution code:
def main():
    k = int(input())
    a = min(k, 50)
    b = k % a
    ans = [i + k//a for i in range(a)]
    for i in range(b):
        ans.sort()
        for j in range(1, a):
            ans[j] -= 1
        ans[0] += a

    print(a)
    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

def arc079():
    K = int(input())
    k = K//50
    a = [i+k*50 for i in range(50)]
    for i in range(K-k):
        a[i] += 51
    for i in range(50):
        a[i] -= K-k
    print(50)
    print(*a)

arc079()

Submission status: Runtime Error

Solution code:
K = int(input())
ans = [K//50 + i for i in range(50)]
if K%50:
  for i in range(K%50):
    ans[i] += 50
print(50)
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
K = int(input())
ans = [K//50 + i for i in range(50)]
if K%50:
  for i in range(K%50):
    ans[i] += N
print(50)
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
N = 50
big = 10 ** 16

K = int(input())

if K <= 50 * 50:
    a = [49] * 50
    a[0] += K * 50
else:
    a = [0] * 50
    index = 0 
    for i in range(K // big):
        a[i] = big
    a[i] = K % big
print(N)
print(" ".join(map(str, a)))

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    K = int(input())
    if (K == 0):
        print (2)
        print (0, 0)
        exit()
    if (K == 1):
        print (2)
        print (2, 0)

    if (K <= 50):
        print (K)
        res = []
        for x in range(K):
            res.append(x + 1)
        print (" ".join(map(str, res)))
        exit()
    assert(False)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    K = int(input())
    if (K == 0):
        print (1)
        print (0)
        exit()
    if (K <= 50):
        print (K)
        res = []
        for x in range(K):
            res.append(x + 1)
        print (" ".join(map(str, res)))
        exit()
    if (K <= 10 ** 16 + 1000):
        print (1)
        print (K)
        exit()
    assert(False)

Submission status: Runtime Error

Solution code:
K = int(input())

b = int(K % 50)
a = int((K - b) / 50)
	
list = [0] * 50
j = print(' '.join(list))0

while (j <= 49 - b) :
	list[j] = 49 + a - b
	j += 1

while (j >49 - b and j <= 49):
	list[j] = 2 * 50 + a - b
	j += 1


list = map(str, list)
print('50')

Submission status: Runtime Error

Solution code:
K = int(input())
a = 0
b = 0

for i in range(1, 51):
	if (K - K % i) / i + i - 1 >= 1000 + 10**16:
		break

	b = int(K % i)
	a = int((K - b) / i)
	N = i
	


list = [0] * N
j = 0


print(a, b, N)


while (j <= N - b - 1) :
	list[j] = N + a - b - 1
	j += 1

while (j > N - b - 1 and j <= N - 1):
	list[j] = 2 * N - b
	j += 1


list = map(str, list)
print(' '.join(list))

Submission status: Runtime Error

Solution code:
x = int(input())
if x == 0:
    print(4)
    print(3, 3, 3, 3)
    1/0

x-= 1
phase = x//50
subphase = x%50
pstart = phase*50

left = 99+phase-(x-pstart)
right = 48+phase-(x-pstart)
ans = [left]*(1+subphase)+[right]*(49-subphase)
print(50)
print(*ans)

Submission status: Runtime Error

Solution code:
MIN_N = 2
MAX_N = 50
MAX_A0 = 10 ** 16 + 1000


def solve(k):
    n = 1
    a0 = -MAX_A0
    for n_cand in range(MIN_N, MAX_N + 1):
        a0_cand = n_cand * (k + 1) - 1
        if a0 < 0 or a0 < a0_cand <= MAX_A0:
            n = n_cand
            a0 = a0_cand
    res = [0] * n
    res[0] = a0
    assert all(0 <= x <= MAX_A0 for x in res)
    return n, res


def main():
    k = int(input())
    n, res = solve(k)
    print(n)
    print(*res)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def show1(n, ans):
    for i in xrange(n):
        print ans[i],
    print

def show2(n, m, l, ans):
    for i in xrange(l):
        print ans[i] * m + 1,
    for i in xrange(l, n):
        print ans[i] * m,
    print

k = int(raw_input())
n = 50
ans = [0] * n
print n
if k <= n:
    for i in xrange(k):
        ans[i] = n - i
    show(n, ans)
else:
    ans = range(50, 0, -1)
    m = k / 50
    l = k % 50
    show2(n, m, l, ans)