text:
Count trailing truths
Inspired by, and in memory of, my dear friend and colleague,

Dan Baronet, 1956 – 2016. R.I.P.
He found the shortest possible APL solution to this task:
Task
Given a Boolean list, count the number of trailing truth values.
Example cases
{} → 0
{0} → 0
{1} → 1
{0, 1, 1, 0, 0} → 0
{1, 1, 1, 0, 1} → 1
{1, 1, 0, 1, 1} → 2
{0, 0, 1, 1, 1} → 3
{1, 1, 1, 1, 1, 1} → 6

Can we take the list as a string of zeros and ones? e.g. 01100?

@Adnan only if that is the most normal way for your language to represent boolean lists.

Sorry for your loss.

@MartinEnder Thank you. It will be tough going forward. Dan taught me all I needed to know to work for Dyalog.

Farewell to Dan. RIP...

Are we allowed to take the input as actual bits in a row instead of individual bytes? i.e. {1,0,1,0} would be 1010000 not 10000000 00000000 10000000 00000000

@moonheart08 Only if that is the most normal way for your language to represent boolean lists.

Dyalog APL, 6 2 bytes
⊥⍨

Test it on TryAPL.
How it works
⊥ (uptack, dyadic: decode) performs base conversion. If the left operand is a vector, it performs mixed base conversion, which is perfect for this task.
For a base vector b = bn, ⋯, b0 and a digit vector a = an, ⋯, a0, b ⊥ a converts a to the mixed base b, i.e., it computes b0⋯bn-1an + ⋯ + b0b1a2 + b0a1 + a0.
Now, ⍨ (tilde dieresis, commute) modifies the operator to the left as follows. In a monadic context, it calls the operator with equal left and right arguments.
For example, ⊥⍨ a is defined as a ⊥ a, which computes a0⋯an + ⋯ + a0a1a2 + a0a1 + a0, the sum of all cumulative products from the right to the left.
For k trailing ones, the k rightmost products are 1 and all others are 0, so their sum is equal to k.

Hint: Dan did it in only two bytes.

Mixed base conversion! That's clever.

Oh. Mixed base conversion, how it strikes again.

Bravo! In fact, because of Dan, we special-cased b⊥b and ⊥⍨b giving up to infinite speed-up.

JavaScript (ES6), 21 bytes
f=l=>l.pop()?f(l)+1:0

Test cases

f=l=>l.pop()?f(l)+1:0

console.log(f([])); // → 0
console.log(f([0])); // → 0
console.log(f([1])); // → 1
console.log(f([0, 1, 1, 0, 0])); // → 0
console.log(f([1, 1, 1, 0, 1])); // → 1
console.log(f([1, 1, 0, 1, 1])); // → 2
console.log(f([0, 0, 1, 1, 1])); // → 3
console.log(f([1, 1, 1, 1, 1, 1])); // → 6

How does this work? How does f(l)+1 return a value > 2?

@Oliver This is a recursive process, evaluated as l.pop()?(l.pop()?(l.pop()?(...etc...)+1:0)+1:0)+1:0.

I see. Thanks for the explanation.

Jelly, 4 bytes
ŒrṪP

Try it online! or Verify all test cases.
For the case where the list is empty, there are some curious observations. First, run-length encoding the empty list [] returns another empty list []. Then retreiving the last element from that using tail Ṫ returns 0 instead of a pair [value, count] which are the regular elements of a run-length encoded array. Then product P returns 0 when called on 0 which is the expected result.
Explanation
ŒrṪP  Main link. Input: list M
Œr    Run-length encode
  Ṫ   Tail, get the last value
   P  Product, multiply the values together

Alternatively, ŒgṪS works, too!

It gives the right output for the empty list as input, but I'm surprised given the dissection. Would you mind walking through that special case?

@PeterTaylor I'm surprised too that it worked. Also, I just noticed that the first link has the wrong code.

@PeterTaylor Ṫ in Jelly is implemented as: lambda z: iterable(z).pop() if iterable(z) else 0. iterable when called on a list just returns the list, and the empty list is of course falsy.

Brachylog, 7 6 5 bytes
@]#=+

Try it online!
Explanation
@]        A suffix of the Input...
  #=      ...whose elements are all equal
    +     Sum its elements

Since @] - Suffix starts from the biggest suffix all the way up to the smallest one, it will find the longest run first.

Haskell, 26 25 bytes
a%b|b=1+a|0<3=0
foldl(%)0

Usage:
Prelude> foldl(%)0 [True,False,True,True]
2

Pointfree version (26 bytes):
length.fst.span id.reverse

Using an integer list instead of a bool list (21 bytes, thanks to Christian Sievers):
a%b=b*(a+1)
foldl(%)0

Usage:
Prelude> foldl(%)0 [1,0,1,1]
2

Pointfree version (25 bytes)
sum.fst.span(==1).reverse

For integer lists the foldl idea works with a%b=b*(a+1)

05AB1E, 12 10 6 5 bytes
Saved 1 byte thanks to carusocomputing.
Î0¡¤g

Try it online!
Explanation
Î      # push 0 and input
 0¡    # split on 0
   ¤   # take last item in list
    g  # get length

0¡¤g is four bytes.

@carusocomputing: Nice! It wasn't yet clarified if string input was okay when I wrote this, but I see now that it is :)

J0¡¤g is also still shorter ;).

@carusocomputing: Unfortunately we need Î to handle the empty input, but it's still a byte saved thanks :)

