Problem:


Score : 100 points

Problem Statement

We will buy a product for N yen (the currency of Japan) at a shop.

If we use only 1000-yen bills to pay the price, how much change will we receive?

Assume we use the minimum number of bills required.

Constraints

1 \leq N \leq 10000

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the amount of change as an integer.

Sample Input 1

1900

Sample Output 1

100

We will use two 1000-yen bills to pay the price and receive 100 yen in change.

Sample Input 2

3000

Sample Output 2

0

We can pay the exact price.



Sample input:
1900


Sample output:
100

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
ans = A[0]

if N%2 == 0:
  for i in range(1,N/2):
    ans = ans + A[i]*2
if N%2 == 1:
  for i in range(1,(N-1)/2):
    ans = ans + A[i]*2
  ans += A[(N+1)/2]
print(ans)

Submission status: Runtime Error

Solution code:
import math
paper = math.floor(N/1000)
print("paper")

Submission status: Runtime Error

Solution code:
import math

paper = math.floor(N/1000)

print("paper")

Submission status: Runtime Error

Solution code:
print(-int(input()%1000)

Submission status: Runtime Error

Solution code:
def N(n):
	if n %1000 == 0:
		print('0')
	elif n %1000 != 0:
		return n %1000
N(n)

Submission status: Runtime Error

Solution code:
N = int(input)
for i in range(11):
	money = i * 1000
	if money - N >= 0:
		print(money - N)
		break

Submission status: Runtime Error

Solution code:
n = input()

money = 0
if int(n)%1000 == 0:
    print(0)
else:
    money = (int(n[:-3]) + 1)*1000 
    ans = money - int(n)
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(input() for i in range(n))
a = s.count("AC")
w = s.count("WA")
t = s.count("TLE")
r = s.count("RE")

print("AC x " + str(a))
print("WA x " + str(w))
print("TLE x " + str(t))
print("RE x " + str(r))

Submission status: Runtime Error

Solution code:
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for A in N :
    str = input()
    if str == 'AC' :
        C0 += 1
    if str == 'WA' :
        C1 += 1
    if str == 'TLE':
        C2 += 1
    if str == 'RE' :
        C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))

Submission status: Runtime Error

Solution code:
n = int(input())
if n % 1000 == 0:
  print(0)
else:
  print(2000-int("1"+str(n[:-3])))

Submission status: Runtime Error

Solution code:
import copy
H,W,K=map(int,input().split())
L=[[x for x in input()] for i in range(H)]
ans=0
for i in range(2**H):
    for j in range(2**W):
        C=copy.deepcopy(L)
        for k in range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l in range(W):
            if (j>>l&1):
                for m in range(H):
                    C[m][l]="r"
        count=0
        for p in range(H):
            for q in range(W):
                if C[p][q]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
def = input(N)
while N<1000:
    N -= 1000
return N

Submission status: Runtime Error

Solution code:
n = input()
change = n[1:]
change = int(change)
print(change)

Submission status: Runtime Error

Solution code:
N = int(input())
for i in range(11):
	if i* 1000>=N:
		print(i * 1000- N)
		beak

Submission status: Runtime Error

Solution code:
N = map(int,input())
x = 0
while x < N :
  x = x + 1000
print(x-N)

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(a)

a_sort_raw = sorted(a)
a_arg_raw = np.argsort(a)

a_abs = list(map(abs,a))
a_abs = np.array(a_abs)

a_sort = sorted(a_abs,reverse=True)

a_arg = np.argsort(-a_abs)

a_arg_k = a_arg[0:k]
a_arg_k_ = a_arg[k:]

a_pow = 1

if all([1 if i < 0 else 0 for i in a]) and (k % 2 != 0):
    for i in range(n-1,k,-1):
        a_pow *= a[a_arg_raw[i]]

else:
    for i in range(k):
        a_pow *= a[a_arg[i]]
    
    if a_pow < 0:
        a_pow_p = 1
        for i in reversed(a_arg_k):
            if a[i] < 0:
                for j in a_arg_k_:
                    if a[j] > 0:
                        a_pow_p = a_pow/a[i]*a[j]
                        break
                break
                
        a_pow_m = 1
        for i in reversed(a_arg_k):
            if a[i] > 0:
                for j in a_arg_k_:
                    if a[j] < 0:
                        a_pow_m = a_pow/a[i]*a[j]
                        break
                break
        if a_pow_p > a_pow_m:
            a_pow = a_pow_p
        else:
            a_pow = a_pow_m

