[Question]
  [
Write a program or function that takes in a positive integer (via stdin, command line, or function arg) and prints or returns a string of that many of these small triangles tiled together, alternating which way they point:
```
 /\
/__\
```
This sole triangle is the output if the input is `1`.
If the input is `2`, the output is
```
  ____
 /\  /
/__\/
```
If the input is `3`, the output is
```
  ____
 /\  /\
/__\/__\
```
If the input is `4`, the output is
```
  ________
 /\  /\  /
/__\/__\/
```
And so on. Your program must support inputs up to 216 - 1 = 65535.
**Details**
* The leftmost triangle always points upwards.
* There may be trailing spaces but there may not be unnecessary leading spaces.
* There may be an optional trailing newline.
* Note that for `1` the output is two lines long but otherwise it's three. This is required.
* The shortest submission [in bytes](https://mothereff.in/byte-counter) wins.
  
[Answer]
# Pyth, ~~44~~ 42
```
ItQpdd*\_*4/Q2)jbms<*dQhQ,c" /\ "2,\/"__\\
```
The first line:
```
ItQpdd*\_*4/Q2)
ItQ           )    If the input is not 1
   pdd             Print two spaces
      *\_*4/Q2     Then groups of 4 underscores, repeated input/2 times.
```
The other two lines are generated by noticing that the second line consists of `" /"` and `"\ "` alternating input + 1 times, and the third line consists of `"/"` and `"__\"` alternated in the same fashion.
[Answer]
# SQL, ~~182~~ ~~175~~ ~~173~~ 187 bytes
Not that this'll ever be the shortest, but it's still amusing to try to minimize sql ;) lol
I did this in Oracle 11, however, these should be basic SQL.
[edit] as pointed out, I didn't apply the when input = 1 rule - only show 2 lines. can't think of a better way to do it, however, I did save a couple bytes by modifying the v logic ;) adding 2 ahead of time saves a couple bytes by not having to repeat it later [/edit]
```
select decode(&i,1,'',rpad('  ',v,'____')||z)||rpad(' /',v,'\  /')||decode(y,1,'\')||z||rpad('/',v-1,'__\/')||decode(y,1,'__\')from(select 2+floor(&i/2)*4v,mod(&i,2)y,chr(10)z from dual);
```
[edit1] removed some unnecessary spaces[/edit1]
[edit2] changed &&i to just &i. It cuts down 2 chars, but forces user to input the # of triangles twice ... :P I realized my "good coding habits" using &&i were costing be 2 bytes!! The horror!! [/edit2]
**Explanation**
(note: I use &&1 in this explanation so it only prompts once, the &1 above saves code space, but prompts multiple times ;) )
```
 select  -- line 1
     decode(&&1,1,'',   -- don't need line 1 if input is 1
     rpad('  ',v,'____') || z ) || -- every pair of triangles
     -- line 2
     rpad(' /',v,'\  /') ||  -- every pair of triangles
          decode(y,1,'\') || z || -- add the final triangle, input: 1,3,5 etc.
     -- line 3
     rpad('/',v-1,'__\/') ||  -- every pair of triangles
          decode(y,1,'__\')   -- add the final triangle, input: 1,3,5 etc.
from (select 2+floor(&&i/2)*4 v,   -- common multiplier. 4 extra chars for every triangle pair
             mod(&&i,2) y,  -- Flag for the final triangle (odd inputs, 1,3,5, etc)
             chr(10) z  -- CR, here to save space.
        from dual);
```
**Output**
```
  SQL> accept i
  1
  SQL> /
   /\
  /__\
  SQL> accept i
  2
  SQL> /
    ____
   /\  /
  /__\/
  SQL> accept i
  3
  SQL> /
    ____
   /\  /\
  /__\/__\
  SQL> accept i
  12
  SQL> /
    ________________________
   /\  /\  /\  /\  /\  /\  /
  /__\/__\/__\/__\/__\/__\/
  SQL>
```
[Answer]
# Python 2, ~~89~~ ~~88~~ ~~87~~ ~~85~~ 83 named / 81 unnamed
```
f=lambda n:1%n*("  "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:n-~n+n%2]
```
*(Thanks to @orlp for a byte, and @xnor for another three)*
This is a function which takes in an int `n` and returns the triangles as a string using the row-by-row approach.
e.g. `print f(10)` gives
```
  ____________________
 /\  /\  /\  /\  /\  /
/__\/__\/__\/__\/__\/
```
For the first row, instead of `(n>1)*` we use `1%n*`, since `1%n` is 0 if `n == 1` and 1 if `n > 1`.
[Answer]
# JavaScript (ES6), 101 ~~109~~
Way too long
```
f=(n,z=a=>a.repeat(n/2))=>(n>1?'  '+z('____')+'\n ':' ')+z('/\\  ',w=' /'[++n&1]+'\n')+w+z('/__\\')+w
```
**Explanation**
Using fat arrow for function definition. Moreover no `{}` block: the function body is a single expression that is the return value. `f=(a,b,c)=>expr` is equivalent to
```
function f(a,b,c)
{
  return expr;
}
```
Inside a single expression you can not use statements like `if` or `var`, but
* parameters with default values can be used as local variables
* conditional expressions `?:` work well instead of `if else`
* you can add more subexpressions using the comma operator or even better as unused parameter to functions. In this case the assignment of `w` is the second (unused) parameter to the function `z`
We can rewrite the `f` function as
```
f = function(n) {
  var z = function(a) { // use current value of n (that changes)
    return a.repeat(n/2);
  };
  var result;
  if (n > 1) {
    result = '  ' + z('____') + '\n '; // top row if more than 1 triangle
  else
    result = ' '; // else just the blank
  ++n; // increase n, so invert even/odd
  w = ' /'[n&1]+'\n'; //  blank if n is now even, else '/' if n is now odd
  // the next rows will end in "/\" or "\  /" based on n even/odd
  result +=  z('/\\  ') + w; // offset by the blank char added before
  result += z('/__\\') + w;
  return result;
}
```
**Test** in Firefox/FireBug console
```
console.log(f(1),f(2),f(3),f(4),f(9))
```
*Output*
```
 /\   
/__\ 
  ____
 /\  /
/__\/
  ____
 /\  /\   
/__\/__\ 
  ________
 /\  /\  /
/__\/__\/
  ________________
 /\  /\  /\  /\  /\   
/__\/__\/__\/__\/__\ 
```
[Answer]
# CJam, ~~55~~ ~~53~~ 51 bytes
```
SSri:I2/4*'_*N]I1>*" /\ "I*I)2*<N"/__\\"I*I2*)I2%+<
```
I tried porting my [Python answer](https://codegolf.stackexchange.com/a/48113/21487) and it turned out to be shorter than the other CJams.
[Permalink](http://cjam.aditsu.net/#code=SSri%3AI2%2F4*'_*N%5DI1%3E*%22%20%2F%5C%20%22I*I%292*%3CN%22%2F__%5C%5C%22I*I2*%29I2%25%2B%3C&input=10).
[Answer]
# Haskell ~~155~~ ~~153~~ ~~139~~ 131 Bytes
I found a slightly different approach that turned out to be shorter than my original method. My original attempt is preserved below. As with before, golfing tips are appreciated.
```
m n=unlines.dropWhile(=="  ").z["  "," /","/"].foldr1 z$map t[1..n]
t n|odd n=["","\\","__\\"]
t _=["____","  /","/"]
z=zipWith(++)
```
Thanks to Nimi for the golfing tips.
---
# Previous Attempt ~~197~~ 179 Bytes
```
t n=putStr.unlines.dropWhile(all(==' ')).z(flip(++))(if odd n then["","\\","__\\"]else repeat"").z(++)["  "," /","/"].map(take(4*div n 2).cycle)$["____","\\  /","__\\/"]
z=zipWith
```
[Answer]
# CJam, ~~73~~ ~~68~~ ~~63~~ ~~62~~ 60 bytes
This definitely needs some golfing...
```
S2*l~:I2/'_4**N]I(g*S"\\  /"'\{I2md@*@@*'/\@}:F~N"__\\/"_W<F
```
[Test it here.](http://cjam.aditsu.net/#code=S2*l~%3AI2%2F'_4**N%5DI(g*S%22%5C%5C%20%20%2F%22'%5C%7BI2md%40*%40%40*'%2F%5C%40%7D%3AF~N%22__%5C%5C%2F%22_W%3CF&input=5)
## Explanation
```
"Print the first line:";
S2*l~:I2/'_4**N]I(g*
S2*                  "Push a string with 2 spaces.";
   l~:I              "Read and eval the input, store it in I.";
       2/            "Divide by two to get the number of top segments.";
         '_4**       "Push '____' and repeat it by the number of segments.";
              N]     "Push a newline and wrap everything in an array.";
                I(g* "Get sign(I-1) and repeat the array that often. This is a no-op
                      for I > 1 but otherwise empties the array.";
"Print the other two lines. The basic idea is to define block which takes as arguments
 a repeatable 4-character string as well as another string which only gets printed for
 even I.";
S"\\  /"'\{I2md@*@@*'/\@}:F~N"__\\/"_W<F
S                                        "Push a space.";
 "\\__/"'\                               "Push the string '\__/' and the character \.";
          {             }:F~             "Store this block in F and evaluate it.";
           I2md                          "Get I/2 and I%2 using divmod.";
               @*                        "Pull up the second argument and repeat it I%2
                                          times. This turns it into an empty string for
                                          even I.";
                 @@                      "Pull up I/2 and the 4-character string.";
                   *                     "Repeat the string I/2 times.";
                    '/\@                 "Push a / and reorder the three line parts.";
                            N            "Push a newline.";
                             "__\\/"_W<F "Call F again, with '__\/' and '__\'.";
```
[Answer]
# Julia, 115 bytes
```
n->(m=n÷2;p=println;k=n%2>0?m+1:m;e=m<k?"":"/";t=" /\\ ";b="/__\\";if n>1 p("  "*"_"^4m)end;p(t^k*" "*e);p(b^k*e))
```
This creates an unnamed function which accepts an integer and prints the triangles. To call it, give it a name, e.g. `f=n->(...)`.
Ungolfed + explanation:
```
function f(n)
    m = n ÷ 2                    # Number of upside down triangles
    p = println                  # Store println function to save space
    k = n % 2 > 0 ? m + 1 : m    # Number of right side up triangles
    e = m < k ? "" : "/"         # n even? End lines with a /
    # Top of the triangle
    t = " /\\ "
    # Bottom of the triangle
    b = "/__\\"
    # Print the bottoms of any upside down triangles
    # * performs string concatenation
    # ^ performs string repetition
    if n > 1
        println("  " * "_"^4m)
    end
    # Print the triangle tops (these have two trailing spaces
    # if the last triangle isn't upside down)
    println(t^k * " " * e)
    # Print the triangle bottoms
    println(b^k * e)
end
```
Example output:
```
julia> for i = 1:10 f(i) end
 /\  
/__\
  ____
 /\  /
/__\/
  ____
 /\  /\  
/__\/__\
  ________
 /\  /\  /
/__\/__\/
  ________
 /\  /\  /\  
/__\/__\/__\
  ____________
 /\  /\  /\  /
/__\/__\/__\/
  ____________
 /\  /\  /\  /\  
/__\/__\/__\/__\
  ________________
 /\  /\  /\  /\  /
/__\/__\/__\/__\/
  ________________
 /\  /\  /\  /\  /\  
/__\/__\/__\/__\/__\
  ____________________
 /\  /\  /\  /\  /\  /
/__\/__\/__\/__\/__\/
```
I'm pretty bummed that this is so long. I'm sure there are golfing opportunities aplenty but they aren't clear to me at the moment. Let me know if you have any suggestions or if you'd like any further explanation!
[Answer]
# CJam, ~~68 62~~ 60 bytes
As far as I can see, this is a completely different approach than the other CJam solution. This can be golfed a lot.
```
"/__\\ /\\"4/]ri:R(['/"  /"'_4*"__\\"'\L]3/R*<+zR1>SS+*\W%N*
```
[Try it online here](http://cjam.aditsu.net/#code=%22%2F__%5C%5C%20%2F%5C%5C%224%2F%5Dri%3AR(%5B'%2F%22%20%20%2F%22'_4*%22__%5C%5C%22'%5CL%5D3%2FR*%3C%2BzR1%3ESS%2B*%5CW%25N*&input=6)
[Answer]
## C# 190
```
void f(int n){string s=(n>1)?"\n  ":"",t=" /",u = "/";bool b=true;int m=n;while(m-->0){s+=(n>1&&b&&m>0)?"____":"";t+=b?"\\":"  /";u+=b?"__\\":"/";b=!b;}Console.Write("{0}\n{1}\n{2}",s,t,u);}
```
Ungolfed
```
void f(int n)
{
string s = (n > 1) ? "\n  " : "", t = " /", u = "/";
bool b = true;
int m = n;
while(m-->0)
{
s += (n > 1 && b && m>0) ? "____" : "";
t += b ? "\\" : "  /";
u += b ? "__\\" : "/";
b = !b;
}
Console.Write("{0}\n{1}\n{2}",s,t,u);
}
```
[Answer]
# C#, ~~257~~183 bytes
```
void C(int t){int i;var n="\r\n";var s="  "+string.Join("____",new string[1+t/2])+n;for(i=0;i++<=t;)s+=i%2<1?"\\ ":" /";s+=n;for(i=0;i++<=t;)s+=i%2<1?"__\\":"/";Console.WriteLine(s);}
```
**Edit:** Thanks to the tips from @VisualMelon, saved 74 bytes.
I know it's far from the best language to golf in, but I'm mostly interested in learning about the various nuances of C#, rather than winning the competition.
This is basically a port of [this](https://codegolf.stackexchange.com/a/48101/15417) Pyth answer.
I'm thinking the for loops could be golfed further, but I'm not quite sure how, given the tertiary statements embedded within them.
Example (1, 2, 3, 10):
```
 /\   
/__\  
  ____
 /\  /
/__\/
  ____
 /\  /\ 
/__\/__\
  ____________________
 /\  /\  /\  /\  /\  /
/__\/__\/__\/__\/__\/
```
**Ungolfed:**
```
void C2(int t)
{
    int i;
    var n="\r\n";
    var s="  "+string.Join("____",new string[1+t/2])+n;
    for(i=0;i++<=t;)
        s+=i%2<1?"\\ ":" /";
    s+=n;
    for(i=0;i++<=t;)
        s+=i%2<1?"__\\":"/";
    Console.WriteLine(s);
}
```
[Answer]
# Java, 185
```
String f(int n){int i;String s="";if(n>1){s="  ";for(i=0;i<n/2;i++)s+="____";s+='\n';}for(i=0;i<=n;)s+=i++%2<1?" /":"\\ ";s+='\n';for(i=0;i<=n;i++)s+=i%2<1?i<n?"/_":"/":"_\\";return s;}
```
# Explanation
```
String f(int n) {
    int i;
    String s = "";
    if (n > 1) {
        s = "  ";
        for (i = 0; i < n / 2; i++) {
            s += "____";
        }
        s += '\n';
    }
    for (i = 0; i <= n; i++) {
        s += i % 2 < 1 ? " /" : "\\ ";
    }
    s += '\n';
    for (i = 0; i <= n; i++) {
        s += i % 2 < 1 ? i < n ? "/_" : "/" : "_\\";
    }
    return s;
}
```
[Answer]
## C# - ~~151~~ ~~146~~ ~~141~~ 138
Inspired by @bacchusbeale's answer
```
string f(int n){string t="\n",s=n>1?"  "+new string('_',n/2*4)+t:"";for(var b=n<0;n-->=0;t+=b?"__\\":"/",b=!b)s+=b?"\\ ":" /";return s+t;}
```
Ungolfed
```
    string f(int n)
    {
        string t = "\n", s = n > 1 ? "  " + new string('_', n / 2 * 4) + t : "";
        for (var b = n < 0; n-- >= 0; t += b ? "__\\" : "/", b = !b)
            s += b ? "\\ " : " /";
        return s + t;
    }
```
[Answer]
# Go, ~~156~~ 144
```
func f(n int){a,b,c:="  ","","";for i:=0;i<=n;i++{if i<n/2{a+="____"};if i%2<1{b+=" /";c+="/"}else{b+=`\ `;c+=`__\`}};print(a+"\n"+b+"\n"+c)}
```
Ungolfed:
```
func f(n int) {
    a, b, c := "  ", "", ""   // Initialize 3 accumulators
    for i := 0; i <= n; i++ { // For each required triangle
        if i < n/2 {          // Yay integer math
            a += "____"
        }
        if i%2 < 1 {          // Even, uneven, (are we drawing up or downslope?)
            b += " /"
            c += "/"
        } else {
            b += `\ `
            c += `__\`
        }
    }
    print(a + "\n" + b + "\n" + c)
}
```
The only real trick here (and it isn't even a good one) is using 3 accumulators so I can condense the solution down to 1 loop.
The code can be run here: <http://play.golang.org/p/urEO1kIjKv>
[Answer]
# [><> (Fish)](http://esolangs.org/wiki/Fish), 215 183 156 bytes
Edit: Notepad++ was giving me 5 extra bytes due to CR, so modified count accordingly
Slightly more golfed, but it is my first fish program so far >\_< The requirement to not have a blank first line for 1 triangle doubled the size of the program.
```
99+0{:}1=?.~~"  "oo:2,:1%-v
-1  oooo  "____"  v!?  )0:/!
" /"oa~~.?=1}:{24~/:oo
v!?)0:-1o"\"v!?)0:/!-1ooo"  /"
/v   ~o"/"oa/!
!\:0)?!;"\__"ooo1-:0)?!;"/"o1-
```
Can test at <http://fishlanguage.com/> (Int on initial stack for length)
Explanation:
```
       Start with initial stack as input number
99+0   Push 18 and 0 to the top of the stack
{:}    Shift the stack to the left (wraps), copy the top value, and shift it back to the left (i.e. copy bottom of stack to the top)
1=     Check to see if the top of the stack is equal to 1, pushes 1 for true, 0 for false
?.     If top of stack is zero, skip the ., otherwise jumps to x,y coordinates on top of stack (18,0). This skips the next 8 instructions
~~     Pop the top 2 values from the stack (if they're not popped by the jump)
"  "   Push the string literal "  " onto the stack
oo     Pop the top two values of stack and output them as characters
:2,    Copy top value of stack, ad divide by 2
:1%-   Since ><> uses float division, and doesn't have >= notation, remove the decimal part (if exists)
v      Redirect pointer down
/      Redirect pointer left
:0)    Copy top of stack, and see if its greater than 0 (1 for true, 0 for false)
?!v    If top of stack is non-zero, then ! is executed, which skips the next instruction (redirect), otherwise, code is redirected
"____" Push the literal "____" to the stack
oooo   Pop the top four values of stack and output them as characters
1-     Decrement the top of the stack by 1
!/     Ignore the redirect action.
       When the loop gets to 0, it goes to next line, and gets redirected to the left.
~      Pops the top of the stack (0 counter)
42     Pushes 4 and 2 to the stack
{:}    As before, copies the bottom of the stack to the top
1=?.   Also as before, if the initial value is 1, jump to (2,4) (skipping next 4 instructions
~~     Pop 2 values from stack if these instructions haven't been skipped
ao     Push 10 onto the stack and output it as a character (LF)
"/ "oo Push the literal "/ " onto the stack and output it
://    Copies the top of the stack then redirects to the line below, which then redirects to the left
:0)    Copies top of the stack and compares if its greater than 0
?!v    If it is, redirect to next line
"\"o   Push "\" to stack, then output it as a character
1-     Decrement top value of stack
:0)?!v If loop is not greater than 0, redirect to next line
       Either mode of redirect will loop to the left, and (potentially) skip the far right redirect because of the !
ao     Push 10 to stack and output it as a character (LF)
"/"o~  Push "/" to stack, then output it as a character. Pop top value of stack (the 0 from previous loop)
v      Redirects to next line, which then redirects to the right
:0)?!; If the top of the stack is not greater than 0, terminate (;)
"\__"  Pushes "\__" to the stack
ooo    Outputs top 3 stack values as characters ("__\")
1-     Decrement top of stack by 1
:0)?!; If the top of the stack is not greater than 0, terminate (;)
"/"o   Push "/" to top of stack then output it as a character
1-     Decrement top of stack by 1
!\     Ignore the redirect
```
[Answer]
# perl 109 108 106
```
$i=<>;$t=join$/,$i-1?"  "."_"x($i/2)x4:(),$m.=(" /")[$_&1]||"\\ ",$b.=("/")[$_&1]||"__\\"for 0..$i;print$t
```
I think this is alright for my first golf, I used Vynce's section for the first line, with the rest of my code to get past the new line problem with 1 triangle.
Now to see if I can shorten it :)
**Edit**: Whitespace
**Edit 2**: replaced `"\n"` with `$/`
```
1:
 /\
/__\
4:
  ________
 /\  /\  /
/__\/__\/
```
[Answer]
# C89, 150
```
r(p,q,n)int*p,*q;{n?printf(p),r(q,p,n-1):puts(p);}main(c,v)int**v;{c=atoi(v[1]);if(c>1)printf("  "),r("","____",c-1);r(" /","\\ ",c);r("/","__\\",c);}
```
An ungolfed version:
```
r(p, q, n) char *p, *q; {
    if(n > 0) {
        printf(p);
        r(q, p, n-1); /* swap p and q */
    } else {
        puts(p);
    }
}
main(c, v) char**v; {
    c = atoi(v[1]);
    if(c>1) {
        printf("  ");
        r("", "____", c - 1);
    }
    r(" /", "\\ ", c);
    r("/", "__\\", c);
}
```
The output: 
```
$ seq 1 3 10 | xargs -n1 ./triangles
 /\
/__\
  ________
 /\  /\  /
/__\/__\/
  ____________
 /\  /\  /\  /\
/__\/__\/__\/__\
  ____________________
 /\  /\  /\  /\  /\  /
/__\/__\/__\/__\/__\/
```
The stack overflows if I enter `65535` (but not if you compile with `-O3`!), but theoretically it should work ;-)
*edit:* program now fulfills the requirement that only two lines should be outputted if `1` is passed to the program
*edit 2:* use `int*` instead of `char*`
[Answer]
# C++ stdlib, 194 bytes
```
string f(int n){char* p[]={"____"," /\\ ","/__\\"};int x[]={(n-n%2)*2,n*2+2-n%2,n*2+1+n%2},i,j;string s=n>1?"  ":"";for (i=n>1?0:1;i<3;s+=++i<3?"\n":"")for (j=0;j<x[i];)s+=p[i][j++%4];return s;}
```
Test program:
```
#include <string>
#include <iostream>
using namespace std;
string f(int n)
{
    char* p[]={"____"," /\\ ","/__\\"};
    int x[]={(n-n%2)*2,n*2+2-n%2,n*2+1+n%2},i,j;
    string s=n>1?"  ":"";
    for (i=n>1?0:1;i<3;s+=++i<3?"\n":"")
        for (j=0;j<x[i];)
            s+=p[i][j++%4];
    return s;
}
int main(int argc, char* argv[])
{
    cout << f(10);
    return 0;
}
```
[Answer]
# Bash, ~~166~~ ~~127~~ ~~125~~ ~~119~~ 105 bytes
```
printf -v l %$[$1/2]s;(($1%2))&&r= j=$l\ ||r=/ j=$l;echo "  ${l// /____}
${j// / /\ } $r
${j// //__\\}"$r
```
In a function:
```
triangle() {
    printf -v l %$[$1/2]s;(($1%2))&&r= j=$l\ ||r=/ j=$l;echo "  ${l// /____}
${j// / /\ } $r
${j// //__\\}"$r
}
```
With some presentations:
```
for i in {1..5} 10 31;do
    paste -d\  <(
        figlet -fsmall $i |
             sed 's/^/         /;s/^ *\(.\{10\}\)$/\1  /;$d'
    ) <(triangle $i)
  done
```
May render (if you have *figlet* installed):
```
        _      
       / |    /\  
       | |   /__\
       |_|   
      ___      ____
     |_  )    /\  /
      / /    /__\/
     /___|   
      ____     ____
     |__ /    /\  /\  
      |_ \   /__\/__\
     |___/   
     _ _       ________
    | | |     /\  /\  /
    |_  _|   /__\/__\/
      |_|    
      ___      ________
     | __|    /\  /\  /\  
     |__ \   /__\/__\/__\
     |___/   
   _  __       ____________________
  / |/  \     /\  /\  /\  /\  /\  /
  | | () |   /__\/__\/__\/__\/__\/
  |_|\__/    
    _____      ____________________________________________________________
   |__ / |    /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  
    |_ \ |   /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\
   |___/_|   
```
### Save 2 chars if *input* from variable instead of `$1`: 103
```
printf -v l %$[i/2]s;((i%2))&&r= j=$l\ ||r=/ j=$l;echo "  ${l// /____}
${j// / /\ } $r
${j// //__\\}"$r
```
Into the loop:
```
for i in {1..3} {31..34};do
    [ $i == 31 ] && figlet -fsmall ...
    paste -d\  <(
        figlet -fsmall $i |
            sed 's/^/         /;s/^ *\(.\{10\}\)$/\1   /;$d'
    ) <(
        printf -v l %$[i/2]s;((i%2))&&r= j=$l\ ||r=/ j=$l;echo "  ${l// /____}
${j// / /\ } $r
${j// //__\\}"$r
    )
  done
```
Will render (approx) same:
```
        _       
       / |     /\  
       | |    /__\
       |_|    
      ___       ____
     |_  )     /\  /
      / /     /__\/
     /___|    
      ____      ____
     |__ /     /\  /\  
      |_ \    /__\/__\
     |___/    
       
       
 _ _ _ 
(_|_|_)
       
    _____       ____________________________________________________________
   |__ / |     /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  
    |_ \ |    /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\
   |___/_|    
  _______       ________________________________________________________________
 |__ /_  )     /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /
  |_ \/ /     /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/
 |___/___|    
  ________      ________________________________________________________________
 |__ /__ /     /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  
  |_ \|_ \    /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\
 |___/___/    
 _____ _        ____________________________________________________________________
|__ / | |      /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /\  /
 |_ \_  _|    /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/
|___/ |_|     
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~116~~ 95 bytes
Big thanks to Mazzy and ASCII-Only for saving 21 bytes
```
param($n)@("  "+"_"*4*($x=$n-shr1))[$n-eq1]
" /"+"\  /"*$x+"\"*($a=$n%2)
"/"+"__\/"*$x+"__\"*$a
```
[Try it online!](https://tio.run/##LY1BCsIwEEX3OcUwTCWJWInosuA9rIQsIl3U2qYLC7VnH7/g6j94D/74eucyd7nvVR7U0KpjKulpZXBXy0S858j@7K0sjQyHuSvBuRsoT@FumI4IWsJ4WUCMMCGsTs7wz8XY/h0IkHQzoa4vn2rd4VDiphq@ "PowerShell – Try It Online")
Not allowing an empty line for n = 1 ate up like ~~14~~ 10 bytes. This solution is ~~pretty brain dead~~ now much more clever with a minimal amount of repeated code. Banker's Rounding is still the actual devil.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 27 bytes
```
ＦＥＮ﹪ι²«Ｐ×⁴_↗⊗¬ι↓Ｐ↘²↘⊗ι↑Ｐ↗⊗ι
```
[Try it online!](https://tio.run/##ZY09C8IwFEXn9leETi@QLsXFunZxSBGxs/Qj2gdpX4hJHcTfHiEoFh3v4d5z@7G1PbU6hAtZBrI1sJ@Nd7WfOmWBCyZp8JoABSs45@yRJtJrh8bi7OCEk7rBRrDsnHG@S5NDxGVjjngdnWAV@U6rAWpygDxWJC0Kyoruc0xfWWTvXbGSrfBHhytTY349f@@x/gxhG/JFvwA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
ＦＥＮ﹪ι²«
```
Generate a list of alternating bits of length `n` and loop over them.
```
Ｐ×⁴_
```
Draw `____` without moving the cursor.
```
↗⊗¬ι↓
```
On the first and every other triangle, draw the left `/` side.
```
Ｐ↘²
```
Draw the `\` side without moving the cursor.
```
↘⊗ι↑
```
On the second and every other triangle, draw the left `\` side again to move the cursor.
```
Ｐ↗⊗ι
```
On the second and every other triangle, draw the right `/` side, without moving the cursor.
[Answer]
# C, 368 Bytes
```
void p(char* c){printf(c);}
int x(int s,int f){int t=0,p=s;for(int i=0;i<f;i++){if(p==1){t++;p=0;}else{p=1;}}return t;}
int main(int argc,char* argv[]){int t=atoi(argv[1]);if(t>1){p("  ");for(int i=0;i<x(0,t);i++)
{p("____");}p("\n");}for(int i=0;i<x(1,t);i++){p(" /\\ ");}if(t%2==0){p(" /");}p("\n");
for(int i=0;i<x(1,t);i++){p("/__\\");}if(t%2==0){p("/");}p("\n");}
```
It's more if you count the `#include` statements, but it compiled on gcc, albeit with warnings, without them. I know it's not the shortest by far, but I still like that I did it in C.
[Answer]
# Perl (simple) 131 125 120
fairly straightforward first pass:
```
$i=<>;print join"\n",$i-1?"  "."_"x(4*int($i/2)):(),join("",map{(" /","\\ ")[$_%2]}0..$i),join"",map{("/","__\\")[$_%2]}0..$i
```
oh who needs explicit int?
```
$i=<>;print join"\n",$i-1?"  "."_"x($i/2)x4:(),join("",map{(" /","\\ ")[$_%2]}0..$i),join"",map{("/","__\\")[$_%2]}0..$i
```
[Answer]
# Prolog, 126 bytes
```
A+B:-writef(A,B).
$N:-(N>1,"  %r\n"+['____',N//2];!),(0is N/\1,T='/';T='')," %r%w\n"+['/\\  ',N/2,T],"%r%w\n"+['/__\\',N/2,T].
```
Invoke like `$3`.
More readable:
```
triangle(N):-
    (   N > 1
    ->  writef("  %r\n", ['____', N//2])
    ;   true
    ),
    (   0 is N mod 2
    ->  T = '/'
    ;   T = ''
    ),
    writef(" %r%w\n", ['/\\  ', N/2, T]),
    writef("%r%w\n", ['/__\\', N/2, T]).
```
Example:
```
?- findall(N,between(1,10,N),NN), maplist($, NN), !.
 /\  
/__\
  ____
 /\  /
/__\/
  ____
 /\  /\  
/__\/__\
  ________
 /\  /\  /
/__\/__\/
  ________
 /\  /\  /\  
/__\/__\/__\
  ____________
 /\  /\  /\  /
/__\/__\/__\/
  ____________
 /\  /\  /\  /\  
/__\/__\/__\/__\
  ________________
 /\  /\  /\  /\  /
/__\/__\/__\/__\/
  ________________
 /\  /\  /\  /\  /\  
/__\/__\/__\/__\/__\
  ____________________
 /\  /\  /\  /\  /\  /
/__\/__\/__\/__\/__\/
NN = [1, 2, 3, 4, 5, 6, 7, 8, 9|...].
```
[Answer]
# C#: 1 line LINQ, 198 bytes
```
string f(int n){return(n>1?"  ":"")+string.Join("\n",new[]{"____"," /\\ ","/__\\"}.Zip(new[]{(n-n%2)*2,n*2+2-n%2,n*2+1+n%2},(s,l)=>string.Join(s,new string[n+1]).Substring(0,l)).Where(x=>x.Any()));}
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 83 bytes
```
{~["  {'____'x$_/2-.5}
"x($_>2),'/\  'x$_/2~($!='/'x$_%2),"
"~'/__\\'x$_/2~$!]}o*+1
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/ui5aSUGhWj0eCNQrVOL1jXT1TGu5lCo0VOLtjDR11PVjFBQgEnUaKoq26vogjipQRolLqU5dPz4@JgYqraIYW5uvpW3435pLTy1NrzixUiEtv0jBUE/P9D8A "Perl 6 – Try It Online")
Anonymous code block that takes a number and returns a string.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~117~~ 115 bytes
-2 thanks to ceilingcat.
All those parentheses suggest something less clunky is surely possible.
```
f(n,i,j){for(j=3-1/n;j--;puts("/"+(n%2|j>1)))for(i=0;i<n+(j<2)>>1;)printf("  %.4s"+2-j*!i++,"/__\\/\\  ____"+j*4);}
```
[Try it online!](https://tio.run/##JY5BCoMwEEXX5hTTgDBjTNNYd1FPEpAipCTQVNSurGdPI/2b9xkew5/kc5pSchhrXwfa3XvB0N@lVtEEKc382VbkiguMZfMNgyai0/H9zfguCgxdQ8OgDc2Lj5tDDlBe25WLRobq4oWouRpHa5W1AGMOF6FqyRwp6/B6@IjEdlbkp4DnyUMP2mR0mbdchCBWZKNw6Mlk/jfxsx/sSD8 "C (gcc) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 37 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
≠iðð'_I2÷4*×J}„ /„\ ‚I>∍J'/…__\‚I>∍J»
```
[Try it online](https://tio.run/##yy9OTMpM/f//UeeCzMMbDm9Qj/c0OrzdROvwdK/aRw3zFPSBRIzCo4ZZnnaPOnq91IH8ZfHxMXCBQ7v//zcGAA) or [verify the first 10 outputs](https://tio.run/##yy9OTMpM/R/i6ufyqGHe4f1WOv8fdS7IPLzh8Ab1eD@jw9tNtA5P96oFyinoA4kYhUcNs/zsHnX0eqkD@cvi42PgAod2/9c5tM3@PwA).
**Explanation:**
```
≠i            } # If the (implicit) input is NOT 1:
                #   i.e. 1 → 0 (falsey)
                #   i.e. 5 → 1 (truthy)
  ðð            #  Push two spaces "  "
    '_         '#  Push string "_"
      I         #  Push the input
       2÷       #  Integer-divide it by 2
                #   i.e. 5 → 2
         4*     #  And then multiply it by 4
                #   i.e. 2 → 8
           ×    #  Repeat the "_" that many times
                #   i.e. "_" and 8 → "________"
            J   #  Join everything on the stack together to a single string
                #   i.e. "  ________"
„ /             # Push string " /"
   „\           # Push string "\ "
     ‚          # Pair them together: [" /","\ "]
      I>        # Push the input+1
        ∍       # Extend the list to that size
                #  i.e. [" /","\ "] and 2 → [" /","\ "]
                #  i.e. [" /","\ "] and 6 → [" /","\ "," /","\ "," /","\ "]
         J      # Join the list together to a single string
                #  i.e. [" /","\ "] → " /\ "
                #  i.e. [" /","\ "," /","\ "," /","\ "] → " /\  /\  /\ "
'/             '# Push string "/"
  …__\          # Push string "__\"
      ‚         # Pair them together: ["/","__\"]
       I>       # Push the input+1
         ∍      # Extend the list to that size
                #  i.e. ["/","__\"] and 2 → ["/","__\"]
                #  i.e. ["/","__\"] and 6 → ["/","__\","/","__\","/","__\"]
          J     # Join the list together to a single string
                #  i.e. ["/","__\"] → "/__\"
                #  i.e. ["/","__\","/","__\","/","__\"] → "/__\/__\/__\"
»               # Join the entire stack with a newline delimiter
                #  i.e. " /\ " and "/__\" → " /\ \n/__\"
                #  i.e. "  ________", " /\  /\  /\ " and "/__\/__\/__\"
                #   → "  ________\n /\  /\  /\ \n/__\/__\/__\"
                # (and output the result implicitly)
```
[Answer]
# Java 11, 122 bytes
```
n->(n>1?"  "+"_".repeat(n/2*4)+"\n":"")+" /\\ ".repeat(n).substring(0,++n*2)+"\n"+"/__\\".repeat(n).substring(0,n/2*4+n%2)
```
[Try it online.](https://tio.run/##fZBBbsMgEEX3OcUIqRKEBsdWVnWcnqDZdFkqizikInHGlsGRqspndyfYUlfpBhj@h3l/zuZmVufjZaxq4z28GYc/CwCHwXYnU1nY30uA99A5/IKKkwIocrocFrT4YIKrYA8IBYy42nHcpa8MgElWMtXZ1prAMcmWGyGZRvbCGB0g0Rr@ZKF8f/CxBV8/S4nLbHJLlpSl1o@c8V@JT5kY8ztN2x9qopmhbo07wpUS8Yn@4xOMmOKcmi4mcUWag9sW6Zo2KWeV4n77YK@q6YNq6WmokTtJ7DH4AwMqmo74zzFrQxzeMP4C)
**Explanation:**
```
n->                   // Method with integer parameter and String return-type
  (n>1?               //  If the input is larger than 1:
    "  "              //   Return two spaces
    +"_".repeat(      //   Appended with "_" repeated the following amount of times:
          n/2         //    The input integer-divided by 2
             *4)      //    And then multiplied by 4
    +"\n"             //   Appended with a newline
   :                  //  Else:
    "")               //   Return nothing
  +" /\\ ".repeat(n)  //  Appended with " /\ " repeated the input amount of times
    .substring(0,     //   After which we only leave the first `x` characters, where `x` is:
      ++n             //    Increase the input by 1 first with `++n`
         *2)          //    And then multiply it by 2
                      //     i.e. For input 1, `x` becomes 4 here
                      //     i.e. For input 6, `x` becomes 14 here
  +"\n"               //  Appended with a newline
  +"/__\\".repeat(n)  //  Appended with "/__\" repeated the input amount of times
    .substring(0,     //   After which we only leave the first `y` characters, where `y` is:
      n/2             //    The input+1 integer-divided by 2
         *4           //    Then multiplied by 4
           +n%2)      //    And then the input+1 modulo-2 added
                      //     i.e. For input 1, `y` becomes 4 here
                      //     i.e. For input 6, `y` becomes 13 here
```
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf), 35 bytes
```
½û__∞* ∞qpÿ /\ *k∞⌠<p)½ÿ/__\*k¥┬'/*
```
[Try it online!](https://tio.run/##y00syUjPz0n7///Q3sO74@MfdczTUgAShQWH9yvoxyhoZQM5j3oW2BRoAhXs14@Pj9HKPrT00ZQ16vpa//8bchlxGXOZcJlymRr8100BAA "MathGolf – Try It Online")
## Explanation
The program is split into 3 parts, `½û__∞* ∞qp`, `ÿ /\ *k∞⌠<p`, and `)½ÿ/__\*k¥┬'/*`. One part for each line of the output.
### First part
```
½           Halve input to integer
 û__∞       Push "__" and double
     *      Repeat string (input//2 times)
       ∞    Push space character and double
        qp  Print the spaces first, then the underscores
```
### Second part
```
ÿ /\ *      Push " /\ " and repeat it <input> times
      k∞    Push input and double it
        ⌠   Increment by two
         <p Slice the string to get the first (<input>*2 + 2) characters and print
```
### Third part
```
)½              Increment input by 1 and halve it to integer
  ÿ/__\*        Repeat "/__\" that many times
        k¥┬     Check if input is divisible by 2
           '/*  Repeat "/" either zero or one times based on input
```
]