text:
Fully parenthesize expressions
Today your challenge is to produce all possible full parenthesizations of an expression.
Your input is a single line of printable ASCII containing one or more terms separated by operators. The input might also contains spaces - you must ignore these. A term is [a-zA-Z0-9], an operator is [^ ()a-zA-Z0-9]. You may assume that the input is always valid.
Output all possible ways to fully parenthesize the given expression, separated by newlines with an optional trailing newline.
Do not:

Parenthesize terms - only parenthesize around operators.
Reorder the terms.
Output any spaces.

Example input/output:
N
N

a * b
(a*b)

x_x_0
(x_(x_0))
((x_x)_0)

a * b|c|d
(a*(b|(c|d)))
(a*((b|c)|d))
((a*b)|(c|d))
((a*(b|c))|d)
(((a*b)|c)|d)

Smallest code in bytes wins.

You have to list down the exact operators we have to consider. Is ! an operator? What about ↑ ?

@Optimizer I listed the exact regular expression of what is considered an operator. ! fits the regex, so does ↑, however ↑ can not be part of the input because it is not printable ASCII.

Ah okay. So anything except a term is an operator...

So both terms and operators are always one character long?

@user81655 Correct.

Can we optionally assume a trailing newline in the input?

@Optimizer and except spaces and parentheses.

@MartinBüttner Sure, you may assume a trailing newline in the input.

This means that you can't write a function?

@LegionMammal978 The default rules apply.

insert obligatory LISP-related pun here

Pyth, 38 bytes
L?tbsmmjj@bdk"()"*y<bdy>bhd:1lb2bjy-zd

Try it online.
It defines a recursive function that:

returns the input if its length is 1
takes all two-splits of the input on operators, and for each split:

calls itself recursively on each of the halves
takes the Cartesian product of the results of each half
joins each result by the operator at the split
parenthesizes the joined result

and finally concatenates the resulting arrays.

The function is then called with the input string with spaces removed and the results are joined by newlines.

JavaScript (ES6), 208 197 bytes
s=>((q=x=>x.map((_,i)=>(a=[...x.slice(0,i*=2),p="("+x[i]+x[++i]+x[++i]+")",...x.slice(i+1)],x[i]?a[1]?q(a):r.push(p):0)))([...s.replace(/ /g,o="")],r=[]),r.map((l,i)=>r.indexOf(l)(                                  // s = input string
  (q=x=>                              // q = parenthesise array function
    x.map((_,i)=>(
      a=[                             // a = p with parenthesised pair of terms
        ...x.slice(0,i*=2),
        p="("+x[i]+x[++i]+x[++i]+")", // parenthesise and join 2 terms and an operator
        ...x.slice(i+1)
      ],
      x[i]?a[1]                       // make sure the loop is not over
        ?q(a)                         // check next level of permutations
        :r.push(p)                    // add the permutation to the results
      :0
    ))
  )([...s.replace(/ /g,               // remove spaces and parenthesise all expressions
    o="")],                           // o = output string
    r=[]),                            // r = array of result strings
  r.map(                              // filter out duplicates
    (l,i)=>r.indexOf(l)<i?0:o+=l+`
`
  ),o)                                // return o

Test

Input = <input type="text" id="input" value="a * b|c|d" /><button onclick='results.innerHTML=(

s=>((q=x=>x.map((_,i)=>(a=[...x.slice(0,i*=2),p="("+x[i]+x[++i]+x[++i]+")",...x.slice(i+1)],x[i]?a[1]?q(a):r.push(p):0)))([...s.replace(/ /g,o="")],r=[]),r.map((l,i)=>r.indexOf(l)Go</button>


text:
Help the architects visualize the skyline
As part of a city planning project, you've gotten the assignment of creating a program or function that will display the city skyline, given some input from the architects. The project is only in the startup phase, so a very rough sketch is sufficient. The easiest approach is of course to simply draw the skyline in ASCII-art.
All buildings will be by the river, thus they are all aligned. The architects will give the height of each building as input, and your code should display the skyline.
The input from the architects will either be an integer or a half-integer. If the number is an integer, the building will have a flat roof, while a half-integer will result in a pitched roof. A zero will just be flat ground. The walls of a building are 3 characters apart, while a zero will be a single character wide. Adjacent buildings share walls.
For details and clarifications regarding the output, please have a look at the examples below:
N = 3
 ___
|   |
|   |
|___|

N = 3.5
  _
 / \
|   |
|   |
|___|

N = 6
 ___
|   |
|   |
|   |
|   |
|   |
|___|

n = 0
_

Example input: 3 3.5 0 2
      _
 ___ / \
|   |   |  ___
|   |   | |   |
|___|___|_|___|

Example input: 0 0 2.5 3 0 4 1
             ___
    _  ___  |   |
   / \|   | |   |
  |   |   | |   |___
__|___|___|_|___|___|

Louisville, 0 2 1 3.5 0 4 2 4 2 4 6 1 6 0 5 1
                                    ___     ___
                                   |   |   |   |  ___
           _    ___     ___     ___|   |   |   | |   |
          / \  |   |   |   |   |   |   |   |   | |   |
  ___    |   | |   |___|   |___|   |   |   |   | |   |
 |   |___|   | |   |   |   |   |   |   |___|   | |   |___
_|___|___|___|_|___|___|___|___|___|___|___|___|_|___|___|

The ASCII-characters used are: newline, space, and /\_| (code points 10, 32, 47, 92, 95, 124).
Rules:

It's optional to make a program that only take integers as input, by multiplying all numbers by two. So, instead of taking 3 3.5 2, your program may take 6 7 4. If the second input format is chosen, an input of 6 should result in a 3 story building, 7 should be a 3 story building with pitched roofs etc.
The output should be exactly as described above, but trailing spaces and newlines are OK.
The exact format of the input is optional. Whatever is best in your language.
The result must be displayed on the screen, so that the architects can have a look at it.
You can assume there will be at least one integer given, and that only valid input will be given.

This is codegolf, so the shortest code in bytes win.

What would a building of height 0.5 look like?

Haven't thought of it really. The most obvious choice would be just a pitched roof, almost like a hobbit home :-) but you're free to choose, or you can assume the input will never be 0.5...

At the moment weird things happen as there are no walls (I assumed 0.5 high didn't exist), so I'll have to work on my answer a bit.

I just tried your code with height 0.5, and I agree, "weird" is a very descriptive word =P I haven't gone through it in detail, so I'm not sure what is going on... Anyhow, you answer is perfectly valid, you can assume there aren't any 0.5 buildings...

Python 2, 199 193 188 185 bytes
a=map(int,raw_input().split())
l=max(a)+1|1
while~l:print''.join((x%2*'/  _\\ '[x<l::2]*(x<=l<x+4)or'_ '[x|1!=l>1]*3)[x<1:x+2]+'| '[x<=l>=y]*(x+y>0)for x,y in zip([0]+a,a+[0]))[1:];l-=2

This is a full program that accepts integers as input. Example input.

wonderful! i'ma have to steal some of these tricks for future golfs...

MATLAB, 219 209 203 bytes
i=input('');x=1;c=0;m(1:4*numel(i))='_';for a=i;b=fix(a);m(1:b,x)='|';s=95;if a~=b;m(b+2,x+2)=95;s='/ \';end;m(b+1,x+(1:3))=s;x=x+(a>0)*3+1;m(1:b,x)='|';x=x+(a<1&c>0);c=a;end;disp(flipud(m(:,1:x-(a<1))))

This unfortunately doesn't work on Octave. Not entirely sure why, seems to be something to do with the disp/flipud bit that breaks.
Also, there is currently no definition of what a 0.5 height building looks like, nor any mention of them, so in this code I assume that they are disallowed.
The following is the code in a slightly more readable way:
i=input(''); %e.g. [0 0 2 1 3.5 0 4 2 4 2 4 6 1 6 0 5 1 0 0 1 0]
x=1;
c=0;
m(1:4*numel(i))='_';
for a=i;
    b=fix(a);
    m(1:b,x)='|';
    s=95;
    if a~=b;
        m(b+2,x+2)=95;
        s='/ \';
    end;
    m(b+1,x+(1:3))=s;
    x=x+(a>0)*3+1;
    m(1:b,x)='|';
    x=x+(a<1&c>0);
    c=a;
end;
disp(flipud(m(:,1:x-(a<1))))

First we take an input as an array, and do some variable initialisation.
i=input(''); %e.g. [0 0 2 1 3.5 0 4 2 4 2 4 6 1 6 0 5 1]
x=1;
c=0;

Because the zero height buildings are a pain - they basically end up with a width which is dependent on what they are next to (though what is printed doesn't change), we simplify things by drawing enough ground for all of the buildings. We assume each building will be 4 characters wide (because adjacent buildings merge together) - zero height ones aren't, but the excess will be trimmed later.
m(1:4*numel(i))='_';

Now we draw out each building in turn.
for a=i

First we get the integer part of the height as this will determine how many '|' we need.
    b=fix(a);

Now draw in the wall for this building - if there are two adjacent buildings, the wall for this new one will be in the same column as the wall from the last one.
    m(1:b,x)='|';

Check to see if this is a half height building. If it is, then the roof will be different. For the half heights, the roof is going to be / \ whereas full height ones it will be ___ (Matlab will implicitly replicate this from a single underscore, so save a couple of bytes there). There is an extra bit of roof one row higher for the half height buildings, so that is added as well.
    s=95;
    if a~=b;
        m(b+2,x+2)=95;
        s='/ \';
    end;

Draw in the roof
    m(b+1,x+(1:3))=s;

Now move to the start of the next building and draw in the shared wall (if the wall is too short at this point, it will be made larger when the next building is drawn). Note that zero height buildings are 1 wide, normal buildings are 4 wide, so we simplify what would otherwise be an if-else by treating (a>0) as a decimal number not a Boolean.
    x=x+(a>0)*3+1;
    m(1:b,x)='|';

Next comes a bit of hackery to work with zero height buildings. Basically what this says is if this building was zero height, and the one before that wasn't, it means the place of the next building needs incrementing by 1 because a zero height building sandwiched between two other buildings is effectively twice as wide - this accounts for the extra wall which is normally shared with an adjacent building. We also keep track of this building height for doing this check next time.
    x=x+(a<1&c>0);
    c=a;
end;

Once done, flip the building matrix to be the correct way up, and display it. Note that we also trim off any excess ground here as well.
disp(flipud(m(:,1:x-(a<1))))

So, when we run this script, we are asked for our input, for example:
[0 0 2 1 3.5 0 4 2 4 2 4 6 1 6 0 5 1 0 0 1 0]

It then generates the building and displays the result. For the above input, the following is generated:
                                     ___     ___
                                    |   |   |   |  ___
            _    ___     ___     ___|   |   |   | |   |
           / \  |   |   |   |   |   |   |   |   | |   |
   ___    |   | |   |___|   |___|   |   |   |   | |   |
  |   |___|   | |   |   |   |   |   |   |___|   | |   |___    ___
__|___|___|___|_|___|___|___|___|___|___|___|___|_|___|___|__|___|_

Very well done!

Kotlin, 447 442 bytes
val a={s:String->val f=s.split(" ").map{it.toFloat()}.toFloatArray();val m=(f.max()!!+1).toInt();for(d in m downTo 0){var l=0f;for(c in f){val h=c.toInt();print(if(h==d&&d!=0)if(h<l-0.5)"|" else{" "}+if(c>h)"/ \\" else "___" else if(h<d)if(d<l-0.5)"|" else{" "}+if(h==0)" " else if((c+0.5).toInt()==d)" _ " else "   " else{if(h==0)if(l<1)"  " else "| " else "|   "}.replace(' ',if(d==0)'_' else ' '));l=c;};if(d<l-0.5)print("|");println();}}

Ungolfed version:
val ungolfed: (String) -> Unit = {
    s ->

    val floats = s.split(" ").map { it.toFloat() }.toFloatArray()
    val maxH = (floats.max()!! + 1).toInt()

    for (drawHeight in maxH downTo 0) {
        var lastBuildingH = 0f
        for (f in floats) {
            val buildingH = f.toInt()
            if (drawHeight == 0) {
                // Baseline
                if (buildingH == 0)
                    if (lastBuildingH.toInt() == 0) print("__")
                    else print("|_")
                else print("|___")
            } else if (buildingH == drawHeight) {
                // Ceiling
                if (buildingH < lastBuildingH - 0.5) print("|")
                else print(" ")
                if (f > buildingH) print("/ \\")
                else print("___")
            } else if (buildingH < drawHeight) {
                // Above building
                if (drawHeight < lastBuildingH - 0.5) print("|")
                else print(" ")
                if (buildingH == 0) print(" ")
                else {
                    if ((f + 0.5).toInt() == drawHeight) print(" _ ")
                    else print("   ")
                }
            } else {
                if (buildingH == 0) print("| ")
                else print("|   ")
            }
            lastBuildingH = f;
        }
        if (drawHeight < lastBuildingH - 0.5) print("|")
        println()
    }
}

Python 2, 357 306 299 294 287 281 276 bytes
def s(l):
 d=len(l)+1;l=[0]+l+[0];h=(max(l)+3)/2;o=''
 for i in range(d*h):
  a=l[i%d+1];c=l[i%d];b=2*(h-1-i/d);o+="|"if(a>b+1)+(c>b+1)else" "*(a+c>0);o+=" _/__  _\\"[a-b+1::3]if b*(1>=abs(a-b))else" "*(1+2*(a>0))
  if b==0:o=o.replace(" ","_")
  if i%d==d-1:print o[:-1];o=''

This uses the "doubled" encoding, to be passed to the function as a list.
Edit: Shaved bytes by redoing part of the big conditional as an array selector, and switching to the doubled encoding. Shaved more bytes by rearranging the conditional even more and converting more logic to arithmetic.
EDIT: xsot's is better
Explanation:
d=len(l)+1;l=[0]+l+[0];m=max(l);h=m/2+m%2+1;o=''

d is 1 more than the length of the array, because we're going to add zeros on each end of the list from the second element up to the zero we added on the end. h is the height of the drawing. (We have to divide by 2 in this calculation because we are using the doubled representation, which we use specifically to avoid having to cast floats to ints all over the place. We also add 1 before dividing so odd heights--pointy buildings--get a little more clearance than the regular kind.) o is the output string.
 for i in range(d*h):

A standard trick for collapsing a double for loop into a single for loop. Once we do:
  a=l[i%d+1];c=l[i%d];b=2*(h-1-i/d)

we have now accomplished the same as:
for b in range(2*h-2,-2,-2):
 for j in range(d):
  a=l[j+1];c=l[j]

but in a way which nets us ten bytes saved (including whitespace on the following lines).
  o+="|"if(a>b+1)+(c>b+1)else" "*(a+c>0)

Stick a wall in any time the height of either the current building or the previous building is taller than the current line, as long as there is at least one building boundary here. It's the equivalent of the following conditional:
  o+=("|" if a>b+1 or c>b+1 else " ") if a or c else ""

where b is the current scan height, a is the current building height, and c is the previous building height. The latter part of the conditional prevents putting walls between ground spaces.
  o+=" _/__  _\\"[a-b+1::3]if b*(1>=abs(a-b))else" "*(1+2*(a>0))

This is the part that draws the correct roof, selecting roof parts by comparing the building's height with the current scan height. If a roof doesn't go here, it prints an appropriate number of spaces (3 when it's an actual building, e.g., a>0, otherwise 1). Note that when we're at ground level, it never attempts to draw a roof, which means 0.5 size buildings don't get pointy roofs. Oh well.
  if b==0:o=o.replace(" ","_")

When we're at ground level, we want underscores instead of spaces. We just replace them all in at once here.
  if i%d==d-1:print o[:-1];o=''

Just before we start processing the next line, print the current one and clear the output line. We chop off the last character because it is the "_" corresponding to the ground space we added by appending a zero at the beginning of the function. (We appended that zero so we would not have to add a special case to insert a right wall, if it exists, which would add far more code than we added by adding the 0 and chopping off the "_".)

Car-golfing. Wow. (Also, +1)

Python 3
725 bytes
608 bytes
Golfed code:
import sys,math;
m,l,w,s,bh,ls,ins,r,a="|   |","___","|"," ",0,[],[],range,sys.argv[1:]
def ru(n):return math.ceil(n)
def bl(h,n):
    if(n>ru(h)):return(s*5,s)[h==0]
    if(h==0):return"_"
    if(n==0):return w+l+w
    if(n<h-1):return m
    return("  _  "," / \ ")[n==ru(h)-1]if(h%1)else(s+l+s,m)[n==h-1]
for arg in a:
    f=ru(float(arg))
    if(bh<f):bh=f
for i in r(bh,-1,-1):
    ln=""
    for bld in a:ln+=bl(float(bld),i)
    ls.append(ln)
for i in r(len(ls[-1])-1):
    if(ls[-1][i]==ls[-1][i+1]==w):ins.append(i-len(ins))
for ln in ls:
    for i in ins:ln=(ln[:i]+ln[i+1:],ln[:i+1]+ln[i+2:])[ln[i]==w]
    print(ln)

Here's the ungolfed code. There are some comments but the basic idea is to create buildings with double walls, so the bottom line looks like:
_|___||___|_|___||___|

Then to get indexes of those double walls and remove those columns so we get:
_|___|___|_|___|___|

Code:
import sys
import numbers
import math

mid="|   |";
l="___";
w="|";
s=" ";

def printList(lst):
    for it in lst:
        print(it);

# h = height of building
# l = line numeber starting at 0
def buildingline(h,n):
    #if (h==0):
    #   return " " if(n>math.ceil(h)) else "   ";
    if(n>math.ceil(h)):
        return s if(h == 0) else s*5;
    if(h==0): return "_";
    if(n==0): return w+l+w;
    if(n<h-1): return mid;
    if(h.is_integer()):
        return mid if(n==h-1) else  s+l+s;
    else:
        return " / \ " if (n==math.ceil(h)-1) else "  _  ";
# max height
bh=0;

for arg in sys.argv[1:]:
    f = math.ceil(float(arg));
    if(bh<f):bh=f;

# lines for printing
lines = []

for i in range(bh,-1,-1):
    line="";
    for bld in sys.argv[1:]:
        bld=float(bld);
        line += buildingline(bld,i);
        #lh = bld;
    lines.append(line);

#for line in lines:
#   print(line);
#printList(lines);

# column merging
#find indexes for merging (if there are | | next to each other)
indexes = [];
for i in range(len(lines[-1])-1):
    if (lines[-1][i]=='|' and lines[-1][i+1] == '|'):
        indexes.append(i-len(indexes));

#printList(indexes);

#index counter
for line in lines:
    newLine = line;
    for i in indexes:
        if newLine[i] == '|' :
            newLine=newLine[:i+1] + newLine[i+2:];
        else : newLine = newLine[:i] + newLine[i+1:];
    print(newLine);

Time to do some golfing!

You might want to have a look here. I think there's a lot of golfing potential here =) I only know basic Python, so I can't suggest anything specific I'm afraid...

It looks to me like you have removed spaces and shortened the variable names, but kept the rest unchanged. You should try to find clever ways to e.g. get rid of some loops, use fewer comparisons etc. Of course, stuff like ru(n):return math.ceil(n) counts as golfing, but still... Please don't take this in a negative way, I'm not a good golfer myself, and sure as hell not a good programmer. I suggest you try to improve it some... It's actually kind of fun once you realize you manage to shorten it. I went from many many to 120 to 55 a few days ago. So it's possible even if you're new at it.

@StewieGriffin Thank you for that link! I'm really a newbie to code-golfing so it's more about completing the actual task rather than doing code-golfing for me. But it's amazing to discover possibilities of various languages

FTR: For some of the more complex challenges, such as this one, I would be happy just to finish it myself =)

PHP, 307 297 293 bytes
<?$r=str_pad("",$p=((max($argv)+1)>>1)*$w=4*$argc,str_pad("\n",$w," ",0));for(;++$i<$argc&&$r[$p++]=_;$m=$n)if($n=$argv[$i]){$q=$p+=!$m;eval($x='$r[$q-1]=$r[$q]=$r[$q+1]=_;');for($h=$n>>1;$h--;$q-=$w)$r[$q-2]=$r[$q+2]="|";$n&1?($r[$q-1]="/")&($r[$q-$w]=_)&$r[$q+1]="\\":eval($x);$p+=3;}echo$r;

Takes arguments*2 from command line. save to file, run with php <filename> <parameters>.
breakdown
// initialize result
$r=str_pad("",              // nested str_pad is 3 bytes shorter than a loop
    $p=                     // cursor=(max height-1)*(max width)=(start of last line)
    ((max($argv)+1)>>1)     // max height-1
    *
    $w=4*$argc              // we need at least 4*($argc-1)-1, +1 for newline
    ,
    // one line
    str_pad("\n",$w," ",0)  // (`str_pad("",$w-1)."\n"` is one byte shorter,
);                          // but requires `$w+1`)

// draw skyline
for(;
    ++$i<$argc              // loop through arguments
    &&$r[$p++]=_                // 0. draw empty ground and go one forward
    ;
    $m=$n                       // 7. remember value
)
    if($n=$argv[$i])            // if there is a house
    {
        $q=                         // 2. copy $p to $q
        $p+=!$m;                    // 1. go one forward if there was no house before this
        // offset all further positions by -2 (overwrite empty ground, share walls)
        eval($x=                    // 3. draw floor
        '$r[$q-1]=$r[$q]=$r[$q+1]=_;'
        );
        for($h=$n>>1;$h--;$q-=$w)   // 4. draw walls
            $r[$q-2]=$r[$q+2]="|";
        $n&1                        // 5. draw roof
            ?($r[$q-1]="/")&($r[$q-$w]=_)&$r[$q+1]="\\"
            :eval($x)               // (eval saved 7 bytes)
        ;                           // (ternary saved 6 bytes over `if`)
        $p+=3;                      // 6. go three forward (5-2)
    }

// output
echo$r;

C++, ungolfed
(or maybe ungolfable)
Assuming there are less than 100 elements and each element is less than 100. s is the number of buildings (required in input).
#include <iostream>
using namespace std;
int main()
{
float a[100];
int i,j,s;
cin>>s;
for(i=0;i<s;++i)
 cin>>a[i];
for(i=100;i>=1;--i)
{
for(j=0;j<s;++j)
{
if((a[j]>=i)||(a[j-1]>=i))
 cout<<"|";
else
 cout<<" ";
if(i==1)
 cout<<"___";
else if(a[j]+1==i)
 cout<<"___";
else if(a[j]+1.5==i)
 cout<<" _ ";
else if(a[j]+0.5==i)
 cout<<"/ \\";
else cout<<"   ";
}
if(a[s-1]>=i)
 cout<<"|";
cout<<endl;
}
}

There are a few errors in the output... The ground is 3 characters wide (it should only be 1), and the last wall is missing.

@StewieGriffin I was still sorting out the errors when I posted this. 1. I have added the last wall. 2. The ground has to be 3 characters wide, because the slanted roof /_\ is 3 characters wide.

*The ground between the buildings, not inside.

If you're still working on it, you might want to wait, but you can get rid of many bytes if you remove the newlines and the indentation. I haven't fixed the ground problem, but this works.346 bytes instead of 401.

@StewieGriffin I don't actually intend to submit a golfed answer since it's way too long anyways. I can bet there exist better languages where it gets done in under 100 bytes. So my code is more of a reference solution to others.

@StewieGriffin You are free to edit it, either to remove whitespace or to decrease ground length. (Writing programs isn't exactly my interest.)

source: Stack Exchange

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

sort: votes


text:
N Slab Slanted Slash Cake
Write a program or function that takes in a positive integer N.
When N is 1, output
/\
\/

When N is 2, output
/\/\
\/ /
/ /
\/

When N is 3, output
/\/\/\
\/ / /
/ / /
\/ /
/ /
\/

When N is 4, output
/\/\/\/\
\/ / / /
/ / / /
\/ / /
/ / /
\/ /
/ /
\/

For larger N the pattern continues, a new layer is added every time N is incremented.

"Output" means print the slash pattern or return it as a string.
A single trailing newline in the output is allowed.
Trailing spaces in the output are allowed but leading spaces are not.

The shortest code in bytes wins.

Pyth, 25 bytes
j_+t.iJ*R"/ "SQ+L\\J*Q"/\

Try it online: Demonstration or Test Suite
Explanation:
j_+t.iJ*R"/ "SQ+L\\J*Q"/\   implicit: Q = input number
             SQ             create the list [1, 2, ..., Q]
       *R"/ "               repeat "/ " accordingly to this numbers
      J                     assign this list of strings to J
               +L\\J        create a 2nd list, which contains the same strings
                            as in J, just with a "\" prepended
    .i                      interleave these two lists
   t                        remove the first element
                    *Q"/\   repeat the string "/\" Q times
  +                         append it to the list
 _                          reverse it
j                           print each string on a separate line

CJam, 32 30 29 28 bytes
ri_"/\ /"2/f*)@,\f>+_z..e>N*

Test it here.
I was trying to help Reto golf his CJam answer but ended up with a solution that had nothing to do with his, so I figured I might as well post it myself.
Explanation
This makes use of the symmetry of the output. In particular, the fact that the output is the same as its transpose.
First, we generate the first N+1 lines, but without the left edge:
ri       e# Read input and convert to integer N.
_        e# Duplicate.
"/\ /"2/ e# Push an array with two strings: ["/\" " /"]
f*       e# Repeat each of the two strings N times. That gives the first two rows.
)        e# Detach the second row.
@,       e# Pull up the other copy of N and turn into range [0 1 ... N-1].
\f>      e# For each element i in that range, discard the first i characters of
         e# the second row.
+        e# Add all those lines back to the first row.

Now we've got an array of strings representing the following grid:
/\/\/\/\
 / / / /
/ / / /
 / / /
/ / /

The transpose of that looks like this:
/ / /
\/ /
/ / /
\/ /
/ / /
\/ /
/ /
\/

Together, these have all the non-space characters that we need. We can now make use of Dennis's rad tip to combine two ASCII grids into one, by taking the maximum of each corresponding pair of characters. In all positions where the two grids differ, one will have a space (or nothing at all) and the other will have the character we're looking for. When one list in a vectorised operation is longer than the other, the additional elements of the longer list will simply be kept, which is just what we're looking for. In the other cases, the non-space character will always be the maximum of the two characters:
_z   e# Duplicate the grid and transpose it.
..e> e# For each pair of characters in corresponding positions, pick the maximum.
N*   e# Join the lines by linefeed characters.

Japt, 46 44 41 40 bytes
Uo-U £Y?"\\/"sYv)+" /"pU-Y/2 :"/\\"pU} ·

Try it online!
Ungolfed and explanation
Uo-U mXYZ{Y?"\\/"sYv)+" /"pU-Y/2 :"/\\"pU} qR

The core of the program makes a list of U * 2 items, maps each to one row of the pattern, then joins them with newlines:
Uo-U    // Build an array of all integers in the range [-U, U).
mXYZ{   // Map each item X and index Y in this array with the following function.
 ...
} qR    // Join the resulting array with newlines.

As for the pattern itself, here's how I have broken it up:
/\/\/\/\

\/   / / /
/    / / /
\/   / /
/    / /
\/   /
/    /
\/

As you can see here, this now devolves into three simple patterns. The first one is the easiest, generated with this code:
Y? ... :  // If Y, the current index, is 0,
"/\\"pU   // return the pattern "/\" repeated U*2 times.

Now for the left half. Odd indices should map to \/, and even to /, so we use this code:
"\\/"s  // Otherwise, slice the pattern "\/" at
Yv)     //  if Y is even, 1; otherwise, 0.

This makes the right half way easier; all we need to do is repeat  / a few times:
" /"p  // Repeat the pattern " /"
U-Y/2  //  floor(U - (Y/2)) times.

Suggestions welcome!

GNU Sed, 59
Score includes +2 for '-nr' options to sed.
s|1|/\\|gp
y|/\\| /|
s| |\\|p
:
s|\\(..)|\1|p
s|/ |\\|p
t

Input in unary as per this meta answer.
Test output:
$ sed -nrf slantcake.sed <<< 111
/\/\/\
\/ / /
/ / /
\/ /
/ /
\/
$

Python 2, 80 bytes
n=input()
print"/\\"*n
for i in range(n*2,1,-1):print"\\"*(1-i%2)+"/ "*(i/2+i%2)

CJam, 36 35 34 bytes
ri_"/\\"*N@,W%{'\'/@" /"*+_N\N}/;;

Try it online
Thanks to @NinjaBearMonkey for pointing out the extra ;.
While this looks relatively inelegant, I tried a couple of other options, and they did not end up any shorter.
Explanation:
ri_     Get input, convert to integer, and copy.
"/\\"   Pattern for first line.
*N      Repeat N times, and add a newline.
@,      Rotate N to top, and create [0 .. N-1] sequence.
W%      Invert sequence to [N-1 .. 0].
{       Loop over counts, creating two lines for each.
  '\      Leading character for first in pair of lines. Rest will be the same
          for both lines.
  '/      First character for repeated part.
  @       Rotate count to top.
  " /"    Repetitive pattern.
  *       Replicate it by count.
  +       Concatenate with '/.
  _       Copy whole thing for use as second in pair of lines.
  N\      Put a newline between the pair of lines.
  N       Add a newline after second line.
}/      End of loop over counts.
;;      Created an extra line, get rid of it.

Now you can just remove one of the last ;s.

Or replace ;;; with +;

Mathematica, 123 122 121 bytes
""<>(#<>"
"&/@Normal@SparseArray[{{i_,j_}/;2∣(i+j)&&i+j<2#+3->"/",{i_,j_}/;i~Min~j<2&&2∣i~Max~j->"\\"},{2#,2#}," "])&

Could probably be golfed further.

I've raised this on meta.

Java - 141 bytes
Not the shortest of course, but nice to have a Java solution :
String a(int a){String s="";int b=-1,c,e;for(a*=2;++b<a;){for(c=-1;++c<a;)s+=(e=b+c)>a?" ":e%2==0?"/":b==0||c==0?"\\":" ";s+="\n";}return s;}

Ungolfed
String a(int a){
    String s ="";
    int b=-1,c,e;
    for (a*=2;++b < a;){
        for (c = -1 ; ++c < a ;)
            s+= (e=b+c)>a?" ": e%2==0? "/" : b==0||c==0? "\\" : " ";
        s+="\n";
    }
    return s;
}

Input
System.out.println(a(5));

Output
/\/\/\/\/\
\/ / / / /
/ / / / /
\/ / / /
/ / / /
\/ / /
/ / /
\/ /
/ /
\/

JavaScript, 128 125 123 114 bytes
n=>{r='';for(i=0;i<n;i++)r+='/\\';for(j=0;j<2*n-1;j++){r+='\n'+(j%2?'':'\\');for(i=n-j/2;i>0;i--)r+='/ '}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    for (j = 0; j < 2 * n - 1; j++) {
        r += '\n' + (j % 2 ? '' : '\\');
        for (i = n - j / 2; i > 0; i--) r += '/ '
    }
    return r
}

alert(c(prompt()));

Pyth, 30 Bytes
*"/\\"QVr*2Q1+*\\!%N2*s.DN2"/

Try it here.

Javascript (ES6), 107 104 100 98 97 91 90 bytes
p=>{s=`/\\`.repeat(p++)+`
`;for(i=p;i>2;s+='\\'+o+o)o=`/ `.repeat(--i)+`
`;return s+'\\/'}

First post here!
Used to use Array(len).join(str) but now uses String.repeat(len), similar to Ruby's operator*(str,len).
Ungolfed:
len => {
    var str = `/\\`.repeat(len++) + '\n';

    for (var i = len, mid; i > 2; str += '\\' + mid + mid) {
        mid = `/ `.repeat(--i) + '\n';
    }

    return str + '\\/';
}

Thanks to:
107 => 104 bytes: @insertusernamehere
97 => 90 bytes: @user81655

You can save 3 bytes: p=>{s=Array(++p).join('/\\')+'\n';for(i=p;i>2;i--,s+='\\'+o+o)o=Array(i).join('/ ')+'\n';return s+'\\/'}.

I deleted my answer since it was so similar but was posted after yours.

@user81655 Ah, sorry about that. Thank you for showing me the repeat method.

Ruby, 50 bytes
->n{s='/\\'*n
n.times{|i|puts s,?\\+s='/ '*(n-i)}}

In test program:
f=->n{s='/\\'*n
n.times{|i|puts s,?\\+s='/ '*(n-i)}}
f[gets.to_i]

The loop prints 2 rows for every iteration from i=0 to i=n-1.
The second row is always '\' followed by n-i incidences of '/ '.
The first row is the same as the second row of the previous iteration, but with the '\' missing (so we store this value in s when we print the second row of the previous iteration.)
The only exception is iteration zero, which is handled by initializing s to '/\'*n.

Python 2, 66 bytes
n=input();b=1
print'/\\'*n
while~-n+b:print'\\'*b+'/ '*n;b^=1;n-=b

Pretty straightforward. The value n is the number of / on the line, and b says whether the line starts with \. The value of b alternates between 0 and 1, and n decreases every second step. The ugly termination condition stops when n=1, b=0. The alternative of an exec loop would have the issue of needing lots of escapes for "'\\\\'".
I was surprised to find this approach shorter than using a single number k=2*n+b. This is 68 bytes:
k=2*input()+1
print k/2*"/\\"
while k>2:print k%2*'\\'+k/2*'/ ';k-=1

An alternative strategy would avoid a separate print for the top line, but I didn't see a concise way.

Batch, 121 bytes
@echo off
set/an=%1-1
if %1==1 (echo /\%2) else call %0 %n% /\%2
set a=/\%2
echo \%a:\= %
if not \%2==\ echo %a:\= %

Or if unary is acceptable, 107 bytes:
@echo off
set a=%1
echo %a:1=/\%
:a
echo \%a:1=/ %
set a=%a:~1%
if not %a%1==1 echo / %a:1=/ %&goto a

Invoke with the appropriate number of 1s.

Minkolang 0.14, 46 bytes
I'm sure this could be golfed, but it's 4 am here and I need to go to bed.
n$z"/\"z$D$OlOz[" /"zi-$Dlr$d"\"zi1+-3&5$X$O].

Try it here.
Explanation
n$z               Take number from input (n) and store it in the register (z)
   "/\"           Push these characters (in reverse)
       z$D        Push register value and duplicate the whole stack that many times
          $O      Output whole stack as characters
            lO    Output newline

z                                   Push n from register
 [                                  Open for loop that repeats n times
  " /"                              Push these characters (in reverse)
      zi-                           n - loop counter
         $D                         Pop k and duplicate whole stack k times
           l                        Push 10 (for newline)
            r                       Reverse stack
             $d                     Duplicate whole stack
               "\"                  Push this character
                  zi1+-             0 if n = loop counter + 1, truthy otherwise
                       3&           Do the next three characters if top of stack is 0
                         5$X        Dump the bottom-most five items of the stack
                            $O      Output whole stack as characters
                              ].    Close for loop and stop

Vyxal, 27 bytes
`/\\`*,ɾṘƛ\/*fṄ;:ƛ\\p;$YṪ⁋,

Try it Online!
`/\\`                       # '/\'
     *,                     # Input times
       ɾṘ                   # n...1
         ƛ     ;            # Map...
          \/*               # That many slashes
             fṄ             # Joined by spaces
                :           # Duplicate
                 ƛ\\p;      # Prepend a backslash to each
                      $Y    # Swap and interleave
                        Ṫ   # Cut off last
                         ⁋, # Joined by newlines

Matlab, 122 bytes
M=2*input('');
z=zeros(M);[y,x]=ndgrid(1:M);
z(~mod(x+y,2)&x+y<M+3)=1;v=2-mod(1:M,2);
z(1,:)=v;z(:,1)=v;disp([15*z.^2+32,''])

Ceylon, 100
String s(Integer n)=>"\n".join{"/\\".repeat(n),for(i in 2*n+1..3)"\\".repeat(i%2)+"/ ".repeat(i/2)};

This features an "named argument list" for join (without any named arguments, but an iterable comprehension instead), and several uses String.repeat (one of which actually means "include only for odd i").
Formatted:
String s(Integer n) =>
        "\n".join{
            "/\\".repeat(n),
            for (i in 2*n + 1 .. 3)
                "\\".repeat(i % 2)
                        + "/ ".repeat(i / 2)
        };

Haskell, 99 bytes
Two solutions of equal length.
Call f.
f n=mapM_ putStrLn$[[x?y|x<-[0..2*n-y-0^y]]|y<-[0..2*n-1]]
x?y|mod(x+y)2==0='/'|x*y==0='\\'|0<1=' '

and
f n=mapM_ putStrLn$[[x?y|x<-[y..2*n-0^y]]|y<-[0..2*n-1]]
x?y|mod x 2==0='/'|mod y x==0='\\'|0<1=' '

Haskell, 96
f=g.(*2)
g m=unlines$t m(c"/\\"):[t n l|(n,l)<-zip[m,m-1..2]$c['\\':p,p]]
p=c"/ "
c=cycle
t=take

This is not actually competitive against the existing Haskell solution because it saves 5 characters by returning instead of printing a string. I am posting it only to show how the infinite pattern approach compares to the coordinate-based approach. Notes:

p can be inlined for no change in length.
[t n l|(n,l)<-...] saves 2 over (map(uncurry t)$...).

PHP, 117 bytes
<?$n=$argv[1];$r=str_repeat;echo$r("/\\",$n);for(;$i++<$n*2-1;)echo"\n".($i%2?"\\":'').$r("/ ",$n-floor(($i-1)/2));?>

Assumes notices are turned off and input is taken from command line.
Ungolfed:
<?php
error_reporting(E_ALL & ~E_NOTICE);

$n = $argv[1];
$r='str_repeat';
echo $r("/\\",$n);
for(;$i++<$n*2-1;){
    echo"\n".(($i%2)?"\\":'') . $r("/ ",$n-floor(($i-1)/2));
}
?>

Comments are welcome :)

Japt -R, 24 bytes
õç'/ú2)cÈ·p'\+XÃÅÔiUç"/\

Try it

all_licenses: 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/


text:
Reverse and square
In this challenge you will compute numbers from a curious sequence.
Your input is a single decimal nonnegative integer. Reverse the bits in this integer and then square the number to get the required output.
When reversing the bits you must not use any leading zeroes in the input. For example:
26 (base 10) = 11010 (base 2) -> 01011 (base 2) = 11 -> 11*11 = 121

The first 25 inputs/outputs of this sequence:
0: 0
1: 1
2: 1
3: 9
4: 1
5: 25
6: 9
7: 49
8: 1
9: 81
10: 25
11: 169
12: 9
13: 121
14: 49
15: 225
16: 1
17: 289
18: 81
19: 625
20: 25
21: 441
22: 169
23: 841
24: 9

Your solution should work for arbitrarily sized integers. If your language does not have a convenient built-in method of using those, implement your answer as if it does. You are then excused if your answer breaks for large numbers. However, do not use tricks/bounds that only work for a limited domain (such as a lookup table).

Your score is the number of bytes of source code.
-50% bonus if you never convert the number to/from binary. This is not limited to builtins, if you loop over the number bit by bit (either by shifting or masking or any other method), it will also count as conversion. I don't know whether this is actually possible, but it gives an incentive to spot a pattern in the sequence.
Smallest score wins.

So close

If the code calls a method that results in a character string that represents the bits, is that eligible for the bonus?

@BradGilbertb2gills No.

I presume that using math to extract the bits also counts as binary conversion?

@ThomasKwa Yes.

If the code converts to a hex string, then uses magic to reverse bits in each nybble, then reverses all nybbles in the hex string, does that qualify for the bonus?

@DigitalTrauma No. Only a radically different approach (such as a closed algebraic form) qualifies for the bonus. As I've said in the question - I'm not certain whether that's possible at all.

Can I use binary conversion if I'm converting a separate result? (For the bonus)

Relevant and relevant

This challenge is conversion-to-bits away from a Dock Length 5 Fishing solution: IrnSP.

I take it partitioning a number into powers of 2 (e.g. using Mathematica's IntegerPartition) also counts as conversion to binary?

@MartinBüttner Yes.

Par, 5 bytes
✶Σ⌐Σ²

That's read-binary-reverse-binary-square.

I count 12

@CᴏɴᴏʀO'Bʀɪᴇɴ That byte counter assumes UTF-8. I believe Mauris is using some encoding that is not UTF-8 to count his bytes, but he did not specify this encoding.

Par uses its own weird encoding. Its canonical representation is a certain subset of <256 Unicode characters. I'm not sure if it has a name; I should wait for @Ypnypn to chime in.

Oh, I see. @orlp

Possibly it has its own SBCS?

Mathematica, 42 21 bytes
Thanks to alephalpha for halving the score.
#~IntegerReverse~2^2&

The actual reason I did this in Mathematica was because I wanted to look at a plot... it sure looks funny:

But I like the score! XD

why does this answer have more votes than the answer with the least bytes? o_O

@Seadrus You know what they say. A picture is worth 7 bytes.

Nice plot. The distribution does not look too surprising to me. You would expect the range of results to quadruple every time the input reaches a new power of 2 (i.e. has an additional bit). Then, within that range, the values are sort of randomly distributed, with a bias to lower values since  the result is the square of a uniformly distributed value.

@RetoKoradi Actually, since trailing zeroes of the input are ignored, it's not quite uniform and even more biased to lower values :P

so your score is 42 + 7 = 49 bytes :P

@Sp3000 I think that's part of the uniformity. For each binary length, we get every odd number up to that length exactly once.

#~IntegerReverse~2^2&

@alephalpha ah nice, I forgot that takes a base.

Sorry, @CᴏɴᴏʀO'Bʀɪᴇɴ.

@MartinBüttner Oh well. 21 is okay in its own right ;)

Good money says it shelves again after 1024. I wonder how the distribution compares to true uniform distribution after culling some of the condensed clusters at the bottom. Does the shelving hold up in base 3? base 10? I'd be interested to see it.

@Seadrus Because it's insightful and interesting!

@corsiKa 12 votes more insightful?

Mathematica is not specifically designed for golfing like the languages that usually win these kinds of competitions, which makes this answer more impressive than those in some ways.

@Seadrus jokes aside, the shortest solution is no more interesting or impressive than any other solution, because they all us the same approach and it's only shortest due to having short built-ins for parts of the solution. In that sense, the plot does give this answer the edge.

right. but in another sense, this is a code-golf question

Japt, 29 28 11 7 bytes
(You can save the program as a 7-byte IEC_8859-1-encoded file, then upload it to the interpreter.)
Japt is shortened JavaScript made by ETHproductions.
¢w n2 ²

Try it online!
Explanation:

¢ is shortcut to Us2, which compiles to U.s(2). U is input (implicit), .s(2) called by a number, invokes .toString(2) (converts to binary, parses as string).

w compiles to .w(), which reverses the string (.split('').reverse().join('')).

n2 works as parseInt(<number>,2), i.e. converts binary to decimal.

² invokes Math.pow(<number>,2), i.e. squares the number.

There's a string function toNumber on n, so you could do Us2 a w a n2 p2. Good job though!

Also, w works the same on strings as it does on arrays, so you don't need the two as :)

One last thing: Us2  = ¢, and p2 = ², bringing it down to 7 bytes: ¢w n2 ²

I get 9 bytes here.  Surely ¢ and ² are 2 bytes each according to this utf8 table.  Or are you using some other weird encoding or codepage?

@Dig it's seven bytes per this encoding  https://en.m.wikipedia.org/wiki/ISO/IEC_8859.  I've linked the interpreter I used - http://bytesizematters.com/.

@nicael I've used that interpreter before and was called out on it.

@Cᴏɴᴏʀ Ok, as it's considered invalid to use anything other than UTF-8, I've stated it's 9 bytes, so as not to be considered a cheater.

@nicael If my understanding of IEC_8859 encoding is correct (I may be wrong), I think your program encoded accordingly is the output of echo -n a277206e3220b2 | xxd -p -r.  If I paste this into the online interpreter I get "SyntaxError: Unexpected token ILLEGAL".  The UTF8 encoding can be generated with echo -n c2a277206e3220c2b20a | xxd -p -r and works fine.  If you have an interpreter that understands the IEC_8859 encoding, then I'm fine with you claiming 7 bytes.

The online interpreter now accepts IEC_8859-1 encoded files. (Although I'm not sure how to do UTF-8 and UTF-16 as well...)

@ETHproductions - now I can +1 this :)

@ETHproductions The online interpreter breaks in IE on tablet.

@CᴏɴᴏʀO'Bʀɪᴇɴ I'd arranged the site so that it looked good on my screen, but maybe not many others. This should be fixed now. Is that what you meant by "breaks"?

@ETHproductions It's beautiful :D

@CᴏɴᴏʀO'Bʀɪᴇɴ Great, glad you like it :) BTW, nicael, I've added a section on Unicode shortcuts.

Minkolang 0.14, 43 bytes
Thanks to Mego for inspiring this.
n1{d1`,2$3*&$z2zd2%-2l$Md1%-;z2%*z2:{+}2;N.

Test the code here and check all test cases here.
Explanation
This uses this recurrence relation:
a(0) = 0
a(1) = 1
a(2n) = a(n)
a(2n+1) = a(n) + 2^(floor(log_2(n))+1)

If n is the input, then a(n) is the resulting number after its binary sequence has been flipped. 0 and 1 are obvious. For a(2n) = a(n), consider that x0 (where x is any sequence of binary digits) flipped is 0x, which is the same as x. For a(2n+1), the reasoning is a bit more complicated. x1 flipped is 1x, which is equal to x + 2^k for some k. This k is one more than the number of digits in x, which is floor(log_2(n))+1. The full formula follows, except that it's modified a bit. This is what I actually code:
a(0) = 0
a(1) = 1
a(n) = a(n//2) + (n%2) * 2^(floor(log_2(n - n%2)))

As Mego and I worked out in chat, floor(n/2) = (n - n%2)/2. Thus, log_2(floor(n/2))+1 = log_2(n - n%2). Furthermore, multiplying by (n%2) collapses both the odd and even parts into one expression.
Finally, without any further ado, here's the code, explained.
n                                              Take number from input
 1{                                            Start recursion that takes only one element
   d1`,                                        1 if top of stack 0 or 1, 0 otherwise
       2$3*                                    26
           &                                   Jump if top of stack is not zero
            $z                                 Store top of stack in register (z)

               zd2%-                           n - n%2
                    2l$M                       log_2(n - n%2)
                        d1%-                   floor(log_2(n - n%2))
              2             ;                  2^floor(log_2(n - n%2))
                             z2%               n%2
                                *              Multiply
                                 z2:           n//2
                                    {          Recurse
                                     +         Add
                                      }        Return
                                       2;N.    Square it, output as number, and stop.

I think the recurrence is just a reformulation of iterating over the individual bits.

I'm afraid this doesn't count. Whenever you see 2n and 2n+1 in a recurrence relation you should immediately think of it as looping over bits.

@orlp: Well, that's a bummer. I'm kinda convinced now that your bonus is impossible.

@El'endiaStarman I've almost got it, I think.

Python, 32 bytes
lambda x:int(bin(x)[:1:-1],2)**2

Try it online.
The code is pretty straightforward: bin(6), for example, gives 0b110, the binary representation of 6. [:1:-1] reverses the string and removes 0b. int converts the string to an integer from binary, and **2 squares it.

Jolf, 7 bytes
Just run it. The input on the page doesn't work.
^C_Bj22

Explanation
^C_Bj22
    j   numeric input
   B    convert to binary (str)
  _     reverse
 C   2  parse as binary integer to base 10
^     2 square
        implicit output

I added the Q command, which makes this 6 bytes: QC_Bj2

Crossed out 7 still looks like a 7.

@quartata Not as bad as a crossed out 4.

TeaScript, 9 bytes 11
TeaScript is Javascript for golfing
®x÷v¤)**2

Will golf more once I get back to my computer
Try it online!
Test all

Does the interpreter understand any encodings other than UTF8?  Using UTF8 encoding, I think your entry is 12 bytes long.

J, 10 9 bytes
2^~|.&.#:

This is a tacit, monadic verb. Try it online!
Thanks to @randomra for golfing off 1 byte!
How it works
2^~|.&.#:  Right argument: y

       #:  Convert y to binary.
   |.      Reverse the digits.
     &.    Dual; apply the inverse of #:, i.e., convert back to integer.
 ^~        Apply power (^) with reversed argument order (~)...
2          to 2 and the previous result.

Link doesn't work, I get a 404 error on a google page that says "The requested URL /host/0B3cbLoy-_9Dbb0NaSk9MRGE5UEU/index.html was not found on this server. That’s all we know."

Seriously, 8 7 bytes
2;,¡R¿ª

Challenges like these are perfect for Seriously :)
Try it online
Explanation:
2;,¡    get a string representing the (decimal) input in binary, with a 2 on the bottom of the stack
R      reverse the string
¿    convert binary string to decimal int (using that extra 2 from earlier)
ª      square it

Nice job matching Jolf!

+1 for having your interpreter accept CP437 encoding (or at least the hex representation of it)

Perl 6, 21 bytes
{:2(.base(2).flip)²}

Example usage:
say {:2(.base(2).flip)²}(26); # 121

say (0..24).map: {:2(.base(2).flip)²};
# (0 1 1 9 1 25 9 49 1 81 25 169 9 121 49 225 1 289 81 625 25 441 169 841 9)

my &code = {:2(.base(2).flip)²};
say code 3; # 9

say chars code 10¹⁰⁰; # 140

JavaScript, 64 63 56 53 bytes
n=>parseInt([...n.toString(2)].reverse().join``,2)**2

I realize I'm extra long, but hey, I can do it :P
Demo

instead of parseInt( you can do +("0b"+

@Downgoat hm, it doesn't appear to give correct results.

[...n.toString(2)] and .join\``

Even shorter w/ ES7 (49 bytes): n=>+("0b"+[...n.toString(2)].reverse().join\`)**2`. Doesn't work in any browsers yet

@CᴏɴᴏʀO'Bʀɪᴇɴ Thanks, this saves some bytes.

This works for me in the latest version of Firefox: n=>(y=+('0b'+[...n.toString(2)].reverse().join``))*y (51 bytes) Or with exponentiation, 49 bytes:n=>+('0b'+[...n.toString(2)].reverse().join``)**2 but this doesn't work yet.

@Eth In Safari it doesn't work, gonna try in Chrome.

@Eth With Chrome, the first example (51 bytes) doesn't work, but the second does. Those don't seem to be universal anyway.

CJam, 10 bytes
ri2bW%2b_*

Try it online

Shell, 25
dc -e2o?p|rev|dc -e2i?d*p

Input/output via STDIN/STDOUT:
$ echo 26|dc -e2o?p|rev|dc -e2i?d*p
121
$

PHP, 45 bytes
echo pow(bindec(strrev(decbin($argv[1]))),2);

Ruby, 35 bytes
->(x){x.to_s(2).reverse.to_i(2)**2}

05AB1E, 4 bytes
bRCn

Try it online!
Explanation
     Implicit input
b    Convert to binary
 R   Reverse
  C  Convert from binary
   n Square
     Implicit output

MathGolf, 4 bytes
àxå²

Try it online.
Explanation:
à     # Convert the (implicit) input-integer to a binary-string
 x    # Reverse this string
  å   # Convert it from a binary-string back to an integer
   ²  # Take the square of this integer
      # (after which the entire stack joined together is output implicitly as result)

Vyxal, 4 bytes
bṘB²

Try it Online!
bṘB²
bṘB  # Convert to binary, reverse, convert back to decimal
   ² # Square

Wolfram Language (Mathematica), 40 bytes
#+##&~Fold~Reverse@IntegerDigits[#,2]^2&

Try it online!

Haskell, 38 bytes
(#0)
0#s=s^2
n#s=div n 2#(2*s+n`mod`2)
Attempt This Online!

Desmos, 124 72 bytes
f(n)=total(mod(floor(n/2^l),2)2^k/2^l)^2
k=floor(log_2(n+0^n))
l=[k...0]

Try it on Desmos!
-52 bytes thanks to Aiden Chow

Pyth - 9 bytes
Straightforward conversions. I actually assigned 2 to a var which is pretty weird.
^i_jQK2KK

Test Suite.

, 12 chars / 21 bytes
⦅`ᶀ`+ᴙ(ïß2)²

Try it here (Firefox only).
Noncompetitive answer, 9 chars / 18 bytes
⦅Յ+ᴙ(ïⓑ)²

Try it here (Firefox only).

Via this byte counter, gives 15 bytes (uses another encoding).

I grade using UTF-8 (until I can get Mines encoding to work).

The... name of the language... is boxes?

It's ESMin in doublestruck. The Unicode chars aren't fully supported.

Pyth, 9 bytes
^i_.BQ2 2

This is a very simple pyth based answer similar to the Python one

TI-Basic (TI-84 Plus CE), 42 bytes
Prompt X
0→S
While X
2S→S
If X/2≠int(X/2
S+1→S
End
S2

C (gcc), 38 bytes
r;f(n){for(r=n%2;n/=2;r+=r+n%2);r*=r;}

Reverse all the bits, square the result. Pretty standard.
-1 byte thanks to ceilingcat!
Try it online!

37 bytes

LOLCODE, 192 bytes
HAI 1.3
I HAS A s ITZ 0
I HAS A x
GIMMEH x
IM IN YR l
s R SUM OF PRODUKT OF s 2 MOD OF x 2
x R QUOSHUNT OF x 2
BOTH SAEM x 0,O RLY?
YA RLY
GTFO
OIC
IM OUTTA YR l
VISIBLE PRODUKT OF s s
KTHXBYE

Try it online!

Splunk (v8.2.6) Search Processing Language, 182 170 bytes:
|inputcsv b|foreach *[eval x=<<FIELD>>]|eval p=mvrange(0,floor(log(x,2)+1))|mvexpand p|eval x=floor(x/pow(2,p))%2|stats list(x) as x|eval x=tonumber(mvjoin(x,""),2),x=x*x

Big data. Smallish code.
Am learning Splunk for work, and decided to try to have a bit of fun with it.
Input is expected in a file at $SPLUNK_HOME/var/run/splunk/csv/b.csv. The file must contain the number in base 10 followed by a newline. The output is the search result, which is analogous to an SQL SELECT. This is as close to our standard I/O rules as I could reasonably do in SPL, but I'm willing to work something out if this is problematic.
With whitespace:
| inputcsv b
| foreach * [eval x=<<FIELD>>]
| eval p=mvrange(0,floor(log(x,2)+1))
| mvexpand p
| eval x=floor(x/pow(2,p))%2
| stats list(x) as x
| eval x=tonumber(mvjoin(x,""),2),x=x*x

Explanation (I plan to flesh this out more later):
| inputcsv b                            ``` Read in b ```
| foreach * [eval x=<<FIELD>>]          ``` Get the value into a field "x" (Splunk reads our "CSV" file in as an event with one field, named the value we want, with a value of the empty string.) ```
| eval p=mvrange(0,floor(log(x,2))+1)   ``` Create a multivalue field "p" which contains the numbers 0 to the number of bits required to represent our number, the order here also means we get the reverse for free ```
| mvexpand p                            ``` Expand our single event with a multivalue field "p" into multiple events, each with a certain value of p ```
| eval x=floor(x/pow(2,p))%2            ``` Calculate (x/(2**p))%2, and set that value back to x```
| stats list(x) as x                    ``` Collect the values of x back into a single multivalue event ```
| eval x=tonumber(mvjoin(x,""),2),x=x*x ``` Combine all the bits back into a string, and convert that string back into a numeric value, then square it```
```result is a single event with field x, containing the square of the bit reversed input.```

Edit: forgot how math works (ceil instead of floor + 1 for the bit length calculation), and managed to only check with inputs that worked with my wrong math. Also sort happened to be a leftover from when I was doing the problem more verbosely, we get the reverse sort for free. Nets to -12.

Perl 5 -p, 38 bytes
$_=(oct"0b".reverse sprintf"%b",$_)**2

Try it online!

cQuents, 10 bytes
K\rJ$)))^2

Try it online!
First time using cQuents.
Explanation
    $      # Take the index.
   J )     # Convert to (default) base 2.
 \r   )    # Reverse it.
K      )   # Convert from (default) base 2 to base 10.
        ^2 # And square it.

Factor, 24 bytes
[ >bin reverse bin> sq ]

Try it online!

Jelly, 4 bytes
BUḄ²
Attempt This Online!

JavaScript, 39 bytes
n=>`0b${(g=n=>n?n%2+g(n>>1):'')(n)}`**2

Try it online!
The function must take input as a decimal string.
This is because the f(0) attempts to coerce '0b' to number, which results in NaN, but f('0') uses '0b0'.
Ungolfed and explained
n => `0b${      // create a string template literal starting for a binary number
  (g = n =>     // define a function g that creates a reversed binary string
    n ?         // if n is not zero
      n % 2 +   // put least sig. bit to the front
      g(n >> 1) // recursively add the rest
    :           // if n is 0
      ''        // return empty string
  )(n)          // call g with n
}` ** 2         // exponent operation implicitly coerces string to number

Thunno 2, 4 bytes
ḃrḂ²

Try it online!
Explanation
ḃrḂ²  # Implicit input
ḃ     # To binary
 r    # Reverse
  Ḃ   # From binary
   ²  # Square
      # Implicit output


text:
golffs - Implement a FUSE filesystem
Implement a FUSE filesystem in minimum bytes.
Your program must do three things:

Mounting the virtual filesystem to a directory
Handling requests to enumerate files in that directory (showing one file)
Handling requests to read the file in that directory

Rules:

ls (a system program, you don't need to implement it) must show hello.txt file (other unrelated files can also be visible, as well as errors may be printed). hello.txt must be exact, 68 65 6c 6c 6f 2e 74 78 74 in hex).
cat (a system program) pointed to the file should output Hello, world. (punctuation, case and end of lines may differ. A bunch of zero bytes can also slip unnoticed). It can also be cat m/hello.txt; echo if there is no trailing newline.
It must be actual FUSE filesystem, not just a regular file created by your program. For example, freezing your program should freeze the hello.txt file (cat and ls would hang). Creating a socket instead of mounting FUSE filesystem isn't an allowed workaround. Your mounted filesystem should be visible in /proc/mounts (or platform analogue).
For 200 bytes penalty, you may depend on libfuse or use it's header files (or depend on the appropriate FUSE binding in some other language)
Detaching is optional
You program may be platform-specific. Somebody else on that platform should check and write a comment that it works (or not)
Your program can't be a kernel module (fuse.ko is the involved kernel module on Linux and is considered a part of environtment, not your program)
Your program can access /dev/fuse (or platform analogue) directly. It may require root access (or changing permissions) for it if needed. It can also rely on fusermount for the mounting step (like the example below). Whether using fusermount for mounting carry penalty or not I have not decided yet (because of I don't know implementation details enough): if the rest feels like talking to kernel directly then it should not be a problem.
Additional compilation and invocation parameters are added to the score. A directory to be mounted may be specified as a free (non-penalty) parameter or may be just hardcoded (like m)

Example (directly based on official hello.c):
#define FUSE_USE_VERSION 26

#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>

static const char *hello_str = "Hello, world\n";
static const char *hello_path = "/hello.txt";

static int hello_getattr(const char *path, struct stat *stbuf)
{
    int res = 0;

    memset(stbuf, 0, sizeof(struct stat));
    if (strcmp(path, "/") == 0) {
        stbuf->st_mode = S_IFDIR | 0755;
        stbuf->st_nlink = 2;
    } else if (strcmp(path, hello_path) == 0) {
        stbuf->st_mode = S_IFREG | 0444;
        stbuf->st_nlink = 1;
        stbuf->st_size = strlen(hello_str);
    }
    return res;
}

static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
             off_t offset, struct fuse_file_info *fi)
{
    filler(buf, hello_path + 1, NULL, 0);
    return 0;
}

static int hello_open(const char *path, struct fuse_file_info *fi)
{
    return 0;
}

static int hello_read(const char *path, char *buf, size_t size, off_t offset,
              struct fuse_file_info *fi)
{
    size_t len;
    (void) fi;
    if(strcmp(path, hello_path) != 0)
        return -ENOENT;

    len = strlen(hello_str);
    if (offset < len) {
        if (offset + size > len)
            size = len - offset;
        memcpy(buf, hello_str + offset, size);
    } else
        size = 0;

    return size;
}

static struct fuse_operations hello_oper = {
    .getattr    = hello_getattr,
    .readdir    = hello_readdir,
    .open        = hello_open,
    .read        = hello_read,
};

int main(int argc, char *argv[])
{
    return fuse_main(argc, argv, &hello_oper, NULL);
}

$ gcc -D_FILE_OFFSET_BITS=64 golffs.c -lfuse -o golffs
$ ./golffs  m     # uses fusermount under the hood
$ ls m
hello.txt
$ cat m/hello.txt
Hello, world
$ fusermount -u m

Score of the example: 1974 + 29 (compilation parameters) + 0 (invocation parameters) + 200 (penalty) = 2203

"hello.txt must be exactly this hex" seems to collide with the next line "cat should output Hello, world. punctuation, EOL and case may differ"

The first is about the virtual file name, the second is about virtual file content. The former is exact, the latter should match /^hello,?\s?world[.!;?]?\r?\n$?/im (for example).

Ohh, okay. I like this challenge because it gives real, non-golfing languages a chance; it will be a while before I have something that works.

Wait, why are cat and ls builtins for the filesystem? shouldn't they be standalone binaries?

cat and ls are assumed to be system binaries. They are used to test the filesystem. They are clarified because of for poorly behaving filesystems, using other programs (like dd and find) can lead to different results (due to different syscalls or reaction to them).

So we get a 200 byte penalty if we use the actual library, which is a kernel module (because in order for a filesystem to show up in /proc/mounts or have udev even sneeze at it, it needs to have some sort of kernel bus, specifically a module) but we also aren't allowed to make a kernel module, so we have to use the existing library ( on *ix, at least ) which means for Mac and GNU/Linux the 200 byte penalty is unavoidable.

The fuse.ko kernel module is considered part of the system (like kernel or C library). The libfuse.so library is considered part of your program. To avoid penalty, you should implement it on low level (on the level the libfuse.so itself is implemented), i.e. open /dev/fuse and use it. fusermount program may be used to get access to /dev/fuse without requiring administrator access (assuming it does not take part in filesystem activity after starting up).

Perl, 1348 998 846 748 714 683 642 575 520 + strlen("perl -mFuse") + 200 penalty for Fuse.pm = 731 bytes
Was interesting diversion from usual golf challenges.  Started life as a version of https://metacpan.org/source/DPATES/Fuse-0.16/examples/example.pl before getting stripped down.
%k=('hello.txt'=>{});sub f{$_=shift;s,^/,,;return$_}Fuse::main(mountpoint=>$ARGV[0],getattr=>sub{$c=f(shift);$c=~s,^/,,;$c=~s/^$/\./;return(exists($k{$c})?0:-2,0,$c eq'.'?16877:33261,1,0,0,0,12,0,0,0,1024,0)},getdir=>sub{return(keys%k),0},open=>sub{return(0,[rand()])},statfs=>sub{return0},read=>sub{$c=f(shift);($x,$z,$h)=@_;return-2 unless exists($k{$c});if(!exists($k{$c})){$u=fuse_get_context();return sprintf("pid=0x%08x uid=0x%08x gid=0x%08x\n",@$u{'pid','uid','gid'})}return$z==12?0:substr("Hello, world",$z,$x)})

Long lines, but if presented via fold, appears as below:
# fold foo.pl
%k=('hello.txt'=>{});sub f{$_=shift;s,^/,,;return$_}Fuse::main(mountpoint=>$ARGV
[0],getattr=>sub{$c=f(shift);$c=~s,^/,,;$c=~s/^$/\./;return(exists($k{$c})?0:-2,
0,$c eq'.'?16877:33261,1,0,0,0,12,0,0,0,1024,0)},getdir=>sub{return(keys%k),0},o
pen=>sub{return(0,[rand()])},statfs=>sub{return0},read=>sub{$c=f(shift);($x,$z,$
h)=@_;return-2 unless exists($k{$c});if(!exists($k{$c})){$u=fuse_get_context();r
eturn sprintf("pid=0x%08x uid=0x%08x gid=0x%08x\n",@$u{'pid','uid','gid'})}retur
n$z==12?0:substr("Hello, world",$z,$x)})
#

Example use:
# perl -mFuse foo.pl m &
[1] 6410
# ls -ld m
drwxr-xr-x 1 root root 0 Jan  1  1970 m
# cd m
# ls -l
total 0
-rwxr-xr-x 1 root root 12 Jan  1  1970 hello.txt
# cat hello.txt
Hello, world#

Works (although there is lot of room for golfing). Shebang (#!/usr/bin/perl) can be moved to invocation perl foo.pl m.

For more interesting diversions, see my other challenges.

Updated source also works, score = 575 + strlen("perl -mFuse") + 200 = 786.

Are you aware that you don't really need to provide . and .. entries?

Good point, shaved a few more bytes


text:
You're a Romanizer, Baby
Romanization of Japanese is converting Japanese text into Latin characters. In this challenge, you will be given a string of Japanese characters as input and expected to convert them to the correct ASCII string.
What You'll Need To Know
The Japanese language has three writing systems: hiragana (the curvy one used for short words), katakana (the angle-y one used for sounds and words borrowed from other langauges), and kanji (the dense characters originally from Chinese). In this challenge we will only worry about hiragana.
There are 46 characters in the hiragana syllabary. Each character represents a syllable. The characters are organized by first sound (consonant) and second sound (vowel). The columns in order are aiueo.
 : あいうえお
k: かきくけこ
s: さしすせそ
t: たちつてと
n: なにぬねの
h: はひふへほ
m: まみむめも
y: や　ゆ　よ
r: らりるれろ
w: わ　　　を
N: ん

(if you copy and paste this table note that I have used ideographic spaces U+3000 to space out y and w)
So, for instance, あとめ should produce an output of atome. The first character is a, the second is to, and the third is me.
Exceptions
Like any good language, Japanese has exceptions to its rules, and the hiragana table has several. These characters are pronounced slightly differently than their location in the table would imply:
し: shi, not si
ち: chi, not ti
つ: tsu, not tu
ふ: fu, not hu
Dakuten ゛
The word 'dakuten' means 'muddy mark': the dakuten turns sounds into their voiced equivalents (usually); for example, か ka turns into か゛ ga. A full list of the changes:
k → g
s → z
t → d
h → b
The exceptions change too:
し゛: ji (or zhi), not zi
ち゛: ji, not di
つ゛: dzu, not du
(ふ゛ acts as you would expect; it is not an exception)
The handakuten is an additional character ゜ that applies to the h row. If placed after a character, it changes the character's sound to p rather than b.
Both the dakuten and handakuten are going to be given as individual characters. You will not need to deal with the precomposed forms or the combining characters.
Small Characters
Finally, there are small versions of some of the characters. They modify characters that come before or after them.
ゃゅょ
These are the small forms of ya, yu, and yo. They are only placed after sounds in the i-column; they remove the i and add their sound. So, きや turns into kiya; きゃ turns into kya.
If placed after chi or shi (or their dakuten-ed forms), the y is removed too.  しゆ is shiyu; しゅ is shu.
The last thing you'll have to deal with is the small tsu. っ doubles the consonant that comes after it, no matter what; it does nothing else. For instance, きた is kita; きった is kitta.
Summary, Input, and Output
Your program must be able to transliterate: the 46 basic hiragana, their dakuten and handakuten forms, and their combinations with small characters.
Undefined behavior includes: small ya, yu, and yo not after a character with i, small tsu at the end of a string, dakuten on an unaffected character, handakuten on a non-p character, and anything else not mentioned in the above spec/introduction.
You may assume all inputs are valid and contain only the Japanese characters mentioned above.
Case does not matter in output; you may also replace r with l or a lone n with m. Output can have either one space between every syllable or no spaces at all.
This is code-golf: shortest code in bytes wins.
Test Cases
Many test cases for each individual part are given in the spec. Some additional cases:
ひらか゛な → hiragana
かたかな → katakana
た゛いき゛ゃくてんさいは゛ん → daigyakutensaiban
ふ゜ろく゛らみんく゛は゜す゛るこうと゛こ゛るふ → puroguramingupazurucoudogorufu
か゛んほ゛って → ganbatte
Notes

I do not know much Japanese besides what I've written here. Please let me know if I've made any mistakes.

I was originally planning to include katakana too (so my English transliteration test case could be slightly more accurate), but that would be too much for a code golf challenge.

The Unicode names include the transliteration of each character individually, but without the exceptions. This may or may not be helpful to you.

Thanks to squeamishossifrage for correcting two typos!

I'm sorry if this is too long; I attempted to fit most of the quirks of hiragana into the challenge but some things (like small vowel-only hiragana, changing n to m in front of some consonants, and the repetition mark) had to be cut to keep the challenge manageable.

I'm not at all sorry for the title. It's a masterpiece.

What should be the output for きっった?

@Thomas: That's an invalid input. Output can be whatever you want.

should っし be sshi or shshi?

@Thomas: It shouls be sshi.

Romanization is converting any non-Latin text into Latin characters.

Should the programs support ーs? For example: こーどごるふ?

@ConfusedMr_C: No need; AFAIK that's only (or at least mostly) used with katakana.

True enough, but you specified that katakana should be written as hiragana, so コードゴルフ should be こーどごるふ, correct?

@Mr_C: Hm? I don't quite understand. I said your program only had to support hiragana; the program does not have to know the rules of Japanese besides the ones mentioned in the spec.

@Desuovi: Oh, okay. Just leaving out support for ー is okay then?

@Mr_C: Yeah, you don't need to support ー at all. In my test case I specifically used こうと゛こ゛るふ rather than こーどごるふ because as far as I know using ー with hiragana is extremely uncommon.

I'm not at all sorry for the title. It's a masterpiece. Downvoted

@Fatalize No need to bring your anti-Britney bias here. Even though I may personally be more of a J-Lo fan, I'm not gonna downvote an excellent puzzle over that.

It's never zhi, while zi is standard for kunrei-shiki.

The last test case is incorrect, it should be ganbOtte vs ganbAtte.

Python 2, 638 bytes
import unicodedata
s=input()
k=[0x309B,0x309C,0x3063]
m=[0x3083,0x3085,0x3087]
e={0x3057:'shi',0x3061:'chi',0x3064:'tsu',0x3075:'fu'}
d={0x3057:'ji',0x3061:'ji',0x3064:'dzu'}
D=dict(zip('ksth','gzdb'))
f=lambda c:unicodedata.name(c).split()[-1].lower()if ord(c)not in e else e[ord(c)]
g=lambda c:d[c]if c in d else D[f(c)[0]]+f(c)[1:]
R=[]
r=[]
t=[]
i=0
while i<len(s):
 c=ord(s[i])
 if c==k[0]:R[-1]=g(s[i-1])
 elif c==k[1]:R[-1]='p'+R[-1][1:]
 elif c in m:R[-1]=R[-1][:-1];n=f(s[i]);R+=[n[1:]]if r[-1]in[0x3057,0x3061]else[n];r+=[c]
 elif c==k[2]:t+=[len(R)]
 else:R+=[f(s[i])];r+=[c]
 i+=1
for i in t:R[i]=R[i][0]+R[i]
print ''.join(R)

Takes input as unicode string.
Test it on Ideone

You can save a measly bye by changing print ''.join(R) to print''.join(R)

Python 2, 447 bytes
import unicodedata as u
r=str.replace
i=''.join('x'*('SM'in u.name(x)or ord(x)==12444)+u.name(x)[-2:].strip()for x in raw_input().decode('utf-8'))
for a,o in zip('KSTH','GZDB'):
    for b in'AEIOU':i=r(r(i,a+b+'xRK','P'+b),a+b+'RK',o+b)
for a,b,c,d in zip('STDZ',('SH','CH','J','J'),'TDHH',('TS','DZ','F','F')):i=r(r(i,a+'I',b+'I'),c+'U',d+'U')
for a in'CH','SH','J':i=r(i,a+'IxY',a)
for a in'BCDFGHJKMNPRSTWYZ':i=r(i,'xTSU'+a,a+a)
print r(i,'Ix','')

This takes Unicode input directly, which made me lose a few bytes because of the decode('utf-8') but I think is more in the spirit of the challenge.
I began by replacing every character by the last two characters of its unicode name, as suggested in the notes of the puzzle. Unfortunately, this doesn't distinguish between alternate versions of the same character, so I had to make an ugly hack to add an 'x' before the small characters and the handakuten.
The rest of the for loops are just fixing exceptions, in order:

the first for loop turns dakutens and handakutens into the correct consonants;
the second for loop deals with the hiragana exceptions of shi, chi, tsu and fu;
third for loop deals with the exceptions before a small y- character (like sha, jo);
fourth for loop deals with doubling consonants after a small tsu.
final line deals with small y-.

I wish I could have combined more steps, but in some cases the steps have to be performed in order to avoid conflicts.
Try it online! (a multi-line version with more examples can be found here).

TIO link

Welcome to PPCG. Very nice first solution :)

Turn your four spaces in front of for b in'AEIOU' into a tab or a single space to save 3 bytes. You may also be able to use from unicodedata import* to save some bytes - not sure.

Swift 3, 67 64 characters

let r={(s:String) in s.applyingTransform(.toLatin, reverse: false)}

let r={(s:String)in s.applyingTransform(.toLatin,reverse:false)}

A builtin, really, Swift has a BUILTIN FOR THIS?

Don't know Swift at all, but can you chop the whitespaces after s:String) and .toLatin,?

@TuukkaX, well spotted!

@Zacharý, well Foundation has.

Python 3, 259 bytes
import re,unicodedata as u
s=re.sub
n=u.normalize
k,*r=r'NFKC DZU DU TSU TU \1\1 SM.{6}(.) \1 (CH|J|SH)Y \1 ISMALL.(Y.) CHI TI JI [ZD]I SHI SI FU HU'.split()
t=''.join(u.name(c)[16:]for c in n(k,s(' ','',n(k,input()))))
while r:t=s(r.pop(),r.pop(),t)
print(t)

Try it online!
Explanation
We’re in luck with this input format! Look what happens if I pass the input through NFKC normalization:
>>> nfkc = lambda x: u.normalize('NFKC', x)
>>> [u.name(c) for c in 'は゛']
['HIRAGANA LETTER HA', 'KATAKANA-HIRAGANA VOICED SOUND MARK']
>>> [u.name(c) for c in nfkc('は゛')]
['HIRAGANA LETTER HA', 'SPACE', 'COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK']

The dakuten gets replaced by a space and a combining dakuten. Now that space is all that’s separating the は from its dakuten. So we get rid of it and normalize again:
>>> [u.name(c) for c in nfkc(nfkc('は゛').replace(' ', ''))]
['HIRAGANA LETTER BA']

Bingo. The fifth line turns the input into something like
KONOSUBARASIISEKAINISISMALL YUKUHUKUWO

Then we apply 9 boring regex substitutions crammed in r, and we’re done:
KONOSUBARASHIISEKAINISHUKUFUKUWO

(Jonathan French saved 4 bytes, writing import re,unicodedata as u instead of import re;from unicodedata import*. Thanks!)

Abusing normalisation for fun and profit. That's beautiful.

import re,unicodedata as u as in Kirill L. answer to a related challenge saves 4 bytes.

Lexurgy, 549 498 bytes
Lexurgy does have a romanizer function that uses the rules as everything else, but it's meant more for debugging/additional output purposes and is not useful for this challenge.
Symbol sh,ch,ts
k:
{あ,い,う,え,お,か,き,く,け,こ,さ,し,す,せ,そ,た,ち,つ,て,と,な,に,ぬ,ね,の,は,ひ,ふ,へ,ほ,ま,み,む,め,も,ら,り,る,れ,ろ,や,ゆ,よ,わ,を,ん,ゃ,ゅ,ょ}=>{a,i,u,e,o,ka,ki,ku,ke,ko,sa,shi,su,se,so,ta,chi,tsu,te,to,na,ni,nu,ne,no,ha,hi,hu,he,ho,ma,mi,mu,me,mo,ra,ri,ru,re,ro,ya,yu,yo,wa,wo,n,Ya,Yu,Yo}
v:
{k,s,t,ch,ts,h,sh} []$1 ゛=>{g,z,d,j,dz,b,j} $1 *
h []$1 ゜=>p $1 *
hu=>fu
s:
iY=>* y
iY=>*/{ch,sh,j} _
っ []$1=>$1 $1

Ungolfed explanation:
Symbol sh, ch, ts # treat these as a single character

# unfortunate kana -> latin mappings
Class kana {あ,い,う,え,お,か,き,く,け,こ,さ,し,す,せ,そ,た,ち,つ,て,と,な,に,ぬ,ね,の,は,ひ,ふ,へ,ほ,ま,み,む,め,も,ら,り,る,れ,ろ,や,ゆ,よ,わ,を,ん,ゃ,ゅ,ょ}
Class latin {a,i,u,e,o,ka,ki,ku,ke,ko,sa,shi,su,se,so,ta,chi,tsu,te,to,na,ni,nu,ne,no,ha,hi,hu,he,ho,ma,mi,mu,me,mo,ra,ri,ru,re,ro,ya,yu,yo,wa,wo,n,Ya,Yu,Yo}
# voicing mappings
Class unvoiced {k,s,t,ch,ts,h,sh}
Class voiced {g,z,d,j,dz,b,j}

kana-to-latin:
@kana => @latin

voicing:
@unvoiced []$1 ゛ => @voiced $1 * # apply dakuden
h []$1 ゜ => p $1 * # apply handakuden

fu: # explicit exception for ふ
hu => fu

small-y: # small やゆよ
i => * / _ Y
Y => y

shyu: # handle ちぢしじ
y => * / {ch,sh,j} _

small-tsu: # gemination (duplication of a character) is the prototypical use-case for capturing
っ []$1 => $1 $1
```

Python3, 607 bytes:
def f(s):
 V='aiueo'
 v,k,d,u,w,t,l,q,g,j=(t:=b.split('\n'))[0][3:],{a:i[0]+V[j]for i in t[1:]for j,a in enumerate(i[3:])},'',0,0,0,{'し':'shi','ち':'chi','つ':'tsu','ふ':'fu'},{'し':'ji','ち':'ji','つ':'dzu'},{'k':'g','s':'z','t':'d','h':'b'},{'ゃ':'ya','ゅ':'yu','ょ':'yo'}
 k['ん']='n'
 for i in s:
  if i in v:d+=(w:=V[v.index(i)])
  if(W:=l.get(i,k.get(i))):d+=(w:=(W[0]*(t+1)+W[1:]));t=0
  if'゛'==i and u!='ふ':d=d[:-1*len(w)]+(w:=q.get(u,g.get(w[0],w[0])+w[1]));I=1
  if'゜'==i:d=d[:-1*len(w)]+(w:='p'*len(w[:-1])+w[-1])
  if i in j:d=d[:-1*len(w)]+(w:=w[:-1]+j[i][i in['し','ち']:])
  if i=='っ':t=1
  u=i
 return d

Try it online!


text:
Count the number of sides on a polygon
Count the number of sides on a polygon
The polygon-side-counting robot has decided to travel the world without telling anyone before, but it is crucial that the process of polygon counting is not stopped for too long. So you have following task: Given a black and white image of a polygon, your program/functoin should return the number of sides.
The program will be fed to an old punch card computer, and as punchcards are very expensive nowadays, you better try to make your program as short as possible.
The edges are at least 10 pixels long, and the angles formed by two adjecent edges is at least 10° but no more than 170° (or again greater than 190°). The polygon is completely contained within the image, and the polygon as well as it's complement is connected (there are no isolated islands) so this input would not be valid:

Scoring
This is codegolf, that means the shortest submission in bytes wins, your submission has to find the correct number of edges for every test case. (And the submission should work for other cases as well, optimization for just those test cases is not allowed.)
If you want to submit a solution that does not find the correct number each time, you can submit that too, but it will be ranked behind all the submissions that perform better.
Please include the total number in your submission title. (The total error the sum of the absolute differences between the real number of sides and the each output).
Test cases
n=10

n=36

n = 7

n=5

This is not a test case, just out of curiosity: How many edges do you get for this input?

I see many angles in your test cases that are greater than 170°. For example, all the "non-point" angles (the ones closer to the center) in your star.

@Doorknob It's the smaller angle that should be less than 170°.

Yes, but they are again greater than 190°. The point of this restriction is to eliminate examples where the two adjecent sides are difficult to tell apart.

Which color is the interior of the polygon?

It does not matter, choose whichever you want. It should be irrelevant to your algorithm anyway. Just note that as I said, the sides are completely within the image. This means that tha boarders of the image do not count as sides.

The program will be fed to an old punch card computer, and as punchcards are very expensive nowadays, you better try to make your program as short as possible :-)

In case you ever find a source for cheap punchcards please let me know!

Python 2 + PIL, no error, 313 307 bytes
from Image import*
I=open(sys.argv[1])
w,h=I.size;D=I.getdata()
B={i%w+i/w*1j for i in range(w*h)if D[i]!=D[0]}
n=d=1;o=v=q=p=max(B,key=abs)
while p-w:
 p+=d*1j;e=2*({p}<B)+({p+d}<B)
 if e!=2:e%=2;d*=1j-e*2j;p-=d/1j**e
 if abs(p-q)>5:
    t=(q-v)*(p-q).conjugate();q=p;w=o
    if.98*abs(t)>t.real:n+=1;v=p
print n

Takes an image file name on the command line, and prints the result to STDOUT.
Gives the correct result for all tests, and n = 28 for the circle.
Explanation
The algorithm works by walking along the perimeter of the polygon, and counting the number of encountered vertices (detected as changes in direction).
We start at the pixel farthest away from the origin, o, which is guaranteed to be a vertex, and therefore, to be adjacent to an edge (i.e., a boundary between a foreground pixel and a background pixel).
We keep track of our position, p, the most recent vertex, v, and the most recent "checkpoint", q, all of which are initially equal to o.
We also keep track of the direction of the edge, d, relative to the current pixel; d initially points east, which is a safe direction, since we know there's an edge to the east of o, or else it wouldn't be farthest from the origin.
We move along the edge, in a direction perpendicular to d, such that d points to our left, i.e., in a clockwise direction.
Whenever we "fall off the edge", i.e., in any situation where p is outside the polygon, or where the pixel to our left (i.e., in the direction of d) is inside the polygon, we adjust p and d accordingly before resuming.
Every time the distance between p and the last checkpoint, q, gets bigger than 5, we try to determine whether we passed over a vertex between q and p:
We compare the angle between vq (i.e., the vector from v to q), which is the general direction of the side of the polygon we were walking along when we reached the last checkpoint, and qp, the displacement between the last checkpoint and the current position.
If the angle is greater than about 10°, we conclude that we're walking along a different side of the polygon, increase the vertex count, and set v, the current vertex, to p.
At each checkpoint, regardless of whether we detected a vertex or not, we update q, the last checkpoint, to p.
We continue in this fashion until we arrive back at o, the starting point, and return the number of vertices found (note that the vertex count is initially 1, since the starting point, o, is itself a vertex.)
The images below show the detected vertices.
Note that taking p, the current position at each checkpoint, as the position of the new vertex is not optimal, since the real vertex is probably somewhere between the last checkpoint, q, and p, along the perimeter.
As you can see, all the vertices other than the first one (generally, the bottom-right vertex) are a little off.
Fixing this would cost more bytes, but this seems to be working well enough as it is.
That being said, it's a little hard not to overfit with only four test cases.

Thank you for this detailed explanation! I love your illustrations!

If there's an edge to the east of o, wouldn't the other end be even farther from the origin?

@aditsu I think the terminology might be a little confusing here. We talk about the sides of the polygon, in the geometric sense, and the edges of the (set of pixels comprising the) polygon, as a raster graphic. o is the farthest foreground pixel from the origin, so the pixel to its east must be a background pixel, hence we say that there's an edge to the east of o.

Wolfram Language (Mathematica), 32 bytes
Length[ImageCorners[#,3,.01,4]]&

Try it online! (Testcases are base64 encoded after running it through optipng)

Does your code give 0 for the circle?

@Simd, yes it is 0