Language: Common Lisp

General information



Your program should read its input from standard input and produce output on standard output. This can for instance be done using read / format. Anything written on standard error (*error-output*) will be ignored. This can be used for debugging your program during development (i.e., you do not have to remove debug output before submitting if you use standard error for debug output). Of course, writing to standard error will take some runtime.


Compiler settings

For Common Lisp, we use Common Lisp version SBCL 1.5.5.debian with the following flags: --control-stack-size 4 --noinform --noprint --non-interactive --eval (if (equal (compile-file "{file}") NIL) (sb-ext:exit :code 43) ()).

System libraries

You are allowed to use all standard libraries included with Common Lisp.





Solving a problem


  1. The problem
  2. Reading the input
  3. Computing the answer
  4. The solution

Step 1: The problem


Step 2: Reading the input

One thing to note is that the integers can be fairly large, as large as 1015. Luckily, Common Lisp supports integers that are arbitrarily large.


(loop for a = (read *standard-input* nil) until (null a) do (let ((b (read))) ; compute and print the answer here ))

Step 3: Computing the answer

Now that we've read the input, it's time to actually solve the problem. Since Common Lisp supports arbitrarily large integers, there is no danger of overflow involved in just subtracting the two numbers a and b. Then, we can just take the absolute value by using the abs function.

Finally, it's time to print the result. Using format, we can print it as:

(format t "~a~%" (abs (- a b)))

Step 4: The solution


Here is a version of the complete solution.


Frequently asked questions


I keep getting rejected but my solution works on the provided cases





Sorry, no. We can't share the secret testdata.




See the judgements page.

Interacting with the judge system

Can I test my solution before I submit?


Do you store my submissions?



Please contact us and tell us about it.