Skip to content

Instantly share code, notes, and snippets.

@lifthrasiir
Created October 18, 2012 01:19
Show Gist options
  • Save lifthrasiir/3909337 to your computer and use it in GitHub Desktop.
Save lifthrasiir/3909337 to your computer and use it in GitHub Desktop.
The making of IOCCC entry (2012/kang)
#if 0
gcc $0 && (
for i in \
zero \
one two three four five six seven eight nine ten \
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen \
twenty thirty forty fifty sixty seventy eighty ninety \
"one hundred" "one thousand" "one million" "one billion" "one trillion";
do echo $i | ./a.out; echo
done
echo 'a million and forty-eight thousands and five hundreds and seventy-six' | ./a.out; echo
echo 'two billion, one hundred forty seven million, four hundred eighty three thousand, six hundred forty seven' | ./a.out; echo
)
exit 0
#endif
/*
43798720 43798726
morpheme: fglnrstwy abfglnrstwy abefglnrswy abfhlnrstwy abfglnorstwy
0 r r er r ro
1 n n n(e) n on
2 tw[n] tw[n] w[en] tw[n] tw[on]
3 tr tr r(ee) th(r) tr
4 fr fr fr fr for
5 f[f] f[f] f[ef] f[f] f[f]
6 s s s s s
7 sn sn se(n) sn sn
8 g[t] g[t] e(g) h[t] g[t]
9 nn nn nn(e) nn nn
10 tn tn en tn tn
11 ln ln el(een) ln ln
12 twl twl wel(e) twl twl
(100) nr nr nr(e) hn(r) nr
(1000) tsn ts(an) = t<s'> sa(n) ths(an) tos(an)
(1000000) lln l(ln) l(ln) l(ln) l(ln)
(1000000000) bl(ln) bl(ln) bl(ln) bl(ln)
(1000000000000) trl(ln) rl(ln) tr(lln) trl(ln)
suffix +10 -tn -tn -een? -tn
suffix *10 -ty -ty -y -ty
a = 1 - a = <1><0> a a
and = (1) n an = <1><0>n an an
+-- translated to tt
v
.t...........
^ ^^ ^^^
[bfgl] [abg]
1. n maps to 1.
2. a maps to a non-standard digit past the base, "a" expands to "n<0>" which should be unused.
3. "0" thus cannot be "r" (will conflict with "nr").
4. "0" also cannot be others' prefixes: "n", "t", "f", "s", "g", "l", "b".
5. thus only "w" or "y" can map to 0.
6. a mapping next to "s" should not be "w", "r" or "n" ("tsan" = "t<s'><0>n" will conflict).
7. t maps to 2 (not 1 as per 1.), so that "twl" and "trl" stays in the byte range
8. the last "an" (for "and") entry is a part of 10^n table (n=0 case is identity).
mod 15 remapping:
ab...fgh...l.n
...rst..w.y.
mod 15 + div 21 remapping:
ab...fgh...l.n
...rst*..w.y.
u = lambda z: reduce(lambda x,y:x*15+'.abrstfgw.y.l.n'.index(y),z,0)
v = lambda i: chr(64+i//64)+chr(64+i%64)
#print [u(z) for z in 'r n tw tr fr f s sn g nn tn ln twl nr ts l bl trl'.split()]
#print ''.join(v(u(z))[0] for z in 'r n tw tr fr f s sn g nn tn ln twl nr ts l bl trl'.split()), ''.join(v(u(z))[1] for z in 'r n tw tr fr f s sn g nn tn ln twl nr ts l bl trl'.split())
import itertools, re
def rr(s):
v = ''; d = False
for c in s[::-1]:
if not d and c == '\0': pass
elif c in '\a\b\f\n\r\t\v"\\': v = '\\' + {'\a':'a','\b':'b','\f':'f','\n':'n','\r':'r','\t':'t','\v':'v','"':'"','\\':'\\'}[c] + v
elif ' ' <= c <= '\x7e': v = c + v
elif v and '0' <= v[0] <= '9': v = '\\%03o' % ord(c) + v
else: v = '\\%o' % ord(c) + v
d = True
return '"%s"' % v
def check(fmt, st, mul, mut, q, filt='', prefix='', suffix=''):
ichr = lambda i: chr(i) if i < 256 else '*'*99
st = ''.join(set(st)-set(fmt.replace('%s','')))
mp = lambda f: ''.join(ichr(mut(reduce(lambda x,y:x*mul+f.index(y),z,0))) for z in q.split())
w = sorted((len(rr(mp(fmt%''.join(d)))), fmt%''.join(d)) for d in itertools.permutations(st) if re.search(filt,fmt%''.join(d)))
for e, f in w:
if e!=w[0][0]: break
g = mp(f)
if g.startswith(prefix) and g.endswith(suffix): print f, rr(g)
check('wnt%sa', 'abfglnrstwy', 10, lambda x:x^64, 'r n tw tr fr f s sn g nn nr an ts l bl trl tn ln twl', 'sl')
u1 = lambda z: reduce(lambda x,y:x*10+'wntrfslygba'.index(y),z,0)
print rr(''.join(chr(u1(z)^64) for z in 'r n tw tr fr f s sn g nn nr an ts l bl trl tn ln twl'.replace(' ts ',' tl ').split()))
print u1('tn'), u1('ty')
check('wnt%sa', 'abfglnrstwy', 10, lambda x:(x+50)&255, 'r n tw tr fr f s sn g nn nr an ts l bl trl tn ln twl', 'sl')
u1a = lambda z: reduce(lambda x,y:x*10+'wntfrslbgya'.index(y),z,0)
print rr(''.join(chr((u1a(z)+50)&255) for z in 'r n tw tr fr f s sn g nn nr an ts l bl trl tn ln twl'.replace(' ts ',' tl ').split()))
print u1a('tn'), u1a('ty')
check('wnt%sab', 'abfglnrstwy', 9, lambda x:(x+31)&255, 'r n tw tr fr f s sn g nn nr an ts l bl trl tn ln twl', 'sl')
u1b = lambda z: reduce(lambda x,y:x*9+'wntslygfrab'.index(y),z,0)
print rr(''.join(chr((u1b(z)+31)&255) for z in 'r n tw tr fr f s sn g nn nr an ts l bl trl tn ln twl'.replace(' ts ',' tl ').split()))
print u1b('tn'), u1b('ty')
i=42; check('yn%s', 'abfglnrstwy', 8, lambda x:(x+i)&255 if (((x+i)&255)-i)&255 == x else 999, 'r n tw tr fr f s sn g nn nr bl l ts an trl tn ln twl', 's[^wrn].*[ag]b[ag]$')
u1c = lambda z: reduce(lambda x,y:x*8+'ynwtsflrabg'.index(y),z,0)
print rr(''.join(chr((u1c(z)+42)&255) for z in 'r n tw tr fr f s sn g nn l bl nr ts trl an tn ln twl'.replace(' ts ',' tf ').split()))
print u1c('tn'), u1c('ty')
check('ynt%sa', 'abfglnrstwy', 9, lambda x:x^96, 'r n tw tr fr f s sn g nn tn ln twl nr ts an l', 'sl', 'faux')
u2 = lambda z: reduce(lambda x,y:x*9+'yntwgfrsla'.index(y),z,0)
print rr(''.join(chr(u2(z)^96) for z in 'r n tw tr fr f s sn g nn tn ln twl nr ts an l'.replace(' ts ',' tl ').split()))
print u2('tn'), u2('ty')
check('ynt%sa', 'afglnrstwy', 9, lambda x:(x+34)&255, 'r n tw tr fr f s sn g nn tn ln twl nr ts an l', 'sl')
u2a = lambda z: reduce(lambda x,y:x*9+'yntrgslwfa'.index(y),z,0)
print rr(''.join(chr((u2a(z)+34)&255) for z in 'r n tw tr fr f s sn g nn tn ln twl nr ts an l'.replace(' ts ',' tl ').split()))
print u2a('tn'), u2a('ty')
i=42; check('yn%sa', 'afglnrstwy', 9, lambda x:(x+i)&255 if (((x+i)&255)-i)&255 == x else 999, 'r n tw tr fr f s sn g nn l ts nr tn ln twl', 's[^wrn]')
u2b = lambda z: reduce(lambda x,y:x*9+'yntfgwslra'.index(y),z,0)
print rr(''.join(chr((u2b(z)+42)&255) for z in 'r n tw tr fr f s sn g nn an l ts nr tn ln twl'.replace(' ts ',' tl ').split()))
print u2b('tn'), u2b('ty')
exponent table [<=8,8,12,24,36,48] = 4*[<=2,2,3,6,9,12]
- "an" does not necessarily map to (1); it can be (10) or (100) as the last two digits of v is zeroes whenever "and" appears.
import itertools
def rnsmap(keys, start):
def gcdex(x,y):
a,b,c,d = 0,1,1,0
while x: q,r = divmod(y,x); y,x,a,b,c,d = x,r,c,d,a-c*q,b-d*q
return (a,b,y)
best = 99999999999
for k in itertools.permutations(keys):
p,q = 1,0; i = start
for c in k:
if c>=i: break # invalid permutation
u,v,g = gcdex(p,i) # then up + vi = g = gcd(p,i)
if (q-c)%g!=0: break # necessary condition
p,q = p*i//g, (u*p*(c-q)//g+q)%(p*i//g); i += 1
else:
if best > q: best = q
return best
c1 = min(rnsmap([i,2*v,3*v,6*v,9*v,12*v], 10) for v in [1,2,4] for i in xrange(2*v+1))
print c1, [c1%i for i in xrange(10,16)] # 42 [2, 9, 6, 3, 0, 12]
c1a = min(rnsmap([i,2*v,3*v,6*v,9*v,12*v], 11) for v in [1,2,4] for i in xrange(2*v+1))
print c1a, [c1a%i for i in xrange(11,17)] # 6177 [6, 9, 2, 3, 12, 1]
c2 = min(rnsmap([i,2*v,3*v,6*v], 10) for v in [1,2,4] for i in xrange(2*v+1))
print c2, [c2%i for i in xrange(10,14)] # 171 [1, 6, 3, 2]
c2a = min(rnsmap([i,2*v,3*v,6*v], 11) for v in [1,2,4] for i in xrange(2*v+1))
print c2a, [c2a%i for i in xrange(11,15)] # 198 [0, 6, 3, 2]
*/
#if 1
long long n,u,m,b;
main(e,r){
for(;n++||(e=getchar()|32)>0;b="ynwtsflrabg"[n%=11]-e?b:b*8+n)
for(r=b%64-25;e<47&&b;b/=8)
for(n=19;n;"1+DIY/.K430x9G(kC["[n]-42&255^b||(m+=n>15?n:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))
u=1ll<<6177%n--*4;
printf("%llx",m);
}
#elif 1
n,u,m,b;
main(e,r){
for(;n++||(e=getchar()|32)>0;b="yntfgwslra"[n%=10]-e?b:b*9+n)
for(r=b%81-19;e<47&&b;b/=9)
for(n=17;n;"2+ADM-0a.4|1C;=j"[n]-42&255^b||(m+=n>13?n+2:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))
u=1<<198%n--*4;
printf("%x",m);
}
#elif 1
#if 0
v;w[]={18,14,663,658,210,6,19,622,7,462,654,398,21228,466,674862,12686};main(a,b,c,d){for(b=0;(a=getchar())>45;)if((43798722>>a&31)&1)b=b<<5|a&31;for(c=b&1023;b;b>>=5)for(d=0;d<16;++d)if(w[d]==b){if(d<10)d=c-654?c-665?d:d*10:d+10;v+=d-15?d-14?d-13?d:v%100*99:v%1000*999:v%1000000*999999;b=0;break;}a<0?printf("%d",v):main();}
v;w[]={18,14,663,658,210,6,19,622,7,462,654,398,21228,466,674862,12686};main(a,b,c,d){for(b=0;(a=getchar())>45;)if((43798722>>a&31)&1)b=b<<5|a&31;for(c=b&1023;b;b>>=5)for(d=16;d--;w[d]-b||(v+=d-15?d-14?d-13?d>9?d:c-654?c-665?d:d*10:d+10:v%100*99:v%1000*999:v%1000000*999999,b=d=0));a<0?printf("%d",v):main();}
v,w[]={18,14,663,658,210,6,19,622,7,462,654,398,21228,466,659,12,100,1e3,1e6};main(a,b,c,d){for(b=0;(a=getchar())>45;)if((43798726>>a&31)&1)b=b<<5|a&31;for(c=b&1023;b;b>>=5)for(d=16;d--;w[d]-b||(v+=d>12?v%w[d+3]*~-w[d+3]:d>9?d:c-654?c-665?d:d*10:d+10,b=d=0));a<0?printf("%d",v):main();}
v,w[]={3,14,83,78,93,6,4,74,7,224,89,194,1257,213,79,12,100,1e3,1e6};main(a,b,c,d){for(b=0;(a=getchar())>45;)if(a%=32,43798726>>a&1)b=b*15+a%15;for(c=b%225;b;b/=15)for(d=16;d--;w[d]-b||(v+=d>12?v%w[d+3]*~-w[d+3]:d>9?d:c-89?c-85?d:d*10:d+10,b=d=0));a<0?printf("%d",v):main();}
v,w[]={3,14,83,78,93,6,4,74,7,224,89,194,1257,213,79,12,100,1e3,1e6};main(a,b,c,d){for(b=0;(a=getchar())>45;b=43798726>>a&1?b*15+a%15:b)a%=32;for(c=b%225;b;b/=15)for(d=16;d--;w[d]-b||(v+=d>12?v%w[d+3]*~-w[d+3]:d>9?d:c-89?c-85?d:d*10:d+10,b=d=0));a<0?printf("%d",v):main();}
v,w[]={1e6,100,1e3};main(a,b,c,d){for(b=0;(a=getchar())>45;b=43798726>>a&1?b*15+a%15:b)a%=32;for(c=b%225;b;b/=15)for(d=16;d--;"CNSN]FDJG`YBiUOL"[d]+"@@AAA@@A@CACSCA@"[d]*64-4160-b||(v+=d>12?v%w[d%3]*~-w[d%3]:d>9?d:c-89?c-85?d:d*10:d+10,b=d=0));a<0?printf("%d",v):main();}
u,v;main(a,b,c,d){for(b=0;(a=getchar())>45;b=43798726>>a&1?b*15+a%15:b)a%=32;for(c=b%225;b;b/=15)for(d=18;d--;"CNSN]FDJG`YBiUOL"[d]+"@@AAA@@A@CACSCA@"[d]*64-4160-b||(v+=d>12?v%u*~-u:d>9?d+6:c-89?c-85?d:d*16:d+16,b=d=0))u=1<<"` 0"[d%3]/4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=0;(a=getchar()|32)>45;)for(c=10;c--;b="rtasfgwyln"[c]-a?b:b*10+c);for(c=b%100;b;b/=10)for(d=16;d--;"`ipjHdcGe\3s9\310:mh"[d]&255^96^b||(v+=d>12?v%u*~-u:d>9?d+6:c-19?c-17?d:d*16:d+16,b=d=0))u=1<<"` 0"[d%3]/4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="rtasfgwyln"[c]-a?b:b*10+c)c%=10;for(c=b%100;b;b/=10)for(d=16;d--;"`ipjHdcGe\3s9\310:mh"[d]&255^96^b||(v+=d>12?v%u*~-u:d>9?d+6:c-19?c-17?d:d*16:d+16,b=d=0))u=1<<"` 0"[d%3]/4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="rtnsfgwyla"[c]-a?b:b*9+c)c%=10;for(c=b%81;b;b/=9)for(d=16;d--;"3boiDdc}etk*\357rmh"[d]&255^96^b||(v+=d>12?v%u*~-u:d>9?d+6:c-11?c-16?d:d*16:d+16,b=d=0))u=1<<"` 0"[d%3]/4;a<0?printf("%x",v):main();}
// from now "a" is properly handled
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="yntwgfrsla"[c]-a?b:b*9+c)c%=10;for(c=b%81;b;b/=9)for(d=17;d--;"fauxSeg djs)\245oz2h"[d]&255^96^b||(v+=d>12?v%u*~-u:d>9?d+6:c-19?c-18?d:d*16:d+16,b=d=0))u=1<<"` 0"[d%4]/4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="yntwgfrsla"[c]-a?b:b*9+c)c%=10;for(c=b%81-18;b;b/=9)for(d=17;d--;"fauxSeg djs)\245oz2h"[d]&255^96^b||(v+=d>12?v%u*~-u:d>9?d+6:c-1?c?d:d*16:d+16,b=d=0))u=1<<"` 0"[d%4]/4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="yntrgslwfa"[c]-a?b:b*9+c)c%=10;for(c=b%81-18;b;b/=9)for(d=17;d--;"%#;7m*'P&,5Y\t.:t("[d]-34&255^b||(v+=d>12?v%u*~-u:d>9?d+6:c-1?c?d:d*16:d+16,b=d=0))u=1<<"` 0"[d%4]/4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="yntfgwslra"[c]-a?b:b*9+c)c%=10;for(c=b%81-19;b;b/=9)for(d=17;d--;"2+ADM-0a.4;|C1=j"[d]-42&255^b||(v+=d>13?d+2:d>9?v%u*~-u:c+1?d+!c*16:d*16,b=d=0))u=1<<"0` "[d%4]/4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="yntfgwslra"[c]-a?b:b*9+c)c%=10;for(c=b%81-19;b;b/=9)for(d=17;d;"2+ADM-0a.4|1C;=j"[d]-42&255^b||(v+=d>13?d+2:d>9?v%u*~-u:c+1?d+!c*16:d*16,b=d=0))u=1<<198%d--*4;a<0?printf("%x",v):main();}
// this is the initially published version:
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>46;b="yntfgwslra"[c]-a?b:b*9+c)c%=10;for(c=b%81-19;b;b/=9)for(d=17;d;"2+ADM-0a.4|1C;=j"[d]-42&255^b||(v+=d>13?d+2:d>9?v%u*~-u:c+1?d+!c*16:d*16,b=0))u=1<<198%d--*4;a<0?printf("%x",v):main();}
u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>46;b="yntfgwslra"[c%=10]-a?b:b*9+c);for(c=b%81-19;b;b/=9)for(d=17;d;"2+ADM-0a.4|1C;=j"[d]-42&255^b||(v+=d>13?d+2:d>9?v%u*~-u:~c?d+!c*16:d*16,b=0))u=1<<198%d--*4;a<0?printf("%x",v):main();}
n,u,m,b;main(e,r){for(;n++||(e=getchar()|32)>46;b="yntfgwslra"[n%=10]-e?b:b*9+n);for(r=b%81-19;b;b/=9)for(n=17;n;"2+ADM-0a.4|1C;=j"[n]-42&255^b||(m+=n>13?n+2:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))u=1<<198%n--*4;e<0?printf("%x",m):main();}
n,u,m,b;main(e,r){for(;n++||(e=getchar()|32)>=0;b="yntfgwslra"[n%=10]-e?b:b*9+n)for(r=b%81-19;e<47&&b;b/=9)for(n=17;n;"2+ADM-0a.4|1C;=j"[n]-42&255^b||(m+=n>13?n+2:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))u=1<<198%n--*4;printf("%x",m);}
#endif
n,u,m,b;main(e,r){for(;n++||(e=getchar()|32)>0;b="yntfgwslra"[n%=10]-e?b:b*9+n)for(r=b%81-19;e<47&&b;b/=9)for(n=17;n;"2+ADM-0a.4|1C;=j"[n]-42&255^b||(m+=n>13?n+2:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))u=1<<198%n--*4;printf("%x",m);}
// 226B
#else
#if 0
// version with billions and trillions
long long v,w[]={18,14,663,658,210,6,19,622,7,462,654,398,21228,466,659,12,76,21068,100,1e3,1e6,1e9,1e12};main(a,b,c,d){for(b=0;(a=getchar())>45;)if((43798726>>a&31)&1)b=b<<5|a&31;for(c=b&1023;b;b>>=5)for(d=18;d--;w[d]-b||(v+=d>12?v%w[d+5]*~-w[d+5]:d>9?d:c-654?c-665?d:d*10:d+10,b=d=0));a<0?printf("%lld",v):main();}
long long v,w[]={3,14,83,78,93,6,4,74,7,224,89,194,1257,213,79,12,42,1182,100,1e3,1e6,1e9,1e12};main(a,b,c,d){for(b=0;(a=getchar())>45;)if(a%=32,43798726>>a&1)b=b*15+a%15;for(c=b%225;b;b/=15)for(d=18;d--;w[d]-b||(v+=d>12?v%w[d+5]*~-w[d+5]:d>9?d:c-89?c-85?d:d*10:d+10,b=d=0));a<0?printf("%lld",v):main();}
long long v,w[]={3,14,83,78,93,6,4,74,7,224,89,194,1257,213,79,12,42,1182,100,1e3,1e6,1e9,1e12};main(a,b,c,d){for(b=0;(a=getchar())>45;b=43798726>>a&1?b*15+a%15:b)a%=32;for(c=b%225;b;b/=15)for(d=18;d--;w[d]-b||(v+=d>12?v%w[d+5]*~-w[d+5]:d>9?d:c-89?c-85?d:d*10:d+10,b=d=0));a<0?printf("%lld",v):main();}
long long v,w[]={1e6,1e9,1e12,100,1e3};main(a,b,c,d){for(b=0;(a=getchar())>45;b=43798726>>a&1?b*15+a%15:b)a%=32;for(c=b%225;b;b/=15)for(d=18;d--;"CNSN]FDJG`YBiUOLj^"[d]+"@@AAA@@A@CACSCA@@R"[d]*64-4160-b||(v+=d>12?v%w[d%5]*~-w[d%5]:d>9?d:c-89?c-85?d:d*10:d+10,b=d=0));a<0?printf("%lld",v):main();}
long long u,v;main(a,b,c,d){for(b=0;(a=getchar())>45;b=43798726>>a&1?b*15+a%15:b)a%=32;for(c=b%225;b;b/=15)for(d=18;d--;"CNSN]FDJG`YBiUOLj^"[d]+"@@AAA@@A@CACSCA@@R"[d]*64-4160-b||(v+=d>12?v%u*~-u:d>9?d+6:c-89?c-85?d:d*16:d+16,b=d=0))u=1ll<<"XdpHL"[d%5]-64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=0;(a=getchar()|32)>45;)for(c=11;c--;b="rtabsfgwyln"[c]-a?b:b*11+c);for(c=b%121;b;b/=11)for(d=18;d--;"@JRKwEDvF8U-\217.OIj\302"[d]&255^64^b||(v+=d>12?v%u*~-u:d>9?d+6:c-21?c-19?d:d*16:d+16,b=d=0))u=1ll<<"XdpHL"[d%5]-64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=0;(a=getchar()|32)>45;)for(c=11;c--;b="rtlbsfgwyan"[c]-a?b:b*11+c);for(c=b%121;b;b/=11)for(d=18;d--;"@JRKwEDvF8U`\210.OBc;"[d]&255^64^b||(v+=d>12?v%u*~-u:d>9?d+6:c-21?c-19?d:d*16:d+16,b=d=0))u=1ll<<"XdpHL"[d%5]-64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="rtlbsfgwyan"[c]-a?b:b*11+c)c%=11;for(c=b%121;b;b/=11)for(d=18;d--;"@JRKwEDvF8U`\210.OBc;"[d]&255^64^b||(v+=d>12?v%u*~-u:d>9?d+6:c-21?c-19?d:d*16:d+16,b=d=0))u=1ll<<"XdpHL"[d%5]-64;a<0?printf("%llx",v):main();}
// from now "a" is properly handled
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="wntrfslygba"[c]-a?b:b*10+c)c%=11;for(c=b%100;b;b/=10)for(d=19;d--;"CATWkDEsHKU}\216MZF %\254"[d]&255^64^b||(v+=d>12?v%u*~-u:d>9?d+6:c-21?c-27?d:d*16:d+16,b=d=0))u=1ll<<"pHLXd"[d%6]%64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="wntrfslygba"[c]-a?b:b*10+c)c%=11;for(c=b%100;b;b/=10)for(d=19;d--;"CATWkDEsHKM%ZF \254U}\216"[d]&255^64^b||(v+=d>15?d:d>9?v%u*~-u:c-21?c-27?d:d*16:d+16,b=d=0))u=1ll<<"LXdpH"[d%6]%64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="wntrfslygba"[c]-a?b:b*10+c)c%=11;for(c=b%100-21;b;b/=10)for(d=19;d--;"CATWkDEsHKM%ZF \254U}\216"[d]&255^64^b||(v+=d>15?d:d>9?v%u*~-u:c?c-6?d:d*16:d+16,b=d=0))u=1ll<<"LXdpH"[d%6]%64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="wntfrslbgya"[c]-a?b:b*10+c)c%=11;for(c=b%100-21;b;b/=10)for(d=19;d--;"63FJT57e:=@\227L8~(Go"[d]-50&255^b||(v+=d>15?d:d>9?v%u*~-u:c?c-8?d:d*16:d+16,b=d=0))u=1ll<<"LXdpH"[d%6]%64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="ynwtsflrabg"[c]-a?b:b*8+c)c%=11;for(c=b%64-24;b;b/=8)for(d=19;d--;"1+DIY/.K439kG0x(C["[d]-42&255^b||(v+=d>15?d:d>9?v%u*~-u:c-1?c?d:d*16:d+16,b=d=0))u=1ll<<"LXdpH"[d%6]%64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="ynwtsflrabg"[c]-a?b:b*8+c)c%=11;for(c=b%64-25;b;b/=8)for(d=19;d--;"1+DIY/.K439kG0x(C["[d]-42&255^b||(v+=d>15?d:d>9?v%u*~-u:c+1?d+!c*16:d*16,b=d=0))u=1ll<<"LXdpH"[d%6]%64;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>45;b="ynwtsflrabg"[c]-a?b:b*8+c)c%=11;for(c=b%64-25;b;b/=8)for(d=19;d;"1+DIY/.K430x9G(kC["[d]-42&255^b||(v+=d>15?d:d>9?v%u*~-u:c+1?d+!c*16:d*16,b=d=0))u=1ll<<6177%d--*4;a<0?printf("%llx",v):main();}
// this is the initially published version:
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>46;b="ynwtsflrabg"[c]-a?b:b*8+c)c%=11;for(c=b%64-25;b;b/=8)for(d=19;d;"1+DIY/.K430x9G(kC["[d]-42&255^b||(v+=d>15?d:d>9?v%u*~-u:c+1?d+!c*16:d*16,b=0))u=1ll<<6177%d--*4;a<0?printf("%llx",v):main();}
long long u,v;main(a,b,c,d){for(b=c=0;c++||(a=getchar()|32)>46;b="ynwtsflrabg"[c%=11]-a?b:b*8+c);for(c=b%64-25;b;b/=8)for(d=19;d;"1+DIY/.K430x9G(kC["[d]-42&255^b||(v+=d>15?d:d>9?v%u*~-u:~c?d+!c*16:d*16,b=0))u=1ll<<6177%d--*4;a<0?printf("%llx",v):main();}
long long n,u,m,b;main(e,r){for(;n++||(e=getchar()|32)>46;b="ynwtsflrabg"[n%=11]-e?b:b*8+n);for(r=b%64-25;b;b/=8)for(n=19;n;"1+DIY/.K430x9G(kC["[n]-42&255^b||(m+=n>15?n:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))u=1ll<<6177%n--*4;e<0?printf("%llx",m):main();}
long long n,u,m,b;main(e,r){for(;n++||(e=getchar()|32)>=0;b="ynwtsflrabg"[n%=11]-e?b:b*8+n)for(r=b%64-25;e<47&&b;b/=8)for(n=19;n;"1+DIY/.K430x9G(kC["[n]-42&255^b||(m+=n>15?n:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))u=1ll<<6177%n--*4;printf("%llx",m);}
#endif
long long n,u,m,b;main(e,r){for(;n++||(e=getchar()|32)>0;b="ynwtsflrabg"[n%=11]-e?b:b*8+n)for(r=b%64-25;e<47&&b;b/=8)for(n=19;n;"1+DIY/.K430x9G(kC["[n]-42&255^b||(m+=n>15?n:n>9?m%u*~-u:~r?n+!r*16:n*16,b=0))u=1ll<<6177%n--*4;printf("%llx",m);}
// 242B
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment