[Question]
  [
## Background
Sometimes when I'm golfing a program, I'm presented with the following situation: I have an integer value \$x\$ on some fixed interval \$[a, b]\$, and I'd like to test whether it's in some fixed subset \$S \subset [a, b]\$ with as few bytes as possible.
One trick that sometimes works in a language where nonzero integers are truthy is finding small integers \$n\$ and \$k\$ such that \$x \in S\$ holds precisely when \$x + k\$ doesn't divide \$n\$, because then my test can be just `n%(x+k)`.
In this challenge your task is to compute the minimal \$n\$ and \$k\$ from the fixed data.
## The task
Your inputs are a number \$b\$ and a set \$S\$ of integers between \$1\$ and \$b\$ inclusive (we assume \$a = 1\$ for simplicity), in any reasonable format.
You may take the complement of \$S\$ if you want.
If you take \$S\$ as a list, you can assume it's sorted and duplicate-free.
You can also assume \$b\$ is at most the number of bits in an integer and take \$S\$ as a bitmask if you want.
Your output is the lexicographically smallest pair of integers \$(n,k)\$ with \$n \geq 1\$ and \$k \geq 0\$ such that for each \$1 \leq x \leq b\$, \$k+x\$ divides \$n\$ if and only if \$x\$ is *not* an element of \$S\$.
This means that \$n\$ should be minimal, and then \$k\$ should be minimal for that \$n\$.
Output format is also flexible.
Note that you only have to consider \$k \leq n\$, because no \$k+x\$ can divide \$n\$ when \$k \geq n\$.
The lowest byte count in each language wins.
## Example
Suppose the inputs are \$b = 4\$ and \$S = [1,2,4]\$.
Let's try \$n = 5\$ (assuming all lower values have been ruled out).
* The choice \$k=0\$ doesn't work because \$k+1 = 1\$ divides \$5\$ but \$1 \in S\$.
* The choice \$k=1\$ doesn't work because \$k+3 = 4\$ does not divide \$5\$ but \$3 \notin S\$.
* The choice \$k=2\$ works: \$k+1 = 3\$, \$k+2 = 4\$ and \$k+4 = 6\$ don't divide \$5\$, and \$k+3 = 5\$ divides \$5\$.
## Test cases
```
b S -> n k
1 [] -> 1 0
1 [1] -> 1 1
2 [] -> 2 0
2 [1] -> 3 1
2 [2] -> 1 0
2 [1,2] -> 1 1
4 [1,2,4] -> 5 2
4 [1,3,4] -> 3 1
5 [1,5] -> 168 4
5 [2,5] -> 20 1
5 [3,4] -> 6 1
5 [2,3,4,5] -> 1 0
6 [1] -> 3960 6
8 [2,3,6,7] -> 616 3
8 [1,3,5,7,8] -> 105 1
8 [1,2,3,4,5] -> 5814 11
9 [2,3,5,7] -> 420 6
14 [3,4,6,7,8,9,10,12,13,14] -> 72 7
```
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~21~~ ~~20~~ ~~19~~ 18 bytes
Thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen) for -1 byte!  
-1 byte inspired by [xash](https://codegolf.stackexchange.com/users/95594/xash)'s [Brachylog answer](https://codegolf.stackexchange.com/a/212162/64121)!
```
[¼¾ƒ²L¾ÑN-K¹Qi¾N‚q
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/@tCeQ/uOTTq0yefQvsMT/XS9D@0MzDy0z@9Rw6xCoKyhjrGOqY65jkUslwUA "05AB1E – Try It Online")  
or  
[Try most test cases!](https://tio.run/##TVBLTsMwEF3jU4xcUEBMaJ00bbqgYg@qxDr1ImlcEgnFIckOkLgCLDkGOySUhStxEC4SYtf9eDPvzbyZ8bwkrrNOrDIJtIvUj2p/P9TXnWo37wv3Vn3f56pd/L19PnUUXqCJ80dwV3DJepKJONXEZTCHspIPV3EiCGlE3dTX507EgTnEiZiNHDxLTfR2HI8QjjmMt9g/wgGHwPTskanaXI9tfmDGTwzQ@QlOOYS7eQFOMTR8sF1mG8O9PtD6mZ2vuzHEGbIRMg@Zj6zfyfovXRCylhXoQyEvgJ4@m5ujG/5KSSoJ2FdWedGsgZ65/qgGdw6012opJSfGcUO0rZUuAV0W2uShLJuhrOMkFzYc3E1lIbp/ "Bash – Try It Online") (based on the test-suite by [FryAmTheEggman](https://codegolf.stackexchange.com/users/31625/fryamtheeggman) for [this answer](https://codegolf.stackexchange.com/a/212123/64121).)
```
            # see below for the remainder of the code
²L          # push [1 .. b]
  ¾Ñ        # push the divisors of n
    N-      # subtract k from each
            # this is now a list of all x in [-k+1 .. n-k] with n%(x+k)==0
      K     # remove this from [1 .. b]
       ¹Q   # is this equal to S?
```
---
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~24~~ 23 bytes
First line of input is the set \$S\$, second one \$b\$.
```
[¼¾ƒ¾¹²L‚N+Ö_O¹gªËi¾N‚q
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/@tCeQ/uOTTq079DOQ5t8HjXM8tM@PC3e/9DO9EOrDndnHtrnBxQrBKoz1DHWMdUx17GI5bIAAA "05AB1E – Try It Online")
This iterates through all possible pairs in lexicographical order and checks for each pair:
\begin{align\*}
\left|S\right| &=\left|\left\{ x \in [1 .. b] \mid x \;\text{does not divide}\; n \right\}\right| \\&= \left|\left\{ x \in S \mid x \;\text{does not divide}\; n \right\}\right|
\end{align\*}
**Commented**:
```
[                # infinite loop
 ¼¾              # increment and push the counter (n)
   ƒ             # for N(=k) in [0 .. n]:
¾                #   push n
 ¹               #   push the first input (S)
  ²L             #   push [1 .. second input (b)]
    ‚            #   pair these two lists up
     N+          #   add current k to both lists
       Ö_        #   do they not divide n (vectorizes)
         O       #   sum both lists
          ¹g     #   push the length of S
            ª    #   append this to the list
             Ë   #   are all equal?
i                #   if this is true:
 ¾               #     push n
  N              #     push k
   ‚             #     pair n and k
    q            #     quit the program (implicit output)
```
[Answer]
# [Haskell](https://www.haskell.org/), 63 bytes
```
b!s=[(n,k)|n<-[1..],k<-[0..n],[x|x<-[1..b],mod n(k+x)>0]==s]!!0
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P0mx2DZaI08nW7Mmz0Y32lBPL1YnG8gw0NPLi9WJrqipgIgmxerk5qco5Glka1do2hnE2toWxyoqGvzPTczMsy0oyswrUTFVjDbUMY39DwA "Haskell – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~110~~ ~~91~~ 89 bytes
Saved a whopping ~~19~~ 21 bytes thanks to [Jitse](https://codegolf.stackexchange.com/users/87681/jitse)!!!
Blows up on TIO because of insane recursion depths! :(
```
f=lambda b,S,n=1,k=0:S==[x+1for x in range(b)if n%(k-~x)]and(n,k)or f(b,S,n+k//n,-~k%-~n)
```
[Try it online!](https://tio.run/##ZVLbjoIwFHznK/qyoY2HlZarJuxP@Oj6AAq7BC2m1ERj9NfZtuBykaThZGbOnB6Y803@1txry9O5FhI1t8ZS57PJpcj3F9GUNT@Wp1Ji6qqHtEVyTE/ZIUUZbIAnFKrEXW@SZHtd0KIW6IpKjkTKf3KckbJA/ANXzvNKdik/YA4VUZoCm@ZFtVxycJ7Vh/PkpJV5IxuUIGwh9WBMYbsjgNTbJQQGkPYoHVDWS9lYyl5SbyZl77ZaC@zd2Dc4@IYJgM0Yr2cmEwLNBJ1XGIM/YVjPMHfW8rIKZzjTQ1524yuH/@utQhfCgYi7phCizpCG4E1Yfe8AIog7UzcYj4y7jYehQUx9oCPFqvMPen@fTaYrsd5Fj4cYVkDVogyo@kLdfhGDSKuJJfS/tr8vLPL3NiBTUc8mlo6RhFwHyWRibaxVZFSDNLXKkapNjIgBzqLkEhf2PXug@@aBnC9056qs1BFbk7skyXcPm7R/ "Python 3 – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~92~~ ~~86~~ ~~85~~ ~~83~~ 82 bytes
*Edit: -2 bytes thanks to Giuseppe, then -1 more byte thanks to Robin Ryder*
```
function(b,S)repeat for(k in 0:(F=F+1))if(all(1:b%in%S-!F%%(1:b+k)))return(c(F,k))
```
[Try it online!](https://tio.run/##hZLRasIwFIbvfYozSiHFI/SkTZo6usvCrnbh7odKHUFJJFZ8/K4da6rT1ptA4Mt/vvyJa7Spq@/KfR3X2hXN7my2tbaGbXAVuepYrWvYWcf2oA3ES1YW5ZyiSO/Y@nBgtNyE2oSrxUsZht1uvo@i9lh9doZtWYntttkU9AqrYssiCGDxBgTx7Hro76iZp8hj9BDjN2F8JIzfhiXTYfyJWp@G/Ilc6kFM/1ABfBpNPDpmKXpU9OOlgnQK5R7l8XToMF1Og7wTHQxGmpL/es9lDPKehBZVQ67ErJcgCcnDZDX0JTBD1YvEYsRbDW9xbS4UpUA0C@DeKoDaWjgd7KX79PD5/rEEdzaga7DdegJ7MW10PqgLr57yh1ftfnbqu@6uigpzpBiJIyVIff8Zh@z@ePMD "R – Try It Online")
Tests increasing velues of n (actually defined as `F` here, to exploit its default initial value of zero), and for each one loops through all `k` and returns `F,k` if they satisfy `!F%%(x+k) != x %in% S` for all `x` in `1:b`.
Now 6 bytes shorter than my previous [recursive version](https://tio.run/##rZMxb4MwEIV3fsVVEZKtXCTOYOOkonunSE33ClBorSBTEaIOVX87BbVA0gBZOlr@7t17d3ZZG1vtX/fly3tsyqjOouxk08oUliW4QxsR/8yKkh3AWPA2lpuMxXnOaJO4xrq71Z113fa0PHDOy311Ki1LmcXm6GQ/GkviX3US0T3sopRxWMDqAQg857x1i3Knp6jHaBQTF2JiQkxcivnzYuKGtU4NxQ1zQQ9i8ItKEPOo36NTLmWHyq690hDMoaJHhTcvOnRX86BojQ4OJial/sx9rTxQzgKu2OY@i01@hMLC8@MWklMF2wN8mOoN8iKNc3hqio5V8@Ti9lE22nowojDsXJMCf9SKHgYsMUTdOffkRFA9LO88qtQUANE/hVgPIWQfIhDtlEY/RdCvqQ2NGtdIHpJA8pG61YUCwuvy@hs), *and* it can actually complete all the test cases without needing to increase the [R](https://www.r-project.org/) recursion limit and allocated stack size.
[Answer]
# JavaScript (ES6), ~~85 83~~ 82 bytes
Expects `(b)(s)`, where `s` is a Set. Returns `[n, k]`.
```
b=>s=>{for(n=k=0;(g=x=>x&&n%(x+k)>0^s.has(x)|g(x-1))(b,k=k?k-1:++n););return[n,k]}
```
[Try it online!](https://tio.run/##lZLRToMwFIbvfYreuLTZYesppTCX4kN4udRkm4DKUgxMJVGfHbNETYBSt95//f7/nPO8fds2@/rp5RjY6iHrct3tdNro9COvamp1qfmaFrrVaTub2WvazkuW8vtm8bhtaMs@C9oGyBjdQanL2zLAm/ncsjVb19nxtbYbC6X56vaVbapDtjhUBc0pQUZt9k7usiPdGOJ@jDGyXBIk/MpDo/mHxiEtzneLsVuc7w79bmEu7d1zg5uf7i37NEgzSUdE@OnQRzt6Rz068iZXCZE@Xvh5wf16d/Q/XPlpcaruCDC9NHXBwawUJ2r4QTLQK4in9AoVCX38aXMRxJAYd3wejesng7txDeD3bhKUBEc/rAYNoukGUowngLK/vtMEIIEVIAcUgCGgND98LEjcfQM "JavaScript (Node.js) – Try It Online")
### Commented
```
b => s => {             // b = upper bound; s = set of integers
  for(                  // main loop:
    n = k = 0;          //   start with n = k = 0
    (                   //
      g = x =>          //   g is a recursive function taking x:
        x &&            //     stop if x = 0
        n % (x + k) > 0 //     otherwise yield 1 if x + k does not divide n
        ^ s.has(x)      //     XOR with 1 if x belongs to the set
        | g(x - 1)      //     recursive call with x - 1
    )(                  //   initial call to g:
      b,                //     start with x = b
      k =               //     update k:
        k ? k - 1       //       decrement k if it's not equal to 0
          : ++n         //       otherwise, increment n and set k to n
    );                  //   end of call to g; break if it's falsy
  );                    // end of loop
  return [n, k]         // return the result
}                       //
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 19 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Ż⁴+þ⁸%T€i©
1ç1#‘,®’
```
A full program accepting the set, \$S\$, and the upper bound, \$b\$, which prints the variables as a list, \$[n,k]\$.
**[Try it online!](https://tio.run/##ATMAzP9qZWxsef//xbvigbQrw77igbglVOKCrGnCqQoxw6cxI@KAmCzCruKAmf///3sxLDV9/zU "Jelly – Try It Online")**
Or see the [test-suite](https://tio.run/##S0oszvifmpyRr6D0/@juR41btA/ve9S4QzXkUdOazEMruQwPLzdUftQwQ@fQukcNM/8rKdQolCRm5ijoJitoGwI5GamJKSCOrqGCnUJBUX66XlZqTk4lF1dJanFJsa2GenWtgqE6l3q1IZSuVTCCcsG0EYyvg8TSMalVMIGwjZHYprUKpmA9cBZYFioGZEPFlcHGm8GEzXTMaxUsYMaZ6pjrWID5yhC7oPosYMpNQcotoaaDNOtY6FjqGBroGBrpGBrrGAJtNAQ6SJOLKy2/SAHkTYXMPAUllWqwj6MdYmuVuFLyuTjB4aCQVpqHFCwKEFW1QAV5qf8B "Bash - Try It Online") (without the two longest-running inputs).  
Kindly provided by [FryAmTheEggman](https://codegolf.stackexchange.com/users/31625/fryamtheeggman).
### How?
```
1ç1#‘,®’ - Main Link: S, b
1        - set left to 1
  1#     - count up starting at x=left finding the first x which is truthy under:
 ç       -   call the helper Link as a dyad - f(x, S)
    ‘    - increment -> n+1
      ®  - recall the value from the register -> k+1
     ,   - pair -> [n+1, k+1]
       ’ - decrement -> [n, k]
         - implicit print
Ż⁴+þ⁸%T€i© - Link 1: potential_n, S
Ż          - zero-range -> [0..potential_n] (the potential k values)
 ⁴         - program's 4th argument, b
   þ       - table of (implicitly uses [1..b]):
  +        -   addition
    ⁸      - chain's left argument -> potential_n
     %     - modulo (vectorises)
      T€   - truthy 1-based indexes of each
        i  - first index of (S); 0 if not found
         © - copy that to the register and yield it
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~129~~ \$\cdots\$ ~~111~~ 109 bytes
```
x;s;n;k;f(b,S){for(s=n=1;s;++n)for(k=0;k++<=n&&s;)for(x=b,s=S;x--;)s-=!(n%(x+k))<<x;printf("%d %d",n-1,k-2);}
```
[Try it online!](https://tio.run/##jVbbjpswEH3fr3CRdgWLURnu1KH9iDxu01WTkCrKll0teUBd5dtTAzPYGatSg5SB4zOHmYNt2EW/drvrdVC96tRJHfytXAcfh9d3v2@6BjQchl0wXp@aWJ3CcNV0Dw@9mqCh2cq@WashilTQR80nv7v3h/AUBKvVoN7ej9354Hv3e3G/92QXgTxFSaAuV42L3z@PnR/cfdwJ/RsBcW778/P2aSMa8QESZIJHpo8cj0JW01FLyC6K5a5hTr5IvE5QbAFSRsg4IZ@BZAEKqsdA5QLJbAErAlMLrAnMFwhivIONYd12KiTES8f2DZ7ykiEzzEKWBs9NSbksZWVGTFNcvTRaua1VLRWO95gfQCwhkZDePIlHTJjpmCzxaWBMMWYYc4wFxhJjhbGWZB2dkCKQJJAmkCiQKpAskC5U7szp5oL745/29eAjL/iM148EyBtCwgkJI6SckDJCxgkZI@SckDNCwQkFI5ScUDJCxQkVI9ScUDMCxI5TMae4ZnI3wbETuJ/gGArcUXAsBe4pOKYCdxUcW4H7Co6xwJ0Fx1qN2HOvHd7a3RloNcZ6vc1QsuyCC5TSyjSsjBalYeWuVuFq4SrPp01thipXi3avopr2JSyW9q/YYtIGVthY4pZCm1daF7EsDIyNFHqtpgalXuLclsV28kovdbBw7ClLbpSxrTLRm5m1Sc2j7X4eRa5E7zGmGDOMOcYCY4mxwlhLcohOSBFIEkgTSBRIFUgWSHfZpvSbVvjjfDl2@3bQBccKT1cCpxf1Y@bbgigRhhM7EPO7lmbfVivhK3ca36hl2HpzP3lSbANlZz6KNaWundRpXr8s451DMN1gJ7qLl6nIwNy3Hz8YxPGbJ70vnj7T99ncFqG/H/rT83rS@C9t5IeNgNXKHwVFJMASRcKPRviasQ3GYdcSnfVVeFba@MWEudymVlexzLR/eSz86fso@N7pPtuneDP@A3V7ubtc/wI "C (gcc) – Try It Online")
Takes \$S\$ as an inverted bitmask of length \$b\$ and outputs \$n\$ and \$k\$ to  `stdout`.
### Explanation
```
f(b,S){                  // function f takes b as an int and S as a  
                         // inverted bitmask - the least significant
                         // b-bits of S are unset only if that bit position
                         // corresponds to a member of the original set S    
  for(s=n=1;             // loop starting with n=1 and s temporarily 
                         // set to 1 just to pass the first two loop tests  
            s;           // loop until s is 0
              ++n)       // bumping n up by +1 each time
   for(k=0;              // inner loop trying values of k starting at 0 
           k++           // k is  bumped up by +1 before use to offset b
                         // which will be 1 less than needed
              <=n        // loop until k is +1 greater than n  
                 &&s;)   // or until we've hit our target  
     for(x=b,            // another nested for loop of x starting at b-1  
             s=S;        // first real init of s to input bitmask  
                 x--;)   // loop from b-1 down to 0  
                         // which corresponds to b down to 1  
                         // since x is offset by -1  
      s-=!(n%(x+k))<<x;  // subtract off from s bits corresponding to values
                         // for which n%(x+k) is false - because it's the
                         // inverted bitmask  
                         // s will be 0 at the end of this most inner loop
                         // iff n and k are our minimal targets
   printf("%d %d",       // once we've discovered the smallest n and k
              n-1,       // we need to compensated for loop increments  
              k-2);      // and k being offset by +1 
}
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~32~~ 29 bytes
```
Ｗ¬№ωθ≔⭆⁺Ｌ⊞ＯυθＬθ¬﹪Ｌυ⊕κωＩ⟦Ｌυ⌕ωθ
```
[Try it online!](https://tio.run/##dY49C8IwFEX3/oqML/AEEVGhY6VQsNq9dAjtwwTyUdNEf35MdXDyjod7uHeUwo9O6JS6uEiIyCIvi5dUmhhcXYDKRRtWLjnnrBVz5YwRdoK1f5vJi@D810NWKx3IwwNZ66aoHZxp9GTIBprgQvYe8gTPxcb@eKfjAhqZ4WvKovMqL1ZiCdD/82uVH3xODVlJqT9hv8Ud7vGAx2FIm6d@Aw "Charcoal – Try It Online") Link is to verbose version of code. Takes \$ S \$ as an inverted bitmask of length \$ b \$ and outputs \$ n \$ and \$ k \$ on separate lines. Explanation:
```
Ｗ¬№ωθ
```
Repeat until the desired bitmask is found in the current bitmask.
```
≔⭆⁺Ｌ⊞ＯυθＬθ¬﹪Ｌυ⊕κω
```
Increment \$ n \$ and calculate the full bitmask for \$ 1 \leq k + x \leq n + b \$.
```
Ｉ⟦Ｌυ⌕ωθ
```
Output \$ n \$ and the index \$ k \$ of the input bitmask \$ S \$ in the full bitmask.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 27 bytes
```
∧.Ċℕᵐ≥₁fʰgᵗz≜-ᵐF&h⟦₁;Fx~t?∧
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFSu9qhtw6Ompoe7Omsfbp3w/1HHcr0jXY9apgI5jzqXPmpqTDu1If3h1ulVjzrn6AIF3dQyHs1fBhS3dquoK7EHqv//PzraUCc6NlZHAUQbghlGUAEjJAEjMMMEKKJjpGOC4BhDOaYgjimMaYRgIikwAqkGycQCAA "Brachylog – Try It Online")
### How it works
```
∧.Ċℕᵐ≥₁fʰgᵗz≜-ᵐF&h⟦₁;Fx~t?∧
 .                          The output is
  Ċ                          [N, K], where …
   ℕᵐ                         N ≥ 0 and K ≥ 0, and …
     ≥₁                       N ≥ K.
       fʰ                   Factors of N
           z                 zipped with
         gᵗ                  K:
            ≜-ᵐ               label and take K from every factor.
               F            Save the result as F.
                &h⟦₁        [1, …, b]
                    ;Fx       without the elements in F
                       ~t?    is S.
                          ∧ Return output.
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~63~~ 54 bytes
```
{{(n+^k),k:*&(&/x=)'~(n(1+)\y)!''n:*z}[^y?x;x:1+!x]/1}
```
[Try it online!](https://ngn.bitbucket.io/k#eJxFTrt2gzAM3f0VypJAoh4sYRtDTtuP6EiTIQNLeujQoaQ56bcXWYZOug/dKw3d/V6Mh/O1xGu33xbbanoud7/FWNChfL+Vm91u7PY/j/58e52OU0eHzXSq6GHM0NNxY09pIsnkzHnlyDoJEnACwC2wVuhn6BXwAlaLZUvVmEiARonkPTQQhbbJ8+qRk7xsQoQWyAIxUA00d5pq6IP8B9XXx+e30Ji+0jNZNZW5wBs8vcAIV0PQnwQTWMGUCRnOBs8GL0atBq8RcZDXkEsUXRI8sAp1FiTtRfAaCBGcCJwFtrqw7AelLAVLZr4Z1m/aYCGYqCsBG01RgFpEOeyxwahJ6+e6qA/+F/pIDohMqyU+lziW5tmSZ6QaI7ZIFomRaiR9sGFo/gB3MoHF)
* `{{...}[^y?x;x:1+!x]/1}` set up a "converge" `/` starting with an `n` of `1`, fixing `y` as `1..b`, and `x` as a boolean mask indicating whether or not each value of `1..b` is present in `S` (`1`s if not present, `0`s if present). each invocation returns a pair of integers, `(n;k)`, with the execution ending when a valid `k` is identified
	+ `n:*z` store the first value of `z` in `n`
	+ `(n(1+)\y)` generate a (n+1)-by-b matrix; columns represent potential values of `x`, with rows representing potential values of `k`
	+ `~(...)!''n` identify pairs where `k + x` divides `n`
	+ `(&/x=)'` determine if each pair is invalid because `x` is in (or not in) `S`, then determine if all `x`s are valid for this `k`
	+ `k:*&` identify the first valid `k` (if there isn't one, this returns `0N`, an integer null)
	+ `(...),k` append the identified value of `k`...
	+ `(n+^k)` to `n` if a valid `k` was identified, or an incremented `n` if not
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~38~~ ~~33~~ ~~28~~ ~~22~~ 24 bytes
*Edits: -5 bytes thanks to Razetime, then -6 bytes thanks to Zgarb, then +2 bytes to fix bug that failed to find solutions for which `k` is zero*
```
§,o←ḟVImλVö=²`Wḣ⁴`%¹+ŀ)N
```
[Try it online!](https://tio.run/##ATYAyf9odXNr///Cpyxv4oaQ4bifVkltzrtWw7Y9wrJgV@G4o@KBtGAlwrkrxYApTv///zX/WzEsNV0 "Husk – Try It Online")
Arguments are integer `b` and list `S`; outputs pair of integers `(k,n)`.
My second [Husk](https://github.com/barbuz/Husk) answer, and it took me *ages* to get it to work at all, so ~~I suspect it can still be golfed-down a lot~~ quite significantly golfed-down by Razetime & Zgarb...
Checks increasing values of `n`, and calculates the lowest `k` that can satisfy `S == (n%(b+k)>0)`. Then retrieves this value, and its index, as `k` and `n`, respectively.  
*Edit:* In its original form, this missed solutions with `k` equal to zero, since this is the same result as failing to find a valid `k`. So now edited to calculate `k+1`, and then subtract 1 after retrieving the value.
***How?***
```
mλVö=²`Wḣ⁴`%¹+ḣ)N       # part 1: calculate first value of k+1 for each possible n
m                       # map function to each element of list
                N       # N = infinite list of natural numbers
 λVö=²`Wḣ⁴`%¹+ḣ)        # lambda function taking 1 argument:
  V           ŀ         # find the first 1-based index of k in 0..n with a truthy result of
   ö=²`Wḣ⁴`%¹+          # function to check if true indices of n%(k+b) are equal to S
   ö                    # composition of 4 functions
             +          # add b
          `%¹           # mod n
      `Wḣ⁴              # get set of truthy indices of 1..b
    =²                  # is this equal to S?
                        # (note that because we take the 1-based index
                        # of a range from 0..n, this part calculates k+1, 
                        # or zero if there is no valid k)
          
§,o←ḟVI                 # part 2: return the first k, n
§                       # fork: apply func1 to the results of func2 & func3
 ,                      # func1 = join as pair      
  o←ḟ                   # func2 (takes 2 args, 2-part fucntion combined using o):
                        #   increment the first truthy element of arg1 (a function) applied to arg2 (a list)        
     V                  # func3 (takes 2 args): first truthy index of arg1 (a function) applied to arg2 (a list)
      I                 # arg1 for both func2 & func1 = identity function
                        # arg2 for both func2 & func1 is part1 above: the first k for each n (if any)
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 70 bytes
```
/,/;++$k>$n?$k=0*++$n:0until"@{[grep$n%($k+$_),1..$`]}"eq$';$_="$n $k"
```
[Try it online!](https://tio.run/##DcpLDoIwEADQvaeYNGMUW6ADxV@DegFPQAxuiCHFoSIujPHqVpYveb4ZuiLc30t0CjmyIVWplRLdAfmIrtSrCbzXLx7bTpw@1W1oPPJ8@hLrSFGS4PXyFc0DFxbrUiADOhGCUQQZmBkZlYOBNWxgCzsgDZQB5UDm1/ux7fkZ4s6H@Fwkmv4 "Perl 5 – Try It Online")
or less understandable and trickier 68 bytes
# `-lp`, 68 bytes
```
/,/;++$\>$,?$\=0*++$,:0until"@{[grep$,%($\+$_),1..$`]}"eq$';$_="$, "
```
[Try it online!](https://tio.run/##FchLDoIwEADQvaeYTMb4YYAOFH8N6gU8ARh0gYaEQAVcGOPVrbh8z5ZdnTjiFNH01xdidaN8rwzl/3Ehh8bzxiE@jKWWI3inns1Q1Xh8Z/eutMTTOeUeFQuWIKDL@YPlg2aGihSJAZ3TLBCBnojmGDSsYA0b2IIokAgkBtHf1g5V2/TOr63zT0mg5Ac "Perl 5 – Try It Online")
]