CJam (8 bytes)
{W%0+0#}

Online test suite
Dissection
{    e# begin a block
  W%  e# reverse the array
  0+  e# append 0 so there's something to find
  0#  e# find index of first 0, which is number of nonzeros before it
}

Python, 31 bytes
lambda a:(a[::-1]+[0]).index(0)

Retina, 7 5 bytes
r`1\G

Try it online! (The first line enables a linefeed-separated test suite.)
Defining the input format for Retina isn't entirely unambiguous. Since Retina has no concept of any type except strings (and also no value that can be used for our usual definition of truthy and falsy), I usually use 0 and 1 (or something positive in general) to correspond to truthy and falsy, as they represent zero or some matches, respectively.
With single-character representations, we also don't need a separator for the list (which in a way, is more the more natural list representation for a language that only has strings). Adám confirmed that this is an acceptable input format.
As for the regex itself, it matches from right to left and \G anchors each match to the previous one. Hence, this counts how many 1s we can match from the end of the string.

"Yes, for Retina, being that it handles only strings, I think a "01" or "FT" string is in order.

MATL, 4 bytes
PYps

Try it online!
P       % Flip
 Yp     % Cumulative product
   s    % Sum

Mathematica, 25 24 bytes
Fold[If[#2,#+1,0]&,0,#]&

Just recording a port of Dan's cool mixed-base solution: FromDigits[b=Boole@#,MixedRadix@b]& (35 bytes).

Jelly, 4 bytes
ṣ0ṪL

TryItOnline!, or all tests
How?
ṣ0ṪL - Main link: booleanList
ṣ0   - split on occurrences of 0 ([] -> [[]]; [0] -> [[],[]]; [1] -> [[1]]; ...)
  Ṫ  - tail (rightmost entry)
   L - length

Pyth, 6 bytes
x_+0Q0

Try it here!
Appends a 0, reverses and finds the index of the first 0

@Jakube fixed now - different algorithm

J, 9 3 bytes
#.~

This is reflexive mixed base conversion. Because this is the same as mixed base conversion. Again.
Test cases
   v =: #.~
   ]t =: '';0;1;0 1 1 0 0;1 1 1 0 1;1 1 0 1 1;0 0 1 1 1;1 1 1 1 1 1
++-+-+---------+---------+---------+---------+-----------+
||0|1|0 1 1 0 0|1 1 1 0 1|1 1 0 1 1|0 0 1 1 1|1 1 1 1 1 1|
++-+-+---------+---------+---------+---------+-----------+
   v&.> t
+-+-+-+-+-+-+-+-+
|0|0|1|0|1|2|3|6|
+-+-+-+-+-+-+-+-+
   (,. v&.>) t
+-----------+-+
|           |0|
+-----------+-+
|0          |0|
+-----------+-+
|1          |1|
+-----------+-+
|0 1 1 0 0  |0|
+-----------+-+
|1 1 1 0 1  |1|
+-----------+-+
|1 1 0 1 1  |2|
+-----------+-+
|0 0 1 1 1  |3|
+-----------+-+
|1 1 1 1 1 1|6|
+-----------+-+

Hint: This can be done in only 3 bytes, using the J translation of Dan's solution.

@Adám I tried looking for a solution. Didn't think of base conversion. That's really quite clever of him!

Yes. That was Dan. :-(

C90 (gcc), 46 bytes
r;main(c,v)int**v;{while(0<--c&*v[c])r++;c=r;}

Input is via command-line arguments (one integer per argument), output via exit code.
Try it online!
How it works
r is a global variable. Its type defaults to int and, being global, it value defaults to 0.
The function argument c defaults to int as well. It will hold the integer n + 1 for arrays of n Booleans; the first argument of main is always the path of the executable.
The function argument v is declared as int**. The actual type of v will be char**, but since we'll only examine the least significant bit of each argument to tell the characters 0 (code point 48) and 1 (code point 49) apart, this won't matter on little-endian machines.
The while loop decrements c and compares it to 0. Once c reaches 0, we'll break out of the loop. This is needed only if the array contains no 0's.
As long as 0<--c returns 1, we takes the cth command-line argument (v[c]) and extract its first character with by dereferencing the pointer (*). We take the bitwise AND of the Boolean 0<--c and the code point of the character (and three garbage bytes that follow it), so the condition will return 0 once a 0 is encountered, breaking out of the loop.
In the remaining case, while the command-line arguments are 1, r++ increments r by 1, thus counting the number of trailing 1's.
Finally, c=r stores the computed value of r in c. With default settings, the compiler optimize and remove the assignment; it actually generates the movl %eax, -4(%rbp) instruction. Since ret returns the value of the EAX register, this generates the desired output.
Note that this code does not work with C99, which returns 0 from main if the end of main is reached.

Isn´t argc at least 1 (with argv[0] containing the file name)? You could save one byte with --c&& instead of 0<--c&. gcc´s exit code is taken from argc? Neat.

@Titus That won't work. *v[c] is the code point of 1 or 0, so it's either 49 or 48 and thus always truthy.

With C89 and C90, gcc returns whatever is in RAX at that moment. C99 always returns 0 from main if the end is reached.

R, 40 39 25 bytes
Completely reworked solution thanks to @Dason
sum(cumprod(rev(scan())))

Read input from stdin, reverse the vector and if the first element of is !=0 then output the the first length of the run-length encoding (rle), else 0.

You can save a byte by changing the second line to ifelse(r$v,r$l,0)[1]. (Vectorized if, and then take the first element.)

no need for the iflelse - just multiply r$v and r$l.

But the sum(cumprod(rev(.))) route should save a lot of bytes anyways

k, 6 bytes
+/&\|:

This function composition translates to sum mins reverse in q, the language's more readable sibling, where mins is a rolling minimum.

Can the : be dropped?

A port of APL version is possible in ngn/k for 5 bytes.

Pyke, 10 6 bytes
_0+0R@

Try it here!

Haskell, 24 bytes
foldl(\a b->sum[a+1|b])0

Iterates over the list, adding one for each element, resetting to 0 after it hits a False.
16 bytes with 0/1 input:
foldl((*).(+1))0

If the list were guaranteed non-empty, we could get 14 bytes:
sum.scanr1(*)1

This computes the cumulative product from the back, then sums them. The cumulative product remains 1 until a 0 is hit, and then becomes 0. So, the 1's correspond to trailing 1's.

C#6, 103 72 bytes
using System.Linq;
int a(bool[] l)=>l.Reverse().TakeWhile(x=>x).Count();

Using non-generic list beats generic list by 1 byte lol
-31 bytes thanks to Scott

If you use an array of ints, you can get away with int a(int[] l)=>l.Reverse().TakeWhile(i=>i>0).Sum();

@Scott Of course what was I thinking... I will stick with bool though. Question specifies boolean list and it's not C.

Compile to a Func<bool[], int> for 57 bytes i.e. using System.Linq;l=>l.Reverse().TakeWhile(x=>x).Count();

Japt -hx, 3 bytes
i ô

Try it online!
Japt's flag combinations rock.
How it works
Ui ô

Ui  Insert `undefined` at index 0
ô   Split at falsy items

-h  Take last element
-x  Sum

If we didn't have to handle the special case [], we could get away with 1 byte ô, winning over APL.

Half the job is done by flags‽

Perl, 22 bytes
21 bytes of code + 1 byte for -p flag.
s/.(?=.*0)//g;$_=y;1;

To run it :
perl -pE 's/.(?=.*0)//g;$_=y;1;' <<< "0 1 1 0 1 1 1"

(Actually, the format of the input doesn't matter a lot : 0110111, 0 1 1 0 1 1 1, [0,1,1,0,1,1,1] etc. would all work)

18 bytes version from @Dom Hastings but it requires to supply the input as a string of 0 and 1, which isn't allowed :
perl -pE '/1*$/;$_=length$&' <<< '0110111'

Loving that ; trick :) If format is one continuous string: perl -pE '/1*$/;$_=length$&' <<< '0110111' for 18, not sure if that's bending the rules or not though...

@DomHastings yea, me too! (Thanks Ton for showing me that!) The first and second comments of the question kinda disallow the format of input you need for your solution... But I'll edit my post to suggest your version if the format of the input was more free.

Python, 37 bytes
f=lambda l:len(l)and-~f(l[:-1])*l[-1]

DASH, 16 bytes
@len mstr"1+$"#0

It's not the shortest possible DASH solution, but the shortest possible DASH solution is bugging out on me. I'm posting this novel approach in its place.
Usage:
(@len mstr"1+$"#0)"100111"

Explanation
@(                 #. Lambda
  len (            #. Get the length of the array after...
    mstr "1+$" #0  #. ... matching the argument with regex /1+$/
  )                #. * mstr returns an empty array for no matches
)

Scala, 25 bytes
l=>l.reverse:+0 indexOf 0

Ungolfed:
l=>(l.reverse :+ 0).indexOf(0)

Reverses the list, appends a 0 and find the first index of 0, which is the number of elements before the first 0

Batch, 57 bytes
@set n=0
@for %%n in (%*)do @set/an=n*%%n+%%n
@echo %n%

Takes input as command-line parameters. Works by multiplying the accumulator by the current value before adding it on, so that any zeros in the command line reset the count. Note that %%n is not the same as the n or %n% variable.

GolfSharp, 14 bytes
n=>n.V().O(F);

Java 7, 62 bytes
int c(boolean[]a){int r=0;for(boolean b:a)r=b?r+1:0;return r;}

Ungolfed & test code:
Try it here.
class M{
  static int c(boolean[] a){
    int r = 0;
    for (boolean b : a){
      r = b ? r+1 : 0;
    }
    return r;
  }

  public static void main(String[] a){
    System.out.print(c(new boolean[]{}) + ", ");
    System.out.print(c(new boolean[]{ false }) + ", ");
    System.out.print(c(new boolean[]{ true }) + ", ");
    System.out.print(c(new boolean[]{ false, true, true, false, false }) + ", ");
    System.out.print(c(new boolean[]{ true, true, true, false, true }) + ", ");
    System.out.print(c(new boolean[]{ true, true, false, true, true }) + ", ");
    System.out.print(c(new boolean[]{ false, false, true, true, true }) + ", ");
    System.out.print(c(new boolean[]{ true, true, true, true, true, true }));
  }
}

Output:
0, 0, 1, 0, 1, 2, 3, 6

Perl 5.10, 22 bytes
21 bytes + 1 byte for -a flag.
Since the regex-based expression was done... :p
The input values for the array must be separated by a space.
$n++while pop@F;say$n

Try it online!

Slightly shorter if you take arguments via command line: perl -E '$_++while pop;say' 0 1 1 0 1 1 1 but this doesn't output anything for 0 (not sure if that's a problem though!)

Ruby 37 32 bytes
->n{n.size-1-(n.rindex(!0)||-1)}

Creates an anonymous function that finds the right-most instance of a false value, and counts the size of the subarray starting at that value.
It uses !0 as false, as 0 are truthy values in Ruby. rindex finds the last index of a value in an array.
Usage:
boolean_list = [true, false, false, true]
->n{n.size-1-(n.rindex(!0)||-1)}[boolean_list]

Returns 1

If I was allowed to be passed a string of 0s and 1s as command line parameters (which is not how ruby represents lists of booleans), I could get it down to 24:
$*[0]=~/(1*)\z/;p$1.size

This uses regular expressions and prints the length of the string returned by the regular expression /(1*)\z/, where \z is the end of the string. $*[0] is the first argument passed and is a string of 0s and 1s.
Usage:
trailing_truths.rb 011101

Returns 1.

Once you have the index of the last false value, why do you need to retrieve elements from the array again?

You're right, I don't. Thanks. 5 bytes off!

C++17, 82 66 bytes
int f(){return 0;}int f(int H,auto... L){return(H*...*L)+f(L...);}

Uses the C++17 template parameter fold expression and essentially the same idea as Dennis. Saving 16 bytes by using Generic Variadic Lambda.
Explanation:
int f(){return 0;} //base case for empty list

int f(int H, auto... L) { //first element, variadic arguments
    return (H*...*L)      //a_0*a_1*a_2*...
         + f(L...);       //+ f(a_1,a_2,...)
}

Usage:
f(1,1,0,1,1,0,1,1,1,1,1) -> 5
f() -> 0
f(1,0,1,0) -> 0

Non competing
Albeit longer, this also works with template constants:
template <int...L> int C=0;
template <int H, int...L> int C<H,L...> = (H*...*L)+C<L...>;

Usage:
std::cout << C<1,0,1,1>  << std::endl;
std::cout << C<1,0,1,0,1>  << std::endl;
std::cout << C<1,1,1,0,1,0,1,1>  << std::endl;
std::cout << C<1,1,1,0,1,0,1,1,1,1,1,1>  << std::endl;
std::cout << C<> << std::endl;

PHP, 50 bytes
<?=strlen(preg_filter('/.*[^1]/','',join($argv)));

Weirdly my first try with a regex turned out shorter than my try with arrays...
Use like:
php tt.php 1 1 0 1 1

Pip, 8 bytes
WDQg++ii

Takes input as command-line arguments of 0 and 1 (or any truthy value). Try it online!
Explanation
          g is cmdline args, i is 0
 DQg      Dequeue item from end of g
W   ++i   While this is truthy, increment i
       i  Print i

(Dequeueing from an empty list gives nil, which is falsey.)

PHP, 40 34 bytes
Along with $argv comes $argc ... and both are variable.
Either one of the arguments or +$argv[0]==+"-" is 0.
while(+$argv[--$argc])$i++;echo$i;

takes input from command line arguments. Empty output for 0.
Run with php -nr '<code>' <space separated values>
unary output, 35 29 bytes
while(+$argv[--$argc])echo 1;

brainfuck, 99 bytes
Takes input like 11011. Output is a single byte/character value.
-[>+<-----]>---[>>,]<-[>+<-----]>---[-<+>>>+<<]<[->+<]>+>>+[<+[-<<+>>]<<<[-<+>>>-<<]<[->+<]>>>-]<-.

Try it online - Run with input, then click "view memory" to see the value under the pointer that was printed.
Explanation:
-[>+<-----]>---             put constant 48 (ASCII '0') at start of list
[>>,]                       receive all input, with an empty cell between each
<-[>+<-----]>---            constant 48 near end of list
[-<+>>>+<<]<[->+<]>+>>      move to right and copy right, add one to make 49 (ASCII '1')
                            TAPE: 48 _ i0 _ i1 _ ... in _ 49 _ 48< (pointer)

+[<+[-<<+>>]<<              LOOP. Put counter+=1 in empty cell. Move it left 2 cells.
<[-<+>>>-<<]<[->+<]>        Subtract value from value 2 cells right.
>>-]<-.                     Subtract one more. If zero, print counter-1, Else loop again.

Close, but must contain a zero, and it doesn't handle trailing zeros or an empty list. (49 bytes)
,[>>,]>>+[<+[-<<+>>]<<<[-<+>>>-<<]<[->+<]>>>-]<-.

,[>,]-[>+<-----]>---[-<<[<]>[->]>]<<[>[-<+>]<<]>.

@JoKing Go ahead and create your own answer. That doesn't resemble mine at all.

Pushy, 6 bytes
$v;FL#

Arguments given a list on command line: $ pushy truths.pshy 0,1,1,0,0. Like my binary conversion program, this takes advantage of the second stack in an interesting way. Here's how it works:
         \ Implicit: Input on stack
$        \ While last item is not 0:
 v;      \   Move last item to auxiliary stack
   FL#   \ Output length of auxiliary stack.

Note that the loop will not run if the list is empty, so the output will be 0.

How many stacks does Pushy have?

@KritixiLithos Two, input is automatically on stack 1 and that's where main operations take place. Stack 2 is just for storing counters / variables that need to be kept out of the way.

PHP, 38 bytes
a totally different approach
<?=strpos(strrev(join([0]+$argv)),48);

takes input from command line arguments. Save to file.
[0]+$argv sets the first element (script name) to 0.
Join that without a delimiter, reverse and find the first occurence of the 0 character.
While my first solution works with any truthy and falsy values, this one obviously depends on single characters: 0 is falsy, every other character (apart from maybe the 0 byte) truthy.

-4 Bytes for using $_GET

@JörgHülsermann That would have empty output for any list full of 1s.

Okay now I have realize it

Pari/GP, 30 bytes
p->valuation(Pol(p)*(x-1)+1,x)

Converts the list to a polynomial, say \$p\$, then finds the valuation of \$(x-1)p+1\$ with respect to \$x\$, i.e., the minimal degree of its nonzero terms.
For example, if we take [1, 0, 1, 1, 1] as input, then the polynomial \$p\$ is \$x^4 + x^2 + x + 1\$, and \$(x-1)p+1\$ is \$x^5 - x^4 + x^3\$, whose valuation is \$3\$.
Try it online!

Well, that is truly an original method. +1

Taxi, 1580 1576 1564 bytes
-4 bytes because of a less complex route to the Crime Lab (string equality checker). Also, you don't run out of gas for a sufficiently large number of truthy values anymore!
-12 bytes by getting rid of the quotes.
Go to the Post Office:w 1 l 1 r 1 l.
Pickup a passenger going to Chop Suey.
Go to Chop Suey:n 1 r 1 l 4 r 1 l.
[B]
Switch to plan C if no one is waiting.
Pickup a passenger going to Cyclone.
Go to Cyclone:n 1 l 3 l.
Pickup a passenger going to Narrow Path Park.
Pickup a passenger going to Joyless Park.
Go to Zoom Zoom:n.
Go to Narrow Path Park:w 1 l 1 l 1 r.
Go to Joyless Park:e 1 r 3 l.
Go to Chop Suey:w 1 r 1 r 1 l.
Switch to plan B.
[C]
0 is waiting at Starchild Numerology.
Go to Starchild Numerology:n 1 l 3 l 3 l 2 r.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park:w 1 r.
Go to Narrow Path Park:n 1 r 1 r 1 l 1 r.
[D]
Switch to plan F if no one is waiting.
Pickup a passenger going to Crime Lab.
1 is waiting at Writer's Depot.
Go to Writer's Depot:w 1 l 1 r 2 l.
Pickup a passenger going to Crime Lab.
Go to Zoom Zoom:n.
Go to Crime Lab:w 1 l 2 r.
Switch to plan E if no one is waiting.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:s.
Pickup a passenger going to Addition Alley.
Go to Sunny Skies Park:n 1 l 1 l 1 r.
Pickup a passenger going to Addition Alley.
Go to Addition Alley:n 1 r 1 r 1 r.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park:n 1 l 1 l 1 l.
Go to Narrow Path Park:n 1 r 1 r 1 l 1 r.
Switch to plan D.
[E]
Go to Narrow Path Park:n 5 l.
[F]
Go to Sunny Skies Park:w 1 l 1 r 2 l 1 l.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:s 1 l 1 r 1 r.
Pickup a passenger going to Post Office.
Go to Post Office:n 1 l 1 r.
Go to Taxi Garage:n 1 r 1 l 1 r.

Input is in the form of a string of 0's and 1's (for example: 11101).
Try it online!
Taxi is an esolang in which all programming is done by picking up and dropping off passengers at various stops in the fictional town of Townsburg. Of course, your taxicab will sometimes run out of gas, so you also need to visit gas stations every so often, and pay using the credits you receive as fare.
I had to do some strange management of fuel in this program. Specifically, I have a loop at the beginning (between plans B and C) which pushes each character of the input to Narrow Path Park (which is a LIFO queue, or a stack) by going back and forth between Narrow Path Park and Chop Suey (which split the input string into characters in the first place). However, for sufficiently large inputs, this can cause me to run out of gas. Simply going to a gas station every iteration is insufficient, because I'm not earning enough money from actually bringing passengers to their destinations. The best way I've figured out to earn enough money to make going to a gas station every iteration "worth it" is bringing each new passenger to Cyclone (which clones them), and taking one of those clones to Narrow Path Park while leaving one forever trapped at Joyless Park (which is a FIFO queue, but for the purposes of this program is a dumping ground).
(Note: Bringing passengers to Riverview Bridge is a good way to get rid of them, but they don't pay you - because they always seem to fall off the bridge into the river before they can pay - so I couldn't do this either.)

1531 bytes (STDERR ignored)

Brain-Flak, 30 bytes
(()){{}({}{{}}<><{}>)<>([])}<>

Try it online!
Explanation
(()) #{ Start Loop.  Used instead of ([]) so that the loop will run at least once on empty input. }
{{}  #{Remove the stack height. }
 (
  {}{{}}  #{ Add the TOS with any 1s below it (until a zero). }
  <><{}>  #{ Remove a value on the other stack if there. }
 )     #{ Push the result (# of 1s just removed) to the other stack. }
 <>    #{ Switch stacks back. }
 ([])  #{ Push stack height for the loop. }
}  #{ Once the loop is done (stack is empty)... }
<> #{ Switch stacks to the most recent # of 1s removed. }

Vyxal s, 2 bytes
Ġt

Try it Online!
Tied with first!
Explained
Ġt∑
Ġ   # group by consecutive
 t  # tail

s flag does sum.

Raku, 17 bytes
{sum [\R*] 0,|@_}

Try it online!

0, |@_ is the input list of boolean values with a zero prepended to the front.
R* is the Reversed multiplication operator.  It's the same as the regular multiplication operator *, except that it's right-associative.
[\R*] is the "triangular reduction" of the list to the right, using the R* operator.  Given a list \$x_0, x_1, ... x_n\$, it produces \$x_n, x_n \cdot x_{n-1}, x_n \cdot x_{n-1} \cdot x_{n-2}, ..., x_n \cdot x_{n-1} \cdot x_{n-2} \cdot ... \cdot x_0\$.  Raku's arithmetic operators treat boolean true values as 1 and false values as 0, so this produces a list that starts with as many ones as there are true values at the end of the list, followed by as many zeroes as there are remaining values in the list.
sum adds up those values.

It's necessary to paste a leading zero onto the front of the input list, or else an empty list would produce the multiplicative identity element 1.

Python2, 42 41 Byes
t=input()[::-1];print len(t[:t.index(0)])

takes input as [1, 1, 0, 1, 1]

No joy with the empty list test case.

ABCR, 14 bytes
c7iA)7a!xcx!Bp

Accepts the formatting [0,1,0,1,0, where any non-numeric character can be replaced with any other non-numeric character.  Empty input is the empty list.
Explanation:  Every 7 input number i is queued up A; every "0" input number (or rather, non-"1") )7 will pop from the queue until it's empty 7a!x; before another input number is queued, a delimiter character is grabbed cx to check for the end of queue.  After all the integers are grabbed, !Bp prints the length of the queue of input numbers (which will be all the trailing "1" values.)

PHP, 58 54 53 bytes
function f($a){while(array_pop($a))$i++;return+$i;}

Since PHP has no list I use an array instead
-4 bytes thanks to  user59178
All tests

Assigning $i=0; is unnecessary if you echo/return +$i. Having this as a command line program rather than a function is much shorter as well, though you need to account for the fact that $argv[0] is truthy. With both of these you could save 19 bytes.

return+$i; needs no space.

Swift 3, 49 bytes
func a(b:[Bool]){print(b.reduce(0,{$1 ?$0+1:0}))}

Minkolang, 32 bytes
0$nI1-[1=?v0g1+1R]N.
      .Ng0<

Try it online!
Explanation
0                             pushes 0 (this is the number that will keep track of the number of 1s)
 $n                           pushes all of input as numbers (pushes -1 if there is no input)
   I1-                        pushes stack minus 1 (to exclude the 0)
      [          ]            for loop with the previous number as the number of iterations
       1=?                     check equality with 1 (this is for the empty input testcase)
                               where -1 will be pushed by the interpreter

If number is not 1 (ie 0 or -1[-1 will be pushed if there is no input]):
         <                     start going left
       g0                      gets the first element in stack
     .N                       output it as number and stop program

If number is 1:
          v                    gets jumped over by ? since true has been evaluated
           0g1+                gets the first element and adds 1 to it
               1R              rotates stack once clockwise
                  N.          outputs as number and stops program

Clojure, 39 36 bytes
#(count(take-while{1 1}(reverse %)))

Input as integers [1 0 1 1 0 1 1 1], anything other than 1 is falsy. {1 1} is a hash-map with key 1 and value 1 which can also used as a function. For example ({1 999} 1) is 999 (truthy) whereas ({1 999} 0) is nil (falsy).
Original, based on booleans:
#(count(take-while(fn[i]i)(reverse %)))

Amazing how (fn[i]i) is shorter than identity and also doesn't force you to put a space after take-while. Must take a list or vector of booleans, integers can be converted like this: (map #(= 1 %) [1 0 1 1 0 1 1 1])

PHP, 33 Bytes
<?=strspn(strrev(join($_GET)),1);

Online Version
strspn

Mathematica, 36 bytes
Length[#/.({___,0,x___/;x==1}:>{x})]&

Not the shortest, but short enough where I was proud to submit it :)

brainfuck, 33 bytes
,[+++>-[<->-----],]<[>[-<+>]<<]>.

Try it online!
Takes input via a string like 101011, and then outputs via byte value. I've added some code in the footer to add 48 to the value to output a digit.
 ,[  Loop over input
   +++>-[<->-----]  Subtract 48 from each value to form a tape of 0s and 1s
 ,]
 <[>[-<+>]<<]   Add up all the trailing ones
 >.             And print the value

Rust, 44 bytes
|a|a.iter().rev().take_while(|&&i|i).count()

Try it online!
explanation:
|a|a.iter().rev().take_while(|&&i|i).count() //anonymous function
|a|a.iter()                                  //iterate over the input
           .rev()                            //reverse the iterator
                 .take_while(|&&i|i)         //take while **self is true
                                    .count() //Count the elements in the iterator

Factor, 18 bytes
[ [ ] count-tail ]

Attempt This Online!

Fig, \$5\log_{256}(96)\approx\$ 4.116 bytes
Lt@x$

Try it online!
No "group consecutive," unlike most other golfing languages.
Lt@x$
    $ # Reverse the list
 t    # Take while
  @x  # The identity function
L     # Return the length

Nekomata + -1, 3 bytes
sP∑

Attempt This Online!
s       Find a suffix of the input
 P      that contains only positive integers
  ∑     and sum them.

-1 prints the first solution.

Thunno 2 tS, 1 byte
ġ

Attempt This Online!
Or, if you want it flagless:
Thunno 2, 3 bytes
ġtS

Attempt This Online!
Explanation
ġtS  # Implicit input
ġ    # Group consecutive
 t   # Last item
  S  # Sum
     # Implicit output

Braingolf, 7 bytes
!?&gGL|

Try it online!
Explanation
!?&gGL|  Implicit input from commandline args
!?       If last item on stack is > 0..
  &g     ..Combine all items into single number (1, 1, 0, 1 becomes 1101)
    G    ..Split into digit runs (1101 becomes 11, 0, 1)
     L   ..Pop last item and push length of item (111 becomes 3)
      |  Endif
         Implicit output of last item on stack, either number of trailing ones, or zero

You use 3 chars for the conditional.  Could you maybe multiply by the parity instead?

@Adám that would still be 3 bytes, 2 bytes to get the parity (2%) and one byte to multiply (*)

Backhand, 17 bytes
v I^: ]|{]1$|{O @

Try it online!
Explanation:
v I^: ]|{]1$|{O @
v                  Decrease step value to 2
  I                Get input as a number
    : ]|{          Reflect if not EOF
   ^               Increase step value to 3
v                  Decrease to 2 and repeat the loop
         ]         The leftover EOF (-1) is now our counter. Increment it to 0
           $|{     Reflect if the top value is truthy
       |{ 1        Reflect and repeat
         ]         Increment the counter for every truthy value
              O @  Output the final state of the counter

Ohm v2, 5 bytes
Ö⁾ì]*

RLE encodes the string, takes the last element, flattens, and multiplies
Try it online!

V, 7 bytes
Ó1*0
ø1

Try it online! Takes input as a string of 0 and 1.
Explanation
Ó1*0     Remove all occurences of any number of ones followed by a zero
ø1       Count the number of remaining ones

MBASIC, 112 bytes
1 INPUT B$:T=0:FOR I=LEN(B$) TO 1 STEP -1:C$=MID$(B$,I,1):IF C$="0" THEN 4
2 IF C$="1" THEN T=T+1
3 NEXT
4 PRINT T

Just wanted to see if I could do it.
Explanation
Input is a string of 1's and 0's. String is traversed from right to left. If the current digit is a 0, bail out and print the total. If the digit is a 1, increment the total and continue to loop.
Output
? 01100
 0

? 11011
 2

? 11101
 1

? 111111
 6

05AB1E, 3 bytes
γθO

Try it online!
γθO  # full program
  O  # sum of...
 θ   # last...
γ    # group of consecutive equal elements in...
     # implicit input
     # implicit output

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:
Palindrome polyglot
Your task is to write a program that runs in two different languages, and does the following:

In one language, it palindromizes a given string.

Take the string. abcde
Reverse the string. edcba
Remove the first character. dcba
Glue it onto the original string. abcdedcba

In another language, it depalindromizes a given string.

Take a string palidromized by the above method. abcdedcba
Get the characters from the start to the middle. abcde

Remember, this is code-golf, so the code with the fewest characters (not bytes) wins.
Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language 1/Language 2, N bytes

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

@LuisMendo One second...

@LuisMendo Okay, I have updated the quesiton

Will the string ever contain newlines?

Can the input format be different in the two languages? Like a string with enclosing quotes or without them

@LuisMendo Yes.

This is sort of coming down to finding the language that can depalindromize with the least code, then combining it with ¹û (05AB1E) or ŒB (Jelly) (or Uê in Japt)

05AB1E / MATL, 10 9 characters
9LQ2/)%¹û

In 05AB1E this palindromizes. In MATL it depalindromizes.
Explanation in 05AB1E
This part of the code does nothing (globally):
9L    Pushes array [1, 2, ... 9]
Q     Consumes the array, takes the input implicitly, and produces no output
2/    With no further input to take implicitly, this gives no output
)     Wrap stack into an array: gives an empty array
%     Consumes that array and, with no further input to take implicitly, gives no ouput

This is the part that does the work:
¹     Push input again
û     Palindromize. Implicitly display

Explanation in MATL
This is the part that does the work:
9L    Push array [0, 1j]
Q2/   Add 1, divide by two: transforms into [1/2, (1+1j)/2]
)     Use as index into implicit input. [1/2, (1+1j)/2] is interpreted as
      1/2:(end+1)/2, which is rounded to 1:(end+1)/2. So this takes elements
      from first to half, including both. Implicitly display

This is ignored:
%¹û   Everything after '%' is a comment

05AB1E / Jelly, 6 characters
Palindromizes in 05AB1E.
Depalindromizes in Jelly.
œs2Ḣ¹û

Try it in 05AB1E
05AB1E Explanation
œ       # compute powerset of input
 s      # swap (does nothing)
  2     # push 2
   Ḣ    # does nothing
    ¹û  # palindromize input

Try it in Jelly
Jelly Explanation
œs2     # split input in 2 chunks (first chunk is larger for odd length strings)
   Ḣ    # head, take first
    ¹û  # does nothing

Scala / Javascript, 106 bytes
/*\u002A/print(args(0)+args(0).reverse.tail)//*/
/*/**/
alert((s=prompt()).slice(0,-s.length/2))//\u000A*/

Palindromizes in scala and depalindromizes in javascript.
Try it on ideone (scala) - Warning: wrong syntax highlighting
Try it on jsfiddle (javascript).
Explanation:
Scala, like java, processes unicode escapes before everything else, so scalac sees the code like this:
/**/                                //\u002A is as asterisk, results in an empty block comment
print(args(0)+args(0).reverse.tail) //scala code
//*/                                //a line comment
/*                                  //scala supports nested block comments, so this comment...
  /*
  */
  alert((s=prompt()).slice(0,-s.length/2))
  //                                  //\u000A (newline) inserted here
*/                                  //...ends here

The javascript gets parsed like this:
/*\u002A/print(args(0)+args(0).reverse.tail)//*/ //block comment
/*                                               //a block comment...
  /*
*/                                               //...ending here, no nesting
alert((s=prompt()).slice(0,-s.length/2))         //code
//\u000A*/                                       //line comment

Python 3 / JavaScript, 83 chars
Saved 2 bytes thanks to @LevitatingLion
1//2;x=input();print(x+x[-2::-1]);"""
x=prompt();alert(x.slice(0,-x.length/2))//"""

Python palindromizes, JavaScript depalindromizes.
I tried keeping more code constant between the two, but I couldn't figure out a good way to sneak .slice into Python. Here's an alternate method:
1//2;prompt=input,alert=print
x=prompt();1//2;x+=x[-2::-1]);"""
x=x.slice(0,-x.length/2))//"""
alert(x)

You can replace x[::-1][1:] with x[-2::-1] to save two chars.

@LevitatingLion Thank you! I'd tried to figure out how to combine the two slices, but nothing seemed to work.

CJam / MATL, 18 characters
r_W%(;
"j9LQ2/)%";

In CJam this palindromizes. In MATL it depalindromizes.
Explanation in CJam
Working part:
r           Read string
_           Duplicate
W%          Reverse
(;          Remove first element

Dummy part:
"j9LQ2/)%"  Push this string
;           Remove it from the stack
            Implicitly display both strings obtained previously

Explanation in MATL
Dummy part:
r           Push random number between 0 and 1
_           Negate
W           2 raised to that
%(;  Comment (ignored)

Working part:
"           For each element in the array at the top of the stack. Since it is a number,
            which is the same as a length-1 array, the following is executed once
  j         Input string
  9L        Push array [0, 1j]
  Q2/       Add 1, divide by 2: transforms into [1/2, (1+1j)/2]
  )         Use as index. [1/2, (1+1j)/2] is interpreted as 1/2:(end+1)/2, which is
            rounded to 1:(1+end)/2. So this takes elements from first to half,
            including both

Another dummy part:
   %";      Comment (ignored)
            Implicitly display the previously obtained string

Jelly / CJam, 15 14 chars
q_,2./m]<e#¶ŒB

-1 char thanks to 42545 (ETHproductions)
Try it online! (Jelly) (Palindromization)
CJam interpreter (Depalindromization)
Jelly explanation:
In Jelly, ¶ is the same as \n, so this is what Jelly sees:
q_,2./m]<e#
ṖṚṭ

ṖṚṭ         Main link. Arguments: z
Ṗ           Pop
 Ṛ          Reverse
  ṭ         Append
   ⁸        (implicit) z

CJam explanation:
In CJam, everything after e# on a line is a comment. So, this is what CJam sees:
q_,2./m]< Code
q         All input
 _        Duplicate
  ,       Length
   2.     2.0
     /    Float division
      m]  Ceil
        < Take

@ETHproductions Whoops, I forgot it! It's called "bounce", that's why.

 / Javascript ES6, 55 chars
this._?Σ(`ï+ï.Ħ⬮.Đ1`):(x=prompt()).slice(0,-x.length/2)

Try it here (ES6 browsers only).
Palindromizes in , depalindromizes in Javascript ES6.
I though this was going to be easy, since  compiles to ES6 and most of ES6 can be run in . Apparently, I'm completely wrong.
Explanation
this._ checks to see if variable _ exists in the global scope;  uses Lodash and therefore has _ stored, but pure ES6 doesn't.
The  segment - Σ(`ï+ï.Ħ⬮.Đ1`) - evaluates from string the code that palindromizes input. Normally, the code would be ï+ïĦ⬮Đ1, but I put the dots in to make the compiler happy.
The Javascript segment - (x=prompt()).slice(0,-x.length/2) - depalindromizes a string from a prompt.

I was going to use a function (so I didn't have to deal with prompt), but 's evaluation function didn't like that, so I used prompt and no function to make the compiler happy.

Wow, the compiler's picky.

Perl / JavaScript, 73 bytes
Perl returns a palindrome and JavaScript 'de-palindromizes' the input string.
s=prompt();console.log(s.slice(0,-s.length/2));eg=1;t=eg;s=$=reverse$_=eg

JavaScript
Assumes the string is a valid palindrome already.
All the work happens in the first section:
s=prompt();console.log(s.slice(0,-s.length/2));

Stores input in s, then returns the first half (rounded-up) of the string. The rest of the script is pointless variable assignments:
eg=1;t=eg;s=$=reverse$_=eg

Try it here:

s=prompt();console.log(s.slice(0,-s.length/2));eg=1;t=eg;s=$=reverse$_=eg

Perl
Must be run with -pl, eg:
perl -ple 's=prompt();console.log(s.slice(0,-s.length/2));eg=1;t=eg;s=$=reverse$_=eg' <<< 'test'
# returns testtset

The code is basically two substitutions (s///), but using = as the delimiter instead of /:
s/prompt();console.log(s.slice(0,-s.length\/2));eg/1;t/eg;s/$/reverse$_/eg

The first, replacing prompt();console.log(s.slice(0,-s.length\/2));eg (which, admittedly will mess up your string if it contains something like "prompt;console.logs.slice0,-s.length/2;eg"...) with 1;t which is evaled, returning t, the second replaces the end of the string ($) with reverse$_ which is then also evaled and appends the original source string reversed.
Try it online!

JavaScript ES6 / JavaScript ES3, 143 bytes
function(x){'use strict';function a(){return x+x.split('').reverse().slice(1).join('')}{function a(){return x.slice(0,-x.length/2)}}return a()}

Palindromizes in JavaScript ES6, depalindromizes in JavaScript ES3. Non competing, it's just a try to make a polyglot for two versions of the same language.
In ES3 functions are allowed in blocks, but as blocks don't define scopes the new function just replaces the first function. In ES5 strict mode it fails because it don't allow functions to be defined in blocks. In ES6 it's allowed and, because blocks now define scopes, the first function isn't replaced.
Tested in Internet Explorer 5 (emulated) for ES3 and Node.JS and Firefox for ES6.

Python 2 / Nim, 76 74 bytes
#[
s=input();print s+s[-2::-1]#let s=stdin.readLine;echo s[0..s.len div 2]

Palindromizes in Python, depalindromizes in Nim. Abuses comment syntax.
Python and Nim both use # for comments. Python doesn't support block comments at all (except for multiline strings with """), but Nim does with #[ comment ]#.
We abuse this to comment out the Python (at the beginning) for Nim, then use the trailing ] in the Python to start the Nim code, looking like a comment for Python.
The Python code requires its input surrounded with quotes. The Nim code doesn't have this restriction.
Tested on Python 2.7.8 and Nim 0.14.2.
Ideone it! -- Python 2, palindromizing
Ideone it! -- Nim, depalindromizing Apparently the version of Nim Ideone uses (0.11.2) doesn't support multiline comments. Works on Nim 0.14.2.

05AB1E/V, 14 bytes
û,ò"Bx$xh|ò"bP

Try it online!
Palindromizes in 05AB1E
Try it online!
Depalindromizes in V, using this answer from DrMcMoylex.

Java / Brainfuck, 71 bytes
/*+[,>]<[<]>[.>]<<[.<][*/a->a.substring(0,Math.ceil(a.length()/2d));//]

Palindromizes in BF, depalindromizes in Java.
For the sake of clarity, this is what matters to the BF interpreter:
+[,>]<[<]>[.>]<<[.<][->,..]

where the last loop containing characters from the Java lambda is skipped because the pointer points to a null character at that point.

Jelly / Pyth, 15 14 chars
<Q.EclQ2*0"¶ŒB

Credit where credit is due.
Try it online! (Jelly) (Palindromizes)
pyth.herokuapp.com (Pyth) (Depalindromizes) (trailing newline)

Japt / JavaScript, 63 chars
Lesson of the day: Japt/JavaScript polyglots are always a bad idea...
$Oq=1;$Oq &&0
alert(($U=prompt()).slice(0*$U,-$U.length/2));$Uê

JavaScript
The first line sets the variable $Oq to 1, then performs a no-op with $Oq &&0.
The second line prompts the user for an input string, assigning it to the variable $U, then slices it from index 0*$U (always 0) to index -$U.length/2. This performs the necessary depalindromization; the result is then alerted. The program ends on a ReferenceError because variable $Uê is not defined.
Japt
In Japt, anything between dollar signs is inserted directly into the transpiled source code. Other than that, each lowercase letter transpiles to e.g. .q(, unless the previous char was another lowercase letter, in which case it becomes "q". A space is transpiled to ), and all missing parens are automatically added. The above program transpiles roughly to:
Oq=1;O.q()&&0
.a("l".e("r".t((U=prompt()).slice(0*U,-U.length/2))));U.ê()

This is then executed as JavaScript. Oq=1; sets the variable Oq to 1. This is never used again, so it's a no-op. O.q() is a function that clears STDOUT and returns undefined; this is falsy, so the entire &&0 .a("l".e(... part is not executed.
The only part that really matters is U.ê(). Implicit input puts the input string in U, .ê() turns it into a palindrome, and implicit output sends the result to STDOUT.

If function entries are allowed, the following will work for 34 chars:
X=>($X=X).slice(0,-X.length/2);$Uê

The first part defines an ES6 function, but it's still a full program in Japt. Test it online!

05AB1E / Java 8, 102 chars
//¹ûq
interface M{static void main(String[]a){System.out.print(a[0].substring(0,a[0].length()/2+1));}}

Palindromize in 05AB1E.
Depalindromize in Java 8.
Explanation 05AB1E:
//     # No-ops
¹      # First input
 û     # Palindromize it
  q    # Terminate the program
interface M{static void main(String[]a){System.out.print(a[0].substring(0,a[0].length()/2+1));}}
       # No-ops

Explanation Java 8:
//¹ûq                           // No-ops
interface M{                    // Class
  static void main(String[]a){  //  Mandatory main-method
    System.out.print(           //   Print to STDOUT:
      a[0].substring(0,         //    The substring of the input-argument from index 0 to
        a[0].length()/2+1));}}  //    the length of the input integer-divided by 2 plus 1

source: Stack Exchange

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

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

sort: votes


text:
Fishing for Cube Nets
Cubes can be made of six squares as sides. But you could also fold three 2x1 rectangles in half and glue them together to form a cube. Now in this challenge you get a set of pieces which are each made from squares, and you have to determine whether you can choose pieces to form a unit cube. Not all of the pieces have to be used, there might be some left over.
Details
The pieces are given as a string of two different characters or a black and white image or any convenient 2D raster format. In the following I assume the pixels that form the pieces are black, and the background is in white.
Two pixels who share a side are considered to belong to the same piece. The pieces can only be folded along the gridlines that separate the pixels, and they cannot be cut. Each side of the cube has the size of one pixel, and each side of the cube can only be made of a single layer.
The output must be a truthy or falsey value.
Testcases
In the following, the spaces   are background and hash symbols # represent the pieces.
(more to be added)
Valid
##
 ##
  ##

 #
####
 #

# # # # # # #

# ##
## #

Invalid
###
###

#  #
####

### ## ####

Run the following snippet for more testcases.

document.getElementById("asdfasdf").style.display = "block";

Valid

    ##
     ##
      ##

     #
    ####
     #

    # # # # # # #

    # ##
    ## #

    #   #
    ###
      #

Invalid

    ###
    ###

    #  #
    ####

    ### ## ####

    ##  ##  ##  ##
    ##  ##  ##  ##
      ##  ##  ##  ##
      ##  ##  ##  ##

PS: This is a generalization of this challenge

Why is the JS code snippet just printing additional hardcoded testcases? Why not just put them in the post haha?

@carusocomputing That was just a measure to prevent the post from being to cluttered.

Will there always be six pixels on?

No, there might more or less on.

Can I receive input as an array of pieces rather than a single image containing all the pieces?

I don't quite understand what you mean, can you provide an example?

For test case 4, [([1,0,1,1], 2, 2), ([1,1,0,1], 2, 2)] instead of ([1,0,1,1,1,1,0,1], 4, 2). Each tuple represents the data with a list containing 1 for each piece followed by the width and the height.

@Blue Ah no, analyzing the input for pieces is part of the challenge. This input would simplify that quite a bit, so I would not allow that. Thank you for asking!

C, 824 803 bytes
#define Z return
#define Y char*b
#define N --n
i,j,n,w,h,A,B,C,D,E,F,G,H;char c[9999],*r,*d;x(b)Y;{if(b<c||*b<35)Z;++n;*b^=1;x(b-1);x(b+1);x(b-w);x(b+w);}m(b,p,y)Y,*p;{d=b;if(!y)for(y=-1,--p;1[++p]&31;)d+=w;for(i=0;*p&31?!(*p&16>>i)||b[i]&1:0;++i>4?p+=y,b+=w,i=0:0);Z!(*p&31)?x(d),n:0;}a(b)Y;{for(j=n=0;j<w*h;++j)if(m(c+j,b,1)||m(c+j,b,0))Z n;Z 0;}f(Y){bzero(c,9999);for(h=0,b=strcpy(c,b);r=b,b=strchr(b+1,10);h++,w=b-r);for(A=2,r=1+"@_`^C@|T@^R@XO@XX`|FB@|PP@|DD@PXN@XHX@XPX`PPXL@XHHX@XLDD@XPPX`PPPXH@PXHHH@PPPPP@";*r;r+=A+=r[-1]/96)while(a(r));A=B=C=D=E=F=G=H=0;while(a("PX")||a("XH")) (n-=3)?N?N?N?0:++H:++G:++F:++C;while(a("^")||a("PPPP"))(n-=4)?N?N?0:++H:++G:++E;while(a("P"))N?N?N?N?N?N?0:++H:++G:++F:++D:++B:++A;Z H||(G&&A)||(F&&B+B+A>1)||(E&&A>1)||D>1||C>1||((D||C)*3+B*2+A>5)*(A>1||B>2||A*B);}

Note: Includes a bug fix (the previous entry falsely identified a tromino and two dominoes as forming a cube).
In the TIO driver code, there are more test cases and there's now a pass/fail tracker; hexomino test cases were updated with the expected pass/fail value in the label.

Try it online!
...and before explaining this in detail, it's worth a high level overview.
Basic Overview
This algorithm applies a pattern matcher to classify each polyomino it finds with a given pattern as its subset.  As polyominoes are matched they are "unmarked", excluding them from pattern matching again.  The initial classification given by the matcher is simply a count of the number of tiles in the polyomino.
The matcher is applied first to cull out all polyominoes that cannot be folded onto a cube; the classification of these polyominos is discarded.  The match succeeds if these polyominoes appear within higher level ones; therefore, we only care about the smallest subset of "unfoldable" for each class.  Shown here along with padded encodings are all such polyominoes (excluding their vertical reflections).  The encoding uses bits 4-0 of each character to represent squares on each row:
[^C```] [XHX``] [PPPXH] [XHHX`] [PXN``] [|PP``]
 ####.   ##...   #....   ##...   #....   ###..
 ...##   .#...   #....   .#...   ##...   #....
 .....   ##...   #....   .#...   .###.   #....
 .....   .....   ##...   ##...   .....   .....
 .....   .....   .#...   .....   .....   .....
[|FB``] [XPX``] [PPXL`] [XLDD`] [XPPX`] [|DD``]
 ###..   ##...   #....   ##...   ##...   ###..
 ..##.   #....   #....   .##..   #....   ..#..
 ...#.   ##...   ##...   ..#..   #....   ..#..
 .....   .....   .##..   ..#..   ##...   .....
 .....   .....   .....   .....   .....   .....
