text:
Help me pair my left and right socks!
Inspired by Help me pair my socks, and the fact that I have some pairs of socks where the left sock is distinct from the right.

Background
Again, I have a huge pile of socks. And a machine that can give the list of labels of the socks for me. This time, the labels follow these rules:

Some socks have left and right versions. In this case, left socks are labelled -n and right socks are labelled n, where n is a unique positive integer. The list of such socks will be explicitly given to you.
The others don't have such a thing, and they just match themselves. All socks of this type are simply labelled n (no negative labels).

An example pile would look like this:
[3, 3, -2, 4, -1, -1, 1, 4, 4, 3, 2, 3, -1, 4, 4]

where 1 and 2 have left and right versions. Then the pairs and leftovers are:
pairs: {3: 2, 4: 2, 1: 1, 2: 1} or [1, 2, 3, 3, 4, 4]
leftovers: {4: 1, -1: 2} or [-1, -1, 4]

Note that two -1s don't make a pair because both are left socks.
Challenge
Given the pile of socks and the list of sock labels having L/R versions, output the pairs that can be made from the pile, and leftovers that are not part of any pairs.
Input and output
You can assume the following for input:

Zeros won't appear in either list.
L/R labels are unique and all positive, but possibly not sorted.
Negative numbers that are not part of L/R labels won't appear in the pile.

Both outputs can be represented as either a mapping type (label to count) or a flat list (each item appearing once per count). You can output in following ways:

Pairs can be represented as either a pair (3, 3) / (-1, 1) or a single number 3 / 1 / -1, or a mixture of both. But the same pairs should be represented in the same way in a single run, e.g. outputting [3, (3, 3)] or [(-1, 1), (1, -1)] or [1, -1] is not allowed.
For both pairs and leftovers, a pair and single number can be wrapped in any kind of containers, e.g. singleton arrays can be used to represent a single leftover.
For both pairs and leftovers, the order of items is not important.
If you use a mapping type, zero-count items are allowed, even the ones not in the pile of socks.

Scoring and winning criterion
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
Pile: [3, 3, -2, 4, -1, -1, 1, 4, 4, 3, 2, 3, -1, 4, 4]
LR: [1, 2]
Pairs: [1, 2, 3, 3, 4, 4]
Leftovers: [-1, -1, 4]

Pile: [1, 1, 2, 2]
LR: [1]
Pairs: [2] (two right 1's and two simple 2's, so only 2's make a pair)
Leftovers: [1, 1]

Pile: [5, -10, 5, 10, -10, 10]
LR: [10, 20]
Pairs: [5, 10, 10]
Leftovers: []

Pile: [-6, 7, -9, 3, 4, -6, 4, -9, 8]
LR: [6, 9, 4]
Pairs: []
Leftovers: [-6, 7, -9, 3, 4, -6, 4, -9, 8]

Pile: []
LR: [1, 2]
Pairs: []
Leftovers: []

If we output pairs as single numbers, is it OK if some of those numbers are negative? E.g. in example 3, output [5, 10, -10].

@RobinRyder No, all pairs of 10 should appear in the same way. I tried to clarify the output rule.

Are the values still wrapped in inner lists allowed (i.e. [[4],[-1],[-1]],[[3,3],[3,3],[-2,2],[4,4],[4,4],[-1,1]] - this is the current output of the Jelly answer, or the output of the Japt answer without its second line), or is it mandatory to simplify it (like the Japt answer did with its second line)?

@KevinCruijssen It's allowed.

Can we have a non-consistent order of the outputs, as long as it's clear which ones are the Pairs and which ones are the Leftovers? I.e. can one test case result in [[[1],[1]], [[2,2]]] ([Leftovers, Pairs]) while another test case results in [[[3,3],[-2,2]], [[2],[2],[5]]] (Pairs, Leftovers])?

@KevinCruijssen No. That went a bit too far I guess.

@Bubbler I agree, which is why I had the additional é in my 05AB1E program, but figured I'd ask in case I could remove it, since I just had someone asking about it. :) I'll leave it in in that case.

This is a test case that would have helped me find a bug in my approach: LR=2, Pile=-2 -2 2 -2. Expected: leftovers -2 -2, pairs: 2

05AB1E, 40 27 bytes
.¡Ä}εDÄIåài{γζðδKë2ô]€`é.¡g

Inputs are in the order Pile, LR and outputs in the order Leftovers, Pairs in the format ([[1],[2],[3]], [[1,1], [-2,2], [3,3]]).
-13 bytes by porting @AZTECCO's Japt answer, so make sure to upvote him!
Try it online or verify all test cases.
Explanation:
.¡ }              # Group the (implicit) input integer-list `Pile` by:
  Ä               #  Their absolute values
    ε             # Then map each group to:
          i       #  If
       Iåà        #  any values of the second input-list `LR`
     DÄ           #  is in the current group's absolute values:
           {      #   Sort the values in the group
            γ     #   And then group it on subsequent equal values
             ζ    #   Zip/transpose to create pairs of positive & negative values,
                  #   with space as default filler if the lists are of unequal length
              ðδK #   And remove all those spaces
          ë       #  Else:
           2ô     #   Split split the group into parts of size 2
    ]             # Close the if-else statement and map
     €`           # Flatten each inner list once to remove the groups again
       é          # Sort each inner list by length
        .¡g       # And also group by length
                  # (after which this result is output implicitly as result)

I think é is redundant, .¡g should be enough ?

@AZTECCO Unfortunately no, since the groups remain in the same order in 05AB1E. You can try removing it in the Test suite TIO to see that the output of some of the test cases are then reversed, while others aren't. EDIT: I guess I could remove it, since it's clear that the paired integers are the Pairs and the single wrapped integers are the Leftovers, but a non-consistent output-order seems a bit weird imo.

Oh.. I see, there are some subtle differences between the languages, anyway seems like they have a similar structure.

APL (Dyalog Unicode), 62 bytes (SBCS)
,⌿⎕{⍺∊⍺⍺:((∊|⍴¨⍺××)n)(⍺/⍨0⌈2÷⍨≢⍵↓⍨n←⍺÷⍨+/⍵)⋄/∘⍺¨⌽0 2⊤≢⍵}⌸⍨∘|⍨⎕

Try it online!
The initial "straightforward" version was around 76 bytes long; folks at The APL Orchard helped me golf it substantially to the snippet above. Thanks!
How does it work?
Explanations written for the original "straightforward" version, not for the most golfed version above.
At a high level, the ⌸ Key operator groups items from the pile such that we get an absolute-valued item as a key on the left and an array of all its occurences (with or without a minus sign) on the right.
┌─┬──────────┐
│3│3 3 3 3   │
├─┼──────────┤
│2│¯2 2      │
├─┼──────────┤
│4│4 4 4 4 4 │
├─┼──────────┤
│1│¯1 ¯1 1 ¯1│
└─┴──────────┘

Then we essentially do:
if the key is in the list of LRs:
    compute leftovers and pairs for LRs
else:
    compute leftovers and pairs for normal socks

After doing that for each row, we concatenate the columns (given to us in leftovers, pairs order) to a single array each and return those two arrays as a final result.
Leftovers for LRs:
We sum the items on the right and divide them by the key; this gives us a number of leftovers; we absolute-value that (since it can be negative, eg. -1 -1 1 -1 -> -2) and then replicate the key (with the right sign applied) that many times.
¯2 ¯2 2 ¯2   ⍝ +/ sum:
¯4           ⍝ ÷2 divide by key:
¯2           ⍝ |  absolute value:
2            ⍝ = number of times to replicate

¯2           ⍝ ×  get sign
¯1           ⍝ ×2 multiply by key:
¯2           ⍝ = item to replicate

2/¯2 ---> ¯2 ¯2

Pairs for LRs:
We sum the items on the right, divide that by the key and get the absolute value. That gives us number of leftovers. We subtract that from the original number of items, which gives us the number of paired items. We divide that by two to get the number of pairs. We repeat the key that many times (it's guaranteed to be positive).
¯2 ¯2 2 ¯2   ⍝ +/    sum:
¯4           ⍝ ÷2    divide by key:
¯2           ⍝ |     absolute value:
2            ⍝ (≢⍵)- subtract from count of items:
2            ⍝ ÷2    divide by 2:
1            = number of times to replicate

1/2 ---> 2

Leftovers for normal socks:
We count the items, take remainder after division by 2 (either 0 or 1 odd sock can be the leftover). By problem definition we're guaranteed this number is not negative. We repeat the key that many times.
2 2 2        ⍝ ≢  count:
3            ⍝ 2| mod by 2:
1            ⍝ = number of times to replicate

1/2 ---> 2

Pairs for normal socks:
We count the items, divide by two and round down. We repeat the key that many times.
2 2 2        ⍝ ≢  count:
3            ⍝ ÷2 divide by 2:
1.5          ⍝ ⌊  round down
1            ⍝ = number of times to replicate

1/2 ---> 2

R, 138 134 138 bytes
-2 bytes thanks to Giuseppe; +4 bytes to adhere to the output format
f=function(p,l,a={},b=a,z=p[1],w=abs(z))`if`(any(p),`if`(m<-match(z-2*z*w%in%l,y<-p[-1],0),f(y[-m],l,c(a,w),b),f(y,l,a,c(b,z))),list(a,b))

Try it online!
Recursive function.
Takes the first sock z off the pile, and searches the pile for either z or -z depending on whether w=abs(z) is in LR. If a match is found, adds w to the list of pairs and removes both socks from the pile before recursing, else adds z to the list of leftovers and recurses.
Ungolfed:
# p is pile of socks
# l is vector of LR socks
# a will be vector of pairs
# b will be vector of leftovers
f = function(p, l, a={}, b=a, z=p[1],  # initialize a and b as NULL; z is first sock of pile
               w=abs(z)}
  if(any(p)){                          # check that p is not empty (would mean end of recursion)
    y <- p[-1]                         # y is all socks except the first
    m <- match(z - 2*z*w%in%l,         # look for either z or -z depending on whether w=abs(z) is in l
             y, 0)                     # find position of first match in y; if no match is found, return 0
    if(m){                             # if a match was found
      f(y[-m], l, c(a, w), b)          # append w to a, remove the matching sock from y, and recurse
      } else {
        f(y, l, a, c(b, z))            # else append z to b and recurse
      }
    } else {
      list(a,b)                        # when p is empty, return a and b
  }
}

you can use {} in place of c() and sum(p|1) instead of length(p) to save 2 bytes.

@Giuseppe Thanks! I golfed it 2 bytes further: here, any(p) does what I need, since all entries are non-zero and I just want to check that p is not the empty vector.

Japt,  28 31  23 bytes
üa c_ca øV ?ZüÎyf:ZòÃül

Try it
Takes input as pile, labels.
Returns leftovers, every pair list.
üa                    group by same absolute value
   c_           Ã     for each group:
     ca øV ?              if labeled (using absolute values)
        ZüÎyf          - group by sign and transpose (saving only truthy values)
            :Zò        :  else slice every 2 elements
                ül    group the result by length

g1_cg1 no needed

It's allowed to output pairs as [[-1,1], [3,3], ...], so the second line is not necessary.

@Bubbler thanks! This saves a lot

Sorry to be the bringer of bad news again, but this seems to fail for [3, 3, -2, 2, 2, 2, 5] [1, 2]. It pairs the remaining 2s with null, instead of being in the Leftovers-pile.

@Kevin Cruijssen thanks for the patience ! Your help is always appreciated

Jelly, 25 23 bytes
AĠị$ŒHAf⁹Ɗ?Z$ƙ$ẎL=¥ƇⱮØ½

Try it online!
A dyadic link taking the socks as its left argument and LR list as its right. Returns a list of lists with the leftovers as the first sublist (each wrapped on its own in a list) and the pairs as the second sublist.
Thanks to @JonathanAllan for saving a byte!
Explanation
              $          | Following as a monad:
A           $ƙ           | - For each group of the sock list defined by the absolute of the sock list, do the following as a monad:
         Ɗ?              |   - If the following is non-empty:
      A                  |     - Absolute
       f⁹                |     - Filtered to keep only elememts in LR list
   $                     |   - Then:
 Ġị                      |      - Split into groups based on sign
    ŒH                   |   - Else: split into two (almost) equal halves
           Z             |   - Transpose
                Ẏ        | Join outermost lists together
                   ¥ƇⱮØ½ | Filter the list using the following as a dyad and each of [1, 2] as the right argument:
                 L       | - Length
                  =      | - Equals right argument

Save one with Ġị$ in place of Ṡ¹ƙ$ TIO

@JonathanAllan thanks!

JavaScript (ES6), 85 bytes
Takes input as (pile)(lr), where pile is an array and lr is an object.
Returns the pairs as a list and the leftovers as an object which may contain zero-count items.
a=>L=>[a.filter(x=>s[i=L[A(x)]?-x:x]?s[i]--:!(s[x]=-~s[x]),s={},A=Math.abs).map(A),s]

Try it online!

JavaScript (ES6), 99 bytes
Takes input as (pile)(lr), where pile is an array and lr is an object.
Returns two lists.
a=>L=>[a.filter(x=>~(i=s.indexOf(L[A(x)]?-x:x))?s.splice(i,1):!s.push(x),s=[],A=Math.abs).map(A),s]

Try it online!

Python 3.7, 183 Bytes
Try it online! Link includes uncommented version of code with the five test cases.
def f(p,l):
 a,b=[],[]          #a = pairs, b = loners
 while p:           #iterate through pile
  i=p.pop(0)        #remove and look at first sock in pile
  n=abs(i)          #Prepare to compare abs(i) to LR list
  #If there is a +ve/-ve pair from LR list
  if(-i in p)*(n in l):
   a+=n,            #Add to pairs
   p.remove(-i)     #Remove other half of pair from the pile
  #If there is a +ve/+ve pair not from LR list
  elif(n in p)*(not n in l):
   a+=n,            #Add to pairs
   p.remove(i)      #Remove other half of pair from the pile
  #Otherwise, add sock to loner list
  else:b+=i,
 return a,b         #Return the completed lists

This is my first attempt at a code golf challenge so feel free to comment on any obvious optimizations I have missed.
Cheers

Zsh, 179 177 bytes
typeset -A p l
for x (`<&0`)((l[$x]++))
for k;((p[$k]=l[$k]<l[-$k]?l[$k]:l[-$k],l[$k]-=p[$k],l[-$k]-=p[$k]))
a=({,-}$^@)
for k (${(k)l:|a})((p[$k]=l[$k]/2,l[$k]%=2))
typeset p l

Try it online!
Takes the sock pile on stdin, and the achiral pairs as arguments.
Due to Zsh's lack of filtering and mapping tools, we simply loop over the pile incrementing to create a sock->count map. Thankfully zero-count items are allowed; otherwise this would probably be in the 220-byte range, since filtering by value isn't easily done.
typeset -A p l            # declare p, l as associative arrays
for x (`<&0`)((l[$x]++))  # for each sock in the pile, increment that key of the leftover array
for k; {                  # for each argument (an achiral pair)
  ((p[$k]=l[$k]<l[-$k]?l[$k]:l[-$k]))  # set the paired array to the minimum of the l/r socks
  ((l[$k]-=p[$k],l[-$k]-=p[$k]))       # decrement the leftovers we just paired
}
a=({,-}$^@)               # if our achiral pairs were (2 3), set a=(2 -2 3 -3)
for k (${(k)l:|a})        # take the keys of the leftovers, remove all elements of a
  ((p[$k]=l[$k]/2,l[$k]%=2))    # divmod gets us the pairs and leftovers for the chiral socks
typeset p l               # using typeset to print the current definitions is shorter than
                          # using something like '<<<${(kv)p},${(kv)l}'

Perl 5, 151 bytes
sub f{
  $_="@{[sort{abs$a<=>abs$b}sort@{+pop}]}";
  ($p,@p)=sub{push@p,$1;''};
  for$l(@_){1while s/-($l) +$l\b/&$p/e}
  s/\b(\d+) \1\b/$1~~\@_?$&:&$p/ge;
  "@p",$_
}

Try it online!
...151 bytes with \n\s+ removed.

Charcoal, 58 bytes
Ｉ⟦↔Φθ⎇№η↔ι›№…θκ±ι№…θκι﹪№…θκι²Φθ⎇№η↔ι›№…θ⊕κι№θ±ι›﹪№θι²№…θκι

Try it online! Link is to verbose version of code. Outputs two double-spaced lists of newline-separated socks in a reproducible but unobvious order. Explanation:
Ｉ⟦

Cast both lists of socks to string for implicit print and double-space between the lists.
↔Φθ

Find the matched socks and print their absolute values so that we don't mix left and right socks in the output.
⎇№η↔ι

Is this a self-pairing sock?
›№…θκ±ι№…θκι

If not then it matches if there have been more opposite socks in the list so far (not including this sock, so at least as many opposite socks including this sock).
﹪№…θκι²

If it is then it matches if there have been an odd number of this type of sock so far (not including this sock). (If there are an odd number in total then this sock is actually matched against the next sock of this type.)
Φθ

Find the mismatched socks.
⎇№η↔ι

Is this a self-pairing sock?
›№…θ⊕κι№θ±ι

If not it is mismatched if the number of this type of sock so far (including this sock) is greater than the total number of opposite socks.
›﹪№θι²№…θκι

If it is then it is mismatched if this is the first of a total number of odd socks of this type.
Explanation for which socks get output as (mis)matches:
[[3, 3, -2, 4, -1, -1, 1, 4, 4, 3, 2, 3, -1, 4, 4], [1, 2]]

The 1 gets output as a match for the first -1 and the second and third -1 are output as mismatches.
The 2 gets output as a match for the -2.
The second and fourth 3s get output as matches for the first and third 3s.
The second and fourth 4s get output as matches for the third and fifth 4s, while the first 4 is a mismatch.

Ruby, 143 95 bytes
->a,l,*b{c=[];(s=a.index [w=a.pop,-w][l.count z=w.abs])?(a.slice!s;b<<z):c<<w while a[0];[b,c]}

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Interpreting the Wolfram Code
Introduction
An elementary cellular automaton is a cellular automaton that is 1-dimensional and has 2 states, 1 and 0. These cellular automata are categorized based on a simple code: the Wolfram code, invented by Stephen Wolfram (yes, the Wolfram | Alpha guy). It works like this:

First, you the set of all possible states for a cell and its 2 neighbors; this gives you 8 (2^3) states. You then arrange them in order (in this case) from left to right, so you have 000, 001, 010, 011, 100, 101, 110, and 111.
Then, for each state, you take the resulting state of the center cell, either a 0 or 1. Then, you are left with 8 bits.
You can guess what you do next: you combine the 8 bits into a single 1-byte number. This gives you 255 possible cellular automatons.

Challenge
Given the Wolfram code number of a cellular automaton and a 3-bit state, you must write a program that will output the state of the center cell for that state.

The two integers may be taken from any input method that is convenient (ie. variable, stdin, command line arguments, function arguments) Input can be taken as any type, as long as that type is capable of representing integers. For example, you could take input as an array of digits, a string, or an integer. Input can be in any base you want.
The output may also be in any convenient method (ie. variable, stdout, exit code, return value) The only restriction is that the use must be able to see the output (no outputting to /dev/null). Output can be given as any type as well.

Example I/O

Number: 255, State: 101
  States: 1, 1, 1, 1, 1, 1, 1, 1
  Output: 1

Number: 129, State: 110
  States: 1, 0, 0, 0, 0, 0, 0, 1
  Output: 0

Number: 170, State: 001
  States: 1, 0, 1, 0, 1, 0, 1, 0
  Output: 0

Rules
This is code-golf, so shortest answer in bytes wins!

Now our task is to search for a duplicate of indexing.

You've had a number of questions that have been unclear, duplicates or turned out to be extremely trivial like this one. Have you considered posting your questions in the Sandbox for a couple of days in order to iron out some of the kinks beforehand?

Haskell, 4 bytes
The number is taken as a binary string and the state is taken as a (decimal) integer. This let us use the state as an index to the number, which immediately results in the desired output. So this answer just consists of an indexing function !!.
(!!)

Try it online!

05AB1E, 1 byte
Based on @flawr's previous MATL answer. Remember to give them an upvote! (Note: this takes input in a reversed order.)
è

Try it online!

Your TIO input is incorrect. It should be this instead. Right now you're indexing the 5 into the string "\"10000001\"" (coincidentally resulting in 0 as well). Here perhaps a better example to illustrate the current issue. Although I'm not sure why having those quotes around the first input somehow reverses the input-order (weird bug).. The first input should index into the second. So simply removing the quotes would use 10000001 to index into 5, which of course results in 5.

APL (Dyalog Classic), 8 bytes
I don't know how to set this to a callable function or turn it into a full program. (Based on @flawr's Haskell answer, remember to upvote them!)
Format: 'state' {⍺[⍵+1]} number
{⍺[⍵+1]}

Try it online!

APL has a function for indexing, ⌷. You may also want to consider setting indexing to 0-based to better fit with the question

Keg, 5 SBCS bytes
-2 bytes from Jono 2906 via the -hr flag
?(¿|_

Try it online!

GolfScript, 2 bytes
~=

Try it online!
Explanation
~  # Dump the input onto the stack
 = # Index

JavaScript (Node.js), 34 bytes
(n)=>(s)=>n.toString(2)[+('0b'+s)]

Try it online!
Pretty sure the toString(2) call can be golfed better.

Wren, 17 bytes
Based on @flawr's previous JavaScript answer. Remember to give them an upvote!
Fn.new{|a,b|a[b]}

Try it online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Play Big 2 by yourself, as fast as you can
Introduction
Big 2 is a card game popular in East Asia and South East Asia, in which 4 players are dealt 13 cards each (ie, an equal division of a standard deck without jokers). The goal is to empty your hand before any of the other players. Players take turns playing combinations of a Big 2 subset of standard poker hands until their hands are empty. When cards are played, they are considered to be in a discard pile and cannot be reused.
The challenge here is to determine the fewest number of poker hands needed to completely empty a starting hand assuming that there are no other players. In other words, given 13 cards, produce a list of the poker hands that would empty your hand the fastest (ie, the fewest number of 'turns').
Challenge
Given a list of 13 cards of the format <rank><suit>, produce a delimited combination of Big 2 poker hands that would allow the player to empty their hands as fast as possible. Assume that the given hand can be realistically produced from a single deck of cards (ie, you won't receive 10 aces in your hand).
Inputs

An unsorted list of 13 cards, meaning that the ranks and suits are not in any patterned/sorted order

The ranks can be any of A,2,3,4,5,6,7,8,9,0,J,Q,K, where '0' is a 10. You may use rank 10 in your program if that suits you better.
The suits can be any of D,C,H,S, which correspond to diamonds, clubs, hearts, and spades, respectively.
Sample cards would be AD for ace of diamonds, or 0H for 10 of hearts.

For this example, the inputs are separated by commas, but you can delimit the string however you like, or even use an entirely different representation of a deck of cards that suits your fancy

Outputs

A list (or some delimited string) of cards that indicate play order of your cards. For example the following output formats are valid:
2H, 3D, 4H, 5C, 6S
7S, 7D, 7H
0D, JD, QD, KD, AH

or [[2H, 3D, 4H, 5C, 6S], [7S, 7D, 7H], [0D, JD, QD, KD, AH]]
or 2H3D4H5C6S, 7S7D7H, 0DJDQDKDAH
or anything else that can delineate hand combinations (aka convenient inputs and outputs)

All three sample outputs indicate that 13 cards were played in the following order: a straight from 2-6, a triplet of 7s, and then a straight from 10-A
When outputting a 5 card combination, such as for straights or full houses, the cards' ranks/suits do not have to be sorted or grouped in any way - they're mostly shown here for legibility. For example, the straight 2S3S4S5S6S is equivalent to 6S4S2S5S3S. (23456 == 64253)
The actual order of moves does not matter as cards cannot be reused anyways

Big 2 Poker Hands
In Big 2, the following poker hands are legal:

A single card
A pair of cards, meaning two cards of the same rank regardless of suit
A triplet of cards, meaning three cards of the same rank regardless of suit
A straight, a 5 card combination of consecutive ranks regardless of suit.

Straights cannot start from a jack, queen, or king (ie, the straights of ranks (regardless of suit) JQKA2, QKA23, and KA234 are invalid)
Straights can start from any other rank
Aces can either be the high card or the low card in a straight, but it cannot appear in the middle of a straight. Namely, the only 2 valid straights that include an ace are 0JQKA and A2345.

A full house, a 5 card combination made of three cards of the same rank, and 2 cards of the same, but different rank.

For example, 000QQ is a full house with triplet 10s and a pair of queens, but the combination 000KQ is invalid because a pair is needed to complete the triplet

A quad, a 5 card combination made of four cards of the same rank, plus any card of a different rank
A flush, a 5 card combination of 5 cards of the same suit regardless of rank
And just for completion's sake: a straight flush, a 5 card combination where the 5 cards are a straight in terms of ranks but also share the same suit.

Note the straight flush can be computed from either the definition of a straight or a flush, meaning its own distinct definition here isn't necessary for the completion of this challenge.

Tests
Input: AS,4H,6D,8C,7C,3S,5H,8D,4C,2S,0C,AD,AH
Sample output: ASAHAD8D8C, 2S3S4H5H6D, 4C, 7C, 0C OR 7C, 2S6D3S5H4H, 0C, 4C, 8C8DASAHAD
Explanation: Given the above input, it's possible to generate 2 distinct 5-card combination poker hands. After we play those 2 hands, we only have 3 remaining singles. Thus, the minimum amount of hands we must play is 5. Again, the output card hand combinations do not have to be sorted or played in this specific order (or even in this format) - just leaving it here for legibility.

Input: 2D,0H,5S,0S,4H,AS,4C,6C,6H,KC,8H,5H,8S
Sample output: 5S5H, 4H4C, 0S0H, 6C6H, 8H8S, KC, AS, 2D
Explanation: In this case, it is faster to output 5 pairs instead of a flush (of 5H4H0H6H8H) because the flush would create 5 dangling single cards that must be played one at a time. Playing the flush would yield 9 turns (1 for flush + 5 singles created from flush + 3 standalone singles), whereas the pair method would require 8 turns (5 turns for 5 pairs, 3 for the leftover singles)

Input: 4D,4S,4H,4C,5H,5D,5C,5S,9S,9D,9H,9C,AD
Sample output: 4D4S4H4CAD, 5D5H5C5S9S, 9D9H9C
Explanation: Outputting quads using the dangling AD is more efficient than picking the quad's last card from another quad because we can finish off with a triplet.
Rules

Standard loopholes are forbidden
Convenient inputs and outputs are allowed
This is codegolf, so shortest code in bytes wins

Ah yeah, you're good on the outputs. In the outputs section I wrote a little blurb "or anything else that can delineate hand combinations", but I'll add that to the end too to hopefully make it clearer.

Welcome to the site. Personally I think this is a really nice and well specified challenge. Might well have a go tomorrow if I have time.

@Arnauld Hmmm... personally I think that using an integer representation of cards is fine (ie, the 298-byte version is fine) because you'd have to spend bytes mapping the cards anyways. To be honest, I haven't looked too much into other card game codegolf challenges to see how they handled it, but imo it's fine.

Ok. Thanks for clarifying. :)

Suggested test cases: 2D,7D,8S,AS,2C,9D,5D,2S,AC,0D,8C,8H,5H: flush, full house, pair, single; 5D,2H,4S,QH,9S,2D,9C,JH,0S,AC,KS,JS,3S: special straight A2345, straight 9 to K (the ace must not be used in that one), 3 singles

JavaScript (ES6),  298 ... 256  253 bytes
Takes input as a list of integers in \$[0..51]\$, where the suit is encoded in the 2 least significant bits and the rank in the 4 upper bits.
Returns a list of lists in the same format.
f=(a,k=2)=>(F=(a,H=[])=>H[k]?a+a?0:O=H:a.reduce((a,x)=>[...a,...a.map(y=>[...y,x])],[[]]).some(h=>[b=c=m=s=0,h.map(x=>(c++,b+=m!=(m|=1<<x/4),s|=1<<x%4)),b<2,b<2,,b<3|m==4111|m==31*(m&-m)|8%s<1][c]&&F(a.filter(n=>!h.includes(n)),[...H,h])))(a)?O:f(a,k+1)

Try it online!
This is rather inefficient when more than 5 or 6 turns are required. The 2nd test case completes in a bit less than 2 minutes on my laptop and times out on TIO.
How?
Wrapper code
The wrapper code invokes the search function \$F\$ for a maximum number of turns \$k+1\$. This threshold is incremented until the call is successful. We start with \$k=2\$ because we need at least 3 turns to get rid of all cards.
f = (                 // f is the main function taking:
  a,                  //   a[] = list of cards
  k = 2               //   k   = maximum number of turns, minus 1
) =>                  //
  (F = ...)(a) ?      // invoke the search function F; if successful:
    O                 //   return the output
  :                   // else:
    f(a, k + 1)       //   try again with k + 1

Generating the hands
In the search function, we first build the powerset of the input \$a[\:]\$:
a.reduce((a, x) =>
  [ ...a,
    ...a.map(y => [...y, x])
  ],
  [[]]
)

That is, we build all possible hands, including invalid ones made of more than 5 cards.
Hand variables
We then iterate over each hand \$h\$, and each card \$x\$ in this hand to set up the following variables:

\$c\$ is the number of cards in the hand
\$m\$ is a 13-bit rank bitmask
\$s\$ is a 4-bit suit bitmask
\$b\$ is the number of bits set in \$m\$, i.e. the number of distinct ranks in the hand

h.map(x => (       // for each card x in h[]:
  c++,             //   increment c
  b +=             //   increment b if
    m != (         //   the current value of m is different from
      m |=         //     the updated value of m
        1 << x / 4 //     where the new rank bit is set
    ),             //
  s |= 1 << x % 4  //   update s with the suit bit
))                 // end of map()

Example

a random hand, courtesy of random.org
c = 5

m = 0101010010000 (binary value)
     K J 9  6

b = 4

s = 1110 (binary value)
    SHD

Hand validation
We finally figure out whether the hand is valid by picking the result of the relevant test from a lookup table, according to the number of cards \$c\$:

\$0\$ card: always invalid (variables are initialized to \$0\$ in this slot)
\$1\$ card: always valid (the above map() is performed in this slot and returns a truthy value)
\$2\$ cards: valid if \$b<2\$ (there's only one rank, which means that we have a pair)
\$3\$ cards: valid if \$b<2\$ (there's only one rank, which means that we have a three-of-a-kind)
\$4\$ cards: always invalid (undefined slot)
\$5\$ cards, valid if:

\$b<3\$ because both a quad + another card and a full house lead to \$b=2\$ (two distinct ranks in the hand) while all other patterns result in \$b\ge3\$
OR \$m=4111\$ (1000000001111 in binary), which represents the special straight A,2,3,4,5
OR \$m\$ has 5 consecutive bits set, which means that we have a standard straight
m == 31 * (m & -m)

OR \$s\$ has only one bit set, which means that we have a flush
8 % s < 1

more than \$5\$ cards: always invalid (undefined slots)

Recursion
If the hand is valid, we do a recursive call to \$F\$ with all cards in \$h[\:]\$ removed from \$a[\:]\$.
F(                  // recursive call:
  a.filter(n =>     //   keep only in a[] ...
    !h.includes(n)  //     ... the cards that do not appear in h[]
  ),                //
  [...H, h]         //   append h[] to the list of hands
)                   // end

We know that we have reached the maximum number of turns when \$H[k]\$ is defined. If we have no more cards when this happens, it means that \$H\$ is a valid list of hands, which is saved in the output variable \$O\$ and eventually returned by the wrapper code.

05AB1E, 38 bytes
{æʒ€þ©Ùgyg5Qi3‹y€áË®¥ć8%šPΘ)à]æé.Δ˜I¢P

Try it online!
Input/output uses 1 for Ace, 10 for 10, 11 for Jack, 12 for Queen, 13 for King.
Runtime is exponential in the number of possible hands, making it timeout for all test cases. The TIO link shows an 8 card input, but the algorithm would theoretically work for inputs of any size, including the specified 13.
# The first step is to get a list of all valid hands

{                               # sort the input
 æ                              # all subsets of the input (aka all hands)
  ʒ                          ]  # filter:
   €þ                           #  get the rank of each card in the suit
     ©                          #  save that in the register, without popping
      Ù                         #  uniquify
       g                        #  length (=> number of distinct ranks in the hand)
        yg5Qi                ]  #  if the hand has exactly 5 cards:
             3‹                 #   is the number of distinct ranks < 3? (full house or quad)
               y€áË             #   are all suits of the hand equal? (flush)
                   ®¥           #   deltas of the list of ranks (restored from the register)
                     ć8%š       #   mod 8 the first one (to handle the A0JQK case)
                         PΘ     #   is the product equal to 1? (straight)
                           )    #   wrap those three tests in an array
                            à   #   keep the hand if the maximum is 1 (one of the tests was true)
                                #  else (implicit):
                                #   keep the hand if number of distinct ranks is 1
                                #   this catches singles, pairs, and triplets

æ                               # get all subsets of the list of valid hands
 é                              # sort those subsets by length
  .Δ                            # find the first one such that:
    ˜                           #  deep flattened
     I¢                         #  count occurences of each card of the input in the result
       P                        #  product is 1


text:
I shift the source code, you shift the input!
Sandbox
A spin-off of a rip-off of a  rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you accept it, is to write a program/function that outputs/returns its input/argument. The tricky part is that if I left shift your source code, the output must be left shifted too. Likewise, if I right shift your source code, the output must be right shifted too.
Source code will only be shifted once in each direction (in other words, only one shift will be applied, meaning that there are only three possible programs that need to be run). Consequently, the minimum source length should be 3.
Examples
Let's say your source code is ABC and the input is xyz. If I run ABC, the output must be xyz. But if I run BCA instead, the output must be yzx. And if I run CAB, the output must be zyx.
Let's say your source code is EFG and the input is Hello. If I run EFG, the output must be Hello. If I run GEF, the output must be oHell.  And if I run FGE, the output must be elloH.
Let's say your source code is abcde and the input is 2019. If I run abcde, the output must be 2019. But if I run eabcd instead, the output must be 9201. And if I run bcdea, the output must be 0192.
Rules

