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: Accepted

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy
import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

######################################################################################################
n=int(input())
ans=((n+999)//1000)*1000-n
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

N = int(input().strip())

M = N // 1000 + (0 if N % 1000 == 0 else 1)
R = 1000 * M - N

print(R)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def main():
    n = int(input())
    r = n % 1000
    if r == 0:
        print(0)
    else:
        print(1000 - r)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N = int(input())
    a = (N + 999) // 1000
    print(a * 1000 - N)

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n=I()
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, 11):
    if (N <= 1000 * i):
        print(1000 * i - N)
        exit()

Submission status: Accepted

Solution code:
from math import ceil
n = int(input())
m = ceil(n/1000)
print(m * 1000 - n)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

n = int(sys.stdin.readline())
print(math.ceil(n/1000)*1000 - n)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())

    for i in range(10):
        if n > 1000:
            n -= 1000
            continue
        print(1000 - n)
        return

    # テストクラス


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """1900"""
        output = """100"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3000"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Accepted

Solution code:
n = int(input())

x, y = divmod(n, 1000)

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, 11):
    money = i * 1000
    if money - N >= 0:
        print(money - N)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = int(input())

print(str(0) if i % 1000 == 0 else str((i // 1000 + 1) * 1000 - i))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import *
from bisect import bisect_left

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def bs(arr, l, r, x): 
    while l <= r: 
        mid = l + (r - l) // 2; 
        if arr[mid] == x: 
            return mid 
        elif arr[mid] < x: 
            l = mid + 1
        else: 
            r = mid - 1
    return -1


def main():
    a = cino()
    if a%1000==0:
        print(0)
    else:
        x = a//1000
        # print(x)
        print((x+1)*1000-a)       

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

  print(1000*c - n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    print(math.ceil(n/1000)*1000-n)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N=int(input())
ans=math.ceil(N/1000)
print(ans*1000-N)

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
while 1000*cnt < N:
    cnt += 1

print(1000*cnt - N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

while N > 0:
    N -= 1000

print(-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input()[::-1][:3][::-1])
if N!=0:
    print(1000-N)
else:
    print(0)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
k = 1000 - n % 1000
if k == 1000:
    print(0)
else:
    print(k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline


# S=(input())
# N=int(input())
# N,K=map(int,input().split())
# ListA=list(map(int,input().split()))
# ListA.sort()#reverse=True)



def resolve():
    N=int(input())
    if(N%1000==0):
        print(0)
    else:
        print(1000-N%1000)


resolve()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, 11):
    if i*1000 >= n:
        break
print(i*1000 - n)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
N=int(input())


m=int(N/1000)+1

print((m*1000-N)%1000)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

    n = n % 1000

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(1000-N%1000)

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())

    ans = (1000 - N % 1000) % 1000

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N = ii()
    ans = INF
    for i in range(1,11):
        yen = i * 1000
        c = yen-N
        if c >= 0:
            ans = min(ans,c)
        
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

n = int(input())
print(1000 - (n % 1000) if 1000 - (n % 1000) != 1000 else 0)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(11):
    if n <= i * 1000:
        print(i * 1000 - n)
        exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(11):
    ans = i*1000 - n
    if ans >= 0:
        print(ans)
        exit()

Submission status: Accepted

Solution code:
n=int(input(''))
s=0
while(1):
    if s*1000>=n:
        break

    s=s+1

print(s*1000-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    a=0
    while True:
        a+=1000
        if a>=n:
            break
    print(a-n)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    cnt=0
    while True:
        cnt+=1
        if n<=1000*cnt:
            print(1000*cnt-n)
            break
    
resolve()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    print(0 if n % 1000 == 0 else 1000 - (n % 1000))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

n = int_input()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def div_ceil(a, b):
    return (a + b - 1) // b


def compute(n):
    d = div_ceil(n, 1000)
    return d * 1000 - n


def main():
    n = int(input())
    res = compute(n)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
#A = list(map(int, input().split()))
#a, b = map(int, input().split())
if n%1000 == 0:
  print(0)
else:
  print(1000-(n%1000))

Submission status: Accepted

Solution code:
def main():

	n = int(input())
	amari = n % 1000
	if amari == 0:
		print(0)
	else:
		print(1000-amari)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline().rstrip())

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, 10001):
    if 1000*i >= N:
        print(1000*i-N)
        break

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
def solve():
    n = int(input())

    for i in range(15):
        n -= 1000
        if n < 0:
            return -n
        elif n == 0:
            return n
    


print(solve())

Submission status: Accepted

Solution code:
from math import ceil
n=int(input())
a=ceil(n/(1000))
print(a*1000-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

if N%1000>0:
  print(1000-N%1000)
else:
  print(0)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1000,10010,1000):
  if i>=n:
    print(i-n)
    break

Submission status: Accepted

Solution code:
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


if __name__ == "__main__":
    n = int_in()
    n %= 1000
    n = n if n == 0 else 1000 - n
    out(n)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
ans = 1000-N%1000
if ans == 1000:
    print(0)
else:
    print(ans)

Submission status: Accepted

Solution code:
N,=map(int, input().split()) 
for i in range(10000):
  if i*1000>=N:
    print(i*1000-N)
    exit()

Submission status: Accepted

Solution code:
N = int(input())

amari = N % 1000

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

Submission status: Accepted

Solution code:
n = int(input())

c = 0
for i in range(1000,11000, 1000):
    if i >= n:
        c = i - n
        break
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

for i in range(1,15):
    x = 1000*i - n
    if(0 <= x and x < 1000):
        print(x)
        exit()

Submission status: Accepted

Solution code:
n = int(input())

print((1000 - (n % 1000)) % 1000)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
c = math.ceil(n/1000)
print((c*1000) - n)

Submission status: Accepted

Solution code:

if __name__ == "__main__":
    N = int(input())
    payment = 0
    while N-payment > 0:
        payment += 1000
    print(payment-N)

Submission status: Accepted

Solution code:
N = int(input())

q, mod = divmod(N, 1000)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    t = n//1000
    ans = 1000*(t+1)-n
    if ans == 1000:
        print(0)
    else:
        print(ans)
main()

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
print(1000 - N % 1000 if N % 1000 > 0 else 0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input().strip())

if n%1000:
    print(1000-n%1000)
else:
    print(0)

Submission status: Accepted

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

def li():
    return [int(x) for x in input().split()]

N = int(input())

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

Submission status: Accepted

Solution code:
import math
N = int(input())

print(math.ceil(N/1000)*1000 - N)

Submission status: Accepted

Solution code:
N=int(input())

print(0 if N%1000==0 else 1000-N%1000)

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    osatu = N // 1000
    amari = (osatu + 1)*1000 - N
    if amari == 1000:
        print(0)
    else:
        print(amari)

    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    x = N // 1000
    N -= x * 1000
    if N == 0:
        print(0)
    else:
        print(1000 - N)
    return

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(1000-N%1000)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import math

n = int(input())

print(math.ceil(n/1000)*1000-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1000,10001,1000):
  if i >= n:
    print(i-n)
    break

Submission status: Accepted

Solution code:
import  math
a = int(input())

c = math.ceil(a / 1000)

print(c * 1000 - a)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def main():
    n = int(input())

    price = 0
    while True:
        if n <= price:
            break
        price += 1000

    print(price - n)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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