[|T```] [^R```] [PXHHH] [XO```] [_````] [PPPPP]
 ###..   ####.   #....   ##...   #####   #....
 #.#..   #..#.   ##...   .####   .....   #....
 .....   .....   .#...   .....   .....   #....
 .....   .....   .#...   .....   .....   #....
 .....   .....   .#...   .....   .....   #....

[XX```]
 ##...
 ##...
 .....
 .....
 .....

Once these polyominoes are culled, we categorize the remaining polyominoes into relevant categories.  It's worth noting that in almost all cases, one can just find polyominoes that remain (those foldable onto cubes) and simply search for sums of six.  There are two exceptions:

A corner tromino and a line tromino cannot form a cube
A line tetromino and a domino cannot form a cube

In order to be able to accommodate this restriction we form 8 categories, from A-H: A for monominoes (lone tiles), B for dominoes, C for corner trominoes, D for line trominoes, E for line tetrominoes, F for other tetrominoes, G for pentominoes, and H for hexominoes.  Anything not falling into one of these categories is just ignored.  Counting polyominoes that fall into each category suffices.
At the end, we just return truthiness or falsiness based on a giant equation and these tabulations.
Ungolfed with comments
i,j,n,w,h,A,B,C,D,E,F,G,H;char c[9999],*r,*d;
x(b)char*b;{      // recursively unmarks polyomino pointed to by b.
   if(b<c||*b<35)return;
   ++n; *b^=1;    // Tabulates tiles in n as it goes.
   x(b-1);x(b+1);x(b-w);x(b+w); // left/up/down/right
}
m(b,p,y)char*b,*p;{ // pattern match area b with pattern p, direction y.
                    //   y=1 scans down; y=0 scans up.
   d=b; // d tracks a tile in the currently matched pattern for unmarking.
        // Note that all patterns are oriented to where "top-left" is a tile.
   if(!y) // ...when scanning up, move p to the end, set y to -1 to count backward,
          //    and advance d to guarantee it points to a tile (now "bottom-left")
      for(y=-1,--p;1[++p]&31;)d+=w;
   // Match the pattern
   for(i=0;*p&31?!(*p&16>>i)||b[i]&1:0;++i>4?p+=y,b+=w,i=0:0);
   return !(*p&31)   // If it matches...
          ? x(d),n   // ...unmark/count total polyomino tiles and return the count
          : 0;
}
a(b)char*b;{ // Scan for an occurrence of the pattern b.
   for(j=n=0;j<w*h;++j)
      if(m(c+j,b,1)||m(c+j,b,0)) // (short circuit) try down then up
         return n;
   return 0;
}
// This is our function.  The parameter is a string containing the entire area,
// delimited by new lines.  The algorithm assumes that this is a rectangular area.
// '#' is used for tiles; ' ' spaces.
f(char*b) {
   bzero(c,9999); // Init categories, c buffer
   for(h=0,b=strcpy(c,b);r=b,b=strchr(b+1,10);h++,w=b-r); // Find width/height
   // Unmark all polyominoes that contain unfoldable subsets.  This was
   // compacted since the last version as follows.  A tracks
   // the current pattern's length; r[-1], usually terminator for the
   // previous pattern, encodes whether the length increases; and o/c
   // the patterns were sorted by length.
   for(A=2,r=1+"@_`^C@|T@^R@XO@XX`|FB@|PP@|DD@PXN@XHX@XPX`PPXL@XHHX@XLDD@XPPX`PPPXH@PXHHH@PPPPP@";*r;r+=A+=r[-1]/96)
      while(a(r));
   A=B=C=D=E=F=G=H=0;
   // Match corner trominoes now to ensure they go into C.
   while(a("PX")||a("XH"))
      (n-=3)
         ?   --n
             ?   --n
                 ?   --n
                    ?   0 // More than 6 tiles?  Ignore it.
                    : ++H // 6 tiles?  It's an H.
                 : ++G // 5 tiles?  It's a G.
             : ++F // 4 tiles?  It's an F.
        : ++C; // only 3 tiles?  It's a C.
   // Now match line tetrominoes to ensure they go into E.
   while(a("^")||a("PPPP"))
      (n-=4)
         ?   --n
             ?   --n
                 ?   0 // More than 6 tiles?  Ignore it.
                 : ++H // 6 tiles?  It's an H.
             : ++G // 5 tiles?  It's a G.
         : ++E; // only 4 tiles?  It's an E.
   // Find all remaining tetrominoes ("P" is a monomino pattern)
   while(a("P"))
      --n
         ?   --n
             ?   --n
                 ?   --n
                     ?   --n
                         ?   --n
                             ?   0 // More than 6 tiles?  Ignore it.
                             : ++H // 6 tiles?  It's an H.
                         : ++G // 5 tiles? It's a G.
                     : ++F // 4 tiles?  It's an F.
                : ++D // 3 tiles?  It's a D.
            : ++B // 2 tiles?  It's a B.
         : ++A; // only 1 tile? It's an A.
   // Figure out if we can form a cube:
   return H               // Yes if we have a foldable hexomino
      ||(G&&A)            // Yes if we have a foldable pentomino
                          // and a monomino
      ||(F&&B+B+A>1)      // Yes if we have a foldable non-line tetromino
                          // and 2 other tiles (dominoes count twice).
                          // Either one domino or two monominoes will do.
      ||(E&&A>1)          // Yes if we have a foldable line tetromino (E)
                          // and two monominoes (A).  Note we can't make a
                          // cube with a line tetromino and a domino (B).
      ||D>1               // Yes if we have two line trominoes
      ||C>1               // Yes if we have two corner trominoes
      ||((D||C)*3+B*2+A>5)
                          // Any combination of trominoes, dominoes, monominoes>6,
                          // where trominoes are used at most once
                          // (via logical or)...
         * (A>1||B>2||A*B)
                          // ...times this includer/excluder fudge factor
                          // that culls out the one non-working case;
                          // see table:
                          //
                          // Trominos Dominos Monomos Cube  A>1 B>2 A*B
                          //    1        0       3+    yes   Y   N   0
                          //    1        1       1+    yes   Y   N   1
                          //    1        2       0     no    N   N   0
                          //    0+       3       0+    yes   Y   Y   1
      ;
}

This won't work. The question says some pieces may be unused

@JanDvorak Thanks for pointing that out!

To me it seems weird that you spell it tromino instead of triomino, but they are both valid spellings, it seems.


text:
The meta-polyglot quine
In my time on PPCG, I've noticed that quine problems and polyglot problems are quite popular. Also, meta-solutions to problems, that is, scripts which generate a program which is the solution to a problem, tend to get a lot of positive feedback from the community. Therefore, I have created this challenge, which implements these three ideas.
Your task then, reader and code-golf enthusiast, is to create as short as possible a script which can run in two languages A and B to generate quines for A and B. When your program is run in language A, it should generate a program that is a quine in language B but not in language A and vice versa. The languages A and B can be different version of the same language, provided you keep in mind that the generated quines should only work in one of the versions.

Keep in mind that the standard loopholes should be considered closed and only proper quines are allowed.

Good luck, fewest characters wins!

A quine is basically a meta-meta-meta-meta-meta-meta-meta-etc. program anyways :)

How to count bytes if the two languages use different character encodings? You should probably score in characters rather than bytes

If I run the quine in language A to generate a quine for language B, should that be runnable in A?

@LuisMendo When writing a polyglot for languages with different encodings, I'd assume that they both receive the same byte stream (not different encodings of the same characters).

