text:
Solve a Stack State Diagram
A stack state diagram shows how the values on one stack are changed into the other. For example, this is a stack state diagram:
3 0 2 1 0

This means that there is a stack initially containing 3 values (the 3 part). These values are indexed from 0 to 2, with 0 at the top: 2 1 0. The next part 0 2 1 0 describes the final state of the stack: the value that was originally on top of the stack has been copied to the back as well.
These transformations happen on a stack that has support for several data types:

The "value" type, which is what is originally on the stack. This could be a string, integer, etc. but its value does not need to be known.
The "list" type, which is a list containing values of any data type.

To model this transformation, the following operations are permitted:

S: Swap the two values on top of the stack: 2 1 0 → 2 0 1
D: Duplicate the value on top of the stack: 1 0 → 1 0 0
R: Remove the top value on the stack. 2 1 0 → 2 1
L: Turn the top value into a one-element list containing that value: 2 1 0 → 2 1 (0)
C: Concatenate the top two lists on the stack: 2 (1) (0) → 2 (1 0)
U: Place all the values from a list onto the stack: 2 (1 0) → 2 1 0

These are equivalent to the Underload commands ~ : ! a * ^, provided that no other commands are used.
S, D, R, and L can be used with any values on top of the stack, but C and U must have lists on top of the stack to function. A submission whose generated sequences attempt to preform invalid operations (like D on an empty stack or U on a non-list) is wrong and must be punished fixed.
To solve a stack state diagram, find a sequence of commands that will correctly transform the initial stack state into the new one. For example, one solution to 3: 0 2 1 0 is LSLCSLCULSLCLSLDCSC USLCU:
   2 1 0
L  2 1 (0)
S  2 (0) 1
L  2 (0) (1)
C  2 (0 1)
S  (0 1) 2
L  (0 1) (2)
C  (0 1 2)
U  0 1 2
L  0 1 (2)
S  0 (2) 1
L  0 (2) (1)
C  0 (2 1)
L  0 ((2 1))
S  ((2 1)) 0
L  ((2 1)) (0)
D  ((2 1)) (0) (0)
C  ((2 1)) (0 0)
S  (0 0) ((2 1))
C  (0 0 (2 1))
U  0 0 (2 1)
S  0 (2 1) 0
L  0 (2 1) (0)
C  0 (2 1 0)
U  0 2 1 0

Your task is to write a program that takes a stack state diagram and outputs a solution.
Test Cases
2 1 0       ->

3 2 0       -> SR

9           -> RRRRRRRRR

2 0 1 0     -> LSLCDCUR

2 0 1 1     -> SD

6 2         -> RRSRSRSR

5 0 1 2 3 4 -> LSLCSLCSLCSLCU

4 2 0 1 3 2 -> LSLCSLSCSLCULSLSCSLSCLSLDCSCUSLCU

This is code-golf, so the shortest valid answer (in bytes) wins.

Can you have a list containing lists? EDIT: Nevermind, you can, it's in the example.

Does the C need lists on top and second position of stack? or the element in second position could be added to a list on top?

C needs lists on both positions. It doesn't make sense to concatenate a value and a list.

Python 3, 84 bytes
lambda n,*s:"DLL"+"L".join(i*"SLSC"+"LSLSCDURLCULCULSC"for i in s[::-1])+n*"SR"+"UR"

Usage:
# Example: 4 2 0 1 3 2 -> LSLCSLSCSLCULSLSCSLSCLSLDCSCUSLCU
>>> f = lambda ...
>>> f(4, 2, 0, 1, 3, 2)
'DLLSLSCSLSCLSLSCDURLCULCULSCLSLSCSLSCSLSCLSLSCDURLCULCULSCLSLSCLSLSCDURLCULCULSCLLSLSCDURLCULCULSCLSLSCSLSCLSLSCDURLCULCULSCSRSRSRSRUR'

Explanation: To start off we duplicate the zero and wrap it in a list:
DL -> 3 2 1 0 (0)

This is our base. Now I will explain a general algorithm that turns ... 1 0 (x) into ... 1 0 (i x) for arbitrary integer i. I will use as an example i = 2, and we have some arbitrary list (x). We start by wrapping our current list (x) into another list:
L -> 3 2 1 0 ((x))

Now we repeat the following sequence i times:
SLSC -> 3 2 1 (0 (x))
SLSC -> 3 2 (1 0 (x))

Now we're ready to insert the 2 into list (x). This goes as follows:
LSLSC -> 3 (2 (1 0 (x)))
DU -> 3 (2 (1 0 (x))) 2 (1 0 (x))
RLCU -> 3 2 (1 0 (x)) 2
LCU -> 3 2 1 0 (x) 2
LSC -> 3 2 1 0 (2 x)

Note that we keep pushing new integers on the left. So the very first (0) we started with stays on the right.
After we have inserted every integer we need into the list we remove the rest of the stack by swapping and removing n time (SR). Finally we unpack our list and delete the first 0 we inserted to start our list (UR).

Did you mean to type s instead of l?

@ZacharyT Oops, yep. It worked while shuffling things around because l was defined on my REPL.

The example shown doesn't seem to work... (DLLSLSCSLSCSLSCSLSCLSLSCDURLCULCULSCLSLSCSLSCSLSCLSLSCDURLCULCULSCLSLSCSLSCLSLSCDURLCULCULSCLSLSCLSLSCDURLCULCULSCLLSLSCDURLCULCULSCSRSRSRSRUR ). It tries to execute an S instruction when there's only 1 value on the stack.

@Challenger5 And I also forgot to update the example... Should be fixed now.

Yep, looks good now!

@Challenger5 Did you expect such a... static solution, as opposed to a more dynamic solver?

What do you mean?

@Challenger5 Did you expect a solution like this, where a string just gets repeated a number of times, or a more dynamic solver program?

Anything is fine. I like it!

This doesn't seem to work for the test case 6 2.

@Challenger5 It works fine for me. Output is DLLSLSCSLSCLSLSCDURLCULCULSCSRSRSRSRSRSRUR which evaluates to 2 when the stack is initially 5 4 3 2 1 0

@orlp: I tried it again, and it seems to work, but unless I made a mistake somewhere it evaluates to (2) instead of 2.

@Challenger5 You made a mistake somewhere, I verified by hand.