output = a_pow % (10**9 + 7)
print(output)

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(a)

a_abs = list(map(abs,a))
a_abs = np.array(a_abs)

a_sort = sorted(a_abs,reverse=True)

a_arg = np.argsort(-a_abs)

a_arg_k = a_arg[0:k]
a_arg_k_ = a_arg[k:]

a_pow = 1

if all([1 if i < 0 else 0 for i in a]) and (k % 2 != 0):
    for i in range(n-1,k-1,-1):
        a_pow *= a[a_arg[i]]

else:
    for i in range(k):
        a_pow *= a[a_arg[i]]
    
    if a_pow < 0:
        a_pow_p = 1
        for i in reversed(a_arg_k):
            if a[i] < 0:
                for j in a_arg_k_:
                    if a[j] > 0:
                        a_pow_p = a_pow/a[i]*a[j]
                        break
                break
                
        a_pow_m = 1
        for i in reversed(a_arg_k):
            if a[i] > 0:
                for j in a_arg_k_:
                    if a[j] < 0:
                        a_pow_m = a_pow/a[i]*a[j]
                        break
                break
        if a_pow_p > a_pow_m:
            a_pow = a_pow_p
        else:
            a_pow = a_pow_m

output = a_pow % (10**9 + 7)
print(output)

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(a)

a_abs = list(map(abs,a))
a_abs = np.array(a_abs)

a_sort = sorted(a_abs,reverse=True)

a_arg = np.argsort(-a_abs)

a_arg_k = a_arg[0:k]
a_arg_k_ = a_arg[k:]

a_pow = 1

if all([1 if i < 0 else 0 for i in a]) and (k % 2 != 0):
    for i in range(n,k-1,-1):
        a_pow *= a[a_arg[i-1]]

else:
    for i in range(k):
        a_pow *= a[a_arg[i]]
    
    if a_pow < 0:
        a_pow_p = 1
        for i in reversed(a_arg_k):
            if a[i] < 0:
                for j in a_arg_k_:
                    if a[j] > 0:
                        a_pow_p = a_pow/a[i]*a[j]
                        break
                break
                
        a_pow_m = 1
        for i in reversed(a_arg_k):
            if a[i] > 0:
                for j in a_arg_k_:
                    if a[j] < 0:
                        a_pow_m = a_pow/a[i]*a[j]
                        break
                break
        if a_pow_p > a_pow_m:
            a_pow = a_pow_p
        else:
            a_pow = a_pow_m

output = a_pow % (10**9 + 7)
print(output)

Submission status: Runtime Error