@corvus_192 it doesn't matter how it runs in language A as long as it is not a quine.

@Pavel I actually wrote a similar challenge here, but it got closed as a duplicate.

CJam 0.6.6 dev / GolfScript, 15 14 12 bytes
"0$p"0$~a:n;

Thanks to @jimmy23013 for golfing off 2 bytes!
Rest to be updated.
Verification
Since the submission involves significant whitespace, it's best to compare hexdumps.
$ xxd -g 1 mpquine
0000000: 22 60 30 24 7e 22 30 24 7e 4e 4d 3a 6e 3b        "`0$~"0$~NM:n;
$
$ cjam mpquine | tee quine.gs | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e 0a                 "`0$~"`0$~.
$ golfscript quine.gs | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e 0a                 "`0$~"`0$~.
$ cjam quine.gs | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e                    "`0$~"`0$~
$
$ golfscript mpquine | tee quine.cjam | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e                    "`0$~"`0$~
$ cjam quine.cjam | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e                    "`0$~"`0$~
$ golfscript quine.cjam | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e 0a                 "`0$~"`0$~.

CJam
CJam prints "`0$~"0$~ and a trailing linefeed. Try it online!
The generated program prints "`0$~"0$~ with the trailing linefeed in GolfScript (Try it online!), but without the linefeed in CJam (Try it online!).
How the metaquine works
"`0$~"         e# Push that string on the stack.
      0$~      e# Push a copy and evaluate it:
               e#   `     Inspect the string, pushing "\"`0$~\"".
               e#    0$   Push a copy.
               e#      ~  Evaluate, pushing "`0$~".
               e# Both "\"`0$~\"" and "`0$~" are now on the stack.
         NM    e# Push "\n" and "".
           :n; e# Map print over the elements of "" (none) and pop the result.
               e# "\"`0$~\"", "`0$~", and "\n" are now on the stack, and the
               e# characters they represent will be printed implicitly.

