Problem:
Score: 200 points

Problem Statement

The restaurant AtCoder serves the following five dishes:

ABC Don (rice bowl): takes A minutes to serve.

ARC Curry: takes B minutes to serve.

AGC Pasta: takes C minutes to serve.

APC Ramen: takes D minutes to serve.

ATC Hanbagu (hamburger patty): takes E minutes to serve.

Here, the time to serve a dish is the time between when an order is placed and when the dish is delivered.

This restaurant has the following rules on orders:

An order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).

Only one dish can be ordered at a time.

No new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.

E869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.

Here, he can order the dishes in any order he likes, and he can place an order already at time 0.

Constraints

A, B, C, D and E are integers between 1 and 123 (inclusive).

Input

Input is given from Standard Input in the following format:

A
B
C
D
E

Output

Print the earliest possible time for the last dish to be delivered, as an integer.

Sample Input 1

29
20
7
35
120

Sample Output 1

215

If we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:

Order ABC Don at time 0, which will be delivered at time 29.

Order ARC Curry at time 30, which will be delivered at time 50.

Order AGC Pasta at time 50, which will be delivered at time 57.

Order ATC Hanbagu at time 60, which will be delivered at time 180.

Order APC Ramen at time 180, which will be delivered at time 215.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 2

101
86
119
108
57

Sample Output 2

481

If we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:

Order AGC Pasta at time 0, which will be delivered at time 119.

Order ARC Curry at time 120, which will be delivered at time 206.

Order ATC Hanbagu at time 210, which will be delivered at time 267.

Order APC Ramen at time 270, which will be delivered at time 378.

Order ABC Don at time 380, which will be delivered at time 481.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 3

123
123
123
123
123

Sample Output 3

643

This is the largest valid case.

Solution in JavaScript (node.js v5.12) (judge verdict: Accepted)

parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"Focm":[function(require,module,exports) {
var t={};!function(n){"use strict";(t["Control.Apply"]=t["Control.Apply"]||{}).arrayApply=function(t){return function(n){for(var a=t.length,r=n.length,e=new Array(a*r),o=0,i=0;i<a;i++)for(var u=t[i],c=0;c<r;c++)e[o++]=u(n[c]);return e}}}(),function(n){"use strict";(t["Data.Eq"]=t["Data.Eq"]||{}).refEq=function(t){return function(n){return t===n}}}(),function(n){"use strict";var a=t["Data.Eq"],r=(t["Data.HeytingAlgebra"],t["Data.Symbol"],t["Data.Unit"],t["Data.Void"],t["Record.Unsafe"],t["Type.Data.RowList"],function(t){this.eq=t}),e=new r(a.refEq);n.Eq=r,n.eq=function(t){return t.eq},n.eqInt=e}(t["Data.Eq"]=t["Data.Eq"]||{}),function(n){"use strict";(t["Data.Ord.Unsafe"]=t["Data.Ord.Unsafe"]||{}).unsafeCompareImpl=function(t){return function(n){return function(a){return function(r){return function(e){return r<e?t:r===e?n:a}}}}}}(),function(n){"use strict";(t["Data.Semigroup"]=t["Data.Semigroup"]||{}).concatArray=function(t){return function(n){return 0===t.length?n:0===n.length?t:t.concat(n)}}}(),function(n){"use strict";var a=t["Data.Semigroup"],r=(t["Data.Symbol"],t["Data.Unit"],t["Data.Void"],t["Record.Unsafe"],t["Type.Data.RowList"],function(t){this.append=t}),e=new r(a.concatArray);n.Semigroup=r,n.append=function(t){return t.append},n.semigroupArray=e}(t["Data.Semigroup"]=t["Data.Semigroup"]||{}),function(n){"use strict";(t["Data.Show"]=t["Data.Show"]||{}).showIntImpl=function(t){return t.toString()}}(),function(n){"use strict";var a=t["Data.Show"],r=(t["Data.Symbol"],t["Record.Unsafe"],t["Type.Data.RowList"],function(t){this.show=t}),e=new r(a.showIntImpl);n.Show=r,n.show=function(t){return t.show},n.showInt=e}(t["Data.Show"]=t["Data.Show"]||{}),function(n){"use strict";t["Data.Eq"],t["Data.Semigroup"],t["Data.Show"];var a=function(){function t(){}return t.value=new t,t}(),r=function(){function t(){}return t.value=new t,t}(),e=function(){function t(){}return t.value=new t,t}();n.LT=a,n.GT=r,n.EQ=e}(t["Data.Ordering"]=t["Data.Ordering"]||{}),function(n){"use strict";var a=t["Data.Ord.Unsafe"],r=t["Data.Ordering"],e=a.unsafeCompareImpl(r.LT.value)(r.EQ.value)(r.GT.value);n.unsafeCompare=e}(t["Data.Ord.Unsafe"]=t["Data.Ord.Unsafe"]||{}),function(n){"use strict";(t["Data.Ring"]=t["Data.Ring"]||{}).intSub=function(t){return function(n){return t-n|0}}}(),function(t){"use strict";t.intAdd=function(t){return function(n){return t+n|0}},t.intMul=function(t){return function(n){return t*n|0}}}(t["Data.Semiring"]=t["Data.Semiring"]||{}),function(n){"use strict";var a=t["Data.Semiring"],r=(t["Data.Symbol"],t["Data.Unit"],t["Record.Unsafe"],t["Type.Data.Row"],t["Type.Data.RowList"],function(t,n,a,r){this.add=t,this.mul=n,this.one=a,this.zero=r}),e=new r(a.intAdd,a.intMul,1,0);n.Semiring=r,n.add=function(t){return t.add},n.zero=function(t){return t.zero},n.mul=function(t){return t.mul},n.one=function(t){return t.one},n.semiringInt=e}(t["Data.Semiring"]=t["Data.Semiring"]||{}),function(n){"use strict";var a=t["Data.Ring"],r=t["Data.Semiring"],e=(t["Data.Symbol"],t["Data.Unit"],t["Record.Unsafe"],t["Type.Data.RowList"],function(t,n){this.Semiring0=t,this.sub=n}),o=new e(function(){return r.semiringInt},a.intSub);n.Ring=e,n.sub=function(t){return t.sub},n.ringInt=o}(t["Data.Ring"]=t["Data.Ring"]||{}),function(n){"use strict";t["Data.Ord"];var a=t["Data.Eq"],r=t["Data.Ord.Unsafe"],e=(t["Data.Ordering"],t["Data.Ring"],t["Data.Semiring"],t["Data.Symbol"],t["Data.Unit"],t["Data.Void"],t["Record.Unsafe"],t["Type.Data.RowList"],function(t,n){this.Eq0=t,this.compare=n}),o=new e(function(){return a.eqInt},r.unsafeCompare),i=function(t){return t.compare};n.Ord=e,n.compare=i,n.comparing=function(t){return function(n){return function(a){return function(r){return i(t)(n(a))(n(r))}}}},n.ordInt=o}(t["Data.Ord"]=t["Data.Ord"]||{}),function(n){"use strict";t["Control.Category"],t["Data.Boolean"],t["Data.Ord"],t["Data.Ring"];n.flip=function(t){return function(n){return function(a){return t(a)(n)}}}}(t["Data.Function"]=t["Data.Function"]||{}),function(n){"use strict";(t["Data.Functor"]=t["Data.Functor"]||{}).arrayMap=function(t){return function(n){for(var a=n.length,r=new Array(a),e=0;e<a;e++)r[e]=t(n[e]);return r}}}(),function(n){"use strict";var a=t["Data.Functor"],r=(t["Control.Semigroupoid"],t["Data.Function"],t["Data.Unit"],function(t){this.map=t}),e=new r(a.arrayMap);n.Functor=r,n.map=function(t){return t.map},n.functorArray=e}(t["Data.Functor"]=t["Data.Functor"]||{}),function(n){"use strict";var a=t["Control.Apply"],r=(t["Control.Category"],t["Data.Function"],t["Data.Functor"]),e=function(t,n){this.Functor0=t,this.apply=n},o=new e(function(){return r.functorArray},a.arrayApply);n.Apply=e,n.apply=function(t){return t.apply},n.applyArray=o}(t["Control.Apply"]=t["Control.Apply"]||{}),function(n){"use strict";t["Control.Apply"],t["Data.Functor"],t["Data.Unit"];n.Applicative=function(t,n){this.Apply0=t,this.pure=n},n.pure=function(t){return t.pure}}(t["Control.Applicative"]=t["Control.Applicative"]||{}),function(t){"use strict";t.range=function(t){return function(n){for(var a=t>n?-1:1,r=new Array(a*(n-t)+1),e=t,o=0;e!==n;)r[o++]=e,e+=a;return r[o]=e,r}},t.length=function(t){return t.length},t.reverse=function(t){return t.slice().reverse()},t.filter=function(t){return function(n){return n.filter(t)}},t.sortImpl=function(t){return function(n){return n.slice().sort(function(n,a){return t(n)(a)})}},t.slice=function(t){return function(n){return function(a){return a.slice(t,n)}}},t.zipWith=function(t){return function(n){return function(a){for(var r=n.length<a.length?n.length:a.length,e=new Array(r),o=0;o<r;o++)e[o]=t(n[o])(a[o]);return e}}}}(t["Data.Array"]=t["Data.Array"]||{}),function(n){"use strict";(t["Control.Bind"]=t["Control.Bind"]||{}).arrayBind=function(t){return function(n){for(var a=[],r=0,e=t.length;r<e;r++)Array.prototype.push.apply(a,n(t[r]));return a}}}(),function(n){"use strict";var a=t["Control.Bind"],r=(t["Control.Applicative"],t["Control.Apply"]),e=(t["Control.Category"],t["Data.Function"],t["Data.Functor"],t["Data.Unit"],function(t,n){this.Apply0=t,this.bind=n}),o=new e(function(){return r.applyArray},a.arrayBind);n.Bind=e,n.bind=function(t){return t.bind},n.bindArray=o}(t["Control.Bind"]=t["Control.Bind"]||{}),function(t){"use strict";t.foldrArray=function(t){return function(n){return function(a){for(var r=n,e=a.length-1;e>=0;e--)r=t(a[e])(r);return r}}},t.foldlArray=function(t){return function(n){return function(a){for(var r=n,e=a.length,o=0;o<e;o++)r=t(r)(a[o]);return r}}}}(t["Data.Foldable"]=t["Data.Foldable"]||{}),function(t){"use strict";t.intDegree=function(t){return Math.min(Math.abs(t),2147483647)},t.intDiv=function(t){return function(n){return 0===n?0:n>0?Math.floor(t/n):-Math.floor(t/-n)}},t.intMod=function(t){return function(n){if(0===n)return 0;var a=Math.abs(n);return(t%a+a)%a}}}(t["Data.EuclideanRing"]=t["Data.EuclideanRing"]||{}),function(n){"use strict";var a=t["Data.Ring"],r=(t["Data.Semiring"],t["Data.Symbol"],t["Data.Unit"],function(t){this.Ring0=t}),e=new r(function(){return a.ringInt});n.CommutativeRing=r,n.commutativeRingInt=e}(t["Data.CommutativeRing"]=t["Data.CommutativeRing"]||{}),function(n){"use strict";var a=t["Data.EuclideanRing"],r=(t["Data.BooleanAlgebra"],t["Data.CommutativeRing"]),e=(t["Data.Eq"],t["Data.HeytingAlgebra"],t["Data.Ring"],t["Data.Semiring"],function(t,n,a,r){this.CommutativeRing0=t,this.degree=n,this.div=a,this.mod=r}),o=new e(function(){return r.commutativeRingInt},a.intDegree,a.intDiv,a.intMod);n.EuclideanRing=e,n.degree=function(t){return t.degree},n.div=function(t){return t.div},n.mod=function(t){return t.mod},n.euclideanRingInt=o}(t["Data.EuclideanRing"]=t["Data.EuclideanRing"]||{}),function(n){"use strict";t["Data.Boolean"],t["Data.Eq"],t["Data.EuclideanRing"],t["Data.Ord"],t["Data.Ordering"],t["Data.Semigroup"],t["Data.Symbol"],t["Data.Unit"],t["Record.Unsafe"],t["Type.Data.RowList"];n.mempty=function(t){return t.mempty}}(t["Data.Monoid"]=t["Data.Monoid"]||{}),function(n){"use strict";t["Control.Alt"],t["Control.Alternative"],t["Control.Applicative"],t["Control.Apply"],t["Control.Bind"],t["Control.Category"],t["Control.Extend"],t["Control.Monad"],t["Control.MonadZero"],t["Control.Plus"],t["Data.Bounded"],t["Data.Eq"],t["Data.Function"],t["Data.Functor"],t["Data.Functor.Invariant"],t["Data.Monoid"],t["Data.Ord"],t["Data.Ordering"],t["Data.Semigroup"],t["Data.Show"],t["Data.Unit"],t.Prelude;var a=function(){function t(){}return t.value=new t,t}(),r=function(){function t(t){this.value0=t}return t.create=function(n){return new t(n)},t}();n.Nothing=a,n.Just=r,n.maybe=function(t){return function(n){return function(e){if(e instanceof a)return t;if(e instanceof r)return n(e.value0);throw new Error("Failed pattern match at Data.Maybe (line 217, column 1 - line 217, column 51): "+[t.constructor.name,n.constructor.name,e.constructor.name])}}}}(t["Data.Maybe"]=t["Data.Maybe"]||{}),function(n){"use strict";var a=t["Data.Foldable"],r=(t["Control.Alt"],t["Control.Applicative"],t["Control.Apply"],t["Control.Bind"],t["Control.Category"],t["Control.Plus"],t["Control.Semigroupoid"],t["Data.Eq"],t["Data.Function"],t["Data.Functor"],t["Data.HeytingAlgebra"],t["Data.Maybe"],t["Data.Maybe.First"],t["Data.Maybe.Last"],t["Data.Monoid"]),e=(t["Data.Monoid.Additive"],t["Data.Monoid.Conj"],t["Data.Monoid.Disj"],t["Data.Monoid.Dual"],t["Data.Monoid.Endo"],t["Data.Monoid.Multiplicative"],t["Data.Newtype"],t["Data.Ord"],t["Data.Ordering"],t["Data.Semigroup"]),o=(t["Data.Semiring"],t["Data.Unit"],t.Prelude,function(t,n,a){this.foldMap=t,this.foldl=n,this.foldr=a}),i=function(t){return t.foldr},u=function(t){return function(n){return function(a){return i(t)(function(t){return function(r){return e.append(n.Semigroup0())(a(t))(r)}})(r.mempty(n))}}},c=new o(function(t){return u(c)(t)},a.foldlArray,a.foldrArray);n.Foldable=o,n.foldr=i,n.foldl=function(t){return t.foldl},n.foldMap=function(t){return t.foldMap},n.foldMapDefaultR=u,n.foldableArray=c}(t["Data.Foldable"]=t["Data.Foldable"]||{}),function(n){"use strict";t["Control.Applicative"],t["Control.Apply"],t["Control.Biapplicative"],t["Control.Biapply"],t["Control.Bind"],t["Control.Comonad"],t["Control.Extend"],t["Control.Lazy"],t["Control.Monad"],t["Control.Semigroupoid"],t["Data.Bifoldable"],t["Data.Bifunctor"],t["Data.Bitraversable"],t["Data.BooleanAlgebra"],t["Data.Bounded"],t["Data.CommutativeRing"],t["Data.Distributive"],t["Data.Eq"],t["Data.Foldable"],t["Data.FoldableWithIndex"],t["Data.Function"],t["Data.Functor"],t["Data.Functor.Invariant"],t["Data.FunctorWithIndex"],t["Data.HeytingAlgebra"],t["Data.Maybe"],t["Data.Maybe.First"],t["Data.Monoid"],t["Data.Newtype"],t["Data.Ord"],t["Data.Ordering"],t["Data.Ring"],t["Data.Semigroup"],t["Data.Semigroup.Foldable"],t["Data.Semigroup.Traversable"],t["Data.Semiring"],t["Data.Show"],t["Data.Traversable"],t["Data.TraversableWithIndex"],t["Data.Unit"],t.Prelude,t["Type.Equality"];var a=function(){function t(t,n){this.value0=t,this.value1=n}return t.create=function(n){return function(a){return new t(n,a)}},t}();n.Tuple=a,n.snd=function(t){return t.value1}}(t["Data.Tuple"]=t["Data.Tuple"]||{}),function(n){"use strict";(t["Partial.Unsafe"]=t["Partial.Unsafe"]||{}).unsafePartial=function(t){return t()}}(),function(n){"use strict";(t["Partial"]=t["Partial"]||{}).crashWith=function(){return function(t){throw new Error(t)}}}(),function(n){"use strict";var a=t.Partial;n.crashWith=a.crashWith}(t.Partial=t.Partial||{}),function(n){"use strict";var a=t["Partial.Unsafe"],r=t.Partial;n.unsafeCrashWith=function(t){return a.unsafePartial(function(n){return r.crashWith(n)(t)})}}(t["Partial.Unsafe"]=t["Partial.Unsafe"]||{}),function(n){"use strict";(t["Unsafe.Coerce"]=t["Unsafe.Coerce"]||{}).unsafeCoerce=function(t){return t}}(),function(n){"use strict";var a=t["Unsafe.Coerce"];n.unsafeCoerce=a.unsafeCoerce}(t["Unsafe.Coerce"]=t["Unsafe.Coerce"]||{}),function(n){"use strict";var a=t["Data.Array"],r=(t["Control.Alt"],t["Control.Alternative"],t["Control.Applicative"],t["Control.Apply"],t["Control.Bind"]),e=(t["Control.Category"],t["Control.Lazy"],t["Control.Monad.Rec.Class"],t["Control.Monad.ST"],t["Control.Monad.ST.Internal"],t["Control.Semigroupoid"],t["Data.Array.NonEmpty.Internal"],t["Data.Array.ST"],t["Data.Array.ST.Iterator"],t["Data.Boolean"],t["Data.Eq"],t["Data.Foldable"],t["Data.Function"]),o=(t["Data.Functor"],t["Data.HeytingAlgebra"],t["Data.Maybe"]),i=t["Data.Ord"],u=t["Data.Ordering"],c=(t["Data.Ring"],t["Data.Semigroup"],t["Data.Semiring"],t["Data.Traversable"],t["Data.Tuple"],t["Data.Unfoldable"],t["Partial.Unsafe"],t.Prelude,t["Unsafe.Coerce"],function(t){return function(n){return a.sortImpl(function(n){return function(a){var r=t(n)(a);if(r instanceof u.GT)return 1;if(r instanceof u.EQ)return 0;if(r instanceof u.LT)return-1;throw new Error("Failed pattern match at Data.Array (line 702, column 15 - line 707, column 1): "+[r.constructor.name])}})(n)}}),l=function(t){return[t]},f=e.flip(r.bind(r.bindArray));n.singleton=l,n.concatMap=f,n.mapMaybe=function(t){return f(function(n){return o.maybe([])(l)(t(n))})},n.mapWithIndex=function(t){return function(n){return a.zipWith(t)(a.range(0)(a.length(n)-1|0))(n)}},n.sortBy=c,n.sortWith=function(t){return function(n){return c(i.comparing(t)(n))}},n.length=a.length,n.reverse=a.reverse,n.filter=a.filter}(t["Data.Array"]=t["Data.Array"]||{}),function(n){"use strict";t["Control.Alt"];var a=t["Control.Applicative"],r=t["Control.Apply"],e=(t["Control.Bind"],t["Control.Extend"],t["Control.Monad"],t["Control.Semigroupoid"],t["Data.Bifoldable"],t["Data.Bifunctor"],t["Data.Bitraversable"],t["Data.Bounded"],t["Data.Eq"],t["Data.Foldable"],t["Data.FoldableWithIndex"],t["Data.Function"],t["Data.Functor"]),o=(t["Data.Functor.Invariant"],t["Data.FunctorWithIndex"],t["Data.Maybe"],t["Data.Monoid"],t["Data.Ord"],t["Data.Ordering"],t["Data.Semigroup"],t["Data.Show"],t["Data.Traversable"],t["Data.TraversableWithIndex"],t["Data.Unit"],t.Prelude,function(){function t(t){this.value0=t}return t.create=function(n){return new t(n)},t}()),i=function(){function t(t){this.value0=t}return t.create=function(n){return new t(n)},t}(),u=new e.Functor(function(t){return function(n){if(n instanceof o)return new o(n.value0);if(n instanceof i)return new i(t(n.value0));throw new Error("Failed pattern match at Data.Either (line 38, column 8 - line 38, column 52): "+[n.constructor.name])}}),c=new r.Apply(function(){return u},function(t){return function(n){if(t instanceof o)return new o(t.value0);if(t instanceof i)return e.map(u)(t.value0)(n);throw new Error("Failed pattern match at Data.Either (line 82, column 1 - line 82, column 41): "+[t.constructor.name,n.constructor.name])}}),l=new a.Applicative(function(){return c},i.create);n.Left=o,n.Right=i,n.functorEither=u,n.applyEither=c,n.applicativeEither=l}(t["Data.Either"]=t["Data.Either"]||{}),function(n){"use strict";(t["Data.Int"]=t["Data.Int"]||{}).fromStringAsImpl=function(t){return function(n){return function(a){var r;r=a<11?"[0-"+(a-1).toString()+"]":11===a?"[0-9a]":"[0-9a-"+String.fromCharCode(86+a)+"]";var e=new RegExp("^[\\+\\-]?"+r+"+$","i");return function(r){if(e.test(r)){var o=parseInt(r,a);return(0|o)===o?t(o):n}return n}}}}}(),function(n){"use strict";var a=t["Data.Int"],r=(t["Control.Category"],t["Control.Semigroupoid"],t["Data.Boolean"],t["Data.Bounded"],t["Data.CommutativeRing"],t["Data.DivisionRing"],t["Data.Eq"],t["Data.EuclideanRing"],t["Data.HeytingAlgebra"],t["Data.Int.Bits"],t["Data.Maybe"]),e=(t["Data.Ord"],t["Data.Ordering"],t["Data.Ring"],t["Data.Semiring"],t["Data.Show"],t.Global,t.Math,t.Prelude,a.fromStringAsImpl(r.Just.create)(r.Nothing.value)),o=e(10);n.fromString=o,n.fromStringAs=e}(t["Data.Int"]=t["Data.Int"]||{}),function(t){"use strict";t.split=function(t){return function(n){return n.split(t)}},t.trim=function(t){return t.trim()}}(t["Data.String.Common"]=t["Data.String.Common"]||{}),function(n){"use strict";var a=t["Data.String.Common"];t["Data.Eq"],t["Data.Ordering"],t["Data.String.Pattern"],t.Prelude;n.split=a.split,n.trim=a.trim}(t["Data.String.Common"]=t["Data.String.Common"]||{}),function(n){"use strict";var a=t["Control.Applicative"],r=t["Data.Array"],e=t["Data.Either"],o=(t["Data.Eq"],t["Data.EuclideanRing"]),i=t["Data.Foldable"],u=t["Data.Functor"],c=t["Data.Int"],l=t["Data.Ord"],f=(t["Data.Ring"],t["Data.Semigroup"]),s=(t["Data.Semiring"],t["Data.Show"]),D=(t["Data.String"],t["Data.String.Common"]),d=(t["Data.String.Pattern"],t["Data.Tuple"]),p=t["Partial.Unsafe"];t.Prelude;n.solve=function(t){var n=function(t){var n=r.mapMaybe(c.fromString)(D.split("\n")(D.trim(t))),p=r.sortWith(l.ordInt)(d.snd)(u.map(u.functorArray)(function(t){return new d.Tuple(t,o.mod(o.euclideanRingInt)(t)(10))})(n));return a.pure(e.applicativeEither)(s.show(s.showInt)(i.foldl(i.foldableArray)(function(t){return function(a){return a.value0===(r.length(n)-1|0)?t+a.value1.value0|0:0===a.value1.value1?t+a.value1.value0|0:10+(t+(10*o.div(o.euclideanRingInt)(a.value1.value0)(10)|0)|0)|0}})(0)(r.mapWithIndex(d.Tuple.create)(f.append(f.semigroupArray)(r.filter(function(t){return 0===t.value1})(p))(r.reverse(r.filter(function(t){return 0!==t.value1})(p)))))))}(t);if(n instanceof e.Left)return p.unsafeCrashWith(n.value0);if(n instanceof e.Right)return n.value0;throw new Error("Failed pattern match at AtCoder.ABC123.B (line 17, column 3 - line 19, column 24): "+[n.constructor.name])}}(t["AtCoder.ABC123.B"]=t["AtCoder.ABC123.B"]||{}),function(n){"use strict";(t["Effect.Console"]=t["Effect.Console"]||{}).log=function(t){return function(){return console.log(t),{}}}}(),function(n){"use strict";var a=t["Effect.Console"];t["Data.Show"],t["Data.Unit"],t.Effect;n.log=a.log}(t["Effect.Console"]=t["Effect.Console"]||{}),function(n){"use strict";t["Node.Encoding"];var a=t["Data.Show"],r=(t.Prelude,function(){function t(){}return t.value=new t,t}()),e=function(){function t(){}return t.value=new t,t}(),o=function(){function t(){}return t.value=new t,t}(),i=function(){function t(){}return t.value=new t,t}(),u=function(){function t(){}return t.value=new t,t}(),c=function(){function t(){}return t.value=new t,t}(),l=function(){function t(){}return t.value=new t,t}(),f=function(){function t(){}return t.value=new t,t}(),s=new a.Show(function(t){if(t instanceof r)return"ASCII";if(t instanceof e)return"UTF8";if(t instanceof o)return"UTF16LE";if(t instanceof i)return"UCS2";if(t instanceof u)return"Base64";if(t instanceof c)return"Latin1";if(t instanceof l)return"Binary";if(t instanceof f)return"Hex";throw new Error("Failed pattern match at Node.Encoding (line 19, column 1 - line 19, column 39): "+[t.constructor.name])});n.ASCII=r,n.UTF8=e,n.UTF16LE=o,n.UCS2=i,n.Base64=u,n.Latin1=c,n.Binary=l,n.Hex=f,n.showEncoding=s}(t["Node.Encoding"]=t["Node.Encoding"]||{}),function(n){"use strict";(t["Node.FS.Internal"]=t["Node.FS.Internal"]||{}).unsafeRequireFS=require("fs")}(),function(n){"use strict";var a=t["Node.FS.Internal"],r=(t.Effect,t.Prelude,t["Unsafe.Coerce"].unsafeCoerce);n.mkEffect=r,n.unsafeRequireFS=a.unsafeRequireFS}(t["Node.FS.Internal"]=t["Node.FS.Internal"]||{}),function(n){"use strict";t["Control.Bind"],t["Control.Semigroupoid"],t["Data.DateTime"],t["Data.DateTime.Instant"],t["Data.EuclideanRing"],t["Data.Function"],t["Data.Function.Uncurried"],t["Data.Functor"],t["Data.Int"],t["Data.Maybe"],t["Data.Nullable"];var a=t["Data.Show"],r=(t["Data.Time.Duration"],t.Effect,t["Node.Buffer"],t["Node.Encoding"]),e=(t["Node.FS"],t["Node.FS.Internal"]),o=(t["Node.FS.Perms"],t["Node.FS.Stats"],t["Node.Path"],t.Prelude,e.unsafeRequireFS);n.readTextFile=function(t){return function(n){return e.mkEffect(function(e){return o.readFileSync(n,{encoding:a.show(r.showEncoding)(t)})})}}}(t["Node.FS.Sync"]=t["Node.FS.Sync"]||{}),function(n){"use strict";var a=t["AtCoder.ABC123.B"],r=(t["Control.Applicative"],t["Control.Bind"],t.Effect,t["Effect.Console"]),e=t["Node.Encoding"],o=t["Node.FS.Sync"];t.Prelude;n.main=function(){var t=o.readTextFile(e.UTF8.value)("/dev/stdin")(),n=a.solve(t);return r.log(n)()}}(t.Main=t.Main||{}),t.Main.main();
},{}]},{},["Focm"], null)