[Question]
  [
As a programmer, you've probably heard of forward slashes and backward slashes. But have you heard of downslashes? That's when you take a bunch of slashes, connect their ends and draw them going down.
For today's challenge, you must write a program or function that takes a string consisting purely of slashes, and outputs all of those slashes drawn downwards in a line connecting them. This will be a lot more clear if you see an example. Given the string `\\\//\/\\`, you should output:
```
\
 \
  \
  /
 /
 \
 /
 \
  \
```
Here are some clarifications:
* There must be one slash per line.
* The first line will have 0 leading spaces.
* For each pair of slashes:
	+ If they are different from each other, they will be drawn in the same column. For example, `\/` will give:
	
	
	
	```
	\
	/
	
	```
	+ If they are the same character, the lower one is in the direction *pointed* to, that is moving to the right for a backslash, and moving to the left for a forward slash. So `\\//` will give
	
	
	
	```
	\
	 \
	 /
	/
	
	```
* Each line may have extra trailing whitespace as long as this doesn't change the visual appearance of the output. Up to one trailing and leading newline is also acceptable. Extra leading spaces *are not permitted*!
In order to keep this simpler, you can assume that the string will never contain too many forward slashes. In other words, no prefix of the input will contain more forward slashes than backslashes, so an input like `\\////` or `//` will never be given. This also means that every input will start with a backslash. 
If your input is taken as a string literal, you may escape the backslashes if this is necessary. You will also never need to handle an input that is empty, or contains characters other than a slash.
You may output by any [reasonable format](https://codegolf.meta.stackexchange.com/q/2447/31716).
As usual, this is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge, so try to make the shortest solution possible, even if you pick a language where this is rather difficult. Bonus points for explaining any interesting techniques you used to take bytes off!
## Examples
```
#Input
\\\\\\\\\\\
#Output
\
 \
  \
   \
    \
     \
      \
       \
        \
         \
          \
#Input
\\\//\\/\//\\///
#Output
\
 \
  \
  /
 /
 \
  \
  /
  \
  /
 /
 \
  \
  /
 /
/
#Input
\/\/\/
#Output
\
/
\
/
\
/
```
  
[Answer]
# GNU Sed, 20
```
s|\\|&^L|g
s|/|^H/^L^H|g
```
Note that `^L` and `^H` are literal formfeed and backspace characters (0x12 and 0x8).
This answer works by moving the cursor around using backspace and formfeed characters. The slashes/backslashes are not left-padded with spaces - Not sure of this disqualifies this answer. This doesn't work in TIO, but it looks fine under common terminals such as `xterm` and `gnome-terminal`.
Recreate this sed script as follows:
```
base64 -d <<< c3xcXHwmDHxnCnN8L3wILwwIfGc= > downslash.sed
```
Run it as follows:
```
$ echo '\\\//\/\\' | sed -f downslash.sed
\ 
 \ 
  \ 
  /
 /
 \ 
 /
 \ 
  \ 
$ 
```
### Explanation:
```
s|\\|&^L|g     # move cursor down after every "\"
s|/|^H/^L^H|g  # move cursor left before every "/", then after, down and left again
```
[Answer]
# [///](https://esolangs.org/wiki////), 119 bytes
/// has no input commands, so input must be embedded in the program. For this one, the input string is simply appended, with no escaping needed.
```
/=/\/\///M/
|%%=N/%|||=C/BA=\/\\/\/C\\=C\\/CbC=B\A\=CfC=AB=/A/%Mxy=B/|z%N|x|y% %N%x|y%%% |fzN%M%b|zN|M|%
=|/AB\\=%/|=AC
```
* [Try it online!](https://tio.run/##HY0xCsQwDAT7vCLN1vsCFbJr@wVuErhwxXVuErN/d@RDSMsyMOq/o38/fU4aWwxZuAmwSkiyzOQWYLHcmsUyn9lS8yhXNk9GJ8r9WKIGqm492FGxEth1jYqCU6OqCJuJnsIEyjx08fNvX5ec8wU "/// ‚Äì Try It Online")
* [With `-d` option](https://tio.run/##HY0xCsMwEAR7v8LNlmFfcIWkWnqBmpjYJBDigFLYZt8e5RyOu2UZmGvPa7vPrXcaqw@ZOQiwQkiyxBjMwclSrebLNCWLNXhZkoVoDETedovUgaJNO0YUnAmMWo6CjElHURYGE0N0EygLrvOff/t5yd6/6/vzWF@tX24/ "/// ‚Äì Try It Online") (program state shown in brackets before each command is run).
# How it works
* In the following, an input of `\\/\//` will be appended to the program for demonstration.
* `‚ê§` is used to represent newlines in inline code.
## Abbreviations
The beginning `/=/\/\///M/‚ê§|%%=N/%|||=C/BA=` of the program contains substitutions for golfing abbreviations.
* `=` expands to `//`, `M` to `‚ê§|%%`, `N` to `%|||` and `C` to `BA`.
* After this the current program becomes
```
/\/\\/\/BA\\//BA\\/BAbBA//B\A\//BAfBA//AB///A/%
|%%xy//B/|z%%||||x|y% %%|||%x|y%%% |fz%|||%
|%%%b|z%||||
|%%|%
//|/AB\\//%/|//ABA\\/\//
```
## Input recoding
The next stage transforms the appended input string into a more usable form. Since it consists entirely of ///'s two command characters, this takes some care to avoid mangling the base program.
* The first substantial substitution, `/\/\\/\/BA\\/`, replaces the string `/\` with `/BA\`.
	+ The base program does not contain `/\` at this time, so this substitution doesn't affect it.
	+ However, this splits up the appended input string into sequences of `\`s followed by sequences of `/`s, which together with the `ABA` at the end of the base program makes it possible to iterate through it with the following substitutions.
	+ Including the `ABA` prefix before it, the example input string now becomes `ABA\\/BA\//`.
* The next substitution, `/BA\\/BAbBA/`, replaces `BA\` by `BAbBA`.
	+ Because /// substitutions are repeated until they no longer match, this iterates through all the `\`s of the input string, which with prefix now becomes `ABAbBAbBA/BAbBA//`
* Similarly, `/B\A\//BAfBA/` changes `BA/` to `BAfBA`, iterating through the `/`s.
	+ The escaping `\` in this substitution is needed since otherwise it would be mangled by the previous one.
	+ The input has now turned into `ABAbBAbBAfBABAbBAfBAfBA`.
* Next `/AB//` removes some superfluous parts of the encoding, turning it into `AbBAbBAfBAbBAfBAfBA`.
	+ This also removes an `AB` from the `/|/AB\\/` substitution later in the program, which was needed to protect it from the above `/\` manipulation.
	+ At this point every `\` in the original input string has become `AbB`, and every `/` has become `AfB`. (`b` and `f` stand for backward and forward.) There's a stray `A` at the end.
* The next two substitutions replace all the `A`s and `B`s with program fragments to run in the final stage. In the replacement strings, `%`s and `|`s encode what will become `/`s and `\`s respectively. This has two benefits:
	+ Unlike `/` and `\`, the `%`s and `|`s don't need escaping to be copied.
	+ The replacement strings avoid containing the substring `/\`, which would otherwise have been mangled by the previous manipulations.
* After this, the substitution `/|/\\/` (formerly `/|/AB\\/`) now decodes the `|`s, after which the following `/%/|//` has become `/%/\//` and decodes the `%`s.
## Program structure at final stage
At this point, the base program has run all its substitutions, and all that remains is the program-encoding of the input string.
* Each input character has become a subprogram
```
/
\//xy*\z//\\\\x\y/ //\\\/x\y/// \fz/\\\/
\///b\z/\\\\
\//\/
```
(trailing newline), where `*` represents either `f` for an original `/`, or `b` for an original `\`.
* There is also an incomplete substitution command `/‚ê§\//xy` at the end of the program, which will have no effect except to provide a necessary `/` for the substitutions of the previous subprogram.
## Shared substring
Before the final iteration through the subprograms starts, there is a substring crossing the boundary after each character's subprogram of the form `\/‚ê§/`.
* These substrings are used as a shared global state. All the remaining substitutions in the program will manipulate them identically and in parallel, such that at the end of each input character's subprogram its copy of this shared substring (except the final `/`, which anchors the substitutions) will be run to print the line for that character.
* The initial version of the substring represents printing a line containing just `/`, which is the right imaginary "previous line" to cause the first input character to be printed at the beginning of its line.
* In general, during the printing steps, the shared substring consists of a number of spaces, `\\` or `\/`, a newline, and a following `/`.
## Running a character subprogram
Several of the following substitutions contain extra `\`s inside to prevent them from being matched and mangled by each other (including other copies in other subprograms). Achieving this is also the reason why both of `x` and `y` are needed.
* The first substitution in a character subprogram, `/‚ê§\//xyf\z/` or `/‚ê§\//xyb\z/`, causes the `‚ê§/` at the end of the shared substring to become `xyfz` or `xybz`, immediately following the `\/` or `\\`.
* The substitution `/\\\\x\y/ /` replaces `\\xy` by a space, and the substitution `/\\\/x\y//` replaces `\/xy` by nothing.
	+ They apply when the previous input character printed was a `\` or `/`, respectively.
	+ The shared substring now contains the appropriate number of spaces for printing a `\` next, followed by `fz` or `bz`.
* The substitution `/ \fz/\\\/‚ê§\//` replaces `‚Äã fz` by `\/‚ê§/`, and `/b\z/\\\\‚ê§\//` replaces `bz` by `\\‚ê§/`.
	+ They apply when the current input character is `/` or `\`, respectively.
	+ The first one eats an extra space to place `/` correctly.
		- If this space is missing (i.e. input violating the prefix condition), the following substitutions get misinterpreted, printing a lot of junk and usually hitting a `///`, which is an infinite loop.
	+ Each adds the correct command to print its own character, and reinstates the original `‚ê§/` at the end of the shared substring.
* The character subprogram has now reached its copy of the shared substring, which is ready to print its line.
After the last character subprogram has run, what remains of the program is `/‚ê§\//xy`. Since this is an incomplete substitution with missing final `/`, the program skips it and halts normally.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~13~~ ~~12~~ 11 bytes
```
Ôº¶Ôº≥¬ø‚ÅºŒπ/‚Üì¬∂/‚ÜòŒπ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z8tv0hBwzOvoLQkuKQoMy9dQ1NTITNNQcO1sDQxp1gjU0dBSV8JKBYAlCzRsHLJL88DCsXkAQUVUnOKU5ElgjLTM0p0FDI1rf//j4mJ0dcHYgipr/9ft@y/bnEOAA "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Supports extra `//`s. Explanation:
```
 Ôº≥              Input string
Ôº¶               Loop over each character
  ¬ø             If
    Œπ           Current character
   ‚Åº            Equals
     /          Literal /
      ‚Üì¬∂        Move left
      ‚Üì /       Print a / downwards
         ‚ÜòŒπ     Else it's a \ so print that down and right
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~55~~ ~~54~~ ~~51~~ ~~57~~ 53 bytes
-3 bytes (and a bug fix) thanks to Felipe Nardi Batista
```
i=0
for c in input():i-=c<'<'*i;print' '*i+c;i+=c>'<'
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9PWgCstv0ghWSEzD4gKSks0NK0ydW2TbdRt1LUyrQuKMvNK1BWATO1k60xt22Q7oPj//@r6MUAAIdT/AwA "Python 2 ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~¬†14 13¬†~~ 12 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-1 thanks to [caird coinheringaahing](https://codegolf.stackexchange.com/users/66833/caird-coinheringaahing) (Use of `;"` in place of `≈º` to allow yielding a list of lines and so use of `∆≤`.)
```
=‚Äù\·∏§‚Äô√Ñ_∆≤‚Å∂·∫ã;"
```
A monadic Link that yields a list of lines.
**[Try it online!](https://tio.run/##y0rNyan8/9/2UcPcmIc7ljxqmHm4Jf7YpkeN2x7u6rZW@n@4PfL//5iYGH19IIaQ@voA "Jelly ‚Äì Try It Online")**
### How?
```
=‚Äù\·∏§‚Äô√Ñ_∆≤‚Å∂·∫ã;" - Link: list of characters, s    e.g. "\\\//\\/"
 ‚Äù\          - literal '\'                         '\'
=            - equal? (call this e)                [1, 1, 1, 0, 0, 1, 1, 0]
       ∆≤     - last four links as a monad - f(e)
   ·∏§         -   double (e)                        [2, 2, 2, 0, 0, 2, 2, 0]
    ‚Äô        -   decrement                         [1, 1, 1,-1,-1, 1, 1,-1]
     √Ñ       -   cumulative sums                   [1, 2, 3, 2, 1, 2, 3, 2]
      _      -   subtract (e)                      [0, 1, 2, 2, 1, 1, 2, 2]
        ‚Å∂    - literal ' '                         ' '
         ·∫ã   - repeat                              ["", " ", "  ", "  ", " ", " ", "  ", "  "]
           " - zip with:
          ;  -   concatenate (c from s)            ["\", " \", "  \", "  /", " /", " \", "  \", "  /"]
```
[Answer]
# [Haskell](https://www.haskell.org/), 49 bytes
```
scanl(\x c->drop(sum[1|'/'<-c:x])(' '<$x)++[c])[]
```
[Try it online!](https://tio.run/##y0gszk7Nyflfraus4OPo5x7q6O6q4BwQoKCsW8uVZhvzvzg5MS9HI6ZCIVnXLqUov0CjuDQ32rBGXV/dRjfZqiJWU0NdQd1GpUJTWzs6OVYzOvZ/bmJmnoKtQnpqiU9mXqqCnZ2tQkFpSXBJkYKeQmleDlCsGMhK@x8TE6OvD8QQUl8fAA "Haskell ‚Äì Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~23~~ ~~19~~ 18 bytes
*1 byte off thanks to [@Sanchises](https://codegolf.stackexchange.com/users/32352/sanchises)*
```
fGqoEq1yd~h*YsGZ?c
```
Input is a string enclosed in single quotes.
[**Try it online!**](https://tio.run/##y00syfn/P829MN@10LAypS5DK7LYPco@@f9/9ZiYGH39GP2YGHUA) Or verify test cases: [**1**](https://tio.run/##y00syfn/P829MN@10LAypS5DK7LYPco@@f9/9RgEUAcA), [**2**](https://tio.run/##y00syfn/P829MN@10LAypS5DK7LYPco@@f9/9ZiYGH19IIaQ@vrqAA), [**3**](https://tio.run/##y00syfn/P829MN@10LAypS5DK7LYPco@@f9/9Rh9EFQHAA).
### Explanation
Consider input `'\\\//\/\\'` as an example.
```
f      % Implicit input. Array of indices of nonzeros. Since all chars in the input
       % have nonzero code point, this gives [1 2 ... n] where n is input length
       % STACK: [1 2 3 4 5 6 7 8 9]
G      % Push input again
       % STACK: [1 2 3 4 5 6 7 8 9], '\\\//\/\\'
qo     % Subtract 1 from (the code-point) of each char and then compute modulo 2.
       % This transforms '\' into 1 and '/' into 0
       % STACK: [1 2 3 4 5 6 7 8 9], [1 1 1 0 0 1 0 1 1]
Eq     % Double, subtract 1. This transforms 0 into -1
       % STACK: [1 2 3 4 5 6 7 8 9], [1 1 1 -1 -1 1 -1 1 1]
1y     % Push 1 and duplicate from below
       % STACK: [1 2 3 4 5 6 7 8 9], [1 1 1 -1 -1 1 -1 1 1], 1, [1 1 1 -1 -1 1 -1 1 1]
d~     % Consecutive differences, logical negation: gives 1 if consecutive entries
       % are equal, 0 otherwise
       % STACK: [1 2 3 4 5 6 7 8 9], [1 1 1 -1 -1 1 -1 1 1], 1, [1 1 0 1 0 0 0 1]
h      % Horizontally concatenate
       % STACK: [1 2 3 4 5 6 7 8 9], [1 1 1 -1 -1 1 -1 1 1], [1 1 1 0 1 0 0 0 1]
*      % Element-wise multiplication
       % STACK: [1 2 3 4 5 6 7 8 9], [1 1 1 0 -1 0 0 0 1]
Ys     % Cumulative sum
       % STACK: [1 2 3 4 5 6 7 8 9], [1 2 3 3 2 2 2 2 3]
G      % Push input again
       % STACK: [1 2 3 4 5 6 7 8 9], [1 2 3 3 2 2 2 2 3], '\\\//\/\\'
Z?     % Build sparse matrix with those row indices, column indices, and values
       % STACK: [92  0  0;
                  0 92  0;
                  0  0 92;
                  0  0 47;
                  0 47  0;
                  0 92  0;
                  0 47  0;
                  0 92  0;
                  0  0 92]
c      % Convert to char. Char 0 is shown as space. Implicitly display
       % STACK: ['\  ';
                 ' \ ';
                 '  \';
                 '  /';
                 ' / ';
                 ' \ ';
                 ' / ';
                 ' \ ';
                 '  \']
```
[Answer]
# [Perl 5](https://www.perl.org/), 44 bytes
42 bytes of code + 2 for `-F` flag
```
say$"x($s+=$\eq$_&&$#i**m|/|).($\=$_)for@F
```
[Try it online!](https://tio.run/##K0gtyjH9/784sVJFqUJDpVjbViUmtVAlXk1NRTlTSyu3Rr9GU09DJcZWJV4zLb/Iwe3//5iYGH39mBgIBYT/8gtKMvPziv/r@prqGRga/Nd1AwA "Perl 5 ‚Äì Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 14 bytes
```
√á√àx<Œ∑Os-W-IS√∫¬ª
```
[Try it online!](https://tio.run/##MzBNTDJM/f//cPvhjgqbc9v9i3XDdT2DD@86tPv/f/2YGBACAA "05AB1E ‚Äì Try It Online")
**Explanation**
```
√á                # convert input string to a list of ascii codes
 √à               # check each for evenness
  x              # push a doubled copy
   <             # decrement
    Œ∑            # compute prefixes
     O           # sum each prefix
      s          # swap the unaltered copy of evenness to the top
       -         # subtract from the prefix-sum list
        W-       # subtract the minimum value
          IS     # push input split to a list of chars
            √∫    # pad each with the number of spaces computed
             ¬ª   # join on newline
```
[Answer]
# JavaScript (ES8), ~~66~~ ~~59~~ 63 bytes
*7 bytes saved thanks to [Justin Mariner](https://codegolf.stackexchange.com/users/69583/justin-mariner)  
+4 bytes to fix `/\\/\\/` (noticed by [Neil](https://codegolf.stackexchange.com/users/17602/neil))*
```
f=([a,...z],b=a<'0')=>a?a.padStart(b+=k=a>'/')+`
`+f(z,b-!k):''
```
[Try it online!](https://tio.run/##NYxLDsIwDET3uQUSUhLa2qwRKYdgSYri/qBF/SgNIIE4e0kq8MJjvZlxSw@aCtuMLumHsprnWokTxQDwyuJc0Z5vuVQpHQhGKo@OrBN5pG6KUo5cRoaZqBavOE9WN7njfB7tUFTTBJMrh7uDp21cJQSp1Kzf9DHQkSuuAs8njVpn0RovnfRwDJFakJTQDk1vdG/A2aYzRgYHN4xprRFDK1z/@VGPl43IQgQ9X5Qtlle2Qf97/gI)
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), ~~74~~ ~~88~~ ~~82~~ ~~78~~ ~~77~~ 76 + 18 bytes
*-1 byte thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)*
```
s=>s.Select((x,i)=>$"{x}".PadLeft((x-s[0])/45-~s.Take(i).Sum(y=>y<92?-1:1)))
```
Outputs a collection of strings, one for each line. Byte count also includes:
```
using System.Linq;
```
[Try it online!](https://tio.run/##ZU9RT8IwEH7vrziJD22ATow@KGzGEDAmmBgh8UF8qOWQxq7DtdMRwm@f3aaQyZdce/m@u/vupO3KJMUis8q8w3RjHcZ8osxnnxAjYrRrIfGPHyZao3QqMZbfocFUSbIl4CG1sBZuq7xmSlgnnJLwlagFPAhlKNtLh6IS48zIgXWp36ED9yOTxZiKN42/XBTBEsLChpHlUyxXoDTvKBZGp61tvmvxR7GY4NJRy2fiA6lifJrFdBNGm8HV@U23d91jbZp37cvZKwsuLts9xop@Y4PaCJRZZ66pfK@URqC0kiCEob8@0cif0Jsqg5QxOAnBZFqzRmPzxBLLegifpSr2bXyWTJR1lPFxko6EXNEcwmhv8Jwqh5VDzlj/aNhx2b@iHWlmO7Ir5gcQH0Hgo36DgARl7vnqJ5U0D34A "C# (.NET Core) ‚Äì Try It Online")
Explanation for 77 byte answer:
```
s =>                              // Take input, a string
    s.Select((x, i) =>            // Replace every character with:
        $"{x}"                    //     The character as string
        .PadLeft(                 //     Pad with this many spaces:
            s.Take(i)             //         Take characters, in the input string, preceding current one
            .Sum(y =>             //         Sum them by:
                y < 92 ? -1 : 1   //             If it's a \ add 1, if / subtract 1
            )
            + (x - s[0]) / 45 + 1 //         If first slash is a / add one more space, if current slash is a \ add one more space (I got this through power of MATHS!)
                                  //         How I arrived at this function:
                                  //         + x / 48        If current slash is a \ add one more space
                                  //         - s[0] / 48 + 1 If the first slash is a / add one more space
        )
    )
```
[Answer]
# [Lua](https://www.lua.org), 96 bytes
```
c=0 for s in(...):gmatch(".")do c=c+(p==s and(s=="/"and-1or 1)or 0)p=s print((" "):rep(c)..s)end
```
[Try it online!](https://tio.run/##DYtBCsMwDAS/InSSKJWTa0A/8cXIaRtoHWOn71e0h2Fg2O@/uJsu8DoHTDgaiQhv71@57EMoyPUEU3tQV51QWqWpignDnmt8Vg4s3CP2cbSLCAF5G3snY5HJe6vunmMppZxv "Lua ‚Äì Try It Online")
Shortest one I could come up with in Lua. Input is taken from the command line.
This does use a few tricks:
1. `(...):gmatch(`  
This should be the shortest form of getting a single string into a Lua program from the command line. The `...` expression in Lua captures any excess parameters to a function that aren't specified in the function declaration and is used for varargs. Since the main body of a Lua program gets called as a function with the command line arguments as its parameters, the command line arguments will end up in `...`.  
The parentheses around it turn the potentially multi-valued `...` expression into a single-valued expression. Consider this (somewhat surprising) example:
```
function multipleReturnValues()
    return "abc", "def"
end
print(  multipleReturnValues()  ) --This prints: abc    def
print( (multipleReturnValues()) ) --This prints: abc
```
2. The Lua parser does not need any line terminators, or even whitespace between statements, as long as the two statements' tokens can be clearly separated and there's only one interpretation of the text that's valid Lua code.
3. Abusing `and`/`or` for "if x then value1 else value2" logic.  
Lua's `and` operator returns its first argument if it is falsy; otherwise, it returns its second argument. The `or` operator returns its first argument if it is truthy; otherwise, the second argument.
4. `p`doesn't need any initialization.  
`p==s` always has to be false in the first run of the loop, regardless of the input. Not setting `p` to any value before entering the loop (leaving it `nil`) will make that happen and save bytes, too.
Can anyone golf this (in Lua)?
[Answer]
# [R](https://www.r-project.org/), ~~122~~ 121 bytes
-1 byte thanks to Giuseppe
```
x=el(strsplit(scan(,""),""));n=seq(x);y=x>"/";for(i in n)cat(rep(" ",diffinv(y[n[-1]-1]+y[n[-1]]-1)[i]),x[i],"\n",sep="")
```
[Try it online!](https://tio.run/##LYxBCsMgEEX3PUWY1Qy1hK7FXiRmYRNDB@zEqhRzemug8N7nrX5qgZ/JpQPfvrz2NVOrxgfMJeUYuGBenKACoFPSYrL/YCV9mPqAEfS2J@SBZRBaXMHkI8IAauVtY/niMcl0u8@d6z9708QzqdpXgRVQ2UfT3xuM1p7Apf0A "R ‚Äì Try It Online")
With extra whitespace:
```
x = el(strsplit(scan(,""),""))
n = seq(x)
y = x>"/"
for(i in n) {
  cat(rep(" ", diffinv(y[n[-1]-1]+y[n[-1]]-1)[i]), x[i], "\n", sep="")
}
```
Explanation: This answer is based on the observation that the number of leading spaces changes each line by -1, plus the number of `/` in the previous and current lines. 
If we have N slashes, the variable `y` is a vector of length N, with 1 for each position with `\`, 0 otherwise. Therefore, to get the change in number of leading spaces per line, we calculate `y[1:(N-1)] + y[2:N] - 1`. The function `diffinv` converts these differences into a sequence, starting with 0. The rest is just a matter of assembling each line as the required number of trailing spaces, followed by the relevant slash and a newline.
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 175 bytes (174 chars + 1 flag)
Run with `-c` flag.
```
{(({})<(())>){({}[()]<([{}])>)}{}(({}<>{}<><({}<>)((()()()()()){})>)<{({}[()]<((((()()()()){}){}){})>)}>{})<>}<>{}{({}<>)(({})(())){({}[()]<([{}]())>)}{}{<>{}<>(<{}>)}{}<>}<>
```
[Try it online!](https://tio.run/##XU5BCsNACPzOeAj7AfEjMYckUCgtPfQqvt2qaUgpu7Kj48zs9l7vr@n2XB8RBpgTA0RClngGLYzZfMmBmxfPUsWNCLl7HkqtEF86XGxxx00fqRBpIzttclSxf6n9kcy1IxRs3n2rI1R1DB36@35RTPsH "Brain-Flak ‚Äì Try It Online")
## Explanation
```
{ for each char in the input...
  (({})<(())>){({}[()]<([{}])>)}{} push 1/-1 for backslash/slash
  ((
   {}<>{}<> add the 1/-1 to a running total
   <
    ({}<>) move slash/backslash to other stack
    ((()()()()()){}) newline
   >
  )<{({}[()]<((((()()()()){}){}){})>)}>{}) spaces
  <>
}<>{} end for
reverse data order, removing one space before backslash
{({}<>)(({})(())){({}[()]<([{}]())>)}{}{<>{}<>(<{}>)}{}<>}<>
```
[Answer]
# [Ruby](https://www.ruby-lang.org/en/), 80 76 bytes
-4 bytes thanks to manatwork
```
puts"\\";$*[i=0].chars.each_cons 2{|b,c|puts" "*(b==c ?b==?/?i-=1:i+=1:i)+c}
```
[Try it online!](https://tio.run/##KypNqvz/v6C0pFgpJkbJWkUrOtPWIFYvOSOxqFgvNTE5Iz45P69Ywai6JkknuQasTkFJSyPJ1jZZwR5I2uvbZ@raGlplaoMITe3k2v///8fExOjrx@jHxAAA "Ruby ‚Äì Try It Online")
Explanation:
```
puts "\\"           # Output the first backslash
$*[i=0].            # Get the first argument and set i to 0
chars.              # Go through every individual character,
each_cons 2 { |b,c| # In pairs to compare easily
                    #
    puts " " *      # Decide how many padding spaces to use based on the value
                    # of i. The expression inside the parenthesis will return
                    # i but before that, it will increment/decrement i based
                    # on what the previous character was.
                        #
    ( b==c ?            # if b == c
        b==?/ ?         #   if b == "/" (Going to the left)
            i-=1        #       return decremented i
            :           #   else        (Going to the right)
            i+=1        #       return incremented i
        :               # else
        i) +            #   return i
                    #
                c   # Finally, write the second of the characters that we're
}                   # iterating through.
```
[Answer]
# Java 8, ~~121~~ ~~118~~ ~~110~~ ~~109~~ 102 bytes
```
a->{String r="";int s=0,p=0,i;for(char c:a){for(i=s+=p+(p=c-63)>>5;i-->0;r+=" ");r+=c+"\n";}return r;}
```
-7 bytes thanks to *@Nevay*'s bit-wise magic. :)
**Explanation:**
[Try it here.](https://tio.run/##lY9NT8MwDIbv@xUmp1ajX0capRPizC4cGQfjdZDRpZGTTpqq/vaSdoXTJEQUW3Ycv3reI54xaW1tjvuvkRp0Dp5Rm34FoI2v@YBUw3ZqAV48a/MBFNEn8usbYCzD@xAiXOfRa4ItGFAwYlL1y3dWQsigBU7l9zaEloeWZw2gEuN@6rRya0V3ym7ykqqHYlOUSSF1klS55LUSIGJpFU01rcXOCDlw7Ts2wHIY5RXBdu9NQFhIzq3ewyl4ia4gM/Bi5OJ8fUrbzqc2jHxjIpNSJHY3j0h9@xRoH5nxEsXx7PovkSyb82@RZf@U@dkP6ebmsBrGbw)
```
a->{                    // Method with char-array parameter and String return-type
  String r="";          //  Return-String
  int s=0,              //  Amount of spaces
      p=0,              //  Previous characters (starting at 0)
      i;                //  Index-integer
  for(char c:a){        //  Loop over the input
    for(i=s+=p+(p=c-63)>>5;
                        //   If the current does not equals the previous character
                        //    Leave `s` the same
                        //   Else-if it's a '\':
                        //    Increase `s` by 1
                        //   Else (it's a '/'):
                        //    Decrease `s` by 1
                        //   And set the previous character to the current in the process
        i-->0;r+=" ");  //   Append `r` with `s` amount of spaces               
    r+=c+"\n";          //   Append the character + a new-line to the result
  }                     //  End of loop
  return r;             //  Return result-String
}                       // End of method
```
[Answer]
# C (GCC), 137 134 97 bytes
[Try it online!](https://tio.run/##JU3RCsMgDHzfV0ihYKrSDQaDivRD2j6UuHY@zA11eyn9dhe7g@OSXJJDtSLm7KTVC8fHHJoIW1GGJg5ukp5ECDdpRz5s7@B8WnhVN1jj6CtpxUUiaI7KQ287jsZcb9ArZTshytMIet8zXbHn7DwvxRxWlAxfPiZ2ZDVl9B0mYNuJEZw5a0s8GkobD7QtsRQV/J1wT5/gGe3t@Qc)
‚Ä¢¬†3 bytes thanks ATaco
‚Ä¢ 37 bytes thanks to Digital Trauma & ThePirateBay
```
i,d;f(char*s){char c=s[i],n=s[++i];if(c){printf("%*c%c\n",d+1,c);(c-n)?d:(c==47)?--d:++d;f(s);}}
```
Nothing too fancy just a simple recursive function that takes a string and prints out the slashes, note that the input needs to escape the backslashes first.
## Usage
```
f("\\\\\\//\\/\\\\",0,0);
```
## Ungolfed
This is for the old answer, view the try it online link for updated one!
```
f(char *s, i, d) {
    char c=s[i], n=s[++i];
    if(!c) return;
    for(int j=0; j<d; j++) printf(" ");
    printf("%c\n",c);
    f(s, i, (c!=n)?d:(c=='/')?d-1:d+1);
}
```
## Output
[![enter image description here](https://i.stack.imgur.com/65WBW.png)](https://i.stack.imgur.com/65WBW.png)
[Answer]
# C, 60 bytes
```
i;f(char*s){for(i=1;*s;s++)printf("%*c\n",*s%2?--i:i++,*s);}
```
[Try it online!](https://tio.run/##RYzNCsMgDMdfZRQKahTbHZuVPci6Qwm4Kawr2nkZe3an9tBA8v@A/Eg9iFKyaBg9Zy8C/5q3Z3bsUQQMAHz1dtkMa1pB09JIEdrzVSk7WIAcOP6Sw9dsF0Yy8soQESvEjR0CuAvhAQlDgZzizd25NGzX9bOVR9Z3BZemY4rXOu9@tU66@NxX/QM)
[Answer]
# [Retina](https://github.com/m-ender/retina), 47 bytes
```
^|\\
 $&
+m`^( *)( /|\\)(/| \\)
$1$2¬∂$1$3
m`^ 
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wP64mJoZLQUWNSzs3IU5DQUtTQ0EfKKSpoV@jAKS4VAxVjA5tA5LGXEAFClz//8fExOjrx@gDtcUgABdEFCgMJvX1uUBK9IHiYBoA "Retina ‚Äì Try It Online") Link includes test cases. Explanation:
```
^|\\
 $&
```
Add a space at the beginning of each line and before each `\`.
```
+m`^( *)( /|\\)(/| \\)
$1$2¬∂$1$3
```
Consider the first two characters of the string. If the first is a `/` then the indent needs to be decremented; this is achieved by including the preceding space in the capture (which always exists because the first stage added it); if the second is a `\\` then it needs to be incremented; this is achieved by including the space that the first stage added in the capture. Having given the second character the correct indent, the stage is repeated for the second and third character etc.
```
m`^ 
```
Remove the extra indent.
I've written a 94-byte version which (like my Charcoal answer) allows any combination of slashes: [Try it online!](https://tio.run/##RYs7DsJADER7n8KRDPJuJI/4lEgpcwhMtBQUFFAAZc6VA@Rii0kKphjpPc28bp/781o32pdqQvMkViSzbAnEoLYMajkpY3RP86T8A/cRiWQX64Pslz5S@3jHuDs1w9kdl3ixdo3lFRNRX6xWAIEOEP6h1YZe2v0L "Retina ‚Äì Try It Online") Explanation:
```
.$
¬∂$.`$* $&
```
Get the ball rolling by taking the last slash and indenting it to the same position on its own line.
```
/
 /
```
Prefix spaces to all forward slashes so that they can be captured.
```
+`^(.*)( /|\\)¬∂( *)( \\|/)
$1¬∂$3$2¬∂$3$4
```
Repeatedly take the last slash of the input and align it on its own line with the slash on the line below.
```
+ms`^(?<!^[\\/].*) (?!.*^[\\/])
```
Delete any left-over indentation.
```
G`.
```
Delete the now empty input.
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 98 bytes
```
++++++++[->++++<]<<<,[[->+++++++++++<<+>]>-----[>+>+<<[-]]>-[->>.<+<]>[-<+>]<<<<.[-]>++++++++++.,]
```
[Try it online!](https://tio.run/##TYtRCoAwDEMPtHW9QOhFun6oIIjgh@D5a4b78EEb0ibrvRzX/mxnZpm42BAEgOrTTYBiYTJwK0bvEjwwZQ3smMuIsIrG16/bamT23lU531Z9AQ "brainfuck ‚Äì Try It Online")
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 16 bytes
```
∆õ\/=&-√∞¬•*n+,C‚ÇÇ&+
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C6%9B%5C%2F%3D%26-%C3%B0%C2%A5*n%2B%2CC%E2%82%82%26%2B&inputs=%5C%5C%5C%2F%2F%2F%5C%2F%5C%2F%5C%2F%5C%5C%2F%5C%2F%5C%5C%5C%5C%5C%5C%2F%5C%5C%5C%5C%5C%2F%5C%5C%5C%5C%5C%2F%2F%5C%5C%5C%5C%5C%5C%2F%5C%5C%2F%2F%2F%2F%2F%5C%2F%2F%2F%2F%2F%5C%2F%5C%5C%5C%5C%5C%2F%2F%2F%5C%5C%5C%5C%5C%5C%5C%5C%2F%5C%5C%5C%5C%5C%5C&header=&footer=)
```
∆õ                # Map by...
    &-           # Decrement register by 
 \/=             # (is a forward-slash)
      √∞¬•*        # (register) spaces
         n+,     # prepended to n and outputted
              &+ # Increment register by
            C‚ÇÇ   # (is a backslash)
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 28 bytes
```
j.u+?qeNY?>Y\/+PNdPPNPNYtzhz
```
[Try it online!](http://pyth.herokuapp.com/?code=j.u%2B%3FqeNY%3F%3EY%5C%2F%2BPNdPPNPNYtzhz&input=%5C%5C%5C%2F%2F%5C%2F%5C%5C&debug=0)
[Answer]
# [R](https://www.r-project.org/), 119 bytes
```
function(s)for(i in 1:nchar(s))cat(rep(" ",cumsum(c(0,!diff(S<-(utf8ToInt(s)>48)*2-1))*S)[i]),substr(s,i,i),"
",sep="")
```
[Try it online!](https://tio.run/##HYy7DoJAEAB7v@LcapcsOTEWxIi9NXZigScbtuAg9/h@vDjlZDJhF9Ptkr1LunqMJGtANepNc/VuHkNR5MaEYdoQDLDLS8wLOjzx8asi2N9qzEna5/rwqdT3S0vVuW6Iqp5e@iaO@RNTGbGyEsMBOE5bB0C7IAwFO/yx1hb3Aw "R ‚Äì Try It Online")
This differs somewhat from [user2390246's answer](https://codegolf.stackexchange.com/a/142696/67312). They each iterate over the string, printing out a certain number of space characters and then the appropriate `/\` character.
However, I avoided splitting the string, opting instead to replace the characters with their UTF-8 encoding value instead, which then allows me to do arithmetic on the numbers directly, which saved me just a few bytes.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 60/65 bytes
I tried shorter C# version
```
s=>{int i=0;return s.Select(x=>"".PadLeft(x<92?--i:i++)+x);}
```
as there was stated: "This also means that every input will start with a backslash."
Or slighly longer which solve starting "/"
```
s=>{int i=s[0]&1;return s.Select(x=>"".PadLeft(x<92?--i:i++)+x);}
```
[Try it online!](https://tio.run/##ZU/BTsMwDL3nK8wOqNFYCtygaxGaNoQ0JMQmcWAcQuYxS206khSGpn57SVvYVPYkJ8579rOj7EDlBqvCkn6H2bd1mIkp6Y@IMS0ztBup8I8f5WmKylGurbhDjYYU2zHwUKm0Fm6bvGVqWCcdKfjMaQkPknTA99KhqMak0GponfE7nMH9WBcZGvmW4i@XJLCCuLJxsiPtgGL7cv56ehEZdIXRYMUM672CbZz0euJRLqe48q/h1eXNYEDX1O/z/pZHZRV1prbmQHpTuK7ytaYUIQgaCWIY@R/nKYon9N6kMeAcTmLQRZryTmP3WzVWrYmYG8p8m5jnU7Iu4GKSm7FU62ALcbIf8GzIYTNhy3l0ZHZc9q@oZN2sZGW1OID5CEMf7RmGLKxzzzc3a6RF@AM "C# (.NET Core) ‚Äì Try It Online")
[Answer]
# [Lua](https://www.lua.org), ~~88~~ 84 bytes
Improved version (-4 bytes thanks to QuertyKeyboard)
```
s=""g=s.gsub g(...,".",function(c)s=g(g(g(s,"\\"," "),"/?$",c)," /","/")print(s)end)
```
[Try it online!](https://tio.run/##JYhRCgIxDESvUgY/GgjJCcpeJD9atSxIV8z2/LHWecMwM69xjfACtOLSfNxSyyLCEPBz9HruR8@VvLT8wxlmYCQQQ7cLuM6SdF4Ken/2fmanR79TRNiU6srJsq6tf5l9AQ "Lua ‚Äì Try It Online")
# Original version (88 bytes)
Another attempt in Lua, this time with a completely different approach using string manipulation instead of a counter variable.
```
s=""for c in(...):gmatch"."do s=s:gsub("\\"," "):gsub("/?$",c):gsub(" /","/")print(s)end
```
Ungolfed:  
```
s = ""
for c in string.gmatch((...), ".") do --for each character in the input
  --s contains the output from the previous iteration
  s = s:gsub("\\", " ") --Replace backslash with space -> indent by 1
  s = s:gsub("/?$", c) --Remove any / at the end of the string and append c to the string
  s = s:gsub(" /", "/") --Remove a single space in front of any / -> un-indent by 1
  print(s)
end
```
There's one interesting thing in the code: `(...):gmatch"."`  
This uses some quirks in the Lua parser. When Lua encounters a piece of code in the form `func "string"`, it'll convert this to `func("string")`. This is so that one can write `print "string"` to print a constant string and it only works with a single string literal after the function. Anything else will give a syntax error. However, this syntactic sugar also works with function calls in the middle of an expression, and more surprising, it works just fine together with the `:` method call syntactic sugar. So in the end, Lua will interpret the code like this:  
```
(...):gmatch"."
-> (...):gmatch(".")
-> string.gmatch((...), ".")
```
~~If anyone can think of a way to remove one of the three gsub calls, please tell me.~~
[Answer]
# Dyalog APL, 31 bytes
```
{‚Üë‚çµ,¬®‚ç®' '/¬®‚ç®{‚çµ-‚ç®+\¬Ø1+2√ó‚çµ}‚çµ='\'}
```
[Try it here!](http://tryapl.org/?a=%7B%u2191%u2375%2C%A8%u2368%27%20%27/%A8%u2368%7B%u2375-%u2368+%5C%AF1+2%D7%u2375%7D%u2375%3D%27%5C%27%7D%27%5C%5C%5C//%5C/%5C%5C%27&run)
[Answer]
# QBasic, 79 bytes
```
DO
c$=INPUT$(1)
IF"/">c$THEN END
c=2*ASC(c$)-139
i=i+c+p
?SPC(i\90);c$
p=c
LOOP
```
This program prints the slashes as you type them. To quit, press `Enter` (or anything earlier in the ASCII table than `/`).
[![Downslashes program in action](https://i.stack.imgur.com/KyeVs.gif)](https://i.stack.imgur.com/KyeVs.gif)
### Explanation
With the variables `i` and `p` implicitly initialized to `0`, we enter an infinite loop. `INPUT$(1)` reads one character from keyboard input. If this character is less than forward slash, `END` the program. Otherwise, we calculate `c` such that an input of `/` gives `c=-45` and `\` gives `c=45`. We then add `c` and `p` (the **p**revious value) to `i` (the **i**ndent).
If `p` and `c` are the same, they add together to change `i` by either `-90` or `+90`. If they are different, they cancel out and do not change `i`. We then print `i\90` spaces followed by the character. (We use integer division because the value of `i` is actually going to be `45`, `135`, etc., since `p` is `0` on the first iteration instead of `-45`.)
Finally, set `p=c` for the next iteration, and loop.
[Answer]
# Perl, 33 bytes
Includes `+1` for the `n` option
```
perl -nE 's%.%say$"x(l^$&?--$a:$a++).$&%eg' <<< '\\\//\/\\'
```
Where it not for the fact that `-F` counts as `+3` this would be `32`:
```
echo -n '\\\//\/\\' | perl -F -E 'say$"x(l^$_?--$a:$a++).$_ for@F'
```
[Answer]
# [Zsh](https://www.zsh.org/), 43 bytes
```
for c (`fold -1`)echo ${(l/#c%2?w--:++w/)c}
```
[Try it online!](https://tio.run/##qyrO@P8/Lb9IIVlBIyEtPydFQdcwQTM1OSNfQaVaI0dfOVnVyL5cV9dKW7tcXzO59v//mJgYfX0ghpD6@gA "Zsh ‚Äì Try It Online")
Explanation:
* `fold -1`: line-wrap the input to a width of 1 (i.e., insert a line-break between every character)
* `for c (``)`: for each character `$c`:
	+ `${c}`: take the character,
	+ `(l//)`: left-padded with spaces to the width of:
		- `#c`: the character code of `$c`
		- `%2`: modulo 2 (this is 1 for `/` and 0 for `\`)
		- `?`: if 1 then:
			* `w--`: decrement `$w` (and return the original value)
		- `:`: else:
			* `++w`: increment `$w` (and return the mutated value)
		- note that `$w` starts at 0 implicitly
	+ `echo`: print; we can't use the 2 bytes shorter `<<<` since its argument is evaluated in a sub-shell so the mutation of `$w` has no effect
[Answer]
# Pyth - 33 bytes
First attempt, will golf.
```
jsMC,*L;+ZsM._*VqVtzztMxL"/ \\"zz
```
[Try it online here](http://pyth.herokuapp.com/?code=jsMC%2C%2aL%3B%2BZsM._%2aVqVtzztMxL%22%2F+%5C%5C%22zz&input=%5C%5C%5C%2F%2F%5C%2F%5C%5C&debug=0).
]