How the quine works
"`0$~"          # Push that string on the stack.
      0$~       # As in CJam.
         <LF>   # Does nothing.
                # "\"`0$~\"" and "`0$~" are now on the stack, and the characters
                # they represent will be printed implicitly, plus a linefeed.

Unlike GolfScript, CJam doesn't print a trailing linefeed by default, so this is not a quine in CJam.
GolfScript
GolfScript prints "`0$~"0$~, without trailing whitespace. Try it online!
The generated program prints "`0$~"0$~ without trailing whitespace in CJam (Try it online!), but GolfScript appends a linefeed (Try it online!).
How the metaquine works
"`0$~"0$~       # As in CJam.
         NM     # Unrecognized token. Does nothing.
           :n   # Store the top of the stack – "`0$~" – in the variable n. n holds
                # "\n" by default. When the program finishes, the interpreter
                # prints n implicitly, usually resulting in a trailing linefeed.
                # By redefining n, it will print "0$~" instead.
             ;  # Pop the string from the stack so it won't be printed twice.

How the quine works
"`0$~"0$~      e# Works as in GolfScript.

Unlike CJam, GolfScript will append a linefeed to the contents of the stack, so this is not a quine in GolfScript.

Just curious, in a broad sense, what's the difference between CJam and GolfScript, and why does your code work?

CJam was heavily inspired by GolfScript and is mostly backwards compatible. One big difference is that GolfScript, by default, appends a linefeed to the output, while CJam doesn't, which is what I'm exploiting here. I'll add a detailed explanation asap.

"0$p"0$~a:n;.

@jimmy23013 Nice, thank you! I had toyed with a:n, but using p didn't occur to me.

CJam / Fission, 22 bytes
"'!+OR'")5-"{'_'~}_~";

Try it in CJam. Try it in Fission.
In CJam, this prints the standard Fission quine:
'!+OR"

Try the Fission quine.
In Fission, this prints a "-less variant of the standard CJam quine:
{'_'~}_~

Try the CJam quine.
This also works for 22 bytes (printing the same quines):
"& *NQ!":)R"{'_'~}_~";

Explanation
In CJam:
"'!+OR'"    e# Push this string.
)           e# Pull off the last character.
5-          e# Subtract 5, turning ' into ".
"{'_'~}_~"  e# Push this string.
;           e# And discard it again.

So at the end of the program, the stack contains the string "'!+OR" and the character ", both of which are implicitly printed.
In Fission, program flow starts at the R with a right-going atom. '" just changes the atoms mass, ), 5 and - are ignored for various reasons. Then the atom enters print mode at the " and prints {'_'~}_~. ; destroys the atom and terminates the program.

+1 for emoticon {'_'~}

destroys the atom I'd rather not be anywhere near when that happens

Clojure / Common Lisp, 274 bytes
(defmacro t []"((fn [s] (print (list s (list (quote quote) s)))) (quote (fn [s] (print (list s (list (quote quote) s))))))")(if '()(print(let[s clojure.string/replace](.toUpperCase(s(s(s(s(s(t)"fn""lambda")"[s]""(s)")"(quote ""'")"e)""e")")))))""))))"))))(eval '(princ(t))))

Some spaces added for readability
(defmacro t []"((fn [s] (print (list s (list (quote quote) s))))
     (quote (fn [s] (print (list s (list (quote quote) s))))))")