The program must print the entire output shifted in the specified direction
Input can be taken in any convenient format.
Output can be in any convenient format as well.
Standard Loopholes are forbidden.
Source length should be at least 3 characters long, as to allow for unique shifted programs.

Scoring
This is code-golf so the answer with the fewest amount of bytes wins.
Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=196864;
var OVERRIDE_USER=78850;
var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(d){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(d,e){return"https://api.stackexchange.com/2.2/answers/"+e.join(";")+"/comments?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){answers.push.apply(answers,d.items),answers_hash=[],answer_ids=[],d.items.forEach(function(e){e.comments=[];var f=+e.share_link.match(/\d+/);answer_ids.push(f),answers_hash[f]=e}),d.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){d.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),d.has_more?getComments():more_answers?getAnswers():process()}})}getAnswers();var SCORE_REG=function(){var d=String.raw`h\d`,e=String.raw`\-?\d+\.?\d*`,f=String.raw`[^\n<>]*`,g=String.raw`<s>${f}</s>|<strike>${f}</strike>|<del>${f}</del>`,h=String.raw`[^\n\d<>]*`,j=String.raw`<[^\n<>]+>`;return new RegExp(String.raw`<${d}>`+String.raw`\s*([^\n,]*[^\s,]),.*?`+String.raw`(${e})`+String.raw`(?=`+String.raw`${h}`+String.raw`(?:(?:${g}|${j})${h})*`+String.raw`</${d}>`+String.raw`)`)}(),OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(d){return d.owner.display_name}function process(){var d=[];answers.forEach(function(n){var o=n.body;n.comments.forEach(function(q){OVERRIDE_REG.test(q.body)&&(o="
"+q.body.replace(OVERRIDE_REG,"")+"
")});var p=o.match(SCORE_REG);p&&d.push({user:getAuthorName(n),size:+p[2],language:p[1],link:n.share_link})}),d.sort(function(n,o){var p=n.size,q=o.size;return p-q});var e={},f=1,g=null,h=1;d.forEach(function(n){n.size!=g&&(h=f),g=n.size,++f;var o=jQuery("#answer-template").html();o=o.replace("{{PLACE}}",h+".").replace("{{NAME}}",n.user).replace("{{LANGUAGE}}",n.language).replace("{{SIZE}}",n.size).replace("{{LINK}}",n.link),o=jQuery(o),jQuery("#answers").append(o);var p=n.language;p=jQuery(""+n.language+"").text().toLowerCase(),e[p]=e[p]||{lang:n.language,user:n.user,size:n.size,link:n.link,uniq:p}});var j=[];for(var k in e)e.hasOwnProperty(k)&&j.push(e[k]);j.sort(function(n,o){return n.uniq>o.uniq?1:n.uniq<o.uniq?-1:0});for(var l=0;l<j.length;++l){var m=jQuery("#language-template").html(),k=j[l];m=m.replace("{{LANGUAGE}}",k.lang).replace("{{NAME}}",k.user).replace("{{SIZE}}",k.size).replace("{{LINK}}",k.link),m=jQuery(m),jQuery("#languages").append(m)}}
body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}
  <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654">

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}

{{LANGUAGE}}	{{NAME}}	{{SIZE}}

Is I/O flexible? May input and output be a vector of characters?

@RobinRyder updated the question to allow flexible IO

Is trailing whitespace acceptable?

Trailing and leading whitespace are both acceptable.

For that matter, comments are allowed as well.

How is the empty string shifted?  Does it even have to be handled?

What about newlines?

Going from ABC to BCA or CAB is rotating, not shifting.

Haskell, 51 bytes
midm(a:b)=b++[a]
i=(:).last<*>init
main=interact id

Try it online!
Explanation
Our main function is just interact of a another function.  By default it is id which just returns the input, but if we shift we either add an m to make idm or remove the d to make i.  Both of which we have defined to be roll left and roll right.

Right shift doesnt seem to work? Might just be tio

@frank That looks like it is working, the last character there is a newline which is being shifted to the front.

Oh I see, didnt notice the newline haha

05AB1E, 4 bytes
À\Á\

Try it online
ry it shifted towards the leftT
tTry it shifted towards the righ
Explanation:
À     # Shift the (implicit) input once towards the left
 \    # Discard it from the stack
  Á   # Shift the (implicit) input once towards the right
   \  # Discard it from the stack
      # (output the implicit input implicitly as result)

\     # Discard (no-op, since the stack is already empty)
 À    # Shift the (implicit) input once towards the left
  \   # Discard it from the stack
   Á  # Shift the (implicit) input once towards the right
      # (and output this right-shifted input at the top of the stack implicitly as result)

\     # Discard (no-op, since the stack is already empty)
 Á    # Shift the (implicit) input once towards the right
  \   # Discard it from the stack
   À  # Shift the (implicit) input once towards the left
      # (and output this left-shifted input at the top of the stack implicitly as result)

R, 82 75 67 62 bytes
-4 bytes thanks to Giuseppe.
!-1->i
c(tail(s<-el(strsplit(scan(,""),"")),1/i),head(s,-i))#!

Try it online!
ry it online!T
!Try it online
Uses rightwards assignment -> (this is only the 2nd time I have ever used rightwards assignment). The value of i is either 0, 1 or -1 depending on the shift. This is used to give the correct output:

when i=1, tail(s, 1) gives the last element and head(s, -1) gives all elements but the last
when i=-1, tail(s, -1) gives all elements but the first and head(s, 1) gives  the first element
when i=0, tail(s, Inf) gives s and head(s, 0) gives the empty vector.

I think your first head(s,1) should be head(s,-1), but this is yet another rocking good answer with the ->.

@Giuseppe You are right about the typo in the explanation, thanks!

OK, I think this should work for 63 bytes: Try it online!

@Giuseppe Thanks! I'd been trying things along those lines, but couldn't get it right. I got it down to 62 from your version.

Pyth, 18 bytes
?.<Q1 Q ;*.>Q1qk"

Try it online!, Right-shift, Left-shift
Pretty proud of this one. Has a trailing newline except on right shift. Makes use of the fact that a space before a pyth expression suppresses the output. Note the last byte is a space.
How it works
?.<Q1 Q ;*.>Q1qk" - Unshifted
?.<Q1                - If the input left-shifted is truthy
      Q ;            - Print the input, end if statement
         *.>Q1       - Right shifted input, multiplied by...
              qk"    - whether k (an empty string) is equal to the string at the end.
                       Since there is a space at the end, y(Q) is multiplied by zero.

.<Q1 Q ;*.>Q1qk" ? - Left Shifted
.<Q1               - Left shift the input and print it.
     Q             - This input is preceded by a space and as such does not print
               " ? - Obviously is not equal to an empty string (Pyth
                     closes strings implicitly)

 ?.<Q1 Q ;*.>Q1qk" - Right Shifted
 ?.<Q1 Q ;         - The space before the if statement suppresses the printing
                 " - Since the space has been removed from the end, the
                     terminating string is now an empty string, and y(Q) is printed

APL (Dyalog Unicode), 15 11 bytesSBCS
-4 thanks to inspiration from Luis Mendo's solution.
Full program, prompting for input via stdin.

1⊢⍞⌽⍨¯2+≢1⍬

Try it online!
1⍬ the list [1,[]]
≢ tally the elements in that; 2
¯2+ add negative two to that; 0
…⌽⍨ cyclically rotate the following by that number of steps:
 ⍞ stdin
1⊢ yield that, ignoring the 1

⊢⍞⌽⍨¯2+≢1⍬1

ry it online!T
1⍬1 the list [1,[],1]
≢ tally the elements in that; 3
¯2+ add negative two to that; 1
…⌽⍨ cyclically rotate the following by that number of steps:
 ⍞ stdin
⊢ yield that

⍬1⊢⍞⌽⍨¯2+≢1

!Try it online
1 the number 1
≢ tally the elements in that; 1
¯2+ add negative two to that; -1
…⌽⍨ cyclically rotate the following by that number of steps:
 ⍞ stdin
⍬1⊢ yield that, ignoring the list [[],1]

JavaScript (Browsers), 81 68 66 bytes
xx=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//x

Original solution (81 bytes)
tob=-1;try{ob;atob=1}catch(e){}w=prompt();alert(w.slice(atob)+w.slice(0,atob))//a

No TIO link because it works only in browsers with atob function defined.
In order to show the output in a more friendly way, prompt and alert are overridden in the screenshot below.

Explanation
The declarations of x and xxx are hoisted to the beginning automatically, so the declarations won't clear the values assigned beforehand.
No rotation
xx=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//x

// xx = 1, so a = 0, so we have alert(w.slice(0)+w.slice(0,0))

Left rotation
x=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//xx

// x = 1, so a = 1, so we have alert(w.slice(1)+w.slice(0,1))

Right rotation
xxx=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//

// xxx = 1, so a = -1, so we have alert(w.slice(-1)+w.slice(0,-1))

Python 2, 64 bytes
bc=k=input()
print[k,k[1:]+k[0],k,k[-1]+k[:-1]][len(dir()[5])]#a

Try it online!, !Try it online and ry it online!T
dir is a builtin function that returns a list of all variable names. The length of the first variable name is used to choose the right output.

I think print k[2-len(dir()[5]):]+k[:2-len(dir()[5])] saves 4 bytes and then there's a further obvious 10-byte saving.

C (gcc), 109 86 83 bytes
-20 bytes thanks to xibu
Takes the text to display is a command line argument. The active code is bookended by newlines, having the result of changing what __LINE__ evaluates to when shifting the code. This means 2-__LINE__ will be +1 for shifting left, 0 for no shift, and -1 for shifting right.
No shift

K;main(L,s)char**s;{for(L=strlen(s[1]);K<L;)putchar(s[1][(K+++2-__LINE__+L)%L]);}

Try it online!
Left shift
K;main(L,s)char**s;{for(L=strlen(s[1]);K<L;)putchar(s[1][(K+++2-__LINE__+L)%L]);}

Try it online!
Right shift

K;main(L,s)char**s;{for(L=strlen(s[1]);K<L;)putchar(s[1][(K+++2-__LINE__+L)%L]);}

Try it online!

You can shorten the console print of your function by 20 bytes I,L,K;main(S,s)char**s;{K=L=strlen(s[1]);for(I=2-__LINE__+L;K--;)putchar(s[1][I++%L]);}

@xibu Nice one!

82

Japt, 4 bytes
ÉUé0

Try it

0ÉUé
Ué0É

Works with arrays too.
ÉUé0
Ué0É
0ÉUé

Python 3, 52 48 bytes
Base code:
"i=1#";i=0#';i=-1
a=input()
print(a[i:]+a[:i])#'

Try it online!
Left shift:
i=1#";i=0#';i=-1
a=input()
print(a[i:]+a[:i])#'"

ry it online!T
Right shift:
'"i=1#";i=0#';i=-1
a=input()
print(a[i:]+a[:i])#

!Try it online
Comments in code are useful :)

C (gcc), 96 94 bytes
-2 bytes thanks to gastropner