CJam, 54 bytes
Just a translation from orlp's Python solution into CJam. There's nothing new here.
"DLL"q~("SR"*\W%{"SLSC"*"LSLSCDURLCULCULSC"+}%'L*\"UR"

Explanation:
"DLL"                  e# Push string
q~                     e# Read input and evaluate
(                      e# Pop the first value
"SR"                   e# Push string
*                      e# Repeat string n times
\                      e# Swap (bring s to front)
W%                     e# Reverse
{                      e# For each:
  "SLSC"               e#   Push string
  *                    e#   Repeat i times
  "LSLSCDURLCULCULSC"+ e#   Append string to end
}%                     e# End
'L*                    e# Join with 'L'
\                      e# Swap (bring "SR"*n to front)
"UR"                   e# Push string
                       e# [Stack is implicitly output.]

source: Stack Exchange

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

sort: votes


text:
Count the number of a number in the picture area
Your goal is to write a full program or function that takes 5 positive integers   and a string with an image filename as input [X1,Y1], [X2,Y2], N, image.jpg in any reasonable format, where:

First couple [X1,Y1] are the top left X,Y coordinates (<=20) of the blue rectangle area in the example picture (16,11).
Second couple [X2,Y2] are the bottom right X,Y coordinates (<=20) of the blue rectangle area in the example picture (20,22).
Fifth number N such 0 <= N <= 9 is the number that has to be found.
Sixth parameter is a string with the filename of this JPG picture.

Output how many of N's are present in the indicated area (outlined in blue in the picture for this example):

Click here to obtain a bigger clean version of the same image.
In the picture there are 500 numbers from 0 to 9 (included) arranged in 20 columnns per 25 rows, in monospaced Courier New font.
Each different number has a different color (you can take advantage of this fact or ignore it and consider or convert the image in monocrome if that helps you).
Test cases:
[4,4],[13,5],1,image.jpg    > 4  (outlined in red)
[4,4],[13,5],4,image.jpg    > 2  (outlined in red)
[17,5],[17,5],2,image.jpg   > 1  (outlined in magenta)
[17,5],[17,5],9,image.jpg   > 0  (outlined in magenta)
[20,8],[20,9],3,image.jpg   > 1  (outlined in cyan)
[20,8],[20,9],2,image.jpg   > 0  (outlined in cyan)
[16,11],[20,22],0,image.jpg > 8  (outlined in blue)
[16,11],[20,22],3,image.jpg > 9  (outlined in blue)
[3,14],[11,20],7,image.jpg  > 6  (outlined in green)
[3,14],[11,20],5,image.jpg  > 6  (outlined in green)
[3,14],[11,20],8,image.jpg  > 8  (outlined in green)
[1,1],[20,25],0,image.jpg   > 47 (whole picture)
[1,1],[20,25],8,image.jpg   > 50 (whole picture)
[1,1],[20,25],1,image.jpg   > 55 (whole picture)

Rules:

This is code-golf so the shortest code wins.
You must take as input this JPG file.
You are not allowed to hardcode the matrix of numbers represented in the JPG, or the results.
Standard loopholes are forbidden.

Mathematica, 92 bytes
Count[Take[Characters@StringSplit@TextRecognize@Binarize[Import@#4,.9],#2,#],ToString@#3,2]&

Unnamed function taking the arguments in this format: [{X1,X2}, {Y1,Y2}, N, "image.jpg"]. (Indeed, the fourth argument can be either the local file name or the URL http://i67.tinypic.com/6qh5lj.jpg.)
Import@#4 imports the image file, Binarize[...,.9] darkens all of the numbers to black, and TextRecognize (the function clearly doing the heavy lifting here!) extracts a multi-line string from the resulting image, which is split into a nested list of characters with Characters@.
Take[...,#2,#] keeps only the characters corresponding to the outlined rectangle, and Count[...,ToString@#3,2] counts the number of occurrences of N in the result.

Python 3 + pillow + pytesseract, 239 bytes
from PIL.Image import*
from pytesseract import*
def c(a,b,n,f):w,h=b[0]-a[0]+1,b[1]-a[1]+1;return len([1for i in range(h*w)if image_to_string(open(f).convert('L').point(lambda x:[9,0][x<250],'1')).split()[i//w+a[1]-1][i%w+a[0]-1]==str(n)])

This is horribly inefficient as for each number tile, the whole file is parsed. The much faster and slightly longer 243 bytes solution would be
from PIL.Image import*
from pytesseract import*
def c(a,b,n,f):s=image_to_string(open(f).convert('L').point(lambda x:[9,0][x<250],'1')).split();w,h=b[0]-a[0]+1,b[1]-a[1]+1;return len([1for i in range(h*w)if s[i//w+a[1]-1][i%w+a[0]-1]==str(n)])

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

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


text:
The Primitive and Basic Numbers
Your task is to generate the "Primitive and Basic" numbers, which are made like so:
Start with 110. Take the digits of its base-1 representation (110 = 11) and interpret them as base-2 digits. This gives 12 = 110. Now, add the second prime number – 310 – to the result. This will give you 410, which is our first "Primitive and Basic" (PB) number, or PB(1) (you can now see where I got the name from).
Next, take 410 = 1002 and interpret the digits of its base-2 representation as base-3 digits. This gives 1003 = 910. Add the third prime number – 510 – to the result, which gives 1410. That's the second PB number, or PB(2).
You can see where this is going: take 1410 = 1123 and interpret the digits of its base-3 representation as base-4 digits. This gives 1124 = 2210. Add the fourth prime number – 710 – to the result, which gives 2910.
This continues on and on forever.
In general, PB(n) is equal to PB(n-1), converted to base n and from base n+1 to integer, plus the (n+1)th prime.
The first few terms of this sequence are:
4, 14, 29, 52, 87, 132, 185...

You must write a function or program that creates these numbers. It must take a positive integer n as input, and return PB(n).
I/O:
1 -> 4
5 -> 87

Rules and specs:

Your program must be able to handle all PB numbers below 231-1.
Standard loopholes apply.
The input may be 0-indexed or 1-indexed, whichever you prefer.
The input is guaranteed to be a valid index.
The output must be in base 10.

This is code-golf, so shortest code in bytes wins!
Unfortunately, there isn't an OEIS sequence for this. You can propose to OEIS to add this sequence in if you want.

I find "turn it into base 3" misleading. That sounds like I should convert either 4 or 100 to base 3 which is either 11 or 10201. What you seem to intend is that the representation from the previous base should now be treated as digits in the next base.

What are we supposed to do? Create a program/function takes takes input and gives the nth PB term? Or are we supposed to generate all terms below 2^31-1?

Sorry for the misleading thing: your program must be able to handle terms that are up to 2^31-1. It's meant to take an input n and return the output PB(n).

I just hope all these comments get me the "Blue in the Face" hat

@MartinEnder I believe the base thing is kinda fixed. If it should be improved further, can you edit the post?

I think "add the base-2 equivalent of the second prime" would be more accurate and less confusing, as just "add the second prime". Same in the next two paragraphs.

@smls Wait, what? So you're saying I should just do "add the second prime" instead, right?

@Qwerp-Derp: Yeah. I suggested an edit now.

@smls I looked at the revised edit, and I didn't really think that condensing it down would help with clarity - for me, at least, it made it more confusing, so I changed it to something like "the second prime in base-2", just to clarify the "process" of the sequence.

I didn't understand the task the first time I read it, so I rephrased it in an attempt to make it clearer. Please feel free to roll back any changes you disagree with.

@Dennis Wow, it looks much cleaner and clearer. Thanks!

Ruby, 126 bytes
require("prime")
->n{o=4
(2..n).map{|i|j=i+1
r=[]
(r.unshift o%i;o/=i)while o>0
o=r.inject{|s,k|s*j+k}+Prime.first(j)[-1]}
o}

Jelly, 13 bytes
’ß1¹?bḅ‘+‘ÆN$

Try it online!
How it works
’ß1¹?bḅ‘+‘ÆN$  Main link. Argument: n

’              Decrement; yield n-1.
   ¹?          If n-1 is non-zero:
 ß               Recursively call the main link with argument n-1.
               Else:
  1              Yield 1.
     b         Convert the result to base n.
      ḅ‘       Convert from base n+1 to integer.
         ‘ÆN$  Increment n and yield the (n+1)-th prime.
        +      Add the results to both sides.

Mathematica, 66 bytes
Fold[IntegerDigits[#,#2-1]~FromDigits~#2+Prime@#2&,4,2~Range~#+1]&

Unnamed function taking a single (1-indexed) integer argument and returning an integer.
Fold[...,4,2~Range~#+1] iterates a function of two arguments, with the first argument beginning at 4 and thereafter set to the output of the previous iteration, while the second argument iterates over the set {3,4,...,#+1} (where # is the original integer argument).
The function in question is IntegerDigits[#,#2-1]~FromDigits~#2+Prime@#2. First, IntegerDigits[#,#2-1] converts the first argument into a list of its digits when written in the previous base; then, ...~FromDigits~#2 converts that list of digits back into an integer, assuming the digits are now in the current base. Finally, the #2th prime is added to the result.

Perl 6, 95 bytes
{my $b=1;(4,{grep(*.is-prime,2..*)[++$b]+.polymod($b xx*).&{sum $_ Z*($b+1 X**0..*)}}...*)[$_]}

Zero-based indexed.
Explanation:
Since the language's built-in .base and .parse-base methods are string-based, they only work up to base 36. So in order to fulfill the task requirement that large inputs must be supported, the base conversion is done as follows:

.polymod($b xx *): Convert the current number to a list representing its digits in base $b.
sum $_ Z* ($b+1 X** 0..*): Interpret the resulting digits as a number in base $b+1.


text:
The negative order integer challenge, but it's Prime Time!
Im talking about this question, take a look at it if you are a bit confused.
Main Task
Your task is to output concatenated integers, in decreasing order, but increasing the maximum integer everytime you hit 1 (for this question, 1 will be considered a prime number). While this doesn't sound any different from the first question, here comes the tricky part: All outputted numbers may only be primes. These will be strung together into a single string without spaces or newlines. Your input will also be a prime number.
Example:
1
21
321
5321
75321
1175321
Valid output:
1213215321753211175321
Input
Your code may only take one input: the highest prime to be printed. This input can come from anywhere (graphical, STDIN). You are assured that the input is a prime number.
Output
You will have to output the resulting number. You can get this number by keep counting down, only count the number if it's a prime, then connect all results together to one number. The last number "row" (e.g. 7, 5, 3, 2, 1) has to be printed fully. The output could be anything (numbers, strings, graphical), as long as it's readable. The same Regex pattern for checking your test cases applies:
^(\D*(\d)+\D*|)$

If your output doesn't match with this pattern, your code is invalid.
Rules

The input is assured to be prime, do not include error handling, unless you want/need to.
The output may only be a full-connected number, therefore not split up by anything, not even newlines.
Your algorithm shouldn't check for the first instance of N appearing (for instance, the 17 in 1175321), but rather for the first instance of N as the actual number.
Your input is assured to be positive, do not add handling unless you want/need to.

Test cases
Input: -2, 0
Output: Any, or none (number isn't positive)

Input: 9
Output: Any, or none (number isn't prime)

Input: 1
Output: 1

Input: 7
Output: 121321532175321

Input: 23
Output: 1213215321753211175321131175321171311753211917131175321231917131175321
Winner
This is code-golf, so the author of the code with the least length in bytes wins!

I thought that for input 7 the output would be 121321532175321 instead

I think I fixed them now. @KritixiLithos

I won't suggest changing the challenge, but I don't think 1 is a prime by definition.

Yes, 1 is not a prime, but I added it for the sake of the challenge, I guess ;) @ErikGolferエリックゴルファー

Having a test case 1 directly contradicts the spec, which "assures" that the input number will be a prime. 2. The output spec seems to contain multiple contradictions and ambiguities. "The last number "row" (e.g. 7, 5, 3, 2, 1) has to be printed fully" - so the others don't? "The same Regex pattern for checking your test cases applies", but "The output may only be a full-connected number, therefore not split up by anything" contradicts that regex. But the regex is clearly dodgy anyway because it allows the empty string, and there's no input which could give that.

@PeterTaylor For your first statement, I have specified in the question that (for this question, 1 will be considered a prime number). The other rows obviously have to be printed fully, as explained in the task and test cases. The regex allows for a fully connected number, with anything before and after, because people had problems with printing arrays or other specific characters (e.g. [121321]\n)

"A single trailing newline is allowed." is redundant/inconsistent with the regex pattern that allows any number of trailing characters. 2. The intro sentence "Your task is to output integers" is misleading since you later ask to output a single number. 3. The whole explanation of the sequence and the output is confusing - people basically have to reverse-engineer what you mean by studying the examples (sequence listing and test cases). The last challenge also had these issues, and I addressed them there in a suggested edit there, which you rejected... :(

What's the point in arbitrarily making 1 a prime?

The input is assured to be prime, do not include error handling, unless you want/need to. Adding unnecessary error handling would make an answer not a serious contender, so this might be better worded as just The input is assured to be prime.

The negative order integer challenge but every time it's a prime it gets faster ;)

Jelly, 9 bytes
ÆR1;;\UFV

Try it online!
How it works
ÆR1;;\UFV  Main link. Argument: n

ÆR         Prime range; yield all primes up to n.
  1;       Prepend the "prime" 1.
    ;\     Cumulative concatenation; yield all prefixes of the prime range.
      U    Upend; reverse each prefix.
       F   Flatten the resulting 2D array.
        V  Eval. This casts the integer array to string first, thus concatenating
           the integers.

I know I'm too deep into learning about golfing when I read the Jelly to understand the question rather than the other way round. (This is actually a pretty readable Jelly program, as they go; the only confusing point for me was the weird special case of V on a list.)

Processing, 161 bytes
int p(int n){for(int k=1;++k<=sqrt(n);)if(n%k<1)return 0;return 1;}void t(int n){for(int i=1,j;i<=n;i++){if(p(i)<1)continue;for(j=i;j>0;j--)print(p(j)<1?"":j);}}

One function does the primality checking, the other does the printing. Call it by t(7)
Ungolfed
The first function does the primality checking. It returns an int instead of a boolean since this way more bytes are saved. (int instead of boolean, 0 instead of false, 1 instead of true)
int Q103891p(int n){
  for(int k=1;++k<=sqrt(n);)
    if(n%k<1)return 0;
  return 1;
}

The second function prints out the string. It iterates through every number, if it is not a prime, skip to the next iteration. If it is a prime, it continues down to the printing inside another for-loop. Again, if the number is prime, then we print it, otherwise not.
void Q103891(int n){
  for(int i=1,j;i<=n;i++){
    if(p(i)<1)continue;
    for(j=i;j>0;j--)
      print(p(j)<1?"":j);
  }
}

Jelly, 12 bytes
ÆR;@1
ÇÇ€UVV

Try it online!
If it hadn't been for 1s at all, my code would have just been ÆRÆRUVV for 7 bytes.
Enhanced explanation:
ÇÇ€UVV Main link. Arguments: z.
Ç      Run link1 on z.
 Ç€    Run link1 on z's elements.
   U   Reverse z's elements.
    V  Flatten z.
     V Concatenate z's elements.

ÆR;@1 Link 1. Arguments: z.
ÆR    Range of primes [2..z].
    1 Integer: 1.
  ;@  Concatenate x to y.

The Irish guy (called Dennis?) somehow outgolfed me lol.

05AB1E, 19 bytes
LDpÏX¸ì€Lí˜ÐXQsp+ÏJ

Try it online!
Explanation
L                     # range [1 ... input]
 DpÏ                  # keep only primes
    X¸ì               # prepend a 1
       €L             # map: range [1 ... n]
         í            # reverse each sublist
          ˜           # flatten list to 1D
           Ð          # triplicate
            XQ        # check elements in one copy for equality with 1
              sp      # check elements in one copy for primality
                +     # add the above lists giving a list with true values at indices
                      # comtaining 1 or a prime
                 Ï    # keep only those elements of the unmodified copy of the list
                  J   # join

Amazed by the DpÏ statement. Nice work!

Brachylog, 17 bytes
y:{e1|e#p}f@[rcw\

Try it online!
Can't seem to get shorter than that...
Explanation
y                      The list [0, ..., Input]
 :{      }f            Find all...
   e1                     ...elements that are 1 (there is 1)...
     |                    ...or...
      e#p                 ...elements that are prime...
           @[          Take a prefix of the result
             rc        Reverse it and concatenate it into a number
               w       Write to STDOUT
                  \    Backtrack: try another prefix

GameMaker Language, 169 bytes
Main function (68 bytes)
b=""for(i=1;i<=argument0;i++){c=i while(j)b+=string(p(c--))}return b

Function p (46 bytes)
for(a=0;a<argument0;a++)while q(++b){}return b

Function q (55 bytes)
n=argument0 for(i=2;i<n;i++)if!(n mod i)p=1return p|n=1

Nice, someone who uses GML

@FireCubez Thanks:) I used to use it a lot. It was actually the first programming language I learned.

MATL, 15 bytes
Zq"1@ZqP]1v!VXz

Try it online!
Zq      % Implicit input. Push array of primes up to that value
"       % For each prime in that array
  1     %   Push 1
  @     %   Push current prime
  Zq    %   Push array of primes up to that
  P     %   Reverse
]       % End
1       % Push 1
&h      % Concatenate all stack horizontally
V       % Convert to string
Xz      % Remove spaces. Implicit display

Perl 6, 41 bytes
{[~] flat [\R,] 1,|grep *.is-prime,2..$_}

(Try it online.)
Explanation:

1, |grep(*.is-prime, 2..$_): Sequence of 1 and primes... (1 2 3 5)
[,] ...: Reduce ("fold") over comma operator... (1 2 3 5)
[\,] ...: With intermediate results (triangular reduce)... ((1) (1 2) (1 2 3) (1 2 3 5))
[\R,] ...: Apply reversing meta-operator to the comma... ((1) (2 1) (3 2 1) (5 3 2 1))
[~] flat ...: Remove list nesting, and fold over string concat operator... 1213215321

(This is based on my answer for the previous challenge.)

Mathematica, 61 bytes
ToString/@(1<>Prime@Range[Range@PrimePi@#,0,-1]/.Prime@0->1)&

Unnamed function taking an integer argument and returning a string. (If the input is not a prime, it just "rounds it down" to the nearest prime; if the input is nonpositive, it pretends it's 1.)
This implementation uses the nasty trick from Martin Ender's answer to the similar previous challenge (who says this old dog can't learn new tricks?): abusing <> to flatten a nested list of integers.
The nested list in question starts by generating a similar nested list as in that answer, with the appropriate length (given by PrimePi@#, the number of primes up to and including the input); then Prime is applied to every element. For example, for the input 5 which is the 3rd prime, the code Range[Range@PrimePi@#,0,-1] yields {{1,0},{2,1,0},{3,2,1,0}}, and applying Prime to each element yields {{2,Prime[0]},{3,2,Prime[0]},{5,3,2,Prime[0]}} since the 1st, 2nd, and 3rd primes are 2, 3, and 5, respectively. I feel proud that I managed to add even more errors to Martin Ender's approach—Mathematica complains every time it writes Prime[0].
Prime[0] isn't a thing, but that's okay: /.Prime@0->1 turns them all into 1s. And we also want a 1 on the front, so we replace the "" from Martin Ender's answer with simply 1, which actually saves a byte.

PHP, 72 bytes
for(;$n<$argv[1];print$s=$n.$s)for($i=2;$i>1;)for($i=++$n;--$i&&$n%$i;);

Run wit -r
breakdown
for(;$n<$argv[1];               // loop $n up to argument:
    print$s=$n.$s)                  // 2. prepend $n to $s, print $s
    for($i=2;$i>1;)                 // 1. find next prime: break if $i<2
        for($i=++$n;--$i&&$n%$i;);      // if $n is prime, $i is 1 after loop (0 for $n=1)

Pyth - 12 bytes
jkf!tPTs}R1S

Test Suite.


text:
The strange ordering of Sharkovskii
Introduction
In this challenge, we will be dealing with a certain ordering of the positive integers.
The ordering goes like this:
   3,    5,    7,    9,    11, ...
 2*3,  2*5,  2*7,  2*9,  2*11, ...
 4*3,  4*5,  4*7,  4*9,  4*11, ...
 8*3,  8*5,  8*7,  8*9,  8*11, ...
16*3, 16*5, 16*7, 16*9, 16*11, ...
 ...
... 64, 32, 16, 8, 4, 2, 1

We first list all odd integers greater than 1 in ascending order.
Then we list two times odd integers greater than 1, then 4 times, then 8 times, and so on: for all k, we list 2k times the odd integers greater than 1 in ascending order.
Finally, we list the powers of two in descending order, ending at 1.
Every positive integer occurs in this "list" exactly once.
More explicitly, consider two distinct positive integers A = n·2p and B = m·2q, where n, m ≥ 1 are odd, and p, q ≥ 0.
Then A comes before B in the ordering, if one of the following conditions holds:

n > 1, m > 1 and p < q
1 < n < m and p = q
n > m = 1
n = m = 1 and p > q

This ordering appears in the surprising mathematical result known as Sharkovskii's theorem, which concerns the periodic points of dynamical systems.
I will not go into the details here.
The task
Your task in this challenge is to compute the above ordering.
Your inputs are two positive integers A and B, which may be equal.
Your output is a truthy value if A comes before B in the ordering, and a falsy value otherwise.
If A = B, your output should be truthy.
You can take A and B in either order, as long as you're consistent.
You don't have to worry about integer overflow, but your algorithm should theoretically work for arbitrarily large inputs.
Test cases
Truthy instances
3 11
9 6
48 112
49 112
158 158
36 24
14 28
144 32
32 32
32 8
3 1
1 1

Falsy instances
1 2
1 5
11 5
20 25
2 8
256 255
256 257
72 52
2176 1216
2176 2496

JavaScript (ES6), 53 49 bytes
f=(a,b)=>b<2||a>1&&(a&b&1?a<=b:a&1|~b&f(a/2,b/2))

Explanation:

If b is 1, then a precedes (or equals) b
Otherwise, if a is 1, then a does not precede b
Otherwise, if both a and b are odd, then use regular inequality check
Otherwise, if a is odd, then it precedes b
Otherwise, if b is odd, then a does not precede b
Otherwise, divide both a and b by 2 and try again.

Edit: Saved 2 bytes thanks to @Arnauld.

Nice. I didn't think about using recursion here. Would a&1|~b&1&f(a/2,b/2) work?

@Arnauld I'm not sure, I was worried that it would loop indefinitely.

It can't because b<2 will eventually be true. Now, another problem is that you'll process more iterations than needed and get floating point values. But I can't find any counterexample that would not work as expected.

@Arnauld Ah, right, I wasn't using b<2 originally, but I guess it will work now.

@Arnauld Better still, since f(a/2,b/2) only returns 0, 1, false or true, I don't even need the &1.

Python 2, 87 71 bytes
k=lambda n:[n&~-n<1,(n&-n)*cmp(n&~-n,1),n/(n&-n)]
lambda a,b:k(a)<=k(b)

This probably won't win any size awards, but this answer works by constructing a 3-tuple using 3 expressions from an integer that when lexicographically ordered will result in the correct ordering.
In readable terms, the tuple is for A = n·2p:
[n == 0, p * (1 - 2*(n == 0)), n]

Python 2, 50 bytes
lambda*l:cmp(*[([-n][n&n-1:],n&-n,n)for n in l])<1

Each number is mapped to a triple whose sorted order is the desired order.

The primary value is  [-n][n&n-1:], which handles the powers of 2 at the end. The bitwise "and" n&n-1 is zero exactly when n is a power of 2. If so, we get the list [-n], and otherwise the empty list []. This puts all powers of 2 at the end of the order, in decreasing order.
The secondary value n&-n extracts the power-of-2 factor of n.
The final value n tiebreaks equal powers of 2 in favor of the greater number.

The respective tuples are passed to cmp to see if that comparison is <=0. Python 3 would save a byte with float division (n&n-1<1)/n for the first value in the triple, but lacks cmp.

Isn't cmp(...)<=0 equivalent to cmp(...)<1?

@mathmandan Yes :)

I think it's permissible to take the integers in reverse order and use ~ instead of <1

JavaScript (ES6), 70 64 bytes
Could probably be golfed some more, but as a first attempt:
x=>y=>(a=x&-x,x/=a,b=y&-y,y/=b,y<2?x>1|b<=a:x>1&(b>a|b==a&y>=x))

Takes input with currying syntax (x)(y). Returns 0 / 1.
Test cases

let f =

x=>y=>(a=x&-x,x/=a,b=y&-y,y/=b,y<2?x>1|b<=a:x>1&(b>a|b==a&y>=x))

console.log('Testing truthy instances ...');
console.log(f(3)(11));
console.log(f(9)(6));
console.log(f(48)(112));
console.log(f(49)(112));
console.log(f(158)(158));
console.log(f(36)(24));
console.log(f(14)(28));
console.log(f(144)(32));
console.log(f(32)(32));
console.log(f(32)(8));
console.log(f(3)(1));
console.log(f(1)(1));

console.log('Testing falsy instances ...');
console.log(f(1)(2));
console.log(f(1)(5));
console.log(f(11)(5));
console.log(f(20)(25));
console.log(f(2)(8));
console.log(f(256)(255));
console.log(f(256)(257));
console.log(f(72)(52));
console.log(f(2176)(1216));
console.log(f(2176)(2496));

You can take out the brackets around and inside b>a||(b==a&&y>=x), won't make a difference to execution.

@XavCo7 It's OK to remove the brackets inside but not around. All existing test cases would still pass, but an input such as [1, 5] would be incorrectly identified as truthy.

@Arnauld I'll add that as a new test case for the future.

Perl 6, 89 84 bytes

->\a,\b{my \u=*>max a,b;a==first a|b,flat [1,2,4...u].&{(3*$_,5*$_...u for $_),.reverse}}

{my \u=*>@_.max;@_[0]==first @_.any,flat [1,2,4...u].&{.map(*X*(3,5...u)),.reverse}}

(Try it online.)
Not exactly short, but I thought it would be interesting to write a solution that actually generates the ordering sequence (up to a safe upper bound for each sub-sequence), and then checks which input appears in it first.
For example:

For input 2, 3 it generates:3 5
6
12
4 2 1...and then observes that 3 appears before 2.
For input 9, 6 it generates:3 5 7 9 11
6 10
12
24
48
16 8 4 2 1...and then observes that 9 appears before 6.

It could be smarter and generate even less of the sequence, but that would take more bytes of code.

Python 2, 54 bytes
f=lambda a,b:b<2or[f(a/2,b/2),a>1,0,1<a<=b][a%2+b%2*2]

A recursive solution similar to Neil's.

This seems to mess up some test cases. It says f(158,158) is False and f(2,8) is True.

@xnor Oops, should be fixed now.

This says f(1,5) is False.

My bad, I meant that f(1,5) should be False, but the code gives True.

@xnor Ah, I spotted the bug, fixed now (for good I hope). I went about following Neil's description a bit too loosely.

APL (Dyalog Extended), 27 bytes
1⊃∘⍋⍮⍥{p⍵⍮⍨-⍵⍴⍨⍵=2*p←⊥⍨~⊤⍵}

Try it online!
A tacit dyadic function whose left argument is a and the right is b.
The approach is almost identical to xnor's Python 2 solution, in that we convert each number to a nested array and do lexicographical comparison between them.
Part 1: Convert number to nested array
{p⍵⍮⍨-⍵⍴⍨⍵=2*p←⊥⍨~⊤⍵}  ⍝ Input: positive integer N
                  ⊤⍵   ⍝ Convert N to binary digits
                 ~     ⍝ Flip all the bits (1 to 0, 0 to 1)
             p←⊥⍨      ⍝ Count trailing ones and assign it to p
                       ⍝ (maximum power of 2 that divides N)
         ⍵=2*          ⍝ Test if N itself is equal to 2^p
     -⍵⍴⍨              ⍝ If true, create 1-element array containing -N;
                       ⍝ otherwise, an empty array
 p⍵⍮⍨                  ⍝ Form a 2-element nested array;
                       ⍝ 1st element is the above, 2nd is [p, N]

Part 2: Compare two nested arrays
1⊃∘⍋⍮⍥f  ⍝ Input: A (left) and B (right)
     ⍥f  ⍝ Evaluate f A and f B
    ⍮    ⍝ Create a 2-element nested array [f A, f B]
   ⍋     ⍝ Grade up; indexes of array elements to make it sorted
         ⍝ Here, the result is [0 1] if A ≤ B, [1 0] otherwise
1⊃∘      ⍝ Take the element at index 1 (0-based)

The dfn syntax does support conditional statements e.g. {a:x ⋄ b:y ⋄ z} meaning if a then x else if b then y else z, but it's way too verbose to use in this case.

Mathematica, 65 bytes
OrderedQ[{1,#}&/@#//.{a_,b_/;EvenQ@b}->{2a,b/2}/.{a_,1}->{∞,-a}]&

Unnamed function taking a list of positive integers and returning True if the list forms an ascending sequence in the Sharkovskii order, False otherwise. (In particular, the input list doesn't have to have only two elements—we get the added functionality for free.)
The heart of the algorithm is the function {1,#}&/@#//.{a_,b_/;EvenQ@b}->{2a,b/2}, which repeatedly moves factors of 2 around to convert an integer of the form m*2^k, with m odd, to the ordered pair {2^k,m} (and does so to every element of the input list). OrderedQ then decides whether the resulting list of ordered pairs is already sorted; by default, that means in increasing order by the first element, then increasing order by the second element.
That's exactly what we want, except numbers that are powers of 2 follow different rules. So before checking in with OrderingQ, we apply one last rule /.{a_,1}->{∞,-a}, which converts (for example) {64,1} to {∞,-64}; that puts powers of 2 in the correct spot in the ordering.

Python, 159 158 153 144 142 141 bytes
Saved a 2 bytes thanks to Kritixi Lithos!
This is mainly just to practice golfing my Python!
Used the formula given by the OP rather than the ways of all the cleverer  answers
f=lambda a,p=0:(a&1)*(a,p)or f(a>>1,p+1)
t=lambda(n,p),(m,q):(n==1)*(m==1)&(p>=q)or (m>1)&(p<=q)|(n<=m)&(p==q)or m==1
lambda a,b:t(f(a),f(b))

You can golf it by removing the unnecessary spaces: for example in (a, b) on the second line where you can remove the space between the comma and b.

Haskell, 143 138 bytes
Basically a relatively straightforward implementation of the criteria:
e n=head[k-1|k<-[0..],n`mod`(2^k)>0]   -- exponent of 2
f n=n`div`2^e n                        -- odd part
a#b|n<-f a,p<-e a,m<-f b,q<-e b=n>1&&(m>1&&p<q||n<m&&p==q||m<2)||n<2&&m<2&&p>q||a==b

Try it online!

05AB1E, 14 bytes
ΣxÓs1ǝzDg≠i(]Q

Try it online! or validate all test cases.

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


text:
Sever-sort an array
Challenge
Given a non-empty array of integers, e.g.:
[5, 2, 7, 6, 4, 1, 3]

First sever it into arrays where no item is larger than the previous (i.e. non-ascending arrays):
[5, 2] [7, 6, 4, 1] [3]

Next, reverse each array:
[2, 5] [1, 4, 6, 7] [3]

Finally, concatenate them all together:
[2, 5, 1, 4, 6, 7, 3]

This should be what your program outputs/function returns. Repeat this procedure enough times and the array will be fully sorted.
Rules

Input and output may be given through any standard methods, and may be in any reasonable array format.
The input array will never be empty, but may contain negatives and/or duplicates.
The absolute value of each integer will always be less than 231.

Test cases
Hopefully these cover all edge cases:
[1] -> [1]
[1, 1] -> [1, 1]
[1, 2] -> [1, 2]
[2, 1] -> [1, 2]
[2, 3, 1] -> [2, 1, 3]
[2, 1, 3] -> [1, 2, 3]
[2, 1, 2] -> [1, 2, 2]
[2, 1, 1] -> [1, 1, 2]
[3, 1, 1, 2] -> [1, 1, 3, 2]
[3, 2, 1, 2] -> [1, 2, 3, 2]
[3, 1, 2, 2] -> [1, 3, 2, 2]
[1, 3, 2, 2] -> [1, 2, 2, 3]
[1, 0, 5, -234] -> [0, 1, -234, 5]
[1, 0, 1, 0, 1] -> [0, 1, 0, 1, 1]
[1, 2, 3, 4, 5] -> [1, 2, 3, 4, 5]
[5, 4, 3, 2, 1] -> [1, 2, 3, 4, 5]
[2, 1, 5, 4, 3] -> [1, 2, 3, 4, 5]
[2, 3, 1, 5, 4] -> [2, 1, 3, 4, 5]
[5, 1, 4, 2, 3] -> [1, 5, 2, 4, 3]
[5, 2, 7, 6, 4, 1, 3] -> [2, 5, 1, 4, 6, 7, 3]
[-5, -2, -7, -6, -4, -1, -3] -> [-5, -7, -2, -6, -4, -3, -1]
[14, 5, 3, 8, 15, 7, 4, 19, 12, 0, 2, 18, 6, 11, 13, 1, 17, 16, 10, 9] -> [3, 5, 14, 8, 4, 7, 15, 0, 12, 19, 2, 6, 18, 11, 1, 13, 9, 10, 16, 17]

Scoring
This is code-golf, so the shortest code in bytes wins.

What's the big-o of this sorting method?

@mbomb007 I don't understand big-o notation very well, but I think a single iteration is O(n). Multiply that by worst-case n iterations and you get O(n^2) (worst-case; best-case would be O(n), I think, for a single iteration).

That sounds right to me, however it's worth pointing out that reversing an array isn't a very efficient operation, so it's a slow O(n^2)

@WheatWizard reversing an array doesn't require room for a copy of the array, only room for a single element. and is O(n).   swap first and last elements then swap second and second last elements etc, when you get to the middle stop.

Reversing is O(n), but reversing can be built right into the algorithm (that's what my JS answer does); since each iteration loops over each item in the array once, a single iteration is O(n). (I think...)

It's definitely O(n^2).  Rotating a sorted array by 1 causes causes the O(n^2) lower bound ([2,3,4,5,6,1]).  However the upper bound is also O(n^2) (assuming a good implementation), as it is strictly better than bubble sort (as it swaps two numbers + possibly more)

Here are the average number of severs for random list sizes from 1-20. Each one was run 10000 times, with the total severs counted, and then an average calculated. Note that the "random lists"  were filled with uniform random elements 1-100.

JavaScript (ES6), 64 bytes
f=([n,...a],z=[],q=[n,...z])=>a+a?n<a[0]?[...q,...f(a)]:f(a,q):q

Recursion FTW! The basic algorithm in use here is to keep track of the current non-ascending run in an array, "returning" it whenever an ascending element is found. We do this recursively, continually concatenating the results, until we run out of items. By creating each run in reverse ([n,...z] instead of [...z,n]), we can avoid the lengthy .reverse() at no cost.
Test snippet

f=([n,...a],z=[],q=[n,...z])=>a+a?n<a[0]?[...q,...f(a)]:f(a,q):q

g=a=>console.log("Input:",`[${a}]`,"Output:",`[${f(a)}]`)

g([1])
g([1,1])
g([1,2])
g([2,1])
g([3,2,1])
g([3,1,2])
g([3,1,1,2])
g([5,2,7,6,4,1,3])
<input id=I value="5, 2, 7, 6, 4, 1, 3">
<button onclick="g((I.value.match(/\d+/g)||[]).map(Number))">Run</button>

Can you explain how your array gets parsed into your first parameter [n,...a]. What is n? Is that just the first item in your array?

@obarakon Correct. n is the first item in the array, and a is the rest of the array. You can find more info here.

Thank you. That was very helpful. Since your first parameter is an array, why do you need to include the ...a? Is that just so you can take advantage of n? One more thing, when you call f(a,q), does q get set to the parameter z?

@obarakon Well, f=([n])=>... would only capture the first element, and f=([n,a])=>... would capture only the first in n and the second in a. Another way to do what f=([n,...a])=>,,, does would be f=a=>(n=a.unshift(),....

And since z is the second parameter in the function, when f(a,q) is called, f sees it as z. Hope this helps!

Python 3, 63 bytes
f=lambda x,*p:x[:1]>p>()and p+f(x)or x and f(x[1:],x[0],*p)or p

Try it online!

JavaScript (ES6), 70 bytes
Sure, this is already beaten by ETHproductions answer, but that's the best I could come up with so far without using recursion.
a=>a.map((n,i)=>a[x=[...o,...r=[n,...r]],i+1]>n&&(o=x,r=[]),r=o=[])&&x

Note: Initializing both r and o to the exact same object with r = o = [] may look like a hazardous idea. But it is safe to do so here because r is immediately assigned its own instance (containing the first element of a) on the first iteration with r = [n, ...r].
Test cases

let f =

a=>a.map((n,i)=>a[x=[...o,...r=[n,...r]],i+1]>n&&(o=x,r=[]),r=o=[])&&x

console.log(JSON.stringify(f([1])));
console.log(JSON.stringify(f([1, 1])));
console.log(JSON.stringify(f([1, 2])));
console.log(JSON.stringify(f([2, 1])));
console.log(JSON.stringify(f([2, 3, 1])));
console.log(JSON.stringify(f([2, 1, 3])));
console.log(JSON.stringify(f([2, 1, 2])));
console.log(JSON.stringify(f([2, 1, 1])));
console.log(JSON.stringify(f([3, 1, 1, 2])));
console.log(JSON.stringify(f([3, 2, 1, 2])));
console.log(JSON.stringify(f([3, 1, 2, 2])));
console.log(JSON.stringify(f([1, 3, 2, 2])));
console.log(JSON.stringify(f([1, 0, 5, -234])));
console.log(JSON.stringify(f([1, 0, 1, 0, 1])));
console.log(JSON.stringify(f([1, 2, 3, 4, 5])));
console.log(JSON.stringify(f([5, 4, 3, 2, 1])));
console.log(JSON.stringify(f([2, 1, 5, 4, 3])));
console.log(JSON.stringify(f([2, 3, 1, 5, 4])));
console.log(JSON.stringify(f([5, 1, 4, 2, 3])));
console.log(JSON.stringify(f([5, 2, 7, 6, 4, 1, 3])));
console.log(JSON.stringify(f([-5, -2, -7, -6, -4, -1, -3])));
console.log(JSON.stringify(f([14, 5, 3, 8, 15, 7, 4, 19, 12, 0, 2, 18, 6, 11, 13, 1, 17, 16, 10, 9])));

No worries, I love seeing different approaches. And one often ends up becoming shorter than another after golfing :-)

Jelly, 8 bytes
Ṁ;<œṗ³UF

Try it online!
Explanation:
Ṁ;         Prepend the list [a1, a2… an] with its maximum.
  <        Elementwise compare this with the original list:
           [max(a) < a1, a1 < a2, …, a(n-1) < an, an]
           The first element is always 0.
   œṗ³     Partition the original list (³) at the indices
           of the non-zero values in the working list.
           (The spurious `an` at the end of the left argument,
           resulting from comparing lists of different sizes,
           is ignored by this operation, thankfully.)
      U    Reverse each part.
       F   Flatten.

I was on the verge of hitting Save Edits when I saw your answer... Well done.

@Dennis Heh, so you added Dyalog partitioned enclose, but what about APL2 partition?

MATL, 15 bytes
lidO>vYsGhXSOZ)

Input is a column vector, with the format [5; 2; 7; 6; 4; 1; 3] (semicolon is the row separator).
Try it online!
Take input [5; 2; 7; 6; 4; 1; 3] as an example.
Explanation
l     % Push 1
      % STACK: 1
i     % Push input
      % STACK: 1, [5; 2; 7; 6; 4; 1; 3]
d     % Consecutive differences
      % STACK: 1, [-3; 5; -1; -2; -3; 2]
O>    % Test if greater than 0, element-wise
      % STACK: 1, [0; 1; 0; 0; 0; 1]
v     % Concatenate vertically
      % STACK: [1; 0; 1; 0; 0; 0; 1]
Ys    % Cumulative sum
      % STACK: [1; 1; 2; 2; 2; 2; 3]
G     % Push input again
      % STACK: [1; 1; 2; 2; 2; 2; 3], [5; 2; 7; 6; 4; 1; 3]
h     % Concatenate horizontally
      % STACK: [1 5; 1 2; 2 7; 2 6; 2 4; 2 1; 3 3]
XS    % Sort rows in lexicographical order
      % STACK: [1 2; 1 5; 2 1; 2 4; 2 6; 2 7; 3 3]
OZ)   % Get last column. Implicitly display
      % STACK: [2; 5; 1; 4; 6; 7; 3]

I translated your answer to Octave saved me 31 bytes!

Mathematica, 30 27 bytes
3 bytes saved due to @Martin Ender.
Join@@Sort/@Split[#,#>#2&]&

Anonymous function. Takes a list of numbers as input and returns a list of numbers as output.

Beat me to it! :)

05AB1E, 19 18 16 14 bytes
Saved 2 bytes using Luis Mendo's sorting trick
ü‹X¸ì.pO¹)ø{ø¤

Try it online!
Explanation
Example input [5, 2, 7, 6, 4, 1, 3]
ü‹               # pair-wise less-than
                 # STACK: [0, 1, 0, 0, 0, 1]
  X¸ì            # prepend a 1
                 # STACK: [1, 0, 1, 0, 0, 0, 1]
     .p          # prefixes
       O         # sum
                 # STACK: [1, 1, 2, 2, 2, 2, 3]
        ¹        # push input
                 # STACK: [1, 1, 2, 2, 2, 2, 3], [5, 2, 7, 6, 4, 1, 3]
         )       # wrap stack in list
                 # STACK: [[1, 1, 2, 2, 2, 2, 3], [5, 2, 7, 6, 4, 1, 3]]
          ø      # zip
                 # STACK: [[1, 5], [1, 2], [2, 7], [2, 6], [2, 4], [2, 1], [3, 3]]
           {     # sort
                 # STACK: [[1, 2], [1, 5], [2, 1], [2, 4], [2, 6], [2, 7], [3, 3]]
            ø    # zip
                 # STACK: [[1, 1, 2, 2, 2, 2, 3], [2, 5, 1, 4, 6, 7, 3]]
             ¤   # tail
                 # OUTPUT: [2, 5, 1, 4, 6, 7, 3]

Previous 16 byte solution
Dü‹X¸ì.pO.¡€g£í˜

Those linebreaks explained it wonderfully... :-P

@StewieGriffin: Yeah, I changed up the code and posted before I had rewritten the explanation :P

I know this is 7 years old, but for anyone else coming across this, it can be 9 bytes now using the same approach: ü‹.¥øí{øθ.

Python 2, 100 bytes
A really terrible golf, but I wanted to post my solution (one does not simply outgolf Dennis)...
d=input();L=[];x=0;d+=-~d[-1],
for i in range(1,len(d)):
 if d[i]>d[i-1]:L+=d[x:i][::-1];x=i
print L

Test on repl.it!
Input should be given as a Python list literal, such as [5, 3, 4, 2, 6, 1].
The basic idea is to make heavy use of Python's slicing syntax, slicing each necessary section from the array, reversing it, and adding it to the new array.

I think the first line can be d,L,x=input(),[],0;d+=....

@Dopapp that's exactly the same byte count

Pyke, 11 8 bytes (old version)
$0m<fm_s

Try it here! (works on latest version)
$        -     delta(input)
 0m<     -    map(i<0 for i in ^)
    f    -   split_at(input, ^)
     m_  -  map(reverse, ^)
       s - sum(^)

JavaScript (ECMA 6), 121 128 125 119 108 bytes
f=a=>{p=a[0],c=[],b=[];for(e of a){e>p&&b.push(c.reverse(c=[]));c.push(p=e)}return[].concat.call([],...b,c)}

Lambda expression takes a single Array parameter, a.
Thanks to @ETHproductions for helping me see my first mistake.

Nice! I think you can do return(b+","+c).split`,`  to save a few bytes at the end.

Better yet, you can use c.unshift instead of c.push to remove the need to reverse c. After doing this, I got 94 bytes.

Retina, 163 bytes
Yes, I know how horrid this is. Supporting zeros and negatives was super fun. Byte count assumes ISO 8859-1 encoding.
\d+
$*
(?<=-1*)1
x
-

x,1
x¶1
\b(1+),(1+\1)\b
$1¶$2
,,1
,¶1
x,(¶|$)
x¶¶
(?<=\b\1x+(?=,(x+))),\b
¶
O%$#`.(?=(.*))
$.1
+`¶
,
\bx
-x
(\w+)
$.1
^,
0,
,$
,0
,,
,0,
^$
0

Try it online
Explanation:
\d+                         # Convert to unary
$*
(?<=-1*)1                   # Replace negatives with x's instead of 1's
x
-                           # Remove minus sign

x,1                         # Separate if negative before positive
x¶1
\b(1+),(1+\1)\b             # or greater positive follows a positive
$1¶$2
,,1                         # or positive follows a zero
,¶1
x,(¶|$)                     # or zero follows a negative
x¶¶
(?<=\b\1x+(?=,(x+))),\b     # or negative follows a negative of greater magnitude.
¶
O%$#`.(?=(.*))              # Swear at the input, then reverse each line
$.1
+`¶                         # Remove breaks, putting commas back
,
\bx                         # Put the minus signs back
-x
(\w+)                       # Replace unary with length of match (decimal)
$.1
^,                          # Do a bunch of replacements to resurrect lost zeros
0,
,$
,0
,,
,0,
^$
0

Ruby, 60 55 bytes
s=->x{x.slice_when{|p,q|p<q}.map{|z|z.reverse}.flatten}

Pretty much what the challenge asked for. I defined a lambda s, that takes an array x, and sever (slices) it into smaller pieces where the following element would be greater than. This gives back an enumerator, which we can call map on and reverse the order of the pieces, before finally bringing it all together with flatten, which concatenates the elements in the defined order into one array.
Tests
p s[[1]]===[1]
p s[[1, 1]]===[1, 1]
p s[[1, 2]]===[1, 2]
p s[[2, 1]]===[1, 2]
p s[[2, 3, 1]]===[2, 1, 3]
p s[[2, 1, 3]]===[1, 2, 3]
p s[[2, 1, 2]]===[1, 2, 2]
p s[[2, 1, 1]]===[1, 1, 2]
p s[[3, 1, 1, 2]]===[1, 1, 3, 2]
p s[[3, 2, 1, 2]]===[1, 2, 3, 2]
p s[[3, 1, 2, 2]]===[1, 3, 2, 2]
p s[[1, 3, 2, 2]]===[1, 2, 2, 3]
p s[[1, 0, 5, -234]]===[0, 1, -234, 5]
p s[[1, 0, 1, 0, 1]]===[0, 1, 0, 1, 1]
p s[[1, 2, 3, 4, 5]]===[1, 2, 3, 4, 5]
p s[[5, 4, 3, 2, 1]]===[1, 2, 3, 4, 5]
p s[[2, 1, 5, 4, 3]]===[1, 2, 3, 4, 5]
p s[[2, 3, 1, 5, 4]]===[2, 1, 3, 4, 5]
p s[[5, 1, 4, 2, 3]]===[1, 5, 2, 4, 3]
p s[[5, 2, 7, 6, 4, 1, 3]]===[2, 5, 1, 4, 6, 7, 3]
p s[[-5, -2, -7, -6, -4, -1, -3]]===[-5, -7, -2, -6, -4, -3, -1]
p s[[14, 5, 3, 8, 15, 7, 4, 19, 12, 0, 2, 18, 6, 11, 13, 1, 17, 16, 10, 9]]===[3, 5, 14, 8, 4, 7, 15, 0, 12, 19, 2, 6, 18, 11, 1, 13, 9, 10, 16, 17]

Welcome, nice first second answer, check this: http://codegolf.stackexchange.com/questions/363/tips-for-golfing-in-ruby

Thanks a lot. Turned this into a lambda, as suggested in the link you provided, and saved 5 bytes that way.

Brachylog, 10 bytes
~c:{>=r}ac

Try it online!
Explanation
~c            Deconcatenate the Input
  :{>=r}a     Each resulting sublist must be non-increasing, and then reverse it
         c    Concatenate

Does Brachylog's c, when run in reverse, necessarily try splits into fewer lists first?

@ais523 yes, it does.

Husk, 4 bytes
ṁ↔ġ≤

Try it online!
I've ġot ṁyself the right tools for this job.
Explanation
ġ is "groupby": it divides a list into sublists where in each sublist the given function returns a truthy value for any pair of elements. Used with ≤, this divides the list into non-increasing sequences.
ṁ is "concatmap": it maps a function to each element of a list, and concatenates the results together. With ↔ (reverse), this performs the reverse-and-concatenate final part of the algorithm.

Dyalog APL, 7 15 bytes
Requires ⎕ML←3, which is default on many systems.*
{∊⌽¨⍵⊂⍨1+⍵-⌊/⍵}

∊ enlist (flatten)
⌽¨ each-reversed
⍵⊂⍨ the argument partitioned* by cutting where each corresponding element is larger than its predecessor in
1+ one plus
⍵- the argument minus
⌊/⍵ the smallest element of the argument

Old 7 byte solution fails with non-positive integers:
Requires ⎕ML←3, which is default on many systems.*
∊⌽¨⊆⍨⎕

∊ enlist (flatten) the
⌽¨ each-reversed
⊂⍨ self-partitioned*

* Partition (⊂) is a function which cuts its right argument where the corresponding left argument is larger than the preceding one. (Unfortunately it only accepts non-negative integers, and zero has special meaning.) From version 16, this functionality of ⊂ is available on all systems (even those where ⎕ML≠3), using the glyph ⊆.

Jelly, 6 bytes
<Ɲk$UF

Try it online!
How it works
<Ɲk$UF - Main link. Takes an array A on the left
   $   - To A:
 Ɲ     -   For each overlapping pair of elements [a, b] in A:
<      -     Is a < b?
  k    -   Partition A at the truthy elements
    U  - Reverse each subarray
     F - Flatten

Haskell, 49 bytes
(a:b)%l|any(<a)l=l++b%[a]|1<2=b%(a:l)
_%l=l
(%[])

Usage example: (%[]) [5,2,7,6,4,1,3] -> [2,5,1,4,6,7,3].
Recursive approach. The function % takes the input list as its first parameter and an accumulator l which keeps track of the non-ascending chunk so far (in reverse order). The base case is reached when the input list is empty and then the result is the accumulator. If the input list is not empty and the first element a doesn't fit in the current chunk (any(<a)l), return the accumulator and append a recursive call on the rest of the list and a as the new accumulator (l++b%[a]). Else, make a recursive call on the rest of the list and a prepended to tha accumulator (b%(a:l)). The main function (%[]) calls % with an empty accumulator.

R, 64 bytes
cat(unlist(lapply(split(x<-scan(),cumsum(c(F,diff(x)>0))),rev)))

Reads input from stdin. We split the input into a list of vectors using split() which requires a factor variable that groups the input. The factor is created by taking the cumulative sum of the the logical vector for which the difference is positive.
Consider the vector:
x=c(5, 2, 7, 6, 4, 1, 3)

Now taking the difference and prepending F by running y=c(F,diff(x)>0) would produce the following logical vector:
[1] FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE

Taking the cumulative sum cumsum(y) produces a vector where each group is represented by a unique factor upon which we can combine with the split function:
[1] 0 0 1 1 1 1 2

60 bytes using diffinv rather than cumsum.

Retina, 98 bytes
Byte count assumes ISO 8859-1 encoding.
$

-(\d+)
$1$*-/
\d+
$*
S-`(?<=(-+)/ )(?!\1)|(?=\b(1+))(?<!\2 )
O%`\S*
¶

((-)|1)*/?
$2$#1
 $

Try it online!

Octave, 75 44 bytes
Based on MATL answer of @LuisMendo
@(a)sortrows([cumsum([1;diff(a)>0]),a])(:,2)

Try it Online!
Previous answer
@(a)[fliplr(mat2cell(f=fliplr(a),1,diff(find([1,diff(f)<0,numel(a)])))){:}]

Try it Online!
reverse the array
f=fliplr(a)

take first difference of f
d = diff(f);

find position of where the next element is less than the previous element
p=find([1,diff(f)<0,numel(a)])

first difference of the positions returns length of each sub array
len=diff(p)

use length of each sub array in mat2cell to split the array to nested list of arrays
nest = mat2cell(f,1,len);

reverse the nested list
rev_nest = fliplr(nest)

flatten the nested list
[rev_nest{:}]

R, 41 bytes
ave(x,diffinv(diff(x<-scan())>0),FUN=rev)

Try it online!

K (ngn/k), 17 15 bytes
{,/|'x@=+\>':x}

Try it online!
Chunks the input on indices where the value is greater than the previous value, reversing each chunk and concatenating back into a single array.

>':x check whether each element is larger than the prior element
=+\ group the cumulative sum of this; elements in each run of equal or decreasing values get assigned their own index in the resulting dictionary
x@ index back into the original input to retrieve the original values
|' reverse each chunk
,/ flatten the chunks back into a single array

Husk, 12 bytes
Completely and utterly outgolfed by Leo while I was typing in my answer...!
ṁ↔CẊ-Θ:W<¹L¹

Try it online!
ṁ              # map this function:
 ↔             # reverse
               # across all the elements of:
  C            # cut the input into sublists given by
   Ẋ-          # differences between elements of
       W<¹     # list of indices of the input that are less than their successor
     Θ:   L¹   # prepended with zero and appended with the length of the input

Let me introduce you to ġroupby :) https://codegolf.stackexchange.com/a/218911/62393

@Leo - I pressed 'submit', only to find your answer staring back at me!

Vyxal 3, 6 bytes
ᵃ>ṁƒVf

Try it Online!
a weird quirk of "partition after truthy indices" means it matches lengths so it will never include the last value when getting booleans from comparing the overlapping pairs. By appending the reversed list we can always have a partition such that the last values are kept

Pyth - 15 bytes
s_McQf<@QtT@QTU

Try it online here.

Perl 6, 59 bytes
{map |+«*.[0].reverse,m/:s([(\-?\d+)<?{[>=] $0}>] +)+/[0]}

Regex-based solution.
Because this is Sparta Perl!!

m/  /: Stringify the input array, and match a regex against it.
(\-? \d+): Match a number, and capture it as $0.
<?{ [>=] $0 }>: Zero-width assertion that only matches if all $0 captured so far in the current sub-match are in non-ascending order.
([  ] +)+: Repeat the last two steps as often as possible, otherwise start a new sub-match.
map   ,   [0]: Iterate over the sub-matches.
|+«*.[0].reverse: For each one, take the list of values matched by $0, reverse it, coerce the values to numbers (+«), and slip them into the outer list (|).

Perl 6, 63 bytes
sub f(\a){flat $_,f a[+$_..*]with first {[<=] $_},:end,[\R,] a}

Recursive list processing solution.
More laborious than I had hoped.
Even though the language has lots of convenient built-ins, there seem to be none for list partitioning (e.g. like Ruby's slice_when or Haskell's takeWhile).

Stacked, noncompeting, 34 bytes
Still constantly developing this language.
{e.b:e b last<}chunkby$revmap flat

Argument lies on TOS. Try it here!
chunkby takes a function and collects arrays of contiguous data that satisfy the function. The function then is:
{e.b:e b last<}
{e.b:         }  function with arguments [e, <unused>, b]--the element, <the index>, and the
                 chunk being built
     e       <   check if e is less than
       b last    the last element of b

This gives a strictly decreasing array.
$revmap is basically [rev]map and reverses each item.
flat finally flattens the array.

Some fun for actually sorting the array:
[{e.b:e b last<}chunkby$revmap flat] @:sortstep
[$sortstep periodloop] @:sort

10:> @arr
arr out
arr shuf @arr
arr out
arr sort out

This outputs (for example):
(0 1 2 3 4 5 6 7 8 9)
(4 5 1 0 6 7 2 8 9 3)
(0 1 2 3 4 5 6 7 8 9)

Python, 151 139 Bytes
Saved 12 Bytes thanks to @Flp.Tkc!
Nowhere near @Flp.Tkc, let alone...
def s(l):
 r=[];i=j=0
 while j<len(l)-1:
  if l[j+1]>l[j]:r+=l[i:j+1][::-1],;i=j+1
  j+=1
 r+=l[i:j+1][::-1],;return[i for s in r for i in s]

Instead of using append, use += data, the trailing comma implicitly constructs a tuple, which is then concatenated with the list, adding the data as the last element in the list. In this context, do r+=l[i:j+1][::-1],

Python 2, 74 bytes
b=[];c=[];a+=9e9,
for i in a[:-1]:
 b=[a.pop(0)]+b
 if b[0]<a[0]:c+=b;b=[]

Input in a, output in c

Python 3, 191 Bytes
a=[int(i)for i in input().split()]
while a!=sorted(a):
 b=[[]]
 for i,j in enumerate(a):
  if a[i-1]<j:b+=[[j]]
  else:b[-1]+=[j]
 a=[]
 for l in[k[::-1]for k in b]:a+=[k for k in l]
print(a)

I'm not sure if using the sorted function to check is allowed here, but I couldn't think of a good reason against it, and it brought down my byte count by ~30 Bytes.

Clojure, 105 bytes
#(filter number?(mapcat reverse(partition-by not(mapcat(fn[[a b]][a(< b a)])(partition 2 1(conj % 1))))))

Partitions into pairs on consecutive numbers, puts true or false between them, partitions on not to true and numbers become false and false true, reverses partitions and keeps numerical values.

Perl 5 -MList::Util=reduce -ap, 45 bytes
$_=reduce{$a<$b&&(print$a,$")&&$b||"$b $a"}@F

Try it online!

Japt, 5 bytes
ò< cw

Try it
ò      Partition between elements A, B where the following is true:
 <       A < B
   c   Flatten after mapping each list to:
    w    it reversed

Replace m with c to get the correct output.

@Shaggy Forgot about that, nice idea

Go, 172 bytes
func(s[]int)(o[]int){if len(s)<2{return s}
a:=[]int{s[0]}
for _,e:=range s[1:]{if a[0]<e{o,a=append(o,a...),[]int{e}}else{a=append([]int{e},a...)}}
o=append(o,a...)
return}

Attempt This Online!
Explanation
func(s[]int)(o[]int){
if len(s)<2{return s}            // return the original if it's 1 element or smaller
a:=[]int{s[0]}                   // seed with the first element
for _,e:=range s[1:]{            // for each element of the tail...
 if a[0]<e{                      // if the previous element was smaller than the current...
  o,a=append(o,a...),[]int{e}    // append to the output, and reset
 }else{a=append([]int{e},a...)}} // otherwise push to the front
o=append(o,a...)                 // append the remainder to the output
return}                          // return

JavaScript (Node.js), 54 bytes
x=>x.map((t,i)=>z.splice(q=t<=x[i-1]?q:i,0,t),z=[])&&z

Try it online!
Recurseless win


text:
Golf a Numerical Growing Braid
Braid Description
In this braid, when a strand crosses over the top of another strand it adds the other strand's value to itself and all other strand values pass through. The braid has three strands and each strand begins at 1. The first crossover is the leftmost strand crossing over the middle strand. The next crossover is the rightmost strand crossing over the new middle strand (previously the leftmost strand). These two steps of crossovers repeat. In other words, the first crossover is [a, b, c] -> [b, a+b, c] and the second is [a, b, c] -> [a, b+c, b]. Using these rules here are the first six levels of the braid:
1,1,1
1,2,1
1,3,2
3,4,2
3,6,4
6,9,4

Your task
Write a golfed program or function that accepts an integer as the braid level and outputs the three values for that level of the braid. You must indicate if your levels are zero- or one-based. Input and output may come in any reasonable format and trailing white space is allowed.
Test Cases (1-based)
1 -> 1,1,1

2 -> 1,2,1

5 -> 3,6,4

10 -> 28,41,19

Some related sequences (to the middle numbers)

MATL, 18 17 16 bytes
7Bi:"2:4PB@EX!Y*

Input is 0-based.
Try it online! Or verify all test cases.
Explanation
Given a row vector [a b c], the next vector is obtained post-matrix-multiplying it by either
[1 0 0;
 0 1 1;
 0 1 0]

or
[0 1 0;
 1 1 0;
 0 0 1]

depending on whether the iteration index is odd or even. For example, the matrix product [1 3 2]*[0 1 0; 1 1 0; 0 0 1] gives [3 4 2]. Then [3,4,2]*[1 0 0; 0 1 1; 0 1 0] gives [3 6 4], and so on.
Note also that the second matrix equals the first rotated 180 degrees, which can be exploited to save a few bytes.
7        % Push 7
B        % Convert to binary. Gives [1 1 1]. This is the initial level
i        % Take input n
:        % Push range [1 2 ... n]
"        % For each
  5      %   Push 5
  I:     %   Push range [1 2 3]
  -      %   Subtract, element-wise: gives [4 3 2]
  B      %   Convert to binary. This gives the matrix [1 0 0; 0 1 1; 0 1 0]
  @      %   Push current iteration index
  E      %   Multiply by 2. Gives 2 in the firt iteration, 4 in the second etc
  X!     %   Rotate matrix 90 degrees either 2 or 0 times
  Y*     %   Matrix multiply
         % End. Implicitly display

Have you considered pairing the steps? That way you have one matrix [[0, 1, 0], [1, 1, 1], [1, 1, 0]] and the different starting positions are quite similar for even and odd n

@PeterTaylor Thanks for the idea. In this case varying the initial vector and dividing the input by 2 seems to be more byte-costly

Haskell, 51 bytes
f p@(a,b,c)=p:(b,a+b,c):f(b,a+b+c,a+b)
(f(1,1,1)!!)

This uses 0-based indexing. Usage example: (f(1,1,1)!!) 10 -> (28,60,41).
f creates the infinite list of braid triples and (f(1,1,1)!!) picks the nth one. f itself is a simple recursion which makes a list of its argument, followed by the left crossover and a recursive call with left and right crossover.

Ruby, 60 57 bytes
->n{f=->x{x<2?1:f[x-1]+f[x-3]};[f[n-2|1],f[n],f[n-1&-2]]}

The levels are 1-based.
Based on the following formula:
f(-1) = 1
f(0)  = 1
f(1)  = 1
f(x)  = f(x-1) + f(x-3)

braid(x) = {
    [f(x-1), f(x), f(x-2)]  if x is even,
    [f(x-2), f(x), f(x-1)]  if x is odd
}

Thanks to Neil for 3 bytes off with some nifty bitwise shenanigans.

Bitwise operators FTW: [f[n-2|1],f[n],f[n-1&-2]].

@Neil That's pretty neat, thanks!

Python 2, 57 bytes
f=lambda n,a=1,b=1,c=1:1/n*(c,b,a)or f(n-1,b,b+c,a)[::-1]

Try it online!

Jelly, 14 bytes
Ḋ+\;Ḣ
6BÇ⁸¡Ṛ⁸¡

Try it online!
How it works
6BÇ⁸¡Ṛ⁸¡  Main link. Argument: n (integer)

6B        Convert 6 to binary, yielding [1, 1, 0], which is the braid at index 0.
  Ç⁸¡     Call the helper link n times.
     Ṛ⁸¡  Reverse the resulting array n times.

Ḋ+\;Ḣ     Helper link. Argument: [a, b, c] (integer array)

Ḋ         Dequeue, yielding [b, c].
 +\       Cumulative sum, yielding [b, b+c].
   ;Ḣ     Concatenate with the head of [a, b, c], yielding [b, b+c, a].

TI-Basic, 58 bytes
One-based.
Prompt N
{1,1,1
For(I,1,Ans
If fPart(I/2
Then
{Ans(2),Ans(1)+Ans(2),Ans(3
Else
{Ans(1),Ans(2)+Ans(3),Ans(2
End
End

How is this 58 bytes? I count 114.. am I missing something?

@briantist TI-Basic commands are one or two bytes long. e.g. Prompt is a 2-byte command.

@JungHwanMin cool, did not realize. I had a feeling there was something I wasn't seeing. I'll leave my comment for others who are unfamiliar.

To see which tokens are one or two bytes, you can check http://tibasicdev.wikidot.com/tokens

@JungHwanMin Prompt  is only one byte. But thanks for explaining the concept of tokens :)

@Timtech Thanks for correcting me.

PowerShell 2+, 75 bytes
1-based index
$a=1,1,0;1..$args[0]|%{$d=(0,2)[$_%2];$a[1],$a[$d]=($a[1]+$a[$d]),$a[1]};$a

Try it online! or Try all Test Cases!
The loop always runs once so for the case of braid level 1 I simply start with an array of 1,1,0 so the result of the algorithm with make it 1,1,1.
$a[1] is always the middle, then I just determine whether the other element index ($d) is going to be 0 or 2 based on whether the current level is even or odd. PowerShell supports multiple assignments at once so swapping becomes as easy as $x,$y=$y,$x which is basically what I'm doing with the array elements, just embedding the addition within that assignment.

Javascript (ES6), 55 bytes
x=>(f=y=>y<2?1:f(y-1)+f(y-3),[f(x-2|1),f(x),f(x-1&-2)])

repl.it
1-based
This is just a port of @Doorknob's Ruby answer with @Neil's awesome bitwise golf.

Befunge, 64 bytes
110p100p1&v
01:\_v#:-1<\p00<v\+g
..g.@>_10g
\1-:!#^_\:00g+\v>10p

Try it online!
Explanation
110p                Initialise a to 1 (at location 1;0).
    100p            Initialise c to 1 (at location 0;0).
        1           Initialise b to 1 (on the stack, since it'll be most frequently used).
         &v         Read n from stdin and turn down.

          <         The main loop starts here, executing right to left.
        -1          Decrement n.
    _v#:            Duplicate and check if zero; if not, continue left.
   \                Swap b to the top of the stack, leaving n below it.
01:            g    Make a duplicate copy, and read a from memory (at location 1;0).
              +     Add a to b, the result becoming the new b.
            v\      Swap the original b to the top of the stack and turn down.
            >10p    Turn around and save the original b as a (at location 1;0).
\1-                 Swap n back to the top of the stack and decrement.
   :!#^_            Duplicate and check if zero; if not continue right.
        \           Swap b to the top of the stack, leaving n below it.
         :00g       Make a duplicate copy, and read c from memory (at location 0;0).
             +      Add c to b, the result becoming the new b.
              \v    Swap the original b to the top of the stack and turn down.
            p00<    Turn around and save the original b as c (at location 0;0).
           \        Swap n back to the top of the stack.
          <         And repeat the loop from the beginning.

      >             If either of the zero tests succeed, we end up on line 3 going right.
       _            This just drops the n that is now zero, and continues to the right.
        10g         Read the final value of a (at location 1;0).
..                  Output a along with the b that was already on the stack.
  g                 Read the final value of c (the 0;0 location is implied).
   .@               Output c and exit.

05AB1E, 17 bytes
6bSIF¬¸s¦.pOì}¹FR

Try it online!

Java 8, 121
This uses one-based levels:
(int l)->{int a=1,b=a,c=a,i=a;while(i<l)if(i++%2>0){b^=a;a^=b;b=(a^b)+a;}else{b^=c;c^=b;b=(c^b)+c;}return a+","+b+","+c;}

Ungolfed, with test program:
import java.util.function.IntFunction;

public class GolfANumericalGrowingBraid {

  public static void main(String[] args) {
    for (int level : new int[] { 1, 2, 5, 10 }) {
      output((int l) -> {
        int a = 1, b = a, c = a, i = a;
        while (i < l) {
          if (i++ % 2 > 0) {
            b ^= a;
            a ^= b;
            b = (a ^ b) + a;
          }
          else {
            b ^= c;
            c ^= b;
            b = (c ^ b) + c;
          }
        }
        return a + "," + b + "," + c;
      } , level);
    }
  }

  private static void output(IntFunction<String> function, int level) {
    System.out.println(function.apply(level));
  }
}

Output:

1,1,1
  1,2,1
  3,6,4
  28,41,19

GameMaker Language, 113 bytes
One-indexed, based on Doorknob's recursive solution. Please don't ask why you can't initialize a primitive array all at once in GameMaker, I really don't know...
Main program (69 bytes):
a=argument0 if a mod 2c=1b[0]=a(a-c-1)b[1]=a(a)b[2]=a(a+c-2)return b

Subprogram a (46 bytes):
a=argument0 if a<2return 1return a(a-1)+a(a-3)

Perl 6, 60 bytes
{(1 xx 3,->[\a,\b,\c]{$++%2??(a,b+c,b)!!(b,b+a,c)}...*)[$_]}

Zero-based.
Straight-forwardly generated the lazy infinite sequence, and then indexes it.
There are likely better approaches.

Clojure, 98 bytes
#(ffirst(drop %(iterate(fn[[v[a b c d]]][[(v a)(+(v b)(v c))(v d)][b a d c]])[[1 1 0][0 1 2 1]])))

Keeps track of current value v and from which positions the summation should be made for next round. Starts one state before the [1 1 1] to have 1-based indexing.

C# 88 86 Bytes
f(int n,int a=1,int b=1,int c=1)=>n>1?n--%2>0?f(n,b,a+b,c):f(n,a,b+c,b):a+","+b+","+c;

Explanation
f(int n,int a=1,int b=1,int c=1)=>  //Using an expression bodied function to allow for defaults and remove return statement
    n>1?                            //recurse or return result
        n--%2>0?                    //get odd or even then decrement n
            f(n,b,a+b,c)            //odd recursion
           :f(n,a,b+c,b)            //even recursion
       :a+","+b+","+c;              //build output

Mathematica, 68 bytes
If[#<3,{1,#,1},{{#,+##2,#2}&,{#2,#+#2,#3}&}[[Mod[#,2,1]]]@@#0[#-1]]&

Straightforward recursive definition of an unnamed function, taking a positive integer argument and returning an ordered list of three integers.


text:
Output the first position in your program for each input character
Challenge
Write a non-empty program/function p that, given a non-empty input string s, outputs the position of the first occurrence of each character of s in the source code of p.
For example, if your program is
main() { cout << magic << cin }
^0   ^5   ^10  ^15  ^20  ^25

and it receives an input abcd{, the output should be
[1, x, 9, x, 7] (0-based)        [2, x, 10, x, 8] (1-based)

Here, x represents any output that is not a valid output for a character position (e.g., a negative number, 0 if you use 1-based indexing, NaN, Inf, the string potato, a number greater than your program's length, etc).
Restrictions
Reading the source code is not allowed (like in a proper quine). The use of comments is allowed, but does count towards your score.
Input and output can be done in a reasonable format, but must be unambiguous (only additional delimiters, no rand stream and claiming that the answer is somewhere in there), consistent (e.g., the x from above should always be the same value) and human-readable; for example, a string or a character array. You can assume that the input is a string (or array) of printable ASCII characters; no need to handle the entire Unicode set.

Custom code-page or non-printable ascii in your code?
If your language uses a custom code-page (Jelly, APL, etc), you must take that into account (so a program €æÆ must output [1, x, 2] for an input €%æ). Using only non-ASCII characters to output -1 always (since the input is ASCII-only) is not a valid solution. You may assume that your program natively accepts your custom codepage, i.e., if your program has a method of converting a character A to an integer 65 (ASCII encoding), you may assume that it now converts the 65th character in your codepage to 65.

Inspired on the following challenge: Positional Awareness

Does capitalisation matter?

@KritixiLithos by default, yes.

@KritixiLithos It does indeed.

If my program only uses indices 0 to 9, do I need a separator or could I output, e.g., 01030708070?

@Dennis No, you do not. It's unambiguous, consistent and human-readable. Requiring a separator would not add anything interesting to the challenge, so by all means abuse your low byte count. ;)

Why do I use 05AB1E for quine challenges? I know it's not meant for it...

Python2, 55 Bytes
a=" )dfi(+m,nprut.';";print map(('a="'+a).find,input())

Starts with a string that contains all the characters used in the code, and then search the indexes

I don't see how this is the boring answer. I think using the standard quine is a lot less interesting than this. :)

Since this is Python 2, wouldn't this break on most inputs?. If it does break, you'd have to use raw_input.

@TidB hmm, I guess no? what input do you have in mind?

@Rod Nevermind, I was just being a little dumb. It'll always work when you input an iterable. Silly me.

Lenguage, 56,623 bytes
Below is a hexdump of the first 256 bytes. The remaining bytes can be chosen arbitrarily.
0000000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f  ................
0000010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f  ................
0000020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f   !"#$%&'()*+,-./
0000030: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f  0123456789:;<=>?
0000040: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f  @ABCDEFGHIJKLMNO
0000050: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f  PQRSTUVWXYZ[\]^_
0000060: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f  `abcdefghijklmno
0000070: 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f  pqrstuvwxyz{|}~.
0000080: 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f  ................
0000090: 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f  ................
00000a0: a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af  ................
00000b0: b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf  ................
00000c0: c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf  ................
00000d0: d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df  ................
00000e0: e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef  ................
00000f0: f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff  ................

Output is in bytes, as customary for brainfuck et al.
How it works
This is a simple cat program, specifically ,[.,].
The source code contains all 256 byte values in order, so each byte's index in it matches its value.

Hmmm I think Lenguage is the only language where people are outgolfed by three orders of magnitude...

Lenguage is also the only language that constantly finds ways to cheat that wouldn't even be remotely competitive in other languages. :P

Wouldn't +[,.] make for a much better score?

@Sanchises That would save roughly 12,000 bytes, but it would also print an extra null byte at the end.

Well, I suppose the null byte is in the input (even though it's function is to terminate the string), and would be at the 0th position in your program... ;)

Lenguage, 1.22e7 bytes
Consists of 12263215 NUL bytes, (Hex 0x00).
Outputs a NUL for every character that doesn't appear in the source.

 The ruse is that the input will never contain a NUL, so we always output the amount of NULs that there are characters in the input.

This translates to the following Brainfuck program
,[[-].,]

And with a breakdown...
,[[-].,]
,[    ,]    #Basic Input loop.
  [-]       #Zero out the cell.
     .      #Print it (A NUL).

This just shows the sheer power of Lenguage as a golfing language. Fear it.

Such a clever ruse, you almost won... Did you try the reverse too, I.e 0x00 bytes and 1-indexing?

I would have loved to, but Brainfuck/Lenguage (Or atleast, the interpreter I'm using) cannot differentiate between EOF and 0x00, So I would be unable to actually answer the challenge.

Brainfuck et al. are usually allowed to print integers as bytes, i.e., you'd print SOH for 1, NUL for 0.

@Sanchises Could you confirm that is the case here?

It's not about output in this case, Input is the issue.

But the challenge says the input will contain only printable ASCII characters.

Then I can abuse this much more.
Give me a moment to write a new script.

Hmmm. I suppose I overlooked the fact that some esolangs can use non-printable ascii, as you've shown here - I thought that most languages that used the full 0-255 range would have a custom code page. Your entry then confirms to the letter of the rules, but is definitely against the spirit of the rules, specifically, "...in other words, using only non-ASCII characters to output -1 always (since the input is ASCII-only) is not a valid solution."

As for the output, languages are defined by their implementation. If there's an interpreter that renders 0x00 and 0x01 as distinct characters, it's human-readable and thus allowed.

Actually, it does not depend on an interpreter as to what encoding is outputted, only the bytestream that is outputted. It is up to whatever views that bytestream to determine what that encoding is.

I updated the rules to rule out this answer, seeing as you showed that you could do without. I would include both the old version and this version marked as non-competing and causing the OP a headache.

Outputting raw bytes is fine though, I have decided after much contemplation

Wouldn't ,[>.,] be shorter?

Jelly, 10 9 bytes
“ṾiÐ€Ɠv”v

Try it online!
How it works
“ṾiÐ€Ɠv”v  Main link. No arguments.

“ṾiÐ€Ɠv”   Set the left argument and the return value to s := 'ṾiÐ€Ɠv'.
        v  Execute the string s as a monadic Jelly program with argument s.

 Ṿ         Uneval; yield a string representation of s, i.e., r := '“ṾiÐ€Ɠv”'.
     Ɠ     Read one line from STDIN and evaluate it like Python would.
  iÐ€      Find the index of each character in the input in r.
      v    Eval the list of indices as a monadic Jelly program with argument s.
           Why?
             This is the shortest way to add the character 'v' to the string s,
             meaning that we can use r without having to append anything.
           What?
             The v atom vectorizes at depth 1 for its left argument, meaning that
             it acts on arrays of numbers and/or characters. When fed an array of
             integers, it first converts them to strings, then concatenates the
             strings and evaluates them as a Jelly program. For example, the array
             [1, 2, 3] gets cast to the string '123', then evaluates, yielding 123.
             Something slightly different happens if the array starts with a 0. For
             example, the array [0, 1, 2] gets cast to '012' just as before, but
             Jelly views '0' and '12' as two separate tokens; numeric literals
             cannot start with a 0. Since the Jelly program is monadic, the first
             token – '0' – sets the return value to 0. Since the second token –
             '12' – is also a niladic link, the previous return value is printed
             before changing the return value to 12. Then, the program finishes
             and the last return value is printed implicitly.

pbrain, 402 356 340 338 329 bytes
[(:<>)+,-.](>>>>>>)+([-]<<[->+>+<<]>>[-<<+>>]>>[-<+<+>>]<[->+<]<[-<->]<)+([-]+++++++[>+++++++++++++<-]>)+([-]+++++[>++++++++<-]>)+(-:<+++[->++++++<]>)+(-:++)+(-:++)+(----:+)+(-:++)+(-:+)+(-:+)+(-:+)+([-]++:++)+([>[->+>+<<]>>[-<<+>>]<:>>+:[[-]>+<]>-[<<<<[-.>]>>>>>>+>>>>>]<<[-]<<+<-]>>>)[-]>>>>>>>,[<<<<<<++<+++++++++++++:>>>>>>,]

Phew, @KritixiLithos and I have been working on this for 4 days now.
Prints 0x00 if input char isn't in program, index of the char (1-based) in hex otherwise. Try it online!
Explanation:
[(:<>)+,-.]
All chars listed here; like other submissions
(>>>>>>)
@KritixiLithos added this part; I don't know what it does but saves the program
+([-]<<[->+>+<<]>>[-<<+>>]>>[-<+<+>>]<[->+<]<[-<->]<)
Comparison ;calculates z=x!=y and puts it in between x and y
Start; X _ _ _ Y
           ^
End;   X Z _ _ Y
         ^
+([-]+++++++[>+++++++++++++<-]>)
Function to add 91 to the tape
+([-]+++++[>++++++++<-]>)
Function to add 40 to the tape
+(-:<+++[->++++++<]>)
Function to add 58 to the tape
+(-:++)
Function to add 60 to the tape
+(-:++)
Function to add 62 to the tape
+(----:+)
Function to add 41 to the tape
+(-:++)
Function to add 43 to the tape
+(-:+)
Function to add 44 to the tape
+(-:+)
Function to add 45 to the tape
+(-:+)
Function to add 46 to the tape
+([-]++:++)
Function to add 93 to the tape
+([>[->+>+<<]>>[-<<+>>]<:>>+:[[-]>+<]>-[<<<<[-.>]>>>>>>+>>>>>]<<[-]<<+<-]>>>)

This last function is the loop. It loops through the selected characters [(:<>)+,-.] in order and compares the input with the character. Now I'm going to give a deeper explanation on how this loop works.
12-n n+2 _ n+2: _ _ _ i _ _ _ _ _ _;  n=loop counter
                  ^                ;  i=input

The stack looks like that while in a loop. The loop will run until 12-n is 0. Then we have the counter which is n+2. This counter is also the number of the function for each of the selected characters. So when n=0, n+2 will be corresponding to the first character, ie [. >[->+>+<<]>>[-<<+>>]<: does just that, it converts the counter to the character.
Once the pointer is where the caret is, we will compare the character produced from the counter variable with the input while preserving them.
12-n n+2 _ n+2: Z _ _ i _ _ _ _ _ _;  n=loop counter
                ^                  ;  i=input

Z is 0 when the character is equal to the input, or some other non-zero integer otherwise.
Now we come up with an if-statement to check this equality.
[[-]>+<]

If Z is non-zero, ie the character and the input are not the same, we increment the next memory place.
After we come out of this if-statement, we decrement the next memory place. Now this memory place contains !Z. Finally using this, we output the index of the character if it matches with the input and then exit the loop forcibly. Else, we continue on with the loop until either it is over or a match is found.
[-]>>>>>>>
Clears first byte; goes to position to start program
,[<<<<<<++<+++++++++++++:>>>>>>,]
Loops inputs

CJam, 14 12 bytes
{sq\f#p_~}_~

Uses 0-based indexing and -1 for characters that don't appear in the source.
Try it online!

Javascript, 34 bytes
f=a=>a.map(v=>('f='+f).indexOf(v))

It takes input as array of strings, x is -1 (0-based indexing).

It's allowed, since that method is also acceptable for quines. It doesn't open its source file and read it or use a variable initialized to the source.

@mbomb007 I can't speak for all JavaScript engines but in Firefox Function.toString works by reading the source. At one point it would crash in debug builds if the source was no longer there when it tried to read it. (I haven't tried it recently because debug builds are so crashy in general.)

I don't think it's any different than doing s='s=%s;print s%%s';print s%s in Python. It doesn't include the f=, so it's okay

You can not really do that, because the input a is supposed to be a string. There is no map function for strings.

@manonthemat "You can assume that the input is a string (or array)"

This solution is allowed, because it indeed only toString()'s the function, not the entire source code; with the clever bit being that most of the code is a single function implementation.

Ruby, 41 88 86 71 69 67 61 56 bytes
a='p$<.chrs{| #index};"';$<.chars{|c|p"a='#{a}".index c}

Thx Lynn for killing 6 bytes

a='p$<.chrsm{| #index};"';p$<.chars.map{|c|"a='#{a}".index c} should work too, taking input from STDIN.

C, 153 152 143 bytes
char s[99],p[]="odeflnrti%()*+-0;<={}\\";c;f(char*i){sprintf(s,"char s[99],p[]=\"%s",p);for(c=0;c<strlen(i);)printf("%d ",strchr(s,i[c++])-s);}

Try it online!

119 bytes

><> (Fish) 70 bytes
 #.0+4*a5;!?l|!?f4*b+l1--naolc3*1+0.01?!|~ed+0.0+2e-{:;!?+1:i-1:r}+2:"

Probably the longest ><> 1 liner I've ever made.
It will print the output for each character found on a separate line (0 indexed).
A non found character will always print the length of the code + 1 (I could change this if deemed not okay in it's current state) so in this case 71 will always be the "Not found" characters.
I'll run up an explanation once I get the time.
Some test cases;
##K = 1\n1\n71
#"# = 1\n69\n1
Try it online
><> language

I think 71 is fine as an output for not found. It's consistent, unambiguous and human-readable, which I think is more important than it being "...any output that is not a positive integer". I expanded the rules to reflect this decision.

Perl 6, 50 52 bytes
{(('R~.index$_) for}\\'R~'{((\'').index($_) for $_)}

Translation of G B's Ruby solution and Rod's Python solution.
A lambda that inputs a list of characters and outputs a list of zero-based indexes (Nil for nonexistent characters).
EDIT: Fixed an oversight - required adding 2 bytes :(

Clojure, 43 56 48 bytes
Edit: Damn I forgot about 2! Increased from 43 to 56.
Edit 2: Updated the sample code below this text, updated the number of bytes not to include (def f ...) but just the hash-map part.
{\{ 0\\   1\  3\0   4\1 10\3 14\4 20\2 34 \} 43}

The hash-map consists only of characters 01234{\\}, and it encodes their locations. In Clojure hash-maps can be used functions, as shown in this complete example (f could be replaced by the hash-map definition):
; Keeping track of the zero-based index:
;      00000000001111111111222222222233333333334444444444
;      01234567890123456789012345678901234567890123456789
(def f {\{ 0\\   1\  3\0   4\1 10\3 14\4 20\2 34 \} 43})

(map f "0123456789{} \\abcdef") ; (4 10 34 14 20 nil nil nil nil nil 0 43 3 1 nil nil nil nil nil nil)
(apply str (keys f))            ; " 01234{\\}"

I guess this counts :)

05AB1E, 19 bytes
"'ìsvDyk,"'"ìsvDyk,

Try it online!
This outputs -1 in place of missing chars.

Luis Mendo posted this (slightly modified) on Golf you a quine for great good! , adding "s" and  "k" to that quine results in this answer as well. However, I can't take credit for that trivial of a modification... Luis, you can message me if you'd  like to repost this and I'll just delete it. If you want to see my progress before finding that question, view edits. Well... It was significantly like his at one point.

@Sanchises works for me!

Cool cool cool!

@MagicOctopusUrn Well done!!

"'ìIk"'"ìIk - 11 bytes

Thunno 2, 10 bytes
"Ṙs€Ȯ"Ṙs€Ȯ

Attempt This Online!
Explanation
"Ṙs€Ȯ"Ṙs€Ȯ  # Implicit input
"Ṙs€Ȯ"      # Push the string "Ṙs€Ȯ"
      Ṙ     # Surround it by quotes
       s€Ȯ  # Get the index of each character
            # of the input in the string
            # Implicit output

Can you show this works with multiple characters simultaneously? The challenge specifies a string, not a single character.

@Sanchises sorry, I didn't read that properly. It should be fixed now.

JavaScript, 39 bytes

p=s=>[...s].map(c=>`p=${p}`.indexOf(c))

console.log( p('mapP') )

can you explain [...s] please?

It is known as spread operator, you can see a bit more in the ES6 golfing tips.

Reading the source code is not allowed

Pyth, 11 bytes
xL_+N"N+_Lx

A program that takes input of a "quoted string", with any quotes in the string escaped with a preceding \, and prints a list of zero-indexed values with -1 for characters not in the source.
Try it online!
How it works
xL_+N"N+_Lx    Program. Input: Q
xL_+N"N+_Lx"Q  Implicit quote closure and implicit input
     "N+_Lx"   Yield the string "N+_Lx"
   +N          Prepend a quote
  _            Reverse
 L          Q  Map over Q:
x               Yield the index of the character in the string
               Implicitly print

Java 8, 172 122 119 bytes
a->/*.forEch(Systemupin"\dxO)+ ;:*/a.forEach(c->System.out.print("a->/*.forEch(Systemupin\"\\dxO)+ ;:".indexOf(c)+" "))

0-indexed, and gives -1 for characters that aren't part of the source code.
Try it online.
Explanation:
a->                    // Method with character-array parameter and no return-type
  /*.forEch(Systemupin"\dxO)+ ;:*/
                       //  Comment containing the remaining characters of the code
  a.forEach(c->        //  Loop over the input-array:
    System.out.print(  //   Print
      "a->/*.forEch(Systemupin\"\\dxO)+ ;:"
                       //   from a String containing all the characters used in the code
      .indexOf(c)+" "))//   the index of the char, plus a space as delimiter

SmileBASIC, 128 96 88 86 bytes
?R<3+CD,4LINPUT(S$)WHILE""<S$?INSTR("?R<3+CD,4LINPUT(S$)WHILE"+CHR$(34),SHIFT(S$))WEND

An important thing to realize is that this is not really a quine challenge. You only need the source code up to the last unique character.
I put at least 1 of each character at the beginning of the code: ?R<3+CD,4LINPUT(S$)WHILE" so I only have to store a copy of the program up to the first quotation mark.

Japt -m, 2 bytes
Takes input as a character array. Output is 0-based, using -1 for invalid characters. String input could also be used but there would be no separator between the output indices, which shouldn't be an issue as it would be unambiguous seeing as they can only be 0 & -1.
bb

Try it
bb     :Implicit map of each U in input array/string
b      :First 0-based index in U of
 b     :  Literal "b"

Alternatively:
aa

Try it
a being lastIndexOf.

Python, 90 88 bytes
a,b,d=" ()+.7:[]efilmnor","a,b,d=\"",lambda e:[[b.find(d),a.find(d)+7][d in a]for d in e]

Test case:
print(d("a,b(]q"))
#[0, 1, 2, 8, 15, -1]

Stacked, noncompeting, 36 bytes
When I said this language was still in development, I meant it. Apparently, prompt used to consume the entire stack. This is why I can't have nice things. Try it here!
[tostr ':!' + prompt CS index out]:!

This is the standard quine framework. Basically, : duplicates the function [...] on the stack, which is then executed with !. Then, the inside of [...] executes with the function on the stack. It casts it to a string, appends :! (the program itself), then takes a string input with prompt. CS converts it to a character string. A character string is a bit different from a regular string in that it has operators vectorize over it. In this case, index vectorizes over the input, yielding each index of the input string in the program, finally being outputted.
For input Hello, World!, this gives:
(-1 27 -1 -1 2 -1 6 -1 2 5 -1 26 9)

I tried using the one without a quine (i.e. encoding the string of characters that appear in your source), but there is only one type of quotation mark in Stacked, namely, ', so it would be longer to do that type of solution.

Husk, 12 bytes
m€`:'""m€`:'

Try it online!
Explanation
The explanation is using ¨ to delimit strings and ' to delimit characters:
m€`:'""m€`:'  -- implicit input, for example: ¨m"a1`¨
      "m€`:'  -- string literal: ¨m€`:'¨
  `:'"        -- append character '"': ¨m€`:'"¨
m             -- map function over each character (example with 'a'):
 €            -- | index of first occurrence (1-indexed): 0
              -- : [1,6,0,0,3]

J, 31 22 bytes
11|1+i.~&'11|1+i.~&'''

Try it online!
1-indexed, 0 for characters that aren’t present in the code. '' stands for a single quote. Find each character in the string 11|1+i.~&', add 1, modulo 11.

Perl 5 with -pl, 43 bytes
Uses newline separated input and prints -1 for characters not appearing in the program.
$s=q{$_=index"\$s=q{$s};eval\$s",$_};eval$s

Try it online!

@Sanchises Fixed now, sorry about that. Clearly didn't read properly!

No problem. Thanks for bringing some new life into this challenge!

><>, 31 bytes
'rd3*i:0(?;}{:}-&b0&?.75*l-nao]

Try it online!
Output is 1-indexed, with 32 meaning the character is not in the code.

Stax, 19 bytes
"'sym[]I+"'"s+ym[]I

Run and debug it
Outputs 0-based index, one character per line. Turns out it's shorter than modifying the "34bL"34bL quine I wrote earlier.

JavaScript, 59 57 bytes
-2 Bytes thanks to Shaggy
a=>(m='Opined.fx,"+)',a.map(x=>("a=>(m='"+m).indexOf(x)))

Without reading source.
Attempt This Online!

57 bytes: a=>(m=",.px'+)indeOf",a.map(x=>('a=>(m="'+m).indexOf(x)))

@Shaggy Ah, smart. I don't usually think about variable names as long as they are 1 byte...

SAS, 124 60 bytes;
The new answer is shift from pure SAS 4GL to SAS macrolanguage.
The code:
%let S=%nrstr(%macro _(t);data;s=&t;do i=1to length(s);p=find(symget("S"),char(s,i));put p@;end;run;%mend;%_);%unquote(&S())

To run it, insert your 'string' enclosed in single quotes between brackets after &S, for example:
...%unquote(&S('!#&%macro _sS@'))

and in the log you will see:
0 0 20 1 2 3 4 5 6 7 8 18 57 77

To escape single quote in the string write it doubled: 'AB''CD'.

[EDIT:]
60 bytes answer was suggested for rejection as "a snippet, meaning it cannot just assume variables are defined". In context of SAS 4GL programming I agree to disagree with that opinion. ;-)
I keep it below for further comments.

Code assume that the string is given in a variable s and the source code is stored in macroVariable s.
The code:
do i=1to length(s);p=find(symget("S"),char(s,i));put p@;end;

Process goes as follows:

store source code in macrovariable S by runing:

data _null_;
  call symputX("S",'do i=1to length(s);p=find(symget("S"),char(s,i));put p@;end;',"G");
run;

assign string "i S;abcd{" to variable s and resolve ( by &S. ) the macrovariable S:

data;
s="i S;abcd{";
&S.
run;

The Log says:
1    data _null_;
2    call symputX("S",'do i=1to length(s);p=find(symget("S"),char(s,i));put p@
2  ! ;end;',"G");
3    run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

4
5    data;
6    s="i S;abcd{";
7    &S.
8    run;

4 3 35 19 41 0 39 1 0
NOTE: The data set WORK.DATA14 has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

You can run:
%put %length(%superq(S));

to get source code length.

Your submission must be either a function or a full-program, not just a snippet, meaning it cannot just assume variables are defined. Also, for [tag:quine] challenges, the main part of the challenge is getting the program’s own source code without using any external sources like reading the file or having it already defined.

Ok, will update the answer.

Is there any way SAS can take input or define a function? As it stands, hard-coding the input still does not confirm to the rules.

It's much more complex then it seems... I will split my answer in several comments since there is not enough characters in the comment box.

/* 1 */ SAS is tool/language dedicated to data processing. Mainly in tabular form (but not exclusively).
For SAS 4GL in general there are 4 standard ways of passing data:

by SAS dataset,
by text file (also "inline" inside your code),
by a macrovariable, or
hardcoding in data step.

There are 4 standard interfaces through which you can execute code in SAS:
a) DMS - SAS Display Manager,
b) EG - SAS Enterprise Guide,
c) SAS Studio, or
d) in command line.

/* 2 */ Some of those have possibility to get "interactive" input, but each of them do it differently and method for one does not work for others.
For example:

in DMS you can use Windows statement or %windows macrostatement which allows you to write code (from scratch) of "interactive pop3-up window", but those are not available for other 3 interfaces.
in EG you can (from the interface level) force pop-up prompt asking for a macrovariable value, but the prompt is assigned to code file, and of course other 3 interfaces can't use it.

/* 3 */ 3) execution by command line: .../sas.exe ./myCode.sas allows to add text string parameter which can be used as macrovariable in the script, but of curse other 3 interfaces can't do it.
So the programming practice is: "use one of 4 standard ways of passing data".

Dialects: SAS language is in fact a whole group of programming languages dialects. Starting with: 4GL, Macrolanguage, IML (for matrices), FCMP (for functions), DS2 (alternative to some part of 4GL), SCL (for graphic interface of DMS), SQL (2 separate proprietary implementations), CAS-L, etc...
All of those can be considered as "separate" dialects and can work on it's own, but the most productivity you get if you start to mix/interleave them. The most "global" is macrolanguage which it a code generating language (e.g. you write macro code which writes 4GL code for you).

/* 5 */ For example in 4GL you can't write your own function, but you can use one created in FCMP. You can create function in IML (it's called a module) abut you can't use it in 4GL, but you can embed 4GL code inside IML code...

Python 2, 49 48 bytes
-1 byte thanks to Jo King
c='print map(("c=%r;ex"%c).find,input())';exec c

Try it online!

Python 3, 53 52 51 bytes
-1 byte thanks to Jo King
c='print(*map(("c=%r;ex"%c).find,input()))';exec(c)

Try it online!

Burlesque, 27 bytes
#Qup~-"#Q"j?+wd\[Ppm{pPjFi}

Try it online!
Returns list of indices with -1 for each not present.
#Q      #Push remaining code to stack
up      #Turn to string
~-      #Remove brackets
"#Q"j?+ #Add the "#Q" to the beginning
wd\[    #Remove all spaces
Pp      #Push to virtual stack
m{      #Map (apply to each char in input)
  pP    #Pop from other stack
  jFi}  #Find character in string

PowerShell Core, 33 bytes
$f={$args|%{"`$f={$f}"|% i*f $_}}

Try it online!
Takes the string argument using splatting.
Returns -1 when a character can't be found
It works by storing a code block in the variable $f, then converts it to a string adding the missing bits "`$f={$f}" and does an indexOf each input character and returns the result.