(if '()(print(let[s clojure.string/replace](.toUpperCase
    (s(s(s(s(s(t)"fn""lambda")"[s]""(s)")"(quote ""'")"e)""e")")))))""))))"))))
    (eval '(princ(t))))

Basically defines a macro which returns a quine in Clojure. Clojure requires parameters for macro definition provided as vector ([]) whereas Common Lisp (thankfully) just ignores it. After that we differ 2 languages by evaluating '() which equals to nil and thus falsey in Common Lisp and is true in Clojure. Then we do string manipulations using Clojure which Common Lisp doesn't even try to evaluate as it goes in another if branch. Clojure on the other hand tries to check if another branch is at least correct before executing so had to use eval there to both be correct in Clojure and output correct string in Common Lisp.
Note: just returning two different string might probably be shorter but then it won't be different to a polyglot challenges about outputing different strings in different languages.  ¯\_(ツ)_/¯
Clojure original source run: https://ideone.com/SiQhPf
Common Lisp original source run: https://ideone.com/huLcty
Clojure output : ((LAMBDA (S) (PRINT (LIST S (LIST 'QUOTE S)))) '(LAMBDA (S) (PRINT (LIST S (LIST 'QUOTE S)))))
Common Lisp output : ((fn [s] (print (list s (list (quote quote) s)))) (quote (fn [s] (print (list s (list (quote quote) s))))))
Clojure output run in Common Lisp: https://ideone.com/T1DF7H
Vice versa: https://ideone.com/Fezayq

Jelly / GolfScript, 18 16 bytes
0000000: 3a 6e 22 ff cc cc 22 7d 7f fe 22 3a 6e 60 ff 3b  :n"..."}..":n`.;

Verification
Testing all involved programs with the exact byte streams can only be done locally.
$ LANG=en_US # Latin-1. Jelly doesn't care about the exact encoding,
$            # as longs as it's not UTF-8.
$
$ xxd -g 1 mpquine
0000000: 3a 6e 22 ff cc cc 22 7d 7f fe 22 3a 6e 60 ff 3b  :n"..."}..":n`.;
$
$ jelly f mpquine | tee quine.gs | xxd -g 1
0000000: 22 3a 6e 60 22 3a 6e 60                          ":n`":n`
$ golfscript quine.gs | xxd -g 1
0000000: 22 3a 6e 60 22 3a 6e 60                          ":n`":n`
$ jelly f quine.gs 2> /dev/null | xxd -g 1
$
$ golfscript mpquine | tee quine.jelly | xxd -g 1
0000000: ff cc cc                                         ...
$ jelly f quine.jelly | xxd -g 1
0000000: ff cc cc                                         ...
$ golfscript quine.jelly | xxd -g 1
0000000: 0a

Jelly
With Jelly's code page, the program looks as follows.
:n"”ṘṘ"}
“":n`”;

This prints (Try it online!)
":n`":n`

which is a quine in GolfScript (Try it online!), but a parser error in Jelly (Try it online!).
GolfScript
In Latin-1, the program looks as follows, with an unprintable DEL character between } and þ.
:n"ÿÌÌ"} þ":n`ÿ;

This prints (Try it online!)
ÿÌÌ

or, visualized with Jelly's code page,
”ṘṘ

which is a quine in Jelly (Try it online!), but only prints a linefeed in GolfScript (Try it online!).

Good old ”ṘṘ, thus ØV should be gone, right?

JavaScript / C 278 bytes
At a staggering 278 bytes:
//\
console.log('int main(){char*A="int main(){char*A=%c%s%c;printf(A,34,A,34);}";printf(A,34,A,34);}');/*
int main(){puts("A='A=;B=String.fromCharCode(39);console.log(A.slice(0,2)+B+A+B+A.slice(2));';B=String.fromCharCode(39);console.log(A.slice(0,2)+B+A+B+A.slice(2));");}//*/

The C quine:
int main(){char*A="int main(){char*A=%c%s%c;printf(A,34,A,34);}";printf(A,34,A,34);}
The JavaScript quine:
A='A=;B=String.fromCharCode(39);console.log(A.slice(0,2)+B+A+B+A.slice(2));';B=String.fromCharCode(39);console.log(A.slice(0,2)+B+A+B+A.slice(2));

Holy mother of quines...

Befunge / Fission, 35 bytes
"$TQ-#'">,#-:#2_@;"+1_@#`+66:,g0:"L

Try it in Befunge |
Try it in Fission
In Befunge this produces the Fission quine:
'!+OR"

In Fission this produces the Befunge quine:
:0g,:66+`#@_1+

Python / Retina, 70 65 64 66 bytes
I used the same strategy I used in my previous Python / Retina polyglot.
#
print"\nS`((.+))"*2+"\n\n"
#?
#_='_=%r;%_\n';_
#?;
#;print _%
#

Try in Python | Try in Retina
# is a comment in Python, so it simply prints the Retina quine in Python. In Retina, the first stage (2 lines) does nothing, because no # will be found in the input. The next stage replaces nothing with the basis of the Python quine. The third stage replaces each semicolon with the #print _% piece. The last stage removes all #'s.

Quine in Retina:

S`((.+))
S`((.+))

Quine in Python:
_='_=%r;print _%%_\n';print _%_

The quines used may be seen in this challenge. The Retina quine is an error in Python, and the Python quine has no output in Retina.

Can you add an explanation to your answer for how the metaquine works?

@Pavel Added it.

Python 3 / Python 2, 62 bytes
_='_=%r;print(_%%_['+'~'*-~int(-1/2)+'int(-1/2):])';print(_%_)

Try it in Python 2, Python 3.
Based on the Python quine here. The distinguishing factor between the two versions is what they do with int(-1/2): in Python 2, / is integer division (rounding down), with a result of -1; in Python 3, / is floating point division (-0.5), which int truncates to 0.
We build a string _ in three parts. '_=%r;print(_%%_[' and 'int(-1/2):])' are always the same. The interesting part is '~'*-~int(-1/2):

In Python 2, -~int(-1/2) is 0, and the tilde is not added to the string;
In Python 3, -~int(-1/2) is 1, and the tilde is added to the string.

Thus, Python 2 outputs the Python 3 quine
_='_=%r;print(_%%_[int(-1/2):])';print(_%_[int(-1/2):])

and Python 3 outputs the Python 2 quine
_='_=%r;print(_%%_[~int(-1/2):])';print(_%_[~int(-1/2):])

In each version, the expression inside [ :] evaluates to 0, which makes the slice include the entire string, whereas in the wrong language it evaluates to -1, which makes the slice include only the last character, truncating the output so it's not a full quine.

Brain-Flak, brainfuck 4617 4009 bytes
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()()()())))()())[()()])))()()())[()()])))())[()])[()()()()])))))))))))))))))))))))))))))))))))))))))))()()())()())[()()()()])()()())[()()])()())[()()()()])()()()))()()())[()()])[()()()()])))))))))))))))))))()())))()()())[()()()()])()()()()())[()()]))()())[()()()])()())[()()])))()()())[()()])))())[()()])[()()()])))))))))))))))))))))))))))))))))))))))))))()()()())[()()()])()()()())[()()])[()()()]))()()()())[()()()])()()()())[()()])[()()()])()()()())[()()()])()()()())[()()])[()()()]))))))))))))))()()()())[()()()])()()()())[()()])[()()()]))()()()())[()()()])()()()())[()()])[()()()])))))))))))))))))))))))))))))()()()())[()()()])()()()())[()()])[()()()]))()()()())[()()()])()()()()()))))))[()()()])[()])()()))))()()){({}<>)<>}<>([]){({}[()]<(({}[()]<((((((()()()){}())){}{}){}())<>)>)<>){({}[()]<({}()())>){({}[()]<({}())>){({}[()]<({}((()()()){}()){})>){({}[()]<({}()())>){({}[()]<({}(((()()()){}()){}){}())>){(<{}({}()())>)}}}}}}{}([]<({}<{({}<>)<>}<>>)>){({}[()]<({}<>)<>>)}{}{({}[()]<(({}))>)}{}(((({})(((()()())){}{}){}())))<>>)}{}{<>({}<>)}{+++++++>>>+>>>+++++++>>>++++++++>>>+++>>>++++>>>++>>>+++>>>++++>>>++++++++>>>+++>>>++++>>>+>>>+++++>>>++++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+>>>+>>>+>>>+>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++++++++>>>++>>>+++++++>>>++++++++>>>++>>>+++++++>>>++++++++>>>++>>>+++>>>++++>>>++>>>++>>>+>>>++>>>++>>>++>>>++++>>>++>>>+++>>>++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+>>>++>>>++>>>++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++>>>+++++++>>>++++++++>>>+++++++>>>++++++++>>>++>>>+++++++>>>++++++++>>>+>>>++>>>++>>>++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+>>>++>>>+>>>++>>>++>>>++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++++++++>>>+>>>++>>>++>>>+++++++>>>++++++++>>>++>>>+++++++>>>++++++++>>>+>>>++>>>++>>>++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+>>>++>>>+>>>++>>>++>>>++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++>>>+++++++>>>++++++++>>>+++++++>>>++++++++>>>++>>>+++++++>>>++++++++>>>++>>>++++>>>++>>>+++++++>>>+>>>+++>>>+++++++>>>++++++++>>>+>>>+++++++>>>++++++++>>>+>>>++>>>+>>>++>>>++>>>++++>>>++>>>++++++++>>>++++++++>>>++++++++>>>++++++++>>>++++++++>>>++++++++>>>++++++++>>>+++++++>>>++++++++>>>+>>>+++++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++>>>++++>>>++>>>+++>>>++++>>>++++++++>>>+++>>>++++>>>++++>>>++>>>++++>>>++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+++++++>>>++++++++>>>+++>>>++++>>>++>>>+++>>>++++>>>++++>>>++>>>++++++++>>>+++++++>>>++++++++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>+++>>>+>>>+>>>+>>>+++++++>>>++++++++>>>+++++>>>+>>>++>>>++++++>>>++>>>+>>>++>>>++>>>++>>>++++>>>++>>>++++++++>>>+++++++>>>++++++++>>>+++>>>++++>>>++++>>>++>>>++++++++>>>+++++++>>>++++++++>>>+++>>>++++>>>+++++++>>>+>>>+++++++>>>++++++++>>>+++>>>++++>>>++>>>+++>>>++++>>>++++++++>>>+++>>>++++>>><<<[<<<]>>>[>++++++++++++++++++++++++++++++++++++++++.<[->.+.->+<<]>+.[-]>>]<[<<<]>>>[<++++++++++++++++++++++++++++++++++++++++>-[<+>-[<+++++++++++++++++++>-[<++>-[<+++++++++++++++++++++++++++++>-[<++>-[<++++++++++++++++++++++++++++++>-[<++>-]]]]]]]<.>>>>]}{}

Try it online!
Try it online!
Explanation is on its way I am still golfing this

This generates a brainfuck quine in brainfuck, and a Brain-Flak quine in Brain-Flak. It should generate a brainfuck quine when run in Brain-Flak and a Brain-Flak quine when run in brainfuck.

I will do it again.  I am sorry I just have a hard time following the As and Bs


text:
Product catalog
This problem is about separating a string representing a product identifier into three components.

The first part consists of upper and lower letters of arbitrary length which represents the warehouse.
The second part is digits which represents the product number. This part is also of arbitrary length.
The last part is qualifiers as size and colours, and this part continues to the end of the string. The qualifiers are guaranteed to start with a capital letter and consist of alphanumeric characters.

Each part should be printed clearly separated. It is guaranteed that each part is non-empty.
The winner is the one who uses least bytes to solve this problem.
Example:

Input: UK7898S14

Output:
UK
7898
S14
Here UK is United Kingdom, 7898 is the product code, and S14 is size 14.
Example 2:
Input: cphDK1234CYELLOWS14QGOOD

Output:
cphDK
1234
CYELLOWS14QGOOD
Here cphDK is Copenhagen, Denmark, 1234 is the product code, CYELLOWS14QGOOD represents yellow colour, size 14, and good quality.

Is each part non-empty?

@KarlNapf Yes. Each part is non-empty.

@Emigna An addition example has now been included.

“The first part consists of upper and lower letters” – Maybe one of the examples could contain such mixture of upper and lowercase letters. And maybe also a country code that is not 2 characters long. Also, could the qualifier contain non-alphanumeric characters, like “Quality★★★☆☆”?

Welcome to PPCG!

I hope you're not going to use this in production.

I won't. The story about the products was just to make the puzzle more fun. ;-)

Perl, 12 bytes
11 bytes of code + 1 byte for -p flag.
s/\d+/
$&
/

To run it :
perl -pe 's/\d+/
$&
/' <<< "CYELLOWS14QGOOD"

Love the simplicity! :)