BC=1;C;ABC;S,K;main(N,c)char**c;{K=S=strlen(c[1]);for(N=C-ABC+S;K--;)putchar(c[1][N++%S]);}//A

Try it online!
explanation:
BC=1;       // declare and set variable ABC, BC or C (depending on shift)
C;ABC;      // declare possible variable names
            // existing variables are not changed, newly declared variables are set to 0

int main(int NumArgs,char** c)
{
    char* input = c[1];

    int S = strlen(input);      // string length used for modulo
    int K = S;                  // string length used to count characters
    int I = C - ABC + S;        // set start of output

    for(;K--;)                  // display K characters
        putchar(input[I++%S]);  // display character and move read position
}
//A                             // A used to create valid variable name in first line

Elegant! You can shave another 2 bytes off by using N instead of I: BC=1;C;ABC;S,K;main(N,c)char**c;{K=S=strlen(c[1]);for(N=C-ABC+S;K--;)putchar(c[1][N++%S]);}//A

91

MATL, 9 8 bytes
TFsqYS%T

Try it online! See also right-shifted and left-shifted versions.
How it works
Normal version:
TF    % Push array [true, false]
sq    % Sum; subtract 1. Gives 0
YS    % Implicit input. Circular shift by that amount. Implicit display
%T    % Comment. Ignore rest of line

Right-shifted version:
TTF   % Push array [true, true, false]
sq    % Sum; subtract 1. Gives 1
YS    % Implicit input. Circular shift by that amount. Implicit display
%     % Comment. Ignore rest of line

Left-shifted version:
F     % Push array [false]
sq    % Sum; subtract 1. Gives -1
YS    % Implicit input. Circular shift by that amount. Implicit display
%TT   % Comment. Ignore rest of line

Runic Enchantments, 7 bytes
@{͍{͍

Try it online!
Input is limited to a single string (spaces need to be escaped).
This is the best I can come up with. It is not a full program, but instead a function (see the header on TIO for the entry, stdin handling, and Branch).
This also relies on treating each cell of the function as a single object.
Alternatively this works on space separated inputs and doesn't require modifier characters, but outputs them all with no separator.
Without those concessions, the challenge would be impossible in Runic, due to having explicit input and output, as well as a termination command (eg. sample program i@}, if it was rotated two to the right to @}i, the program would terminate without reading or outputting anything; with an explicit entry point, the program could not distinguish its own rotation).

If I shift it to {@{͍ the output stays xyz? I don't know the language, maybe my fault.

@findusl That's what I meant by treating each cell as a rotation, rather than unicode code points (you accidentally'd one of the ͍). You're looking for this. This is because { rotates's the IP's stack, but {͍ rotates the string on the top of the stack.

Javascript, 63 40 39 bytes
Thanks to @Shaggy and @l4m2, it's now 39 bytes.
0;f=x=>x.slice(o)+x.slice(0,o);o=~-0b01
Explanation
The last line of this snippet assigns the variable o to either -1+0b0, -1+0b01, or -1+0b010. The 0b prefix is used to define a binary literal, causing those to evaluate to -1, 0, or 1, which then gets used inside the function.
Here are try-it-now versions:
Not Shifted

Left Shifted

Right Shifted

History
Original version
0;x=prompt();onload=_=>alert(x.slice(o)+x.slice(0,o));o=-1+0b01
A value gets assigned to o on the last line, but we need it in the middle of the code, so we called a function with a delay (by attaching it to the onload event) in order to do so.
After @Shaggy suggestion to accept I/O from a function
0;f=x=>x.slice(o)+x.slice(0,o);o=-1+0b01
After @l4m2's suggestion to use ~- to subtract 1, instead of -1+ (the current solution).
0;f=x=>x.slice(o)+x.slice(0,o);o=~-0b01

Welcome to the site :) You could get this down to 40 bytes by using a function: https://tio.run/##y0osSyxOLsosKNHNy09J/f/fwDrNtsLWrkKvOCczOVUjX1MbxjTQyde0zrfVNdQ2SDIw/J@cn1ecn5Oql5OfrpGmoVRRWaWkqclFpG4DLuzaDYm0Hrv2/wA

.-1+ => ~-.

Wolfram Language (Mathematica), 33 bytes
0+#~RotateLeft~Log10[.1$]&/.$->10

Try it online!

Ruby, 72 bytes
aa,a,aaa,g=0,-1,1,gets
f=->s,a{(g*3)[s+a..-s+a-1]}
puts f.call g.size,aa

Try it online!
a,a,aaa,g=0,-1,1,gets
f=->s,a{(g*3)[s+a..-s+a-1]}
puts f.call g.size,aaa

Try it online!
aaa,a,aaa,g=0,-1,1,gets
f=->s,a{(g*3)[s+a..-s+a-1]}
puts f.call g.size,a

Try it online!
Triplicates the input then takes a middle substring, shifted according to whether the source code was shifted. Doesn't take kindly to empty input, unfortunately.
Ruby actually has a built-in rotate function, there might be a way to use this but it only works on arrays and not strings.

Charcoal, 8 bytes
←→Ｆθ§θⅈ←

Try it online! Link is to verbose version of code. Explanation:
←           Move cursor left (decrement X-position)
 →          Move cursor right (increment X-position)
  Ｆ         For each character of
   θ        Input string
    §       Implicitly print cyclically indexed character
     θ      Input string
      ⅈ     Current X-position
       ←    Move cursor left (no-op)

Rotating the code simply causes the X-position to start at 1 or -1 appropriately thus causing the characters of string to be output cyclically offset, however Charcoal does not include the cursor movement in the output.
→Ｆθ§θⅈ←←

ry it online!T Link is to verbose version of code.
←←→Ｆθ§θⅈ

!Try it online Link is to verbose version of code.

Klein 000, 59 53 bytes
Original
@>:?!\)>):?!\?@
\(  / \$
/(   \ /)  \
>$:?!/?>:?!/?@/

Try it online!
Left-Shifted
>:?!\)>):?!\?@
\(  / \$
/(   \ /)  \
>$:?!/?>:?!/?@/@

Try it online!
Right-Shifted
/@>:?!\)>):?!\?@
\(  / \$
/(   \ /)  \
>$:?!/?>:?!/?@

Try it online!

This requires topology 000 for some small byte saving measures.  For a version that works on any topology see the 59 byte version in the history.

Perl 5 -p, 37 bytes
's/(.)(.*)/\2\1/;';";s/(.*)(.)/\2\1/"

Try it online!
Left shift
s/(.)(.*)/\2\1/;';";s/(.*)(.)/\2\1/"'

Try it online!
Right shift
"'s/(.)(.*)/\2\1/;';";s/(.*)(.)/\2\1/

Try it online!

Attache, 12 bytes
0&~Rotate??~

Try it online!
Returns a function.
Explanation
Rotate is a function which does string rotation. ~Rotate reverses the argument order. x& binds the x to the left argument of the given function. ??~ is a comment (?? marking the start of it). So, this returns a function which, given y, returns Rotate[y, x]—rotating y by x degree.
For the case of no rotation, this rotates the string by 0.
When rotated once right, this becomes:
~0&~Rotate??

Which is the same as the above, except this time it's Rotate[y, -1], which performs the desired transformation.
If instead we rotate left once, it becomes:
&~Rotate??~0

&, when used in a unary context such as this, will, if given an array as input, apply the each element of the array as an argument for the function. However, the argument is a string, and this is effectively a no-op. Thus, Rotate[y, x] has no right argument; by default, it is 1, so this performs the desired transformation.

Crystal, 52 bytes
Unshifted
25.tap{|n|puts gets.to_s.chars.rotate(n%3-1).join}#2

Try it online!
Left-Shifted
5.tap{|n|puts gets.to_s.chars.rotate(n%3-1).join}#22

Try it online!
Right-Shifted
225.tap{|n|puts gets.to_s.chars.rotate(n%3-1).join}#

Try it online!
Crystal's Object#tap passes the object into the following block. Then we get the input, guarantee it's a string, get an array of that string's characters, and then rotate. We rotate by the number at the beginning, modded by three and then subtracted by 1 (with the number at the beginning "chosen" based on convenient modulo properties).

Jelly, 9 bytes
10%3Cṙ@ḷ4

Try it online!
A monadic link taking a Jelly string and returning the processed Jelly string.
All three variations

Pxem, Content: 0 bytes + Filename: 75 bytes.

Filename (escaped): X.c.Z.w.i.c\001.+.a.s.v.t.p.m.o.d.A.c.Z.w.o.i.c\001.+.a.d.A.w.i.c\001.+.a.s.t.v.m.pX

Try it online!
!Try it online
ry it online!T
With comments
??.z
# number of X's, as literals branches
.a??X.z
# if not empty; then pop; else enter here
.a.c.Z??.z
  # push while EOF
  .a.w.i.c\001.+.a??.z
  # pop; reverse; pop to heap; pop all to print; push heap; pop to print; exit
  .as.v.t.p.m.o.d??.a
.a.A??.z
# if not empty; then pop; else enter here
.a.c.Z??.z
  # cat; as in my previous post
  .a.w.o.i.c\001.+.a.d??.z
.a.A??.z
# and finally
.a.w.i.c\001.+.a.s.t.v.m.pX

brainfuck, 112 75 bytes
+<,[>[>+<-],]+>[-[<<.[-]<[<]>[.[-]>]]<[-<<[<]>[.>]]>]<[-<[<]>>[.>]<[<]>.<]+

Try it online!
!Try it online
ry it online!T


text:
Smallest Fibonacci Multiples
Sandbox
Background (not necessary for the challenge)
A standard number theory result using the pigeonhole principle is the fact that given any natural number k, there is a Fibonacci number that is a multiple of k.
We can see this by considering modular pairs (F(n-1) % k, F(n) % k), and noting that there are only a finite number of possibilities of the pairs, while there are infinitely many pairs, so by the pigeonhole principle, there are naturals n, m such that (F(m-1) % k, F(m) % k) = (F(n-1) % k, F(n) % k). But, this implies that F(m-2) % k = F(n-2) % k, and more generally, F(m-i) % k = F(n-i) % k. Notably, if m < n, F(0) % k = F(n-m) % k. But, F(0)=0, so this means that F(n-m) is a multiple of k.
Challenge
You must provide a program that takes in a natural k as an input and return m, the smallest Fibonacci number that is a multiple of k. This program must be irreducible in the sense that one can't remove any bytes and maintain the same functionality.
This challenge is a code-challenge, as your score will be the smallest Fibonacci multiple of (the number of bytes in your program + 1).
To find your program's score, use this TIO link: Try it online!
The lowest score for a valid response in each language wins!
Test Cases
1: 1
2: 2
3: 3
4: 8
5: 5
6: 144
7: 21
8: 8
9: 144
10: 610
11: 55
12: 144
13: 13
14: 46368
15: 6765
16: 144
17: 34
18: 144
19: 2584
20: 832040
21: 21
22: 832040
23: 46368
24: 144
25: 75025
26: 10946
27: 14930352
28: 46368
29: 377
30: 1548008755920
31: 832040
32: 46368
33: 6765
34: 34
35: 102334155
36: 144
37: 4181
38: 2584
39: 317811
40: 832040
41: 6765
42: 46368
43: 701408733
44: 832040
45: 1548008755920
46: 46368
47: 987
48: 144
49: 225851433717
50: 2111485077978050
51: 14930352
52: 267914296
53: 196418
54: 14930352
55: 55
56: 46368
57: 14930352
58: 267914296
59: 591286729879
60: 1548008755920
61: 610
62: 832040
63: 46368
64: 4807526976
65: 9227465
66: 1548008755920
67: 72723460248141
68: 2584
69: 46368
70: 5358359254990966640871840
71: 190392490709135
72: 144
73: 24157817
74: 365435296162
75: 354224848179261915075
76: 2584
77: 102334155
78: 160500643816367088
79: 8944394323791464
80: 1548008755920
81: 16641027750620563662096
82: 1548008755920
83: 160500643816367088
84: 46368
85: 1134903170
86: 1725375039079340637797070384
87: 317811
88: 832040
89: 89
90: 1548008755920
91: 225851433717
92: 46368
93: 1548008755920
94: 4807526976
95: 2880067194370816120
96: 46368
97: 7778742049
98: 57602132235424755886206198685365216
99: 1548008755920

You can use the TIO link above to generate more test cases if needed.
EDIT: As there seems to be some confusion on the scoring, here is how to generate your score:
Take the number of bytes in your function, add 1, and take the result of this addition, and find the smallest Fibonacci multiple of this result.

Thanks for the tag, didn't know it existed.

Strictly a pristine program is one that will error if bytes are removed. This challenge only requires that the program will have different functionality, which I interpret as producing a different output for some inputs

@LuisMendo That is correct.

@LuisMendo I'll add it to the text

@Shaggy Thanks, I missed that bit.

Any requirements for the range of outputs? 'Cause I can save bytes if leave it as int

@VaradMahashabde Sure, you can leave it as an int.

While you've found a different way of quantifying it, it's unclear to me how this is any different from classic code golf. The shorter the program is in terms of bytes, the lower score it is going to have under your scoring criteria. Are there exceptions that I'm missing? Why not just make this code golf?

@CodyGray That's not completely true. Some small byte patterns have high scores (for example, $13$ bytes). This condition ensured that code isn't just copied directly from other Fibonacci challenges. See Sandbox for discussion.

in other words "a←1⋄r←1x⋄⎕ct←0" is not ok because this can be rewritten
as "a←r←1x⋄⎕ct←0" eliminate 2 bytes (and the result of the funtion would the same) but this "a←1⋄⎕ct←0⋄r←1x" would be ok because if i eliminate some byte the meaning change... is thit right?

@RosLuP I don't know the language, but that looks right to me.

R, 33 bytes, score 34
n=scan();while(T%%n)F={T=T+F}-F;T

Try it online!
I thought I was going to have to resort to a 54 byte solution for a score of 55 (and had fun making an irreducible one), but eventually found this 33 byte solution.
When coerced to integers, F and T are initially worth 0 and 1; they go through the Fibonacci sequence until T is divisible by n.

JavaScript (Node.js), 33 bytes, score: 34
Expects a BigInt as input.
f=(n,x=0n,y=1n)=>y%n?f(n,y,x+y):y

Try it online!

This program's score is 102334155. It is $f(n+1)$

@DonThousand It's now 33 bytes.

C++ (clang), 54 bytes, score : 55
int F(int m,int a=1,int b=1){return a%m?F(m,a+b,a):a;}

Try it online!

I never thought about recursive functions!

Japt, 12 bytes, Score: 13
@XvU}a@MgX+1

Try it
Explanation
The shortest possible solution (below) for this is 9 bytes, which means we're looking for the lowest possible score greater than or equal to f(10)=610.
_©vU}a!gM

Try it
That gives a target length of 12 bytes as f(13)=13, which can easily be achieved with some ungolfing/code bowling, giving:
@XvU}a@MgX+1     :Implicit input of integer U
@                :Left function, taking an integer X as argument
 XvU             :  Is X divisible by U?
    }            :End function
     a           :Starting at 0, pass each integer through the right function and return the first result that returns true when passed through the left function
      @          :Right function, taking an integer X as argument
       MgX+1     :  X+1th Fibonacci number

Proofs
Hopefully, showing that no one character can be removed should also suffice to show that 2 or more characters can't be removed. I'll try to add a few words of explanation to the rest of these tomorrow.

*{box-sizing:border-box;}html{background:#fff;}body{background:#fff;color:#000;margin:0 auto;padding:20px;max-width:600px;}p{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;font-size:14px;line-height:20px;margin:0 0 15px;}p.link{background:#eff0f1;border-radius:3px 0 0 3px;display:inline-block;margin:0 0 10px;width:32px;}a{display:block;padding:4px;}svg{fill:#212121;height:24px;width:24px;vertical-align:middle;}svg.warning{fill:#b00020;}pre{background:#eff0f1;border-radius:0 3px 3px 0;display:inline-block;line-height:16px;margin:0 0 10px 2px;padding:8px;width:calc(100% - 34px);}code{font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif;font-size:13px;}p>code{background:#eee;padding:1px 5px;}

Click the play icon next to each programme to test it. Note that all programmes will auto-run and some, highlighted in red with a circle, may freeze or crash the tab they're running in so proceed with cautiond.

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

XvU}a@MgX+1

Without the first @ to open the left function the, now unmatched, closing } causes the programme to throw an error.

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@vU}a@MgX+1

Removing the first X results in U being auto-inserted between the @ and the v and, therefore, the left function instead testing whether U is divisible by itself, which, of course, it is. So, no matter the input, the programme will exit after the first iteration and always return 1.

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@XU}a@MgX+1

If the v is removed then the X is ignored and the left function now tests whether U is truthy, which, for all non-zero inputs, it always will be. So, as above, the programme will exit after the first iteration and always return 1.

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@Xv}a@MgX+1

The default agrument for the v method when applied to an integer is 2 so, by checking if X is divisible by 2, this version will always return the first even Fibonacci number: 2.
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@XvUa@MgX+1

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@XvU}@MgX+1

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@XvU}aMgX+1

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@XvU}a@gX+1

<svg class="warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M10,16.5L16,12L10,7.5V16.5Z"/></svg>

@XvU}a@MX+1

<svg class="warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M10,16.5L16,12L10,7.5V16.5Z"/></svg>

@XvU}a@Mg+1

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@XvU}a@MgX1

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Try it</title><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>

@XvU}a@MgX+

Alternative, 12 bytes, score: 13
Unlike the original solution above, this one can't be golfed any further.
°õ!gM ævN ªß

Try it

Perl 6, 33 bytes, Score: 34
->$a {(1,1,*+*...*).first(*%%$a)}

Try it online!
There's no specifically redundant parts, even if it would pretty easy to golf.

Jelly, 12 bytes score = 13
ÆḞ
1Çḍ@¥1#ÆḞ

Try it online!
A full program that takes an integer and returns an integer.

Could you explain what each part does in more detail?

Python 2, 54 bytes; score 55
def f(n):
 a,b=0,1
 while b/n*n!=b:a,b=b,a+b
 return b

Try it online!

Cubix, 20 bytes, Score 21
U;;O01I%!^;u.@|W$p+q

Try it online!
Maps onto the cube as follows
    U ;
    ; O
0 1 I % ! ^ ; u
. @ | W $ p + q
    . .
    . .

Watch it run
Fairly basic, builds the sequence on the stack checking the % for each iteration until it is zero then outputs and exits.

01I seed the stack with start of the sequence and input.  11I would also work.
%! take modulus of TOS and test for 0.  Also start of the loop
^;U;O!$@ if 0 pop TOS, u-Turn, pop TOS and output number, a couple of no affecting commands and halt
;uq+p otherwise, pop TOS, u-turn, push TOS to bottom (input), add TOS and pull BOS to top
$W|W some trickery to keep the score nice while keeping it irreducible. skip the next command(W), reflect back onto the W, change the lane up onto the beginning of the loop

Red, 54 bytes, score 55
func[n][a: 0 b: 1 until[t: a a: b(b: t + b)// n = 0]b]

Try it online!
In fact it doesn't work in Red console after removing the space in front of n:
>> f: func[n][a: 0 b: 1 until[t: a a: b(b: t + b)//n = 0]b]
== func [n][a: 0 b: 1 until [t: a a: b (b: t + b) / /n = 0] b]
>> f 55
*** Script Error: / does not allow refinement! for its value2 argument
*** Where: /
*** Stack: f

so I thiink it's a valid submission. I suppose there are some subtle differences in Red for Win and Linux
Alternative:
Red, 67 bytes, score 2584
func[n][set[a b][0 1]until[set[t a]reduce[a b]zero?(b: t + b)% n]b]

Try it online!

Looking back on this, this is invalid, since removing the space between '/' and 'n' doesn't change the functionality.

@Don Thousand Yes, you are right. That's strange - other operators need a space as delimiter. I'll try to find another solution. Thanks for finding this oddity!

@Don Thousand - It works as expected in Red console for Windows - the removal of the space results in an error (please see above). I added an alternative solution.

C (clang), 54 bytes, score 55
f(n){int a=0,b=1;while(b%n){b+=a;a-=b;a=-a;}return b;}

Try it online!

05AB1E, score: 8 (7 bytes)
∞Åf.ΔIÖ

Try it online or verify the first \$n\$ outputs.
Explanation:
∞        # Push an infinite list: [1,2,3,...]
 Åf      # Get the n'th Fibonacci number for each value in this list
   .Δ    # Leave the first value of this list which is truthy for:
      Ö  #  Is it divisible by
     I   #  The input
         # (after which this is output implicitly as result)

These are all the possible builtins after removing one or multiple characters of the program, none of which are able to have the same functionality as the full program above:
∞   # Push an infinite list: [1,2,3,...]
Åf  # Get the `a`'th Fibonacci number
f   # Get the prime factors of the given number(s) `a`
.Δ  # Leave the first value of the given list `a` which is truthy for
Δ   # Repeat the inner code until the result no longer changes
ÅΔ  # Get the (0-based) index of the first element of list `a` which is truthy for
Ö   # Check if integer `a` is divisible by `b`
I   # Push the input
.I  # Get the `a`'th permutation of `b`
Å   # No-op
.   # No-op

Oooo, a new low score. I was waiting for a super short esolang solution.

SNOBOL4 (CSNOBOL4), 71 bytes, score 144
	N =INPUT
	T =1
F	F =(T =F + T) - F
	OUTPUT =T EQ(REMDR(T,N))	:F(F)
END

Try it online!
This might also be the most golfed version of this program, which would be interesting; I also learned that inline assignment works...

Charcoal, 20 bytes, score 21
⊞υ¬υＷ⌊﹪υＩθ⊞υΣ…⮌υ²Ｉ⊟υ

Try it online! Link is to verbose version of code. Explanation:
⊞υ¬υ

Take the logical not of the predefined empty list and push that to the list. (Using a literal 1 would increase my score of course.)
Ｗ⌊﹪υＩθ

Divide each member of the list by the input and repeat while the minimum remainder is nonzero.
⊞υΣ…⮌υ²

Reverse the list, take the first (originally last) two elements (duplicates the single element in the first pass), take the sum, and push that to the list.
Ｉ⊟υ

Cast the last element of the list to string for implicit print.

C++, 60 bytes, score : 610
long f(int m){long a=0,b=1;while(b%m){b+=a;a=b-a;}return b;}

If I had used int all the way, I would have had a score of 591286729879!
Try it online!

I think this works for a score of 55, but due to limitations of int this doesn't work for some values: https://tio.run/##XYtBCoMwFET3OcVgKURaF90U2q9uu@wZfmK0gSaKSQpFPLtVl93MvAczehiKTuvlYL1@p8agtH2Io2FXixSs7@DZmTCwNgixocX6iFZu6fJpKz6r6kJtP0pSR0dcqYJzVakT02hiGj0UzfvNsfUyxySAXWkF3aeIskT2sB@D@PpCcTC4ZwRtPer6b/ZMcVjxjmzTVrqcxCyW6@0H

@79037662 Hello again! Are we taking it on faith that a is initialized as 0?

Yes, isn't that how C++ works? I'm not too clear to be honest.

@79037662 Quite sadly no. C++ is not clean with auto-nulled memory like that as it is designed to be run on, along with other bigger things, resource-limited real-time embedded systems. Any memory that gets allocated to our variables, we clean ourselves

@79037662 Using your approach(with a=b-a also shifted inside the for), I can get down to 56 bytes, but it only worsens the score! Try it online!

score 144

@Noodle9 Nice, but we may not expand like this as it is [tag:pristine-programming], i.e. one may not remove bytes and have the flow of control, variables, etc.

@Varad I thought it was pristine - what could you remove and still have it function as before? You can't just replace ;long  with , that's not removing.

@Noodle9 3 things : You can compress the two long assignments into one, shorten b=b+a to b+=a, and compress the two assignments on a into one. Ref : my answer. BTW it is not about removing statements or logic, but the bytes i.e. one may not write a shorter program which does the exact same thing

That's rewriting the code! Pristine means you can't remove characters and have it function as before. So, for instance, you can't space pad the code to up the byte count.

Let us continue this discussion in chat.

Why not using longer variable name to get a lower score? 88 byte: long f(int m){long a11=0,b1111=1;while(b1111%m){b1111+=a11;a11=b1111-a11;}return b1111;}

Another way: long f(int m){long a=~-~-~-~-~-~-~-~-~-9,b=~-~-~-~-~-6;while(b%m){b+=a;a=b-a;}return b;}

@tsh 1) [tag:pristine-programming] : is it required that it be a continuous  substring? 2) What the heck is happening in the second comment? BTW I am not editing anymore; I have been surpassed anyways

@VaradMahashabde ~-3 just equals to 2, a common way to write (n+1) or (n-1) without parentheses.

MATL, (12 bytes), score 13
Ol`tb+tG\]wx

Try it online!
Explanation
O       % Push 0
l       % Push 1
`       % Do...while. The stack contains F(k), F(k+1)
  tb+   %   Duplicate, bubble up, add. The stack contains F(k+1), F(k+2)
  t     %   Duplicate
  G     %   Push input
  \     %   Modulo
]       % End. If top of the stack is nonzero the loop continues
wx      % Swap, delete. This leaves only the latest Fibonacci number
        % Implicitly display

That's 144 points!

@DonThousand Sorry, I thought it was standard code golf. Score corrected (and improved!)

I'm not smart enough to check, but have you made sure your code is irreducible?

I'm pretty sure it is irreducible, but it's unfeasible to check all 8191 reduced versions by hand. From the explanation it should be obvious that removing any of the used functions or control statements spoils the program

APL(NARS), chars 44, bytes 88, score 89
r←u w
a←1⋄⎕ct←0⋄r←1x
→0×⍳0=w∣r⋄r+←a⋄a←r-a⋄→2

The above has the problem change the global variable ⎕ct, and not
define the variable 'a' as local (so if there is one extern global variable name 'a' and a extern function use 'a' or ⎕ct even trhu some operation, that extern function could return the wrong result...).
test:
  (1..8),¨u¨1..8
 1 1  2 2  3 3  4 8  5 5  6 144  7 21  8 8
  u 70
5358359254990966640871840
  u 89
89
  u 7373
1895175617433302745829870137958720928499852361085393597796453313487
  4796286293483889267053950822315526092023966574765828063258184
  5381860131060934476214808351544411531275197835352771384243811
  1374862903608742278191775434865737602577844700159135211456619
  9731096037977185178018629433653291613989743478589685505639564
  4857727724829027387848536067017682345714489064874396569806069
  164055864141425

I copy "r+←a⋄a←r-a" from https://codegolf.stackexchange.com/a/196929/58988

Ruby, 33 bytes, score 34
->n{a=b=1;a=b+b=a until b%n==0;b}

Try it online!

JavaScript (Node.js), 28 bytes, score 377
for(a=o=1;o%i;t=a,a+=o,o=t);

Edit: -2 bytes
Try it online!
Input goes in i, output goes in o

We do not allow input to be assigned to a predefined variable. It must be taken either as a function argument or via prompt. We also, by default, don't allow snippets; all solutions must be a function or full programme.

Relevant meta posts: Program, Function or Snippet? and its follow-up: Input/Output methods

C (gcc), 33 bytes, Score:34
Based off xibu's answer.
int F(m,a,b){m=a%m?F(m,a+b,a):a;}

Try it online!

This has a score of 1548008755920. Are you sure you want to submit this?

@DonThousand No wait I forgot

There now there is a better score

This is invalid, as it violates the irreducibility condition.

@DonThousand now is irreducible


text:
Give me the first day of next month
Simple question!
Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format.
Example inputs:
2018-05-06
2019-12-20
Their respective outputs:
2018-06-01
2020-01-01
The rules:

Imports are free and don't count towards your score.
The date will be stored in a string called s.
The solution with the least characters, wins

Please avoid creating new tags unless they're really missing. We already have date and parsing. The beginner tag is an interesting idea, but I think that should be discussed in meta. On the other hand, you must include a tag telling what's the winning criterion. Is this code-golf?

I suggest removing The date will be stored in a string called s. and leave it up to the answerers to use any of the default I/O methods. Btw, reading from a pre-defined variable is not among those defaults. Also, not all languages have strings, and not all languages have variables.

Do you mean the output should be stored in s, or that the input would be stored in s?

@Arnauld There was discussion around that topic (a "beginner" or "easy" tag) quite a while ago with no clear consensus. IMO that's still the case because it's very subjective.

Within a day of posting this, 5 people flocked to close it as off-topic because it didn't contain an objective primary winning criterion. I thought "the least characters" was the default winning criterion? Isn't it quite petty to shut this down like that?

I'd say, the newly-added The solution with the least characters, wins could count as the winning criteria, but we prefer not to specify a variable that the input/output have to be stored inside

Will year always in 0001 ~ 9998? If not so, please include testcases "-0001-01-01", "9999-12-31", "+10000-01-01" ect.

Also, Year in 0001 ~ 0999 may cause some solutions fail: "0100-12-01". This may be exclude from requirement or add to testcase.

JavaScript (V8), 67, 57, 56 bytes
-10 thanks to Arnauld,
-1 joining template string and ternary
s=>([a,b]=s.split`-`,+a+!(b%=12))+`-${b++<9?'0'+b:b}-01`

Test cases:

f=s=>([a,b]=s.split`-`,+a+!(b%=12))+`-${b++<9?'0'+b:b}-01`

console.log(f('2018-12-20'))
console.log(f('2019-05-06'))

57 bytes (without assuming that the input is stored in s, as this unusual requirement will hopefully be removed)

I never knew you could do that with split, thanks for the input. Might I also ask what's happening with the -~b part? @Arnauld

-~b is -(-b-1) and works on non-numeric values. But since b is already coerced to a number by the modulo, you can actually just use b+1 here.

@Kobe -~b is basically b+1 (or actually -(-b-1)). It can be useful to skip parenthesis sometimes, although it's not really necessary in this case, so you could change it to b+1 being more readable if you'd prefer. Relevant tip. You might also find Tips for golfing in JavaScript and Tips for golfing in  interesting to read through. Welcome to CGCC!

@KevinCruijssen Thanks for the comment and links, I'll definitely take a look at those soon :)

Bash, 31, 24 bytes
7 bytes saved thanks to @manatwork and @nwellnhof

date -d${1%??}1month +%F

Try it online!

Wow! date's parsing ability keeps amazing me. BTW, I think you can skip the “0”.

Ruby 49 bytes
d=Date.parse(s);print Date.new(d.year,d.mon,1)>>1

Online repl

PHP, 57 bytes
[$y,$m]=explode('-', $s);$m=++$m%13?:!!++$y;$d="$y-$m-1";

Test cases:
<?php
function next_month($s) {
    [$y,$m]=explode('-', $s);
    $m=++$m%13?:!!++$y;
    return "$y-$m-1";
}

$s = "2018-05-06";
echo next_month($s); // Gives 2018-6-1

$s = "2019-12-20";
echo next_month($s); // Gives 2020-1-1

Consider using Try it online! to demonstrate your code.

ISO8601 requires Each date and time value has a fixed number of digits that must be padded with leading zeros, meaning output of 2018-6-1 or 2020-1-1 is not valid.

Retina 0.8.2, 33 bytes
T`9d`d`.9*(-12)?-..$
-23|-..$
-01

Try it online! Link includes test cases. Explanation:
T`9d`d`

Increment with wrap-around...
.9*(-12)?-..$

... the last non-9 digit, plus trailing 9s, in either the year or the month, depending on whether the month is 12. (Digits in the following date parts also get incremented.)
-23|-..$
-01

Replace the day with 01. Also, if the month was 12 before, it will be 23 now, and also needs to be reset to 01.

Red, 39 bytes
t: load s
t/month: t/month + t/day: 1
t

Python 3.6.9, 73 characters
from datetime import *; from dateutil.relativedelta import relativedelta as r;
(datetime(*map(int, s.split('-')), 1) + r(months=1)).strftime('%Y-%m-01')

Your rules say that imports don't count, so I didn't count them.

Welcome to Code Golf! Since imports don't count you can from datetime import datetime as d to save a few bytes. Also, you can remove

Whoops, accidentally hit enter. Your program does not appear to output anything, so you would need a print statement. To catch this, I suggest using TIO, such as by adding a link: Try It Online!. (I incorporated a couple more suggestions to shorten it to 69 bytes).


text:
Can this knot be colored with 3 colors?
In this challenge you will be asked to take a knot and determine if it can be colored in a particular way.
First we draw a diagram of the knot.  We use the standard way of drawing knots where we put gaps in strands where they pass under each other.  Here is an example of some knots drawn this way:

Taken with permission from wikimedia user Jkasd
Once we have drawn the knot we want to color the knot with three colors such that:

Every contiguous length of string in the knot's diagram is colored with the same color (String on the opposite ends gaps where we pass under do not need to be the same color)
The three strands that meet at an intersection are either

all the same color
or all different colors

At least two colors must be used in total

Some knots can be drawn in this way for example:

Taken with permission from wikimedia user n4nojohn
and some cannot for example

Taken with permission from wikimedia user n4nojohn
Your task is to take a knot as input and determine whether or not it can be colored.  You may take a knot in any reasonable format (some examples listed below) and you may output two distinct consistent values one indicating that it can be colored one that it cannot.
This is code-golf so answers will be scored in bytes with fewer bytes being better.

Example input formats
Some nice ways of taking knots as input:

Dowker Notation, A list of pairs of positive integers
Gauss Code, A list of positive integers

Haskell, 249 246 bytes
(i#x)a=[head$[x|j==i]++[s]|(j,s)<-zip[0..]a]
(s%i)[]=i<2&&elem 2(concat s)
(s%i)((l,a):b)|l,[]<-s!!a=or[(a#[i,x]$s)%x$b|x<-[1..3]]|[]<-s!!a=(a#[i]$s)%i$b|[x]<-s!!a,x==i=s%i$b|[x]<-s!!a=s%(6-i-x)$b|u<-s!!a=mod(sum$i:u)3<1&&(s%i)b
f x=(x>>[[]])%1$x

Try it online!
Takes input as a Gauss Code, ([(Bool, Int)]) where False represents crossing over and True represents under
Explanation
This algorithm works by stepping though each intersection and trying to resolve the colors of that intersection.  It keeps track of what color the strand is and branches if multiple colors are possible at a given point.
The function that we build to do this is called r.  It takes, 3 arguments:

The Gauss Code of the knot we are working on (which it will consume in order)
A list of "intersections" and what colors we have already filled in
The color of the strand where we are currently processing.

Our intersections are represented as a list of colors (Int), which we know to be at that intersection.  There are three possible states for this:

It is empty, meaning we have not visited this intersection yet.
It has one element, meaning we visited the intersection going over.
It has two elements (possibly equal), meaning we visited the intersection going under.

We can't have 3 elements because when we visit an intersection the second time we don't have to add the third element since we are never coming back.  Since we don't have to and this is code-golf, we don't.
At each step of the way we can use a very simple case analysis to determine how to branch.  Here is a diagram showing each case and the possible outputs (no possible outputs is a contradiction and return False if we reach it).  Incoming color and location are indicated with the small arrow.

Here are some sample paths of execution on the granny knot and the figure 8 knot as shown in the question.  I skip over steps where we went over a unvisited intersection, since they are quite trivial and the diagrams are quite large even without them.

Since Haskell is lazy we only ever evaluate two of these paths, the left-most path, and when that fails because the result doesn't have two colors we evaluate the second left-most.  Since that one passes we exit without further evaluation.

Here the only branch that does not encounter an error colors everything the same way.
Here is my code ungolfed a bit and commented.  I will expand this a little bit shortly.
-- Update an element of a list
q i x a=[head$[x|j==i]++[s]|(j,s)<-zip[0..]a]
-- Perform the algorithm
-- Iterates through the intersections in order
-- It records colors at each intersection and searches for a contradiction
r[]s i=i<2&&elem 2(concat s)
r((l,a):b)s i
  -- If we reach a new intersection passing under
  -- Branch on the three possible colors
  -- label the intersection with the incoming and outgoing colors
  |l,[]<-s!!a=or[r b(q a[i,x]s)x|x<-[1..3]]
  -- If we reach a new intersection passing over
  -- label the intersection with the incoming color
  |[]<-s!!a=r b(q a[i]s)i
  -- If we reach an intersection going under where the over strand is the same color as the incoming
  -- The outgoing strand is the same color
  |[x]<-s!!a,x==i=r b s i
  -- If we reach an intersection going under where the over strand is different from the incoming
  -- The outgoing strand is the third color
  |[x]<-s!!a=r b s(6-i-x)
  -- If we reach an intersection going under
  -- Check that the three strands have either all the same or all different colors
  -- Since we use 1,2 and 3 for the colors this is the same as checking if their sum is divisible by 3
  |u<-s!!a=mod(sum$i:u)3<1&&r b s i
f x=r x(x>>[[]])1


text:
On the Subject of Memory
This challenge is from a game called Keep Talking And Nobody Explodes.
Memory is a fragile thing but so is everything else when a bomb goes off, so pay attention! – from the manual
The Objective
A number from 1–4 is given as the "display", along with scrambled numbers 1–4 as the "buttons."
The output must be the label of the correct "button." Repeat this process 5 times.
The Format
The input format must be:
<display #> <buttons #>

Repeated 5 times. As long as the numbers are distinguishable and the <display #> is dedicated separately, the input format and type don't matter. For any input that doesn't fit this format, the entire challenge falls in don't care situation.
The output format and type don't matter as long as the numbers are distinguishable.
Which button to press
Pressing a button means to output the label of the button.
The buttons are indexed from left to right, and are 1-indexed.
For the 1st line:
If the display is 1, press the button in the second position.
If the display is 2, press the button in the second position.
If the display is 3, press the button in the third position.
If the display is 4, press the button in the fourth position.
For the 2nd line:
If the display is 1, press the button labeled “4”.
If the display is 2, press the button in the same position as you pressed in line #1.
If the display is 3, press the button in the first position.
If the display is 4, press the button in the same position as you pressed in line #1.
For the 3rd line:
If the display is 1, press the button with the same label you pressed in line #2.
If the display is 2, press the button with the same label you pressed in line #1.
If the display is 3, press the button in the third position.
If the display is 4, press the button labeled “4”.
For the 4th line:
If the display is 1, press the button in the same position as you pressed in line #1.
If the display is 2, press the button in the first position.
If the display is 3, press the button in the same position as you pressed in line #2.
If the display is 4, press the button in the same position as you pressed in line #2.
For the last line:
If the display is 1, press the button with the same label you pressed in line #1.
If the display is 2, press the button with the same label you pressed in line #2.
If the display is 3, press the button with the same label you pressed in line #4.
If the display is 4, press the button with the same label you pressed in line #3.
An Example
Given the following input:
2 1432
4 3214
2 4213
1 4231
1 3214

For the 1st line, press the button in the second position, so output 4.
For the 2nd line, press the button in the same position as you pressed in line #1, so output 2.
For the 3rd line, press the button with the same label you pressed in line #1, so output 4.
For the 4th line, press the button in the same position as you pressed in line #1, so output 2.
For the last line, press the button with the same label you pressed in line #1, so output 4.
So the entire output is 42424, in any format and type.

May the input be taken in more convenient formats such as [[2, [1,4,3,2]], [4, [3,2,1,4]], ... ]? May the buttons be 0-indexed?

@Arnauld Sorry, the input is meant to be a string. ("string" tag is added.) By "1-indexed" I mean it is 1-indexed in the description. If you are going to store them in an array, it doesn't matter whether it's 0-indexed or 1-indexed.

Just as a friendly reminder: unless the very purpose of the challenge is to parse something or to deliver an exact output, cumbersome I/O formats are just an annoyance.

@Arnauld Fine..

Charcoal, 74 bytes
Ｓθ≔∨⊖Ｓ¹η⊞υ§θηＳθ≔§⟦⌕θ4η⁰η⟧⊖Ｓζ⊞υ§θζ⊞υ§⁺⮌υ⟦§Ｓ²4⟧⊖Ｓ⊞υ§Ｓ§⟦η⁰ζζ⟧⊖ＳＳθ⊞υ§υ⌕1243Ｓ↑υ

Try it online! Link is to verbose version of code. Takes input as buttons#1 display#1 buttons#2 ... display#5. Explanation:
Ｓθ

Input the first buttons.
≔∨⊖Ｓ¹η

Decrement the first display to make it 0-indexed, but if that results in zero, increment it again. Save the result for steps 2 and 4.
⊞υ§θη

Save the appropriately indexed button in the predefined empty list.
Ｓθ

Input the second buttons.
≔§⟦⌕θ4η⁰η⟧⊖Ｓζ

Make a list of four elements: the index of "4" in the buttons; the index of the first button; 0 (representing the button in first position); the index of the first button. Get the element corresponding to the (decremented) second display. Save the result for step 4.
⊞υ§θζ

Add the appropriately indexed button to the list.
⊞υ§⁺⮌υ⟦§Ｓ²4⟧⊖Ｓ

Input the third buttons and make a list of four elements: the two buttons so far in reverse order, the button at index 2 (i.e. third position), and 4. Index this using the (decremented) third display. Add the result to the list.
⊞υ§Ｓ§⟦η⁰ζζ⟧⊖Ｓ

Input the fourth buttons, and index them from a list of four elements: the position used for the first button, 0 (representing the first button), and the position used for the second button (twice), first indexed using the (decremented) fourth display. Add the result to the list.
Ｓθ

Input the fifth buttons.
⊞υ§υ⌕1243Ｓ

Input the fifth display, find its index into the string 1243, and index that into the list so far, adding the result to the list.
↑υ

Output the result.

JavaScript (ES6),  109 106 105  104 bytes
Takes input as a list of pairs [display, "buttons"]. Returns a list of pressed buttons.
a=>a.map(([d,b],i)=>a[i]=b[a[~i]=(n='_5567.848106.80990132'[i*4+d])>3?n>7?a[7-n]:n-4:b.search(a[n]||4)])

Try it online!
How?
The action for each line and each displayed value is encoded as a single character as follows (with 0-indexed lines and positions):

\$n=0\$ to \$3\$: press the button with the same label that we pressed in line \$n\$
\$n=4\$ to \$7\$: press the button in position \$n-4\$
\$n=8\$ or \$9\$: press the button in the same position as we pressed in line \$n-8\$
".": press the button labeled "\$4\$"

Translating the rules described in the challenge into these codes leads to the groups 5567, .848, 106., 8099 and 0132, which are concatenated into a single lookup string. The purpose of the leading "_" is just to deal with the 1-indexed input.
The input array \$a[\:]\$ is re-used to store both the labels that are pressed and their positions. For each line \$i\$, we store the label in \$a[i]\$ and its position in \$a[-i-1]\$.
Commented
a =>                              // a[] = input
  a.map(([d, b],                  // for each pair of displayed value d and buttons b
                 i) =>            // at position i in a[]:
    a[i] = b[                     //   save the label in a[i]
      a[~i] =                     //     save its position in a[-i-1]
        ( n =                     //       n = action code taken from ...
          '_5567.848106.80990132' //           ... our lookup string ...
          [i * 4 + d]             //           ... at position i * 4 + d
        ) > 3 ?                   //       if n is greater than 3:
          n > 7 ?                 //         if n is greater than 7:
            a[7 - n]              //           re-use the position used at line n - 8,
                                  //           stored in a[-(n-8)-1], i.e. a[7-n]
          :                       //         else:
            n - 4                 //           use the position n - 4
        :                         //       else:
          b.search(a[n]           //         look for the label used at line n
                        || 4)     //         or look for '4' if a[n] is undefined,
                                  //         which happens only when n is '.'
    ]                             //   end of button lookup
  )                               // end of map()

Python 2, 415 375 351 317 299 273 265 bytes
a=[0]*5;x=input()
for i,z in enumerate(x):j,q=z;exec'a[i]'+['=[q[j-1],j]',';k=a[0][1];a[i]=[4,q.index(4)+1]if j<2else[q[k-1],k]if j-3else[q[0],1]','=[4if j>3else a[j<2][0]if j<3else q[0]]','=[q[a[j>1][1]-1]]if j-2else[q[0]]','=a[6>>4-j&3];print[l[0]for l in a]'][i]

Try it online!
-40 bytes by making everything ternary
-24, -18, -10 by removing unnecessary code
-16 by using (label,position) rather than (position,label)
-4, -4 thanks to @Arnauld
-26, -8 thanks to @Chas Brown
Not quite as competitive as @Arnauld's solution... probably a bit naive as its basically just logic.
Very happy with how this progressed, thanks everyone for the suggestions!

j/2+2*(j==3) can be replaced with 6>>4-j&3.

I think you can save another byte with a[i]=[4]if j>3else[a[j<2][0]]if j<3else[q[0]].

@Arnauld good catches - Im not too familiar with bitwise operations, so I though my solution for the last line could be improved somewhat

299 bytes?

@Arnauld nice, added it

273 bytes by using exec and a list of strings instead of cascading if statements..

@ChasBrown using exec statements is a nice idea, I'll have to keep that in mind for future python answers

One more... 265 bytes because we can then (sort of) compress those strings.