Solution code:
N=int(input())
if(N%1000==0):
  m=(int(N/1000)
else:
  m=(int(N/1000)
change=1000*m-N
print(change)

Submission status: Runtime Error

Solution code:
N=int(input())
if (N%1000=0):
  m=(int(N/1000)
else:
  m=(int(N/1000)
change=1000*m-N
print(change)

Submission status: Runtime Error

Solution code:
N=int(input())
m
change=int(N%1000)+1-N
print(change)

Submission status: Runtime Error

Solution code:
N=int(input())
if n%1000=0:
  print(0)
else:

  n=1000-(N%1000)
  print(n)

Submission status: Runtime Error

Solution code:
N=int(input())
if n%1000!=0:
  n=1000-(N%1000)
  print(n)
else:
  print(0)

Submission status: Runtime Error

Solution code:
N=int(input())
if N%1000!=0:
  n=1000-N%1000
  print(n)
elif N%1000=0:
  print(0)

Submission status: Runtime Error

Solution code:
N=int(input())
if n%1000!=0:
  n=1000-N%1000
  print(n)
elif n%1000=0:
  print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
n = N % 1000
if n == 0;
  	print(0)
else;
  	print(1000-n)

Submission status: Runtime Error

Solution code:
N = int(input())
n = N%1000
if n=0;
  	print(0)
else;
  	print(1000-n)

Submission status: Runtime Error

Solution code:
N = int(input())
n = N%1000
if n=0:
  	print(0)
else:
  	print(1000-n)

Submission status: Runtime Error

Solution code:
N = int
a = (N/1000-int(N/1000))*1000
print(a)

Submission status: Runtime Error

Solution code:
N = int(input())
a = N % 1000
b = a!= 0 ? 1000 - a : 0
print(b)

Submission status: Runtime Error

Solution code:
def money():
	N = int(input())
	if N <= 1000:
      return 2000-N
    
    else:
      for i in range(1, 11):
        money = 1000*i
        if N > money:
          continue
        return money-N
      
print(money())

Submission status: Runtime Error

Solution code:
loop_count = int(input())

ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0

for i in range(loop_count):
    result = input()
    if result == 'AC':
        ac_count += 1
    elif result == 'WA':
        wa_count += 1
    elif result == 'TLE':
        tle_count += 1
    else:
        re_count += 1

print("AC x {0}".format(str(ac_count)))
print("WA x {0}".format(str(wa_count)))
print("TLE x {0}".format(str(tle_count)))
print("RE x {0}".format(str(re_count)))

Submission status: Runtime Error

Solution code:
int a = input()
print((1000-(a%1000))%1000)

Submission status: Runtime Error

Solution code:
a = int(input())
print((1000-(N%1000))%1000)

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
s = [str(input().rstrip()) for i in range(n)]
print("AC ×",s.count("AC"))
print("WA ×",s.count("WA"))
print("TLE ×",s.count("TLE"))
print("RE ×",s.count("RE"))

Submission status: Runtime Error

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
score = [A[0]]
s = 0

for a in A[1:N]:
    s += score[0]
    score = score[1:] + [a,a]

print(s)

Submission status: Runtime Error

Solution code:
N=int(input())
print(N%10000

Submission status: Runtime Error

Solution code:
N = int(input)
a = 1000 - N
print(a)

Submission status: Runtime Error

Solution code:
N = input()
A = 0 if N%1000 == 0 else 1000 - N%1000
print(A)

Submission status: Runtime Error

Solution code:
N = int(input())
X = N%1000
A = 0 if X == 0 else A = 1000 - X
print(A)

Submission status: Runtime Error

Solution code:
N = int(input())
A = 0 if N%1000 == 0 else A = 1000-N%1000
print(A)

Submission status: Runtime Error

Solution code:
N = input()
A = 0 if N%1000 == 0 else A = 1000-N%1000
print(A)

Submission status: Runtime Error

Solution code:
N = input()
A = 0 if N%1000 == 0 else A = (1+N//1000)*1000-N
print(A)

Submission status: Runtime Error

Solution code:
N=input()
print((1+int(N/1000))*1000-N)

Submission status: Runtime Error

Solution code:
n=input()
print((1+int(n/1000))*1000-n)

Submission status: Runtime Error

Solution code:
N=input()
print(1+N/1000)

Submission status: Runtime Error

Solution code:
N = input()
print(1 + N/1000)

Submission status: Runtime Error

Solution code:
N = int(input())
A = 10000 - N
while True == True:
   A = A - 1000
    if A < 0:
      break
print(A+1000)

Submission status: Runtime Error

Solution code:
N = input()
turi = N % 1000
if turi != 0:
  turi = 1000 - turi
print(turi)

Submission status: Runtime Error

Solution code:
N = input()
turi = N mod 1000
if (turi <> 0):
	turi = 1000 - turi
print(turi)

Submission status: Runtime Error

Solution code:
N=int(input())
S=str(N)
s = ""
for i in range(3):
    s = S[len(S)-1-i] + s

n = int(s)
ans = 1000 - n
if ans == 1000:
    ans = 0

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
a=N//1000
if N%1000=0:
  print(0)
else:
  print(1000*(a+1)-N)

Submission status: Runtime Error

Solution code:
n = input()
n = n[-3:]
if n == '000':
  print('0')
else:
  print(str(1000 - int(n))

Submission status: Runtime Error

Solution code:
int(input(n))
print(n%1000)

Submission status: Runtime Error

Solution code:
N = int(input())

if N > 1000:
    hasu = N - (N // 1000)*1000
    
print(1000-hasu)

Submission status: Runtime Error

Solution code:
if N > 1000:
    hasu = N - (N // 1000)*1000
else:
    hasu = N
    
print(1000-hasu)

Submission status: Runtime Error

Solution code:
N = int(input())

ACcount = 0 
WAcount = 0
TLEcount = 0
REcount = 0
for i in range(N):
	S=input()

	if S == "AC":
		ACcount = ACcount + 1
	elif S == "WA":
		WAcount = WAcount + 1
	elif S == "TLE":
		TLEcount = TLEcount + 1
	elif S == "RE":
		REcount = REcount + 1

print("AC x", ACcount)
print("WA x", WAcount)
print("TLE x", TLEcount)
print("RE x", REcount)

Submission status: Runtime Error

Solution code:
N = int(input())

ACcount = 0 
WAcount = 0
TLEcount = 0
REcount = 0
for i in range(N):
	S=input()

	if S == "AC":
		ACcount = ACcount + 1
	elif S == "WA":
		WAcount = WAcount + 1
	elif S == "TLE":
		TLEcount = TLEcount + 1
	elif S == "RE":
		REcount = REcount + 1

print("AC x" + str(ACcount))
print("WA x" + str(WAcount))
print("TLE x" + str(TLEcount))
print("RE x" + str(REcount))

Submission status: Runtime Error

Solution code:
n=int(input())
print(1000 - (input % 1000))

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools
h = int(input())
w = int(input())
k = int(input())
s = [list(input()) for i in range(h)]
data = np.zeros(h*w).reshape(h,w)
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            data[i][j] = 1

ans = 0
## 塗らない場合
if np.sum(data == 1) == k:
    ans = 1
## すべて塗った場合
if k == 0:
    ans = 1

a = list()
b = list()
for i in range(1,h):
    a += list(itertools.combinations(range(h), i))
for i in range(1,w):
    b += list(itertools.combinations(range(w), i))

for i in a:
    for j in b:
        temp = data.copy()
        temp[i,:] = 2
        temp[:,j] = 2
        if np.sum(temp == 1) == k:
            ans += 1

for i in a:
    temp = data.copy()
    temp[i,:] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
for j in b:
    temp = data.copy()
    temp[:,j] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
d={'AC':0,'RE':0,'WA':0,'TLE':0}
for i in range(n):
    s=input().strip()
    d[s]=d[s]+1
print('AC x '+str(d['AC']))
print('WA x '+str(d['WA']))
print('TLE x '+str(d['TLE']))
print('RE x '+str(d['RE']))

Submission status: Runtime Error

Solution code:
n = input()
if n % 1000:
    print(0)
else:
    print(1000 - n%1000)

Submission status: Runtime Error

Solution code:
n = input()
print(1000- n%1000)

Submission status: Runtime Error

Solution code:
n = int(input())
s = ""
ac=0
wa=0
tle=0
re=0

for i in range(n):
    s = input()

    if s == 'AC':
        ac = ac+1
    elif s == 'TLE':
        tle = tle+1
    elif s == 'WA':
        wa = wa+1
    elif s == 'RE':
        re = re+1

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Submission status: Runtime Error

Solution code:
class edge:
    def __init__(self, u, v):
        self.u = u
        self.v = v
    def min(self):
        return min(self.u, self.v)
    def max(self):
        return max(self.u, self.v)

N = int(input())
 
edge_list = []
for i in range(N - 1):
    u, v = map(int, input().split())
    edge_list.append(edge(u - 1, v - 1))
 
ver_num = int(N * (N + 1) * (N + 2) / 6)
 
edge_num = 0
for e in edge_list:
    edge_num += (N + 1 - (e.max() + 1)) * (e.min() + 1)
    
print(ver_num - edge_num)

Submission status: Runtime Error

Solution code:
n = input()
a = n%1000
a = 1000-a
print(a)

Submission status: Runtime Error

Solution code:
i = N % 3
return i

Submission status: Runtime Error

Solution code:
N=int(input())
if N%1000=0:
  print(0)
else:
  print(1000-(N%1000))

Submission status: Runtime Error

Solution code:
n = int(input())

if n%1000 = 0:
    print(n / 1000)
else 
    print(n/1000+1)

Submission status: Runtime Error

Solution code:
n = int(input())

satsu = n / 1000

printf(satsu+1)

Submission status: Runtime Error

Solution code:
a = input()


amari  = a % 1000
otsuri = 1000 - amari
print(otsuri)

Submission status: Runtime Error

Solution code:
N = input()
remainder = N % 1000
if remainder == 0:
  print(0)
else:
  print(1000 - remainder)

Submission status: Runtime Error

Solution code:
n = int(input())
A = input()
A = A.split()
A = [int(i) for i in A]
A = sorted(A, reverse = True)
ans = 0

for x in A:
	ans += x

ans -= A[n-1]

print(ans)

Submission status: Runtime Error

Solution code:
N = input()
remainder = N % 1000
print(remainder)

Submission status: Runtime Error

Solution code:
def main():
  N = input()
  remainder = N % 1000
  print(remainder)

main()

Submission status: Runtime Error

Solution code:
N=int(input())
b=N%1000
if b=0:
  print(0)
else:
  print(1000-b)

Submission status: Runtime Error

Solution code:
x = (1000 - N%1000)%1000

print(x)

Submission status: Runtime Error

Solution code:
x = 1000 - N%1000
print(x)

Submission status: Runtime Error

Solution code:
print(100000-int(input().split())%1000)

Submission status: Runtime Error

Solution code:
N = int(input())
S = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
	print('{} x {}'.format(v, S.count(v)))

Submission status: Runtime Error

Solution code:

taka = input()
remainder = taka%1000
ans = 1000 - remainder

Submission status: Runtime Error

Solution code:
N=int(input())
A=N-1000*(N//1000)
B=((N//1000)+1)*1000-N
if A<=B:
  return A
else:
  return B

Submission status: Runtime Error

Solution code:
N = input()
N = N%1000
ans = 1000 - N if not N else 0
print(ans)

Submission status: Runtime Error

Solution code:
import math

price = input()
payment = math.ceil(float(price) / 1000) * 1000
result = payment - price
print(int(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

A = np.array([int(i) for i in input().split()])
A_sort = np.sort(A)

#print(A_sort)
score = 0
score += A_sort[-1]
for i in range(0, (N-2)//2):
    score += A_sort[-2-i] * 2
    
if (N-2) % 2 == 1:
    score += A_sort[-3-i]
    
print(score)

Submission status: Runtime Error

Solution code:
in = int(input())

if in % 1000 == 0:
  print(0)
else:
  print(1000 - in % 1000)

Submission status: Runtime Error

Solution code:
nu = int(input())

if 1000 % nu == 0:
  return 0
else:
  return 1000-  1000 % num

Submission status: Runtime Error

Solution code:
n = int(input())

if n % 1000 == 0:
  return 0
else:
  return 1000 - n % 1000

Submission status: Runtime Error

Solution code:
N = int(input())

if N % 1000 == 0:
  print(0)
elsif N % 1000 > 0:
  print(100 - N%1000)

Submission status: Runtime Error

Solution code:
N = input()

answer = 1000 - (N%1000)

print(answer)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

N = input()

print(1000 - N%1000)

Submission status: Runtime Error

Solution code:
N=int(input())
return N%1000

Submission status: Runtime Error

Solution code:
n=input()
k=0
while k < n:
    k += 1000
print(k-n)

Submission status: Runtime Error

Solution code:
n=input()
n=int(n)
ac=0
wa=0
tle=0
re=0

for val in range(n):
  judge=input()
  if judge =='AC':
    ac=ac+1
  elif judge=='WA':
    wa=wa+1
  elif judge=='TLE':
    tle=tle+1
  elif judge=='RE':
    re=re+1
    
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Submission status: Runtime Error

Solution code:
n = input()
n = 1000 - n
while n < 0:
    n += 1000
print(n)

Submission status: Runtime Error

Solution code:
N = int(input())
S = ['-1' for _ in range(N+1)]
C = {}
C['AC'] = 0; C['WA'] = 0; C['TLE'] = 0; C['RE'] = 0
for i in range(N):
  S[i+1] = input()
  C[S[i+1]] += 1
for case in ['AC', 'WA', 'TLE', 'RE']:
  print('{} x {}'.format(case,str(C[case])))

Submission status: Runtime Error

Solution code:
a,b,c=map(int, input().split())
l =sorted([a,b,c])

s = sum(l[:2])
print(s)

Submission status: Runtime Error

Solution code:
n=input()
print(999-((n-1)%1000))

Submission status: Runtime Error

Solution code:
a = 0
while N >= 1000:
  N = N - 1000
else:
  a += N
print(a)

Submission status: Runtime Error

Solution code:
my_result = 0
while N >= 1000:
    N = N - 1000
else:
    my_result += N
return my_result

Submission status: Runtime Error

Solution code:
def main():
	x = int(input())
    y = x%1000
    return y

if __name__ =="__main__":
  main()

Submission status: Runtime Error

Solution code:
import sys

N = sys.args[1]

for i in range(10):
    if 1000 * i >= N:
        break

return 1000*i - N

Submission status: Runtime Error

Solution code:
for i in range(10):
    if 1000 * i >= N:
        break

return 1000*i - N

Submission status: Runtime Error

Solution code:
N = int(input())
if N % 1000 = 0:
  print(0)
else:
  a = N % 1000
  print(1000 - a)

Submission status: Runtime Error

Solution code:
a = input()
b = a % 1000
print(b)

Submission status: Runtime Error

Solution code:
N = int(input())
a, w, t, r = 0, 0, 0, 0
for i in range(N):
    S = input()
    if S == 'AC':
        a += 1
    elif S == 'WA':
        w += 1
    elif S == 'TLE':
        t += 1
    else:
        r += 1
print('AC × ' + str(a))
print('WA × ' + str(w))
print('TLE × ' + str(t))
print('RE × ' + str(r))

Submission status: Runtime Error

Solution code:
if N%1000=0:
  print(0)
  else:
    print(1000-N%1000)

Submission status: Runtime Error

Solution code:
y= N%1000
print(y)

Submission status: Runtime Error

Solution code:
y= N%%1000
print(y)

Submission status: Runtime Error

Solution code:
a = input()
print(a/1000 + 1)

Submission status: Runtime Error

Solution code:
import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0 and k%2 ==1 :
  if zero >= 1:
    ans = 0
  else:
    minus.sort(reverse=True)
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2 == 1:
    ans *= plus[0]
    ans %= mod
  q = 1
  judge = []
  for i in range((P-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(M//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
amari = N % 1000
if amari ==0:
  print(amari)
elif:
  print(1000-amari)

Submission status: Runtime Error

Solution code:
x = int input ("")
return 1000-(x%1000)

Submission status: Runtime Error

Solution code:
x = int innput ("")
return 1000-(x%1000)

Submission status: Runtime Error

Solution code:
import operator
N=input()
S=operator.floordiv(N,1000)
print(S*1000-N)

Submission status: Runtime Error

Solution code:
N=int(input())
if 1000-N%1000>0:
  print(1000-N%1000)
else print(0)

Submission status: Runtime Error

Solution code:
N=int(inpuit())
print(1000-N%1000)

Submission status: Runtime Error

Solution code:
AC = 0
WA = 0
TLE = 0
RE = 0
N = int(input())
for i in range(N):
	a = input()
	if(a == "AC"):
		AC = AC + 1
	if(a == "WA"):
 		WA = WA + 1
	if(a == "TLE"):
		TLE = TLE + 1
	if(a=="RE"):
		RE = RE + 1
print("AC x "+ str(AC))
print("WA x "+ str(WA))
print("TLE x "+ str(TLE))
print("RE x "+ str(RE))

Submission status: Runtime Error

Solution code:
N=int(input())

cash=1000

if N%cash==0:

	print(0)else:

	turi=cash-(N%cash)

	print(turi)

Submission status: Runtime Error

Solution code:
import numpy as np
# def main():
#     N=input()
#     N=int(N)
#     A=input().split(" ")
#     A=np.array([int(i) for i in A]).astype(np.uint64)
#     # A=np.random.randint(0,100000,200000)
#     l=[]
#     A=np.sort(A)
#     A=np.flip(A).astype(np.uint64)
#     sum=0
#     for i,num in enumerate(A):
#         if i%2==0:
#             l=l+[num]
#             if i!=0:
#                 sum+=min(l[-2],l[0])
#         else:
#             l=[num]+l
#             sum+=min(l[1],l[-1])
#     print(int(sum))

# def main2():
#     N=input()
#     N=int(N)
#     A=input().split(" ")
#     A=np.array([int(i) for i in A]).astype(np.uint64)
#     # A=np.random.randint(0,100000,200000)
#     A=np.sort(A)
#     A=np.flip(A).astype(np.uint64)
#     sum=0
#     for i,num in enumerate(A):
#         if i==0:
#             l=A[0]
#             r=A[0]
#             continue
#         sum+=min(l,r)
#         if l<r:
#             r=num
#         else:
#             l=num
#     print(int(sum))

def main3():
    N=input()
    N=int(N)
    A=input().split(" ")
    A=np.array([int(i) for i in A]).astype(np.uint64)
    l=[]
    A=np.sort(A)
    A=np.flip(A).astype(np.uint64)
    sum=0
    for i,num in enumerate(A):
        if i==0:
            l.append(num)
            continue
        l1=np.array(l,dtype=np.uint64)
        l2=np.roll(l1,1)
        l1=l1.reshape(-1,1)
        l2=l2.reshape(-1,1)
        l1=np.concatenate([l1,l2],1)
        l2=l1.min(1)
        arg=l2.argmax()
        l=l[:arg+1]+[num]+l[arg+1:]
        sum+=l2[arg]

    print(int(sum))


def correct():
    N=input()
    N=int(N)
    A=input().split(" ")
    A=np.array([int(i) for i in A]).astype(np.uint64)
    l=[]
    A=np.sort(A)
    A=np.flip(A).astype(np.uint64)
    sum=0
    for i in range(N-1):
        i+=1
        sum+=A[N-int(i/2)]
    print(int(sum))

if __name__ == "__main__":
    # main3()
    correct()

Submission status: Runtime Error

Solution code:
input_num = int(input())

n_surplus = input_num % 1000

if n_surplus == 0:
  print(n_surplus)
  else:
    print(1000 - n_surplus)

Submission status: Runtime Error

Solution code:
import numpy as np
# def main():
#     N=input()
#     N=int(N)
#     A=input().split(" ")
#     A=np.array([int(i) for i in A]).astype(np.uint64)
#     # A=np.random.randint(0,100000,200000)
#     l=[]
#     A=np.sort(A)
#     A=np.flip(A).astype(np.uint64)
#     sum=0
#     for i,num in enumerate(A):
#         if i%2==0:
#             l=l+[num]
#             if i!=0:
#                 sum+=min(l[-2],l[0])
#         else:
#             l=[num]+l
#             sum+=min(l[1],l[-1])
#     print(int(sum))

# def main2():
#     N=input()
#     N=int(N)
#     A=input().split(" ")
#     A=np.array([int(i) for i in A]).astype(np.uint64)
#     # A=np.random.randint(0,100000,200000)
#     A=np.sort(A)
#     A=np.flip(A).astype(np.uint64)
#     sum=0
#     for i,num in enumerate(A):
#         if i==0:
#             l=A[0]
#             r=A[0]
#             continue
#         sum+=min(l,r)
#         if l<r:
#             r=num
#         else:
#             l=num
#     print(int(sum))

def main3():
    N=input()
    N=int(N)
    A=input().split(" ")
    A=np.array([int(i) for i in A]).astype(np.uint64)
    l=[]
    A=np.sort(A)
    A=np.flip(A).astype(np.uint64)
    sum=0
    for i,num in enumerate(A):
        if i==0:
            l.append(num)
            continue
        l1=np.array(l,dtype=np.uint64)
        l2=np.roll(l1,1)
        l1=l1.reshape(-1,1)
        l2=l2.reshape(-1,1)
        l1=np.concatenate([l1,l2],1)
        l2=l1.min(1)
        arg=l2.argmax()
        l=l[:arg+1]+[num]+l[arg+1:]
        sum+=l2[arg]

    print(int(sum))

if __name__ == "__main__":
    main3()

Submission status: Runtime Error

Solution code:
import numpy as np
def main():
    N=input()
    N=int(N)
    A=input().split(" ")
    A=np.array([int(i) for i in A]).astype(np.uint64)
    # A=np.random.randint(0,100000,200000)
    l=[]
    A=np.sort(A)
    A=np.flip(A).astype(np.uint64)
    sum=0
    for i,num in enumerate(A):
        if i%2==0:
            l=l+[num]
            if i!=0:
                sum+=min(l[-2],l[0])
        else:
            l=[num]+l
            sum+=min(l[1],l[-1])
    print(int(sum))

def main2():
    N=input()
    N=int(N)
    A=input().split(" ")
    A=np.array([int(i) for i in A]).astype(np.uint64)
    # A=np.random.randint(0,100000,200000)
    A=np.sort(A)
    A=np.flip(A).astype(np.uint64)
    sum=0
    l=A[0]
    r=A[0]
    for i,num in enumerate(A,start=0):
        sum+=min(l,r)
        if l<r:
            r=num
        else:
            l=num
    print(int(sum))


if __name__ == "__main__":
    # main()
    main2()

Submission status: Runtime Error

Solution code:
in = int(input())
print(int(in % 1000))

Submission status: Runtime Error

Solution code:
n = int(input())
ans = (10000 - n) % 1000

print(ans

Submission status: Runtime Error

Solution code:
print((1000-(int(input)%1000))%1000)

Submission status: Runtime Error

Solution code:
print((1000-int(input)%1000)%1000)

Submission status: Runtime Error

Solution code:
n=input()
k=n%1000
print(k)

Submission status: Runtime Error

Solution code:
n = int(input())
 
a = n%1000
b = 1000-a
if b=1000:
  print(0)
else:
  print(b)

Submission status: Runtime Error

Solution code:
n = int(input())

a = n%1000
b = 1000-a
if b=1000:
  print(0)
else:
  print(a)

Submission status: Runtime Error

Solution code:
n, k = [int(x) for x in input().strip().split(" ")]
p = 10**9 + 7

num_list = [int(x) for x in input().strip().split(" ")]
num_list = sorted(num_list, reverse = True)
ans = 1
l_idx = 0
r_idx = -1

while True:
  if k >= 2:
    l_prod = num_list[l_idx] * num_list[l_idx+1]
    r_prod = num_list[r_idx] * num_list[r_idx-1]
    if l_prod >= r_prod:
      ans *= l_prod % p
      ans %= p
      l_idx +=2
      k -= 2
    else:
      ans *= r_prod % p
      ans %= p
      r_idx +=2
      k -= 2
  elif k == 1:
    ans *= num_list[l_idx] % p
    ans %= p
    break
  else:
    break
        
if num_list[0] < 0 and k % 2 == 1:
  ans = 1
  for i in range(k):
    ans *= num_list[i]
    ans %= p

print(ans)

Submission status: Runtime Error

Solution code:
answer = 1000 - N

print(answer)

Submission status: Runtime Error

Solution code:
s =int(input())

a= s%1000

if a==0:
  print(0)
elif:
  print(10-a)

Submission status: Runtime Error

Solution code:
N=int(input())
print(1000-N%1000)%1000

Submission status: Runtime Error

Solution code:

n=int(input())
if n%1000==0:
    print(0)
else:
    x=math.ceil(n/1000)
    ans=int(x*1000)-n
    print(ans)

Submission status: Runtime Error

Solution code:
MB_TLE = 0
MB_WA = 0
MB_RE = o
MB_AC = 0
n=int(input())
for i in range (n):
    ch = input ()
    if (ch =="TLE") :
     MB_TLE += 1
    if (ch =="WA") :
     MB_WA += 1
    if (ch =="RE") : 
     MB_RE += 1
    if (ch =="AC") :
     MB_AC += 1
print('TLE x ',MB_TLE)
print('WA x ',MB_WA)
print('RE x ',MB_RE)
print('AC x ',MB_AC)

Submission status: Runtime Error

Solution code:
MB_TLE = 0
MB_WA = 0
MB_RE = o
MB_AC = 0
n=int(input())
for i in range (n):
    ch = input ()
    if: (ch =="TLE")
     MB_TLE += 1
    if: (ch =="WA")
     MB_WA += 1
    if: (ch =="RE")
     MB_RE += 1
    if: (ch =="AC")
     MB_AC += 1
print('TLE x ',MB_TLE)
print('WA x ',MB_WA)
print('RE x ',MB_RE)
print('AC x ',MB_AC)

Submission status: Runtime Error

Solution code:
MB_TLE = 0
MB_WA = 0
MB_RE = o
MB_AC = 0
n=int(input())
for i in range (n):
    ch = input ()
    if (ch =="TLE")
     MB_TLE += 1
    if (ch =="WA")
     MB_WA += 1
    if (ch =="RE")
     MB_RE += 1
    if (ch =="AC")
     MB_AC += 1
print('TLE x ',MB_TLE)
print('WA x ',MB_WA)
print('RE x ',MB_RE)
print('AC x ',MB_AC)

Submission status: Runtime Error

Solution code:
n = input()
l = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
for i in l:
    if n <= i:
        r = i
        break
result = r - n
print(result)