(use util.queue)(use util.match)(use gauche.collection)(use gauche.sequence) (define-syntax def-syntax (syntax-rules()((_ v e ...)(define-syntax v (syntax-rules e ...))))) (define-syntax def-const define-constant)(define-syntax def define)(define-syntax def-inline define-inline) (def-syntax def-names ()((_[x y]...)(begin(define-constant x y)...))) (def-names [// quotient][% modulo][v-make make-vector][v-ref vector-ref][v-set! vector-set!][ht-make make-hash-table][ht-ref hash-table-get][ht-set! hash-table-put!][ht-keys hash-table-keys][ht-values hash-table-values][q-make make-queue][make-q make-queue][enq! enqueue!][deq! dequeue!][q-empty? queue-empty?]) (def-syntax input (: list vec cons str) ((_ : cons e ...)(cons(input : e ...)(input : e ...)))((_ : list str)(input : string->list str)) ((_ : vec str)(input : string->vector str))((_ : vec n e ...)(vector-tabulate n(^_(input : e ...)))) ((_ : list n e ...)(let l([k n])(if(zero? k)'()(cons(input : e ...)(l(- k 1))))))((_ :)(read))((_ : : e)e) ((_ : str)(let1 s(read-line)(if(string=? s "")(read-line)s)))((_[[v]: e ...])(def v(input : e ...))) ((_[[v w ...]: e ...])(begin(def v(input : e ...))(input[[w ...]: e ...]))) ((_[v : e ...])(def v(input : e ...)))((_ : op e ...)(op(input : e ...))) ((_(e ...))(e ...))((_ v)(def v(read)))((_ e ...)(begin(input e)...))) (define-constant *MOD* 1000000007) ;(define-constant *MOD* 998244353) (def-syntax add-mod! ()((_ v x)(let1 y(+ v x)(set! v(if(< y *MOD*)y(- y *MOD*)))))) (def-inline(v-add-mod! v i x)(let1 y(+(v-ref v i)x)(v-set! v i(if(< y *MOD*)y(- y *MOD*))))) (def-syntax max! ()((_ v x)(set! v (max x v)))) (def-syntax min! ()((_ v x)(set! v (min x v)))) (def-inline(v-add! v i x)(v-set! v i(+ x(v-ref v i)))) (def-inline(ht-add! ht i x)(ht-set! ht i(+ x(ht-ref ht i 0)))) (def-inline(ht-cons! ht i x)(ht-set! ht i(cons x(ht-ref ht i '())))) (def-syntax return () ((_ e ...) (begin (print e ...) (exit)))) ;; 以下スニペットのコピペ ;; 以下が本体 (input [S : (pa$ map char->integer) list str]) (print (- (apply max S) (apply min S)))