Retina, 28 14 10 8 bytes
Saved 4 bytes thanks to Dom Hastings.
Saved 2 bytes thanks to Martin Ender.
S1`(\d+)

Try it online!

Using the same mechanism as @Dada's answer, you can save another 4 bytes: http://retina.tryitonline.net/#code=MWBcZCsKwrYkJsK2&input=Y3BoREsxMjM0Q1lFTExPV1MxNFFHT09E (tbh, probably even more, but that's all I could save! :))

@DomHastings. Aah, nice idea going with the replace!

APL, 18
{⍵⊂⍨3⌊+\1,2≠/⍵∊⎕D}'UK7898S14'
UK  7898  S14

Works by searching the first 2 points where there is a change from character to digit or vice-versa, and using those to split the string.

JavaScript, 38 36 bytes
s=>/(\D+)(\d+)(.+)/.exec(s).slice(1)

Example

const f =

s=>/(\D+)(\d+)(.+)/.exec(s).slice(1)

console.log(f("UK7898S14"));
console.log(f("cphDK1234CYELLOWS14QGOOD"));

@Arnauld Good catch.

Haskell, 36 bytes (no regex)
d c='/'<c&&c<':'
(span d<$>).break d

This gives the result in the format ("UK",("7898","S14")).
The idea is to split at the first digit, and then split the rest at the first non-digit.
Try it on Ideone.

Nice use of fmap on a tuple.

JavaScript (ES6), 28 26 bytes
s=>s.replace(/\d+/,`
$&
`)

Saved 2 bytes thanks to @Grax
Examples

let f =

s=>s.replace(/\d+/,`
$&
`)

console.log(f('UK7898S14'));
console.log(f('cphDK1234CYELLOWS14QGOOD'));

You can reduce 2 more characters by using $& in your replace and removing the parentheses.  s=>s.replace(/\d+/,\
$&
`)`

Gema, 17 12 characters
(The trick of not handling the country code explicitly shamelessly borrowed from Dada's Perl solution. Appreciation should be expressed there.)
<D>*=\n$1\n*

Sample run:
bash-4.3$ gema '<D>*=\n$1\n*' <<< 'UK7898S14'
UK
7898
S14

bash-4.3$ gema '<D>*=\n$1\n*' <<< 'cphDK1234CYELLOWS14QGOOD'
cphDK
1234
CYELLOWS14QGOOD

05AB1E, 39 37 16 bytes
Saved a lot of bytes thanks to Emigna.
It uses CP-1252 encoding.
TvDSdykF¬?¦}¶?}?

T                push "10"
 v               for each element (i.e., 1 and 0). Element is stored in 'y'
  DS             split string (input during the first iteration)
    d            for each character, 1 if digit or 0 otherwise
     yk          get index of the first occurrence of 'y'
       F         for 0 <= i < string.firstIndexOf(y)
        ¬?       print the first character of the string
          ¦      remove it from the string
           }     end inner for
            ¶?   display a newline
              }  end outer for
               ? display the remaining string

Try it online!
(This is my first post here!)

You can save at least 14 bytes by checking digits instead of letters. And this can likely be golfed more.

Also, welcome to PPCG :)

Thanks! And you are right, actually I went all naive on this one, literally from left to right. I also tried to dig .páà¬ to get the first part, but it doesn't seem to help for the rest at first glance.

Feel free to update your answer with my code (and golf it some more if you can). I don't feel that it's different enough to warrant it's own answer.

Ok I'll do it then as I found a way to put it in a loop. Nothing too sophisticated, but at least it goes down to 16 bytes. Thank you again!
(Now I have to update the explanations... but there are fewer bytes to explain)

Python 2, 40 Bytes
I don't know much Regex, but thankfully this problem is simple enough :) Seperates the input string into a list of length 3 which contains each part.
import re
lambda k:re.split('(\d+)',k,1)

MATLAB, 81 73 bytes
function y=f(x)
[~,~,~,m,~,~,s]=regexp(x,'(?<=^\D+)\d+');y=[s(1) m s(2)];

Function that accepts a string and returns a cell array of three strings. Tested in version R20105b.
Example use:
>> f('UK7898S14')
ans =
    'UK'    '7898'    'S14'

>> f('cphDK1234CYELLOWS14QGOOD')
ans =
    'cphDK'    '1234'    'CYELLOWS14QGOOD'

Explanation
The regular expression (?<=^\D+)\d+') matches a group of digits preceded by non-digits from the start of the string; the latter are not part of the match.
The fourth output of regexp is the 'match'; and the seventh output is the 'split', that is, the two parts of the string before and after the match.

Java 7, 200 185 174 167 bytes
import java.util.regex.*;String c(String s){Matcher m=Pattern.compile("(.*?)(\\d+)(.*)").matcher(s);s="";for(int i=0;i<3;)if(m.matches())s+=m.group(++i)+" ";return s;}

Ungolfed & test code:
Try it here.
import java.util.regex.*;
class M{
  static String c(String s){
    Matcher m = Pattern.compile("(.*?)(\\d+)(.*)").matcher(s);
    s = "";
    for(int i = 0; i < 3;){
      if(m.matches()){
        s += m.group(++i) + " ";
      }
    }
    return s;
  }

  public static void main(String[] a){
    System.out.println(c("UK7898S14"));
    System.out.println(c("cphDK1234CYELLOWS14QGOOD"));
  }
}

Output:
UK 7898 S14
cphDK 1234 CYELLOWS14QGOOD

JavaScript (ES6), 36 bytes
s=>/(.+?)(\d+)(.*)/.exec(s).slice(1)

Examples

let f =

s=>/(.+?)(\d+)(.*)/.exec(s).slice(1)

console.log(f('UK7898S14'));
console.log(f('cphDK1234CYELLOWS14QGOOD'));

C#, 191 177 bytes
Golfed:
void F(string s){var a=s.ToList();int i=a.FindIndex(char.IsDigit);int n=a.FindIndex(i,char.IsUpper);Console.Write($"{s.Substring(0,i)}\n{s.Substring(i,n-i)}\n{s.Substring(n)}");

Ungolfed:
    void F(string s)
    {
        var a = s.ToList();
        int i = a.FindIndex(char.IsDigit);
        int n = a.FindIndex(i, char.IsUpper);

        Console.Write($"{s.Substring(0, i)}\n{s.Substring(i, n - i)}\n{s.Substring(n)}");
    }

EDIT1: @Link Ng saved 14 bytes.

You don't need ToCharArray(). string is already IEnumerable

Of course, I can't believe I didn't notice this.

PHP, 48 bytes
print_r(preg_split('/(\D+|\d+)\K/',$argv[1],3));

With its $limit parameter, and the fantastically useful \K, preg_split() is perfect for this challenge.

Ruby, 28 bytes
->s{puts s.sub(/\d+/,"\n\\&\n")}

This surrounds the first cluster of digits with newlines.

PHP, 61 59 5655 bytes
preg_match('/(\D+)(\d+)(.+)/',$argv[1],$a);print_r($a);

This does output the initial code as well:
Array
(
    [0] => cphDK1234CYELLOWS14QGOOD
    [1] => cphDK
    [2] => 1234
    [3] => CYELLOWS14QGOOD
)

Edit
Thanks to @manatwork for saving a few bytes for me
Thanks to @RomanGräf for another few bytes saved

[\d]? :o \d is enough.

@manatwork Thanks.  I don't use regex enough (arguably a good thing) and started down the [0-9]+ route before remembering about \d

Why not replace [a-z] with \D?

Now that you have no [a-z], the i flag is not needed either.

I really need to pend more time working on regular expressions.

You can save  a byte by switching to the deprecated (and removed in php 7) eregi(). It would be much more but the ereg() functions don't seem to support \d or \D.

JavaScript without regex, 84 81 79 bytes
p=>{for(i=n=o='';i<p.length;){if(n==isNaN(c=p[i++])){o+=' ';n++}o+=c}return o}

You could put all initializations in a single place: o=n=i=''.

And move the assignment to c to its first usage: isNaN(c=p[i++]).

p=>{for(i=n=o=0;i<p.length;){c=p[i++];if(n++==c<59){o+=' '}o+=c}return o}

@RomanGräf, the initialization should remain '' because the o, to which the result will be concatenated. But sadly your code is not working for me, n needs to be incremented conditionally.

p=>{for(i=n=0,o='';i<p.length;){c=p[i++];if(n==c<59){o+=' ';n++}o+=c}return o}

Sorry, but definitely something more should be modified as the condition you suggested is not equivalent with the old one: isNaN('A') true vs. 'A'<59 false, and similarly isNaN('1') false vs. '1'<59 true.

Thanks, I updated the solution. I left the init of o where it was as we need it to be initialized with '', and we really don't gain anything by moving it around. Out of curiosity, how does <59 work?

ok, moved the initializations around. I had no idea we could start with '' and increment...

jq, 47 characters
(43 characters code + 4 characters command line options.)
match("(\\D+)(\\d+)(.+)").captures[].string

(Again the old story: fairly elegant at the beginning, then becomes painfully verbose.)
Sample run:
bash-4.3$ jq -Rr 'match("(\\D+)(\\d+)(.+)").captures[].string' <<< 'UK7898S14'
UK
7898
S14

bash-4.3$ jq -Rr 'match("(\\D+)(\\d+)(.+)").captures[].string' <<< 'cphDK1234CYELLOWS14QGOOD'
cphDK
1234
CYELLOWS14QGOOD

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)

R, 63 52 bytes
Edit: Saved a bunch of bytes thanks to @JDL
Takes input from stdin and prints to stdout:
gsub("([a-z]+)(\\d+)(.+)","\\1 \\2 \\3",scan(,""),T)

Example output:
[1] "UK 7898 S1"
[1] "cphDK 1234 CYELLOWS14QGOOD"

Wouldn't gsub (...,"\\1 \\2 \\3") be more efficient?

@JDL Not sure I follow. Care to elaborate or give an example?

something like gsub("([A-Za-z]+)([0-9]+)(.+)","\\1 \\2 \\3",scan()), though the first argument can probably be expressed as something smaller than that...

@JDL Very clever but I have no idea  how the "\\1 \\2 \\3" replacement works though.  Also updated the regex pattern a bit and use ignore.case = TRUE.

They just mean "output whatever was captured in the first/second/third pair of () brackets.

@JDL Alright, that's very useful to know,  thanks!

Python 2, 103 94 88 bytes
Solution without using regex
a,b=input(),""
for f in a:
 if ord(f)<58:b+=f
 elif b"":c,d=a.split(b);print c,b,d;break

Simply extracts the numbers from the middle then slices the input using the number as an index. Requires quotes around the input but I didn't see anywhere that quotes are disallowed.
-9 by splitting a on the middle number then print the components with b in the middle
-6 Thanks to @Shebang
Test Cases
D:\>python codes.py
"UK7898S14"
UK 7898 S14

D:\>python codes.py
"cphDK1234CYELLOWS14QGOOD"
cphDK 1234 CYELLOWS14QGOOD

b!="" -> b>"" and c=a.split(b) -> c,d=a.split(b) ... print c[0],b,c[1] -> print c,b,d saves 5 bytes.

Very nice hints @Shebang. Thanks

Ah, I forgot empty strings are falsy. You can save another 3 bytes by just making it elif b: ;)

Mathematica, 39 bytes
StringSplit[#,a:DigitCharacter..:>a,2]&

Anonymous function. Takes a string as input, and returns a list of strings as output.

Racket 274 bytes
(let((g 0)(j'())(k'())(l'())(m list->string)(r reverse)(n char-numeric?)(c cons))(for((i(string->list s)))
(when(and(= g 0)(n i))(set! g 1))(when(and(= g 1)(not(n i)))(set! g 2))(match g[0(set! j(c i j))]
[1(set! k(c i k))][2(set! l(c i l))]))(list(m(r j))(m(r k))(m(r l))))

Ungolfed:
(define (f s)
  (let ((g 0)
        (j '())
        (k '())
        (l '())
        (m list->string)
        (r reverse)
        (n char-numeric?)
        (c cons))
    (for ((i (string->list s)))
      (when (and (= g 0) (n i)) (set! g 1)  )
      (when (and (= g 1) (not (n i))) (set! g 2) )
      (match g
        [0 (set! j (c i j))]
        [1 (set! k (c i k))]
        [2 (set! l (c i l))]))
    (list (m (r j)) (m (r k)) (m (r l)))))

Testing:
(f "UK7898S14")
(f "cphDK1234CYELLOWS14QGOOD")

Output:
'("UK" "7898" "S14")
'("cphDK" "1234" "CYELLOWS14QGOOD")

Jelly, 14 bytes
O<65ITḣ2‘ṬœṗµY

TryItOnline!
How?
O<65ITḣ2‘ṬœṗµY - Main link: productIdentifier   e.g. "UK7898S14"
O              - cast to ordinals               e.g. [85,75,55,56,57,56,83,49,52]
 <65           - less than 65?                  e.g. [ 0, 0, 1, 1, 1, 1, 0, 1, 1]
    I          - incremental difference         e.g. [ 0, 1, 0, 0, 0,-1, 1, 0]
     T         - truthy indexes                 e.g. [2, 6, 7]
      ḣ2       - head to 2                      e.g. [2, 6]
        ‘      - increment                      e.g. [3, 7]
         Ṭ     - set truthy indexes             e.g. [0, 0, 1, 0, 0, 0, 1]
          œṗ   - split y at truthy indexes of x e.g. ["UK", "7898", "S14"]
            µ  - monadic chain separation
             Y - join with line feeds

C#, 74 bytes
v=>new System.Text.RegularExpressions.Regex("\\d+").Replace(v,"\n$&\n",1);

Replace 1st set of digits with carriage return, set of digits, and another carriage return, as Johan Karlsson did for JavaScript.

C, 107 bytes
#define p(x) printf("%c",x);
f(char*s){for(;*s>64;s++)p(*s)p(10)for(;*s<58;s++)p(*s)p(10)for(;*s;s++)p(*s)}

Call with:
int main()
{
   f("UK7898S14");
   return 0;
}