[Question]
  [
Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease. 
Your job is to take a date and output the number of EU1 members on that date, according to the following table:
```
| Start      | End        | Number of members 
| 0          | 1957-12-31 | 0
| 1958-01-01 | 1972-12-31 | 6
| 1973-01-01 | 1980-12-31 | 9
| 1981-01-01 | 1985-12-31 | 10
| 1986-01-01 | 1994-12-31 | 12
| 1995-01-01 | 2004-04-30 | 15
| 2004-05-01 | 2006-12-31 | 25
| 2007-01-01 | 2013-06-30 | 27
| 2013-07-01 | 2020-01-31 | 28
| 2020-02-01 | Inf        | 27
```
Input may take one of the following forms:
* your language's date format
* any ordering of integers for year, month and day with any separator (e.g. YYYYMMDD or DD/MM/YYYY)
* number of days lapsed since some epoch.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code wins!
1. or [EEC](https://en.wikipedia.org/wiki/European_Economic_Community) before 1993
  
[Answer]
# Javascript, ~~85~~ 83 Bytes
```
a=d=>d<0?0:d<180?6:d<276?9:d<336?10:d<444?12:d<556?15:d<588?25:d<666?27:d<745?28:27
```
It takes an input as a float as the *months / fractions of months passed* since `1958-01-01`  
(`0` for `1958-01-01T00:00:00` and a negative number for any previous date)
(Since number of days from some epoch is allowed, I assume that also a number of months is valid, as well)
[Try it Online](https://tio.run/##bcvBDoIwDMbxu08CB8lW2m4SZp9lYWA0hBExvv7sjkZP3z@/po/4jsf0vO@v85bTXJZQYkjhmkYjZkij9UZYFxzLRbfvWWw9IKJY0CBSoRreC9RgZgGn4ZAE/ACuTHk78jp3a741S0NgOt@2p2/Vtx9ziH@M1Er5AA)
---
# 80 Bytes
(credits: [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld))
```
a=d=>d<0?0:d<180?6:d<276?9:d<336?10:d<444?12:d<556?15:d<588?25:27+(d>=666&d<745)
```
---
Sad to see you go, UK
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~29~~ ~~27~~ ~~26~~ ~~25~~ 33 bytes
```
¬®12Œ≤≈Ω‚ÇÖb-‚Äò¬¥`<lp‚Ç¨¬∏‚Äò√á.¬•@‚Ä¢¬ø‚Äú0p‚Ä¢12–≤<*O
```
[Try it online!](https://tio.run/##yy9OTMpM/f//0ApDo3Obju591NSapPuoYcahLQk2OQWPmtYc2gHkHW7XO7TU4VHDokP7HzXMMSgAsgyNLmyy0fL//z/a0NLUUkfBwBCEYwE "05AB1E ‚Äì Try It Online")
Input is in the form `[yyyy, mm, dd]`.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~110~~ 97 bytes
```
lambda d:ord('069:<?IKLK'[sum(d>i for i in(0,5479,8401,10227,13514,16922,17897,20270,22676))])-48
```
[Try it online!](https://tio.run/##VZGxboMwEIZ3P8VJHbAjO7IPjAGVdmiWKNnaLc1AS1CRQkCEDnl6ahOSuJIX3/fd79O5uww/7QnHKv8cj0XzVRZQZm1f0kDGafb8ut5sN8Hu/NvQ8qWGqu2hhvpEJdeRSXkSScWVRDRchVpFXMUpIlcmSQ1HiUZyxNjEjO2ZiJJxu37/yHckUKmUQip7Ag72po1QKEJ3ewLpuE58btDjseMm9HkiPZ46nqh/XHtcTQ8ksS@kkS@gE1L9EFDKSNgTyqugyVzSDyH2EvAqGD9B2YnjWwIaMpfMXcBpJbeEhMwlvAt6mkHqAK4Je1L1bQNlMRyGujlA3XRtP8CCuG8q7TeB23dGrC0EvBXHb@tezjB1uaXbMoFVfgugi6boaH0aeLk8d8d6oIEIGGPk2pYDXYm76/q5Qh4qxpaOz88Q6HobAaulUynjQWanr6hT2PgH "Python 2 ‚Äì Try It Online")
-13 bytes, thanks to Jonathan Allan
Takes input as number of days since `1957-12-31` (so `1958-01-01` is day `1`)
---
# [Python 3](https://docs.python.org/3/), 93 bytes
```
lambda d:b'069:<?IKLK'[sum(d>i for i in(0,5479,8401,10227,13514,16922,17897,20270,22676))]-48
```
[Try it online!](https://tio.run/##VZGxbsMgEIZ3ngKpg6GCCM4GjFW3Q7NEydZuaQanjlVLcWw57pCnd8FxEiqxcN93P6ejuww/7Skeq/xrPBbNvixwme0joW328rZab9bR9vzbkPK1xlXb4xrXJyKYSoxlaSIkkwLAMBkrmTCpLQCTJrWGgQAjGIA2mtIdT9Jxs/r4zLcoklYILqQ7EcPupgyXwGN/e8LCc5WG3EDAtecmDnkqAm49T@U/rgIupwdSHQo2CQXwglUPAYRIuDuxuAoKzSX1EHSQAFfBhAnSTaxvCWDQXDJ3AaaV3BJSNJfgLqhpBqEifE3YoapvG1wWw2GomwOum67tB/yM/C@V7pew33eGnM05fi@O3869nPHU5Zfuyggv81sAeW6KjtSngZWLc3esBxLxiFKKrm05Jkt@d30/k8BiSenC8/kZhLveRTh34V1CWZS58SviHUrHPw "Python 3 ‚Äì Try It Online")
-4 bytes, thanks to mypetlion
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~42~~ 36 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
‚Ä¢A√Ç í√´.≈°¬°Œµ%≈æ¬∑7√≠‚Ä¢≈ΩL}–≤.¬•‚Ä∫O‚Ä¢=Œ≥1s√¶Œî‚Ä¢‚ÇÜ–≤s√®<
```
Input as number of days since 1957-12-31 (so 1957-12-30 is day `-1`; 1957-12-31 is day `0`; 1958-01-01 is day `1`; etc.)
[Try it online](https://tio.run/##yy9OTMpM/f//UcMix8NNpyYdXq13dOGhhee2qh7dd2i7@eG1QImje31qL2zSO7T0UcMufyDf9txmw@LDy85NAbIfNbVd2FR8eIXN//@GxqaGJgA) or [verify some more test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/Rw2LHA83nZp0eLXe0YWHFp7bqnp036Ht5ofXAiWO7vWpvbBJ79DSRw27/IF823ObDYsPLzs3Bch@1NR2YVPx4RU2/3X@R@sa6hjoGOqYmphbAgkLAx0LEwNDEGGkY2hgZGQOJi10DI1NDU3ApKmOoZmlkRGYNNYxNLewNAeTFjpGBkbmBmDSUMfIyMzcDEya6xgZGxgYxAIA).
**Old 42 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) answer taking input in the format `yyyyMMdd`:**
```
¬®¬®‚Ä¢a3|}\¬ßŒª‚ÄôI≈ìg¬Ω√æ‚Ä¢≈ΩOŒ©–≤‚Ä¢32√ò‚Ä¢+@O‚Ä¢=Œ≥1s√¶Œî‚Ä¢‚ÇÜ–≤s√®<
```
[Try it online](https://tio.run/##yy9OTMpM/f//0IpDKx41LEo0rqmNObT83O5HDTM9j05OP7T38D6g8NG9/udWXtgEZBkbHZ4BpLQd/IGk7bnNhsWHl52bAmQ/amq7sKn48Aqb//8NLS1NDI2MDQE) or [verify some more test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/QysOrXjUsCjRuKY25tDyc7sfNcz0PDo5/dDew/uAwkf3@p9beWETkGVsdHgGkNJ28AeStuc2GxYfXnZuCpD9qKntwqbiwyts/uv8jzY0AAJDA0MdQ0tTc0MjYzDDAipibgQVMTeGigBlICIWhjARU5iIGVTE0gQqYmkKFjEyMDAxMDE2gDBMISJmYDVAhjlUjaGxgRlYDZBhDhYBShoaQxlGIBFDiFNjAQ).
`‚Ä¢a3|}\¬ßŒª‚ÄôI≈ìg¬Ω√æ‚Ä¢≈ΩOŒ©–≤‚Ä¢32√ò‚Ä¢+` can alternatively be `‚Ä¢Me1Œµ√§~.=ŒîŒ©¬ª‚Ä¢≈Ω5√£–≤.¬•‚Ä¢32√ô‚Ä¢+` for the same byte-count: [Try it online](https://tio.run/##yy9OTMpM/f//0IpDKx41LPJNNTy39fCSOj3bc1POrTy0Gyh0dK/p4cUXNukdWgrkGBsdngmktB38gaTtuc2GxYeXnZsCZD9qaruwqfjwCpv//w0tLU0MjYwNAQ) or [verify some more test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/QysOrXjUsMg31fDc1sNL6vRsz005t/LQbqDQ0b2mhxdf2KR3aCmQY2x0eCaQ0nbwB5K25zYbFh9edm4KkP2oqe3CpuLDK2z@6/yPNjQAAkMDQx1DS1NzQyNjMMMCKmJuBBUxN4aKAGUgIhaGMBFTmIgZVMTSBCpiaQoWMTIwMDEwMTaAMEwhImZgNUCGOVSNobGBGVgNkGEOFgFKGhpDGUYgEUOIU2MB).
**Explanation:**
```
‚Ä¢A√Ç í√´.≈°¬°Œµ%≈æ¬∑7√≠‚Ä¢    # Push compressed integer 813218926689775697373196902446
  ≈ΩL}              # Push compressed integer 5480
     –≤             # Convert the larger integer to base-5480 as list:
                   #  [5479,2922,1826,3287,3408,975,2373,2406]
      .¬•           # Undelta it with leading 0:
                   #  [0,5479,8401,10227,13514,16922,17897,20270,22676]
        ‚Ä∫          # Check for each if it's larger than the (implicit) input-integer
         O         # Take the sum to get the amount of truthy values
‚Ä¢=Œ≥1s√¶Œî‚Ä¢           # Push compressed integer 122116126451824
 ‚ÇÜ–≤                # Convert it to base-36 as list:
                   #  [1,7,10,11,13,16,26,28,29,28]
   s√®              # Swap to get the sum, and use it to index into this list
     <             # And decrease it by 1
                   # (since a compressed integer/list cannot contain a leading 0)
                   # (after which the result is output implicitly)
¬®¬®                 # Remove the last two digits from the (implicit) input (the "dd")
  ‚Ä¢a3|}\¬ßŒª‚ÄôI≈ìg¬Ω√æ‚Ä¢  # Push compressed integer 2722385715080006519908031109868
   ≈ΩOŒ©             # Push compressed integer 6203
      –≤            # Convert the larger integer to base-6203 as list:
                   #  [1,1501,2301,2801,3701,4605,4901,5507,6202]
       ‚Ä¢32√ò‚Ä¢       # Push compressed integer 195800
            +      # Add it to each value in the list:
                   #  [195801,197301,198101,198601,199501,200405,200701,201307,202002]
             @     # Check for each if it's larger than or equal to the input minus "dd"
O‚Ä¢=Œ≥1s√¶Œî‚Ä¢‚ÇÜ–≤s√®<     # Same as above
```
[See this 05AB1E tip of mine (sections *How to compress large integers?* and *How to compress integer lists?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand how the compression works.
[Answer]
# [Turing Machine Code](http://morphett.info/turing/turing.html), ~~972~~ 1009 bytes
My input is the date in the format specified in the test cases `YYYY-MM-DD`.
```
0 0 0 * halt
* 1 _ r ‚Ç¨
‚Ç¨ 9 _ r %
* 2 _ r $
$ 0 _ r ¬£
* I 2 r ¬¢
% 5 _ r ^
% 6 6 r c
% 7 _ r x
% 8 _ r B
% 9 _ r i
% * _ r c
^ * 0 r c
^ 8 6 r c
^ 9 6 r c
B 0 9 r c
B 1 1 r r
B 2 1 r r
B 3 1 r r
B 4 1 r r
B 5 1 r r
B * 1 r e
r * 0 r c
e * 2 r c
x 0 6 r c
x 1 6 r c
x 2 6 r c
x * 9 r c
i 0 1 r üá™üá∫
i 1 1 r üá™üá∫
i 2 1 r üá™üá∫
i 3 1 r üá™üá∫
i 4 1 r üá™üá∫
i * 1 r t
t * 5 r c
üá™üá∫ * 2 r c
¬£ 0 _ r üá¨üáß
¬£ 1 _ r ‚òÖ
¬£ 2 _ r üëë
üëë 0 _ r !
üëë * 2 r ¬¢
! - _ r ~
~ 0 _ r 1
1 1 2 r ‚òÜ
1 * 2 r ¬¢
‚òÖ 0 2 r ¬¢ 
‚òÖ 1 2 r ¬¢
‚òÖ 2 2 r ¬¢
‚òÖ 3 _ r &
‚òÖ * 2 r ‚òÜ
& - _ r @
@ 0 _ r 6
6 0 2 r ¬¢
6 1 2 r ¬¢
6 2 2 r ¬¢
6 3 2 r ¬¢
6 4 2 r ¬¢
6 5 2 r ¬¢
6 6 2 r ¬¢
6 * 2 r ‚òÜ
‚òÜ * 8 r c
üá∫üá∞ * 5 r c
üá¨üáß 1 1 r üá∫üá∞
üá¨üáß 2 1 r üá∫üá∞
üá¨üáß 3 1 r üá∫üá∞
üá¨üáß 4 _ r +
üá¨üáß 5 2 r t
üá¨üáß 6 2 r t
üá¨üáß * 2 r ¬¢
¬¢ * 7 r c
+ - _ r ¬¨
¬¨ 0 _ r 4
¬¨ * 2 r t
4 0 1 r t
4 1 1 r t
4 2 1 r t
4 3 1 r t
4 4 1 r t
4 * 2 r t
6 _ 6 l c
c * _ r c
c _ _ * halt
 
```
[Try it online!](http://morphett.info/turing/turing.html?ede7a51c0dff0419b383aae1fb089ce0)
*Added a few bytes thanks to [Grimmy](https://codegolf.stackexchange.com/users/6484/grimmy) being a bit more thorough in testing my code than I was.*
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 48 bytes
```
Ôº©‚åïŒ≥¬ß &)*,/9;<;Ôº¨Œ¶‚™™‚Äù)¬∂‚Ü∂‚åïŒ≤Œ≥‚¶ÑJ‚â¶œÉŒΩ{:XŒ¥p‚Å¥E‚äô‚âï‚çòÔº®‚äôŒ≤g‚Äù‚Å∂‚ÄπŒπŒ∏
```
[Try it online!](https://tio.run/##JYxBCsIwFET3niJ0IT8S8Se1TUPciCAILgRPUNrSBkKqTRBvHxM7i8cMPKab2qWbWxvjYzEuwKX1Aa7G9TAycg431w9fKMiW7thB6ZMuGLkPbgxTkmwYFni@rAlQcFU1yLmSZWbD/6wzVYVcIB6xSpS58xKlwLREeqtpfvQeDCNvukZvYlwFFHH/sT8 "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Takes input as YYYYMMDD. Explanation:
```
                 ‚Äù...‚Äù      Compressed string of YYYYMM values
                ‚™™     ‚Å∂     Split into substrings of length 6
              Ôº¨Œ¶       ‚ÄπŒπŒ∏  Count those that appear before the input
   ¬ß &)*,/9;<;              Look the count up in a translation table
Ôº©‚åïŒ≥                         Subtract 32 from the ASCII code
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~158~~ 150 bytes
```
i=int(input()[:6]);print((((((((27,28)[202002>i>201306],25)[i<200701],15)[i<200405],12)[i<199501],10)[i<198601],9)[i<198101],6)[i<197301],0)[i<195801]
```
[Try it online!](https://tio.run/##NY@7DoMwDEV3vgKxQCoG2yGvtvAjiIkiNQugikrt16dOSDOdc@1EN/v3eG4rhXl7LGVf1nUdfO/Xo/Hr/j4aMV71JG77K0b5kGnJipGAAGjwAwFK0FNLSoz@zqEBnFr8WweKjaKhcyrN4DSro7ksGEWfYmSUvKYsS@BqxfJZ5iZWFReEUPGIkK9VBaPuGFVCo8GiSWj5obzgOiQZkUtBThkVEHYJEUCSPVGDA0oYf8m7Pw "Python 2 ‚Äì Try It Online")
Takes input as a string in `YYYYMMDD` format
Alternative Python 2 approach without imports. Simply uses nested list indexing to create the equivalent of a big `if/elif` structure.
**NB:** Posted by a British guy who is sorry to see us leave. I'm still all for the Community and working together (whether EU or here).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~38~~ 37 bytes
```
‚Äú‚Ç¨…ì‚Å¥5O/·πñ·π™O·πÅ·π™·∏ãg‚Äô·∏É‚ÅΩ√ó·ªµ√Ñ≈ª>‚Å∏S·ªã‚Äú√∑√±ƒ±√ê‚Ç¨¬Ω¬µ¬©¬°√±‚Äò
```
[Try it online!](https://tio.run/##FYwxCsIwFEAv9MHkt2nSxSt08AwiSC/g1qjg0EUQtIKLo@JSsNhSuuTr4DHyLxLr9Jb33nKe56sQuLjw@vE9sH2qbOK7o@/ume/sCN@WCy7Ovt2wHejk@4a2n37Ktp35vhxDelH9rmk/DtzgGndzV6q5qALtQkBMdBIkqNgIMLFAkALRgIyUVCCTFCOQ2qQGUKCW8Pf1Dw "Jelly ‚Äì Try It Online")
A monadic link taking the zero-indexed count of days since 1958-01-01 as a integer argument and returning an integer.
Thanks to @JonathanAllan for saving a byte!
[Answer]
# AWK, 98 bytes
```
{m=$1*12+$2-23496}1,$0=m<1?0:m<181?6:m<277?9:m<337?10:m<445?12:m<557?15:m<589?25:27+(m>666&&m<746)
```
[Try it online!](https://tio.run/##RZDBDsIgDIbvPgWHZVGnCS20pcsmz@LZ7OzB@OzYbchIQ798/EmB5/tVymeZO7gCDh3eMUTlL9w6Py8TZD/aniCzdRTJaj0EybAexEgZ0IDIDK2QNCONKMN5eTBz3y@TRL6U4m05D1YnUBIH6MKGqVnBZiU0m3yzCQ5Lh@VmNTarVC16H51V8BWpWq5ZQ2lZsMG8Z1eU3eJ29fBHrNNUjxntddsHVv4B "AWK ‚Äì Try It Online")
Input format: `YYYY MM DD`
[Answer]
# JavaScript (ES6), 95 bytes
Expects a number of days since `1957-12-31`.
```
n=>[x=0,5479,2922,1826,3287,3408,975,2373,2406].map((d,i)=>x-=(n-=d)>0&&~('52012910'[i]||~1))|x
```
[Try it online!](https://tio.run/##ZYyxbsMgFEX3fAVTAAnSxwMMDHjqX0QZrEAqRymOaqv1YOXXXTlDItnSW@65575r89v055/2PsjSpTxf4lxifRwjCGtcEBgQhfJYCY3eCW3Ai@CsQO20QAPV6fDd3BlLouWxHmVkRcbEa9jvH4xaBIVBAT22p2l6KM6ncR5yP5BIEok1OXel7275cOu@2IWxkv/IZzNkljiR5JWoCtZJhVIryjn5IL4y2XK@2y2/lhqUfB7lL/RevJHfWA43ltMrCwGMBLtCbmMhLEivET6t@R8 "JavaScript (Node.js) ‚Äì Try It Online")
This is however a bit longer than [@FabrizioCalderan's answer](https://codegolf.stackexchange.com/a/198700/58563), even if it is [fixed to use days](https://tio.run/##ZYzBbsMgDEDv/QpugQOb7QAGtNDLfiRq6LSqIlMTdZf9exZ6aKVEsvTkxzOX/t5Pp9v3z6zLOOTl3C2lSyXBsSRrOKzwBnAFAhFXthZNpQtElewDH8lrWT4IiPGvJCLHTkWyEdehiBBDdBGWOU@z6MQguiROY5nGa367jl/yLGXJv@Kzn7MclNDiuTUYLGsk3WKjlHgX3plslToc6l/1GVA/plFP9bp4Kb@rmHYVt5uKAIwGu1G8qwiqareKHtXyDw) instead of months.
[Answer]
# x86 (32-bit) assembly, 43 bytes (13 bytes code + 30 bytes data)
This routine expects input in `ax` as a signed short giving number of days since 1950-01-01, and returns output in `al` (clobbering `edi` along the way).
```
    .text
    .globl eu_members
eu_members: 
    mov $.Ltbl-1, %edi
.Lloop:
    inc %edi
    scas (%edi), %ax
    jg .Lloop
    mov (%edi), %al
    ret
    .section .rodata
.Ltbl:
    .short 2921
    .byte 0
    .short 8400
    .byte 6
    .short 11322
    .byte 9
    .short 13148
    .byte 10
    .short 16435
    .byte 12
    .short 19843
    .byte 15
    .short 20818
    .byte 25
    .short 23191
    .byte 27
    .short 25597
    .byte 28
    .short 32767
    .byte 27
```
Exact opcodes of the code part (in a linked context so that the relocation of .Ltbl doesn't confuse things):
```
0804930b <eu_members>:
 804930b:       bf 49 a0 04 08          mov    $0x804a049,%edi
 8049310:       47                      inc    %edi
 8049311:       66 af                   scas   %es:(%edi),%ax
 8049313:       7f fb                   jg     8049310 <eu_members+0x5>
 8049315:       8a 07                   mov    (%edi),%al
 8049317:       c3                      ret    
```
And here's the test harness I used (note that the assembly code is not PIC safe, so on Debian or Ubuntu systems you will need to pass `-no-pie` to gcc):
```
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
unsigned char eu_members_wrap(short days_since_1950_01_01) {
    unsigned char res;
    __asm__("call eu_members" : "=a"(res) : "0"(days_since_1950_01_01) : "edi", "cc");
    return res;
}
int main(int argc, char* argv[]) {
  struct tm tm;
  time_t epoch, req;
  short days_since_epoch;
  memset(&tm, 0, sizeof(tm));
  tm.tm_year = 50;
  tm.tm_mon = 0;
  tm.tm_mday = 1;
  epoch = mktime(&tm);
  memset(&tm, 0, sizeof(tm));
  tm.tm_year = atoi(argv[1]) - 1900;
  tm.tm_mon = atoi(argv[2]) - 1;
  tm.tm_mday = atoi(argv[3]);
  req = mktime(&tm);
  days_since_epoch = (((unsigned int) (req - epoch)) / (24 * 60 * 60));
  /* printf("epoch = %ld, req = %ld\n", epoch, req);
  printf("Raw number of days: %hd\n", days_since_epoch); */
  printf("EU members: %hhu\n", eu_members_wrap(days_since_epoch));
  return 0;
}
```
[Answer]
# [Perl 5](https://www.perl.org/), 46 bytes
```
($q,%d)=split;$q--while!exists$d{$q};say$d{$q}
```
[Try it online!](https://tio.run/##PcprCsIwEATgq0SIoGDK7tY0CcUjeAihAQOlrwRUxKsbtynI/vlmZie/9Drng5xP@@54iVMfUitnpR730Pudf4aYouzecv608fbalDM6UwMCCuBDp20Jjfj3jmmxENcP22wmttObtSCAM3ASVGxKT4aN9ZoEWTYvVPrvOKUwDjGr4aorhAp@ "Perl 5 ‚Äì Try It Online")
...or try like this on some decent command line:
```
query=19730101
data="0 0 19580101 6 19730101 9 19810101 10 19860101 12 19950101 15 20040501 25 20070101 27 20130701 28 20200201 27"
echo "$query $data" | perl -nE '($q,%d)=split;$q--while!exists$d{$q};say$d{$q}'
```
]