[Question]
  [
Make me a [s'more](https://en.wikipedia.org/wiki/S%27more)! I tell you the width, the amount of graham cracker, the amount of chocolate, and the amount of marshmallow. An example:
Input:
Width: `10`
Graham: `3`
Chocolate: `2`
Marshmallow: `1`.
Output:
```
GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG
CCCCCCCCCC
CCCCCCCCCC
MMMMMMMMMM
GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG
```
Is it *that easy?* Um... yes.
Note that the input should be a list of arguments to a function or a program, not a string. You might choose the first being Width, then Graham, but any order is fine.
[Full test cases if you are interested.](https://pastebin.com/dNzS3FgY)
# Stack snippet (for testing, etc.)
This is to test the output.
```
var smore = function(width, graham, chocolate, marshmallow){
	return ("G".repeat(width) + "\n").repeat(graham) + 
	("C".repeat(width) + "\n").repeat(chocolate) + 
	("M".repeat(width) + "\n").repeat(marshmallow) + 
	("G".repeat(width) + "\n").repeat(graham);
};
Snippetify(smore);
```
```
<script src="https://programmer5000.com/snippetify.min.js"></script>
Width: <input type = "number">
Graham: <input type = "number">
Chocolate: <input type = "number">
Marshmallow: <input type = "number">
<button>Try it out!</button>
<pre data-output></pre>
```
# Notes:
* You may include a trailing newline on the end of the last line. You may also use a `\` instead of a newline.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'").
* Any questions? Comment below:
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~73~~ 48 bytes
```
lambda w,g,c,m:zip(*['G'*g+'C'*c+'M'*m+'G'*g]*w)
```
[Try it online!](https://tio.run/nexus/python2#LYvLCsIwEADv/YoFD5vHIlZvQk8ePPkF1kOMpq6YBzGl4s9HaL0Nw4zr@voy/nozMNFAlvz@y0moMx5RDRoPqKzGEyqvZ3NRk6zccUhjEbJZpcyhgBOKZbMw9gHXz8hBeJMELkxzISX8hzgW8KZk/kB0YB8mG1vu@V3bDe1oS@0P "Python 2 – TIO Nexus")
Creates a transposed version of the answer, than transposes it to the correct format with `zip(*l)`
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~21~~ ~~19~~ 19 bytes
```
"GCMG"S×|D«‚øvy`.D»
```
[Try it online!](https://tio.run/nexus/05ab1e#@6/k7uzrrhR8eHqNy6HVjxpmHd5RVpmg53Jo9///hgZcxlxGXIYA "05AB1E – TIO Nexus")
-2 thanks to my oversight and Emigna.
```
"GCMG"S×            # Push GCMG, separate, duplicate n times.
        |D«         # Push rest of inputs, doubled.
           ‚ø       # Wrap GCMG array and input array, then zip them into pairs.
             vy`.D» # For each pair, print n of G/C/M/G.
```
(See Emigna's answer, it's better: <https://codegolf.stackexchange.com/a/116787/59376>)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~17~~ 16 bytes
1 bytes saved thanks to *carusocomputing*.
```
"GCMG"S×vy²Nè.D»
```
[Try it online!](https://tio.run/nexus/05ab1e#@6/k7uzrrhR8eHpZ5aFNfodX6Lkc2v3/v6EBV7SxjpGOYSwA "05AB1E – TIO Nexus")
Input order is `W, [G,C,M]`
**Explanation**
`10, [3,2,1]` used as example.
```
"GCMG"S           # push the list ['G','C','M','G']
       ×          # repeat each W times
                  # STACK: ['GGGGGGGGGG', 'CCCCCCCCCC', 'MMMMMMMMMM', 'GGGGGGGGGG']
        v         # for each [string, index] y,N in the list
          ²Nè     # get the amount of layers at index N from the [G,C,M] list
         y   .D   # duplicate the string y that many times
               »  # join strings by newlines
```
[Answer]
# JavaScript (ES6), 71 bytes
```
(W,G,C,M)=>[...'GCMG'].map(X=>`${X.repeat(W)}
`.repeat(eval(X))).join``
```
Woohoo, beat 3 other JavaScript answers!
```
f=
(W,G,C,M)=>[...'GCMG'].map(X=>`${X.repeat(W)}
`.repeat(eval(X))).join``
console.log(
    f(10, 3, 2, 1)
)
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 17 bytes
```
'GCMG'iK:)Y"!liX"
```
Input format is: first input `[G, C, M]`, second input `W`.
[Try it online!](https://tio.run/nexus/matl#@6/u7uzrrp7pbaUZqaSYkxmh9P9/tLGCkYJhLJehAQA "MATL – TIO Nexus")
### Explanation with example
Consider inputs `[3 2 1]` and `10`.
```
'GCMG' % Push this string
       % STACK: 'GCMG'
i      % Take first input: array of three numbers
       % STACK: 'GCMG', [3 2 1]
K:     % Push [1 2 3 4]
       % STACK: 'GCMG', [3 2 1], [1 2 3 4]
)      % Index (modular, 1-based). This repeats the first entry of the input array
       % STACK: 'GCMG', [3 2 1 3]
Y"     % Run-length decoding
       % STACK: 'GGGCCMGGG'
!      % Transpose. Gives a column vector of chars
       % STACK: ['G'; 'G'; 'G'; 'C'; 'C'; 'M'; 'G'; 'G'; 'G']
l      % Push 1
       % STACK: ['G'; 'G'; 'G'; 'C'; 'C'; 'M'; 'G'; 'G'; 'G'], 1
i      % Take second input: number
       % STACK: ['G'; 'G'; 'G'; 'C'; 'C'; 'M'; 'G'; 'G'; 'G'], 1, 10
X"     % Repeat the specified numbers of times along first and second dimensions
       % STACK: ['GGGGGGGGGG';'GGGGGGGGGG';'GGGGGGGGGG';'CCCCCCCCCC';...;'GGGGGGGGGG']
       % Implicitly display
```
[Answer]
## [C#](http://csharppad.com/gist/6c2b7ee2d9f3df79de6e4da1950ee4ea), 204 bytes
---
### Golfed
```
(w,g,c,m)=>{string G="\n".PadLeft(++w,'G'),C="\n".PadLeft(w,'C'),M="\n".PadLeft(w,'M'),o="".PadLeft(g,'G');o+="".PadLeft(m,'M')+"".PadLeft(c,'C')+o;return o.Replace("G",G).Replace("C",C).Replace("M",M);};
```
---
### Ungolfed
```
( w, g, c, m ) => {
   string
      G = "\n".PadLeft( ++w, 'G' ),
      C = "\n".PadLeft( w, 'C' ),
      M = "\n".PadLeft( w, 'M' ),
      o = "".PadLeft( g, 'G' );
      
   o +=
      "".PadLeft( m, 'M' ) +
      "".PadLeft( c, 'C' ) +
      o;
   
   return o
      .Replace( "G", G )
      .Replace( "C", C )
      .Replace( "M", M );
};
```
---
### Ungolfed readable
```
// Function with 4 parameters
//   w : Width
//   g : Graham
//   c : Chocolate
//   m : Marshmallow
( w, g, c, m ) => {
   
   // Initialization of vars with the contents
   //    of each line, with a new line at the end
   string
      G = "\n".PadLeft( ++w, 'G' ),
      C = "\n".PadLeft( w, 'C' ),
      M = "\n".PadLeft( w, 'M' ),
      
      // Trick to reduce the byte count
      //   Initialize the output with n 'G's
      o = "".PadLeft( g, 'G' );
      
   // Add again n 'M's and n 'C's
   //   Append the 'G's at the end.
   o +=
      "".PadLeft( m, 'M' ) +
      "".PadLeft( c, 'C' ) +
      o;
   
   // Replce every instance of 'G'/'C'/'M'
   //    with the full line
   return o
      .Replace( "G", G )
      .Replace( "C", C )
      .Replace( "M", M );
};
```
---
### Full code
```
using System;
using System.Collections.Generic;
namespace Namespace {
   class Program {
      static void Main( String[] args ) {
         Func<Int32, Int32, Int32, Int32, String> f = ( w, g, c, m ) => {
            string
               G = "\n".PadLeft( ++w, 'G' ),
               C = "\n".PadLeft( w, 'C' ),
               M = "\n".PadLeft( w, 'M' ),
               o = "".PadLeft( g, 'G' );
               
            o +=
               "".PadLeft( m, 'M' ) +
               "".PadLeft( c, 'C' ) +
               o;
            
            return o
               .Replace( "G", G )
               .Replace( "C", C )
               .Replace( "M", M );
         };
         List<Tuple<Int32, Int32, Int32, Int32>>
            testCases = new List<Tuple<Int32, Int32, Int32, Int32>>() {
               new Tuple<Int32, Int32, Int32, Int32>( 1, 1, 1, 1 ),
               new Tuple<Int32, Int32, Int32, Int32>( 1, 1, 1, 2 ),
               new Tuple<Int32, Int32, Int32, Int32>( 1, 1, 2, 1 ),
               //
               // ...
               //
               // The link above contains the code ready to run
               //    and with every test from the pastebin link
               //
               // Yes, it contains 342 tests ready to run.
               //
               // I can barely fit every test on a 1080p screen...
               //    ... and there's 6 tests per line... Jebus...
               //
            };
         
         foreach( var testCase in testCases ) {
            Console.WriteLine( $"Input:\nWidth: {testCase.Item1,3} Graham: {testCase.Item2,3} Chocolate: {testCase.Item3,3} Marshmellow: {testCase.Item4,3}\nOutput:\n{f( testCase.Item1, testCase.Item2, testCase.Item3, testCase.Item4 )}\n" );
         }
         Console.ReadLine();
      }
   }
}
```
---
### Releases
* **v1.0** - `204 bytes` - Initial solution.
---
### Notes
* [Looking for a picture of my *beautiful* test screen?](https://i.stack.imgur.com/4OERg.png)
* On a second thought, CSharpPad can't handle those tests, [here's a version with fewer tests](http://csharppad.com/gist/ea843ff852f907176d8a3eb86cf93b3a)
[Answer]
# Ruby, 47 bytes
```
->w,g,c,m{puts r=[?G*w]*g,[?C*w]*c,[?M*w]*m,r}
```
thanks to ventero
# Ruby, 51 bytes
```
->w,g,c,m{(?G*g+?C*c+?M*m+?G*g).chars{|i|puts i*w}}
```
Call like this:
```
f=->w,g,c,m{(?G*g+?C*c+?M*m+?G*g).chars{|i|puts i*w}}
f[10,3,2,1]
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 49 bytes
```
$a,$b=$args;0..2+0|%{,("$('GCM'[$_])"*$a)*$b[$_]}
```
[Try it online!](https://tio.run/nexus/powershell#@6@SqKOSZKuSWJRebG2gp2ekbVCjWq2joaSioe7u7KserRIfq6mkpZKoqaWSBOLU/v//39Dgv/F/o/@GAA "PowerShell – TIO Nexus")
Takes input as four command-line arguments, `width graham chocolate marshmallow`, stores the first into `$a` and the rest into `$b` (implicitly as an array). Loops from over the range `0,1,2,0`. Each loop, we index into string `GCM`, re-cast that `char` as a string, and multiply it out by `$a` (the width), and then using the comma-operator `,`, turns that into an array by multiplying the appropriate index of `$b` (i.e., how many layers). Those resultant string arrays are all left on the pipeline and output is implicit, with a newline between elements.
[Answer]
# C, ~~108~~ 105 bytes
*Thanks to @Quentin for saving 3 bytes!*
```
#define F(i,c)for(;i--;puts(""))for(j=w;j--;)putchar(c);
i,j;f(w,g,c,m){i=g;F(i,71)F(c,67)F(m,77)F(g,71)}
```
[Try it online!](https://tio.run/nexus/c-gcc#HcxBCsMgEIXhvacY0s0MTKC2UBeSbe4RbLQjaEuSkkXI2a32bX74Fq9cnrOXPMOIwo78e0ErfW8/323FrqO/xGG3sSJVda9pQUdWCUfrcefAjhMdMgTbPoymER0/TE1i0xIankXyBmmSjKQOBXUe9ZXhznBj0PXxLD8)
[Answer]
## Batch, 146 bytes
```
@set s=
@for /l %%i in (1,1,%1)do @call set s=G%%s%%
@for %%w in (%2.%s% %3.%s:G=C% %4.%s:G=M% %2.%s%)do @for /l %%i in (1,1,%%~nw)do @echo%%~xw
```
Relies on the obscure behaviour of `echo` in that it can often ignore the symbol between `echo` and the text to be echoed to collapse the four loops into a nested loop.
[Answer]
# [V](https://github.com/DJMcMayhem/V), 22 bytes
```
éGÄÀäjMoC
MÀÄkÀÄHdêÀP
```
[Try it online!](https://tio.run/nexus/v#@394pfvhlsMNh5dk@eY7c/lKA5kt2SDCI@XwqsMNAf///zf@b/jf6L@hAQA "V – TIO Nexus")
Hexdump:
```
00000000: e947 c4c0 e46a 4d6f 430a 4d1b c0c4 6bc0  .G...jMoC.M...k.
00000010: c448 64ea c050                           .Hd..P
```
Input order is
```
Graham, Marshmallow, Chocolate, Width
```
Explanation:
```
éG                  " Insert 'G'
  Ä                 " Duplicate this line
   Àäj              " *arg1* times, duplicate this line and the line below it
      M             " Move to the middle line
       o            " Open up a newline, and enter insert mode
        C<cr>M<esc> " Insert 'C\nM'
ÀÄ                  " Make *arg2* copies of this line (Marshmallow)
  k                 " Move up one line
   ÀÄ               " Make *arg3* copies of this line (Chocolate)
     H              " Move to the first line
      dê            " Delete this column
        ÀP          " And paste it horizontally *arg4* times
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 14 bytes
Code:
```
…GCM‚øü×¬)˜S×»
```
Uses the **CP-1252** encoding. [Try it online!](https://tio.run/nexus/05ab1e#@/@oYZm7s@@jhlmHdxzec3j6oTWap@cEA@nd//9HG@soGOkoGMZyGRoAAA "05AB1E – TIO Nexus")
Explanation:
```
…GCM              # Push the string "GCM"
    ‚             # Wrap with the input
     ø            # Transpose the array
      ü×          # Compute the string product of each element (['A', 3] --> 'AAA')
        ¬)˜       # Get the last element and append to the list
           S      # Split the list
            ×     # Vectorized string multiplication with the second input
             »    # Join by newlines and implicitly print
```
[Answer]
# Excel, 104 bytes
Oh, boy! A formula that requires line breaks.
```
=REPT(REPT("G",A1)&"
",A2)&REPT(REPT("C",A1)&"
",A3)&REPT(REPT("M",A1)&"
",A4)&REPT(REPT("G",A1)&"
",A2)
```
`A1` has Width  
`A2` has Graham  
`A3` has Chocolate  
`A4` has Mallow
---
If pre-formatting is allowed, then you can format the cell for Vertical Text and shorten the formula to 65 bytes:
```
=REPT(REPT("G",A2)&REPT("C",A3)&REPT("M",A4)&REPT("G",A2)&"
",A1)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
“GCM”ẋ"ṁ4Fẋ€Y
```
A dyadic program. Inputs are: `[Graham's, Chocolates, Marshmallows]`, `Width`.
**[Try it online!](https://tio.run/nexus/jelly#@/@oYY67s@@jhrkPd3UrPdzZaOIGZDxqWhP5////aGMdIx3D2P@GBl/z8nWTE5MzUgE "Jelly – TIO Nexus")**
### How?
```
“GCM”ẋ"ṁ4Fẋ€Y - Main link: [g,c,m], w    e.g. [1,2,1], 2
“GCM”         - literal ['G', 'C', 'M']
      "       - zip that and [g,c,m] with the dyadic operation:
     ẋ        -     repeat list               [['G'],['C','C'],['M']]
       ṁ4     - mould like [1,2,3,4]          [['G'],['C','C'],['M'],['G']]
         F    - flatten                       ['G','C','C','M','G']
          ẋ€  - repeat €ach w times           [['G','G'],['C','C'],['C','C'],['M','M'],['G','G']]
            Y - join with line feeds          ['G','G','\n','C','C','\n','C','C','\n','M','M','\n','G','G']
              - implicit print                GG
                                              CC
                                              CC
                                              MM
                                              GG
```
[Answer]
# PHP, 85 Bytes
```
for($m=$argv;$i++<4;)for($c=$m[_2342[$i]]*$m[1];$c;)echo$c--%$m[1]?"":"\n",_GCMG[$i];
```
or
```
for($m=$argv;$i++<4;)for($c=$m[_2342[$i]];$c--;)echo"\n".str_pad("",$m[1],_GCMG[$i]);
```
[Online Versions](http://sandbox.onlinephpfunctions.com/code/cff5f84dd5595e66e64ba0052ad5d010c97ba969)
# PHP, 96 Bytes
```
<?[$n,$w,$G,$C,$M]=$argv;for(;$i<4;$i++)for($t=${"$n[$i]"};$t--;)echo"\n".str_pad("",$w,$n[$i]);
```
[Online Version](http://sandbox.onlinephpfunctions.com/code/a8b9676c4d0c543ce552a1197933205118616e22)
Expanded
```
[$n,$w,$G,$C,$M]=$argv; # $argv[0] must contain a file beginning with "GCMG"
for(;$i<4;$i++) # Take the first 4 values of the filename
for($t=${"$n[$i]"};$t--;) # How many rows should be printed
echo"\n".str_pad("",$w,$n[$i]); # print $w times the actual letter
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~67~~57 bytes
(Edit: now that matrices are allowed, no need to newline-join it.)
```
def s(w,g,c,m):g=['G'*w]*g;print g+['C'*w]*c+['M'*w]*m+g
```
[Answer]
# C# (150 bytes)
```
void S(int w,int g,int c,int m){P(w,g,'G');P(w,c,'C');P(w,m,'M');P(w,g,'G');}void P(int w,int i,char c){while(i-->0)Console.Write("\n".PadLeft(w,c));}
```
Ungolfed:
```
void SMores(int w, int g, int c, int m)
{
    Print(w,g,'G');
    Print(w,c,'C');
    Print(w,m,'M');
    Print(w,g,'G');
}
void Print(int w, int i, char c)
{
    while(i-->0)
        Console.Write("\n".PadLeft(w,c));
}
```
[Answer]
# C, 90 bytes (based on [Steadybox's answer](https://codegolf.stackexchange.com/a/116782/30000))
Renamed the variables and exploited the stringification preprocessor operator to cut down on the macro parameters. I hope posting this idea as its own answer is fine :)
```
#define F(x)for(i=x;i--;puts(""))for(j=w;j--;)printf(#x);
i,j;f(w,G,C,M){F(G)F(C)F(M)F(G)}
```
[TIO link](https://tio.run/nexus/c-gcc#HYzBCoMwEETv@Yqgl13YQG2PwZMQT36EtG7Z0KailgTEX2@aduDB8Bgm17eJJUzaQUJ@LSBtsmKMnd/bClWFf@nbaH2ROC8SNoY6oVVC3jJE6qmjAXcHPTroCgP@@pHLVD9HCYBqV7qEoTmRvpA@k27Kw5E/V36M9zWb@AU)
[Answer]
# Java, 138 bytes
```
String s(int w,int g,int c,int m){String b="";int i=-g-c,j;for(;i++<g+m;){for(j=0;j++<w;)b+=i<=-c|i>m?'G':i<=0?'C':'M';b+="\n";}return b;}
```
[Try it online!](https://tio.run/nexus/java-openjdk#NU6xboMwFNzzFU8stoVBJN3y4kZRhk6dMiYdwKHoodhE2ARVlG8nhqY33NPdvZNO33Ln4ADDdPIt2QocJ@uhlzNXC@uFjRheH4WKIpwtUkmVaFnjd9NypDjeVbFBMcyyVhnWwelRFLGinUr0L72bPftg26CyPTuyLftkGNLoYiMc29J3rYUCxwkC7l1xIw3O5z6cR0NXMDlZ/jfi/AW5gGEFL5x@nC9N2nQ@vYfcc1v2cOAidXydSXiTsJGwFgL/C0tzXI3TEw "Java (OpenJDK 8) – TIO Nexus")
Explanation:
```
String s(int w, int g, int c, int m) {
    String b = "";
    int i = -g - c, j;              // i is the layer
    for (; i++ < g + m;) {          // Repeat (G+C+M+G) times, starting from -g-c to m+g 
                                    //Layer 0 is the last chocolate layer
        
        for (j = 0; j++ < w;) {     // Repeat W times
            b += 
                i <= -c | i > m ? 'G': //If before the chocolate or after the marshmellow, output a G
                i <= 0 ? 'C' :      // Else if equal or before last chocolate layer output C
                'M';                //Otherwise output an M
        }
        b += "\n";
    }
    return b;
}
```
[Answer]
# Swift, ~~138~~ ~~137~~ ~~134~~ 130 bytes
Saved 7 bytes thanks to ***@Kevin***
```
let f=String.init(repeating:count:)
let r={w,g,c,m in f(f("G",w)+"\n",g)+f(f("C",w)+"\n",c)+f(f("M",w)+"\n",m)+f(f("G",w)+"\n",g)}
```
Two functions that return the expected value: `f` is a helper function and `r` is the actual lamdba-like function that generates the output. ***Usage:*** `print(r(10,3,2,1))`
**[Check it out!](http://swift.sandbox.bluemix.net/#/repl/58f5b479da4eb37edb42a2ac)**
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
ṁ4“GCMG”x×Y
```
[Try it online!](https://tio.run/nexus/jelly#@/9wZ6PJo4Y57s6@7o8a5lYcnh75//9/Yx0FIx0Fw/@GBgA "Jelly – TIO Nexus")
### How it works
```
ṁ4“GCMG”x×Y  Main link. Left argument: g, c, m. Right argument: w
ṁ4           Mold 4; repeat g, c, m until length 4 is reached. Yields [g, c, m, g].
  “GCMG”x    Repeat 'G' g times, then 'C' c times, then 'M' m times, and finally
             'G' g times. This yields a string.
         ×   Multiply each character w times. This is essentially a bug, but
             Jelly's × behaves like Python's * (and vectorizes), so it can be
             abused for character repetition.
          Y  Join, separating by linefeeds.
```
[Answer]
# JS (ES6), 111 bytes
```
n=`
`,G="G",C="C",M="M",r=(s,t)=>s.repeat(t),(w,g,c,m)=>r(r(G,w)+n,g)+r(r(C,w)+n,c)+r(r(M,w)+n,m)+r(r(G,w)+n,g)
```
[Answer]
# [Convex](https://github.com/GamrCorps/Convex), 20 bytes
```
"GCM"f*]z{~N+*}%(_@@
```
[Try it online!](https://tio.run/nexus/convex#@6/k7uyrlKYVW1Vd56etVauqEe/g8P///2hjBSMFw9j/hgYA "Convex – TIO Nexus")
[Answer]
# JavaScript (ES6), 91 bytes
Includes trailing newline.
```
f=
(w,g,c,m)=>(b=(`G`[r=`repeat`](w)+`
`)[r](g))+(`C`[r](w)+`
`)[r](c)+(`M`[r](w)+`
`)[r](m)+b
console.log(f(10,3,2,1))
```
[Answer]
# JS (ES6), 87 bytes
```
x=(w,g,c,m)=>(f=>f`Gg`+f`Cc`+f`Mm`+f`Gg`)(([[x,y]])=>(x.repeat(w)+`
`).repeat(eval(y)))
```
`x` acts as a standalone lambda function. The result has a trailing newline.
Try in a snippet:
```
x=(w,g,c,m)=>(f=>f`Gg`+f`Cc`+f`Mm`+f`Gg`)(([[x,y]])=>(x.repeat(w)+`
`).repeat(eval(y)))
function doTheThing() {
  document.getElementById("target").innerText = x(
    document.getElementById("width").value,
    document.getElementById("graham").value,
    document.getElementById("chocolate").value,
    document.getElementById("marshmallow").value,
  )
}
```
```
Width: <input id='width' value='10'>
Graham: <input id='graham' value='3'>
Chocolate: <input id='chocolate' value='2'>
Marshmallow: <input id='marshmallow' value='1'>
<pre id='target'></pre>
<button onclick='doTheThing()'>Do the thing</button>
```
[Answer]
# F# (148 99 bytes)
```
let s w q="GCMG"|>Seq.iteri(fun i c->for j in 1..(q|>Seq.item(i%3))do printf"%A"("".PadLeft(w,c)))
```
Usage:
```
s 10 [2;3;4]
```
Ungolfed:
```
let smores width quantities =
    "GCMG"
    |>Seq.iteri(fun i char ->
        for j in 1..(quantities|>Seq.nth(i%3))
            do printf "%A" ("".PadLeft(width,char))) 
```
I'm still new to F#, so if I did anything weird or stupid, please let me know.
[Answer]
# JavaScript ES6, ~~69~~ ~~68~~ 66 bytes
Thanks @Arnauld for golfing off one byte
```
a=>b=>"GCMG".replace(/./g,(c,i)=>`${c.repeat(a)}
`.repeat(b[i%3]))
```
[Try it online!](https://tio.run/nexus/javascript-node#S7P9n2hrl2Rrp@Tu7OuupFeUWpCTmJyqoa@nn66jkayTqWlrl6BSnQySSE0s0UjUrOVKgHGSojNVjWM1Nf8n5@cV5@ek6uXkp2ukaRgaaGpEG@sY6RiB5AA)
## Explanation
Receives input in curried format `(Width)([Graham,Chocolate,Marshmallow])`
Using `.replace(/./g,...)` replaces each character in the string `GCMG` with the return value from the function `(c,i)=>`${c.repeat(a)}
`.repeat(b[i%3])`
``${c.repeat(a)}
`` creates each line of the graham cracker with a newline appended
`.repeat(b[i%3])` repeats this line the required number of times
[Answer]
# Google Sheets, 103 Bytes
Anonymous Google Sheets worksheet formula that takes input from cells `A1,B1,C1,D1` and outputs a s'more to the calling cell
```
=REPT(REPT("G",A1)&"
",B1)&REPT(REPT("C",A1)&"
",C1)&REPT(REPT("M",A1)&"
",D1)&REPT(REPT("G",A1)&"
",B1
```
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), ~~32~~ 17 bytes
**Solution:**
```
{x#',/4#y#'"GCM"}
```
[Try it online!](https://tio.run/##y9bNz/7/v7pCWV1H30S5Ulldyd3ZV6k22tDAWsPY2sjaUDP2/38A "K (oK) – Try It Online")
**Example:**
```
> {x#',/4#y#'"GCM"}[10;(3;2;1)]
("GGGGGGGGGG"
 "GGGGGGGGGG"
 "GGGGGGGGGG"
 "CCCCCCCCCC"
 "CCCCCCCCCC"
 "MMMMMMMMMM"
 "GGGGGGGGGG"
 "GGGGGGGGGG"
 "GGGGGGGGGG")
```
**Explanation:**
```
{x#',/4#y#'"GCM"} / solution
{               } / lambda function with implicit parameters x and y
        y#'"GCM"  / take input each-both (#') number "G", "C" and "M"
      4#          / 4-take, ("GGG";"CC";"M") -> ("GGG";"CC";"M";"GGG")
    ,/            / flatten list into string, ("GGG";"CC";"M";"GGG") -> "GGGCCMGGG"
 x#'              / width-take each (10#"G" -> "GGGGGGGGGG" etc)
```
**Notes:**
* -15 bytes as looking through other answers it seems acceptable to take parameters as `[width;(graham;chocolate;marshmallow)]`, which means I don't have to explicitly list the parameters to the function
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), ~~12~~ 11 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
GCMG｛²└＠＊×Ｐ
```
[Try it here!](https://dzaima.github.io/Canvas/?u=R0NNRyV1RkY1QiVCMiV1MjUxNCV1RkYyMCV1RkYwQSVENyV1RkYzMA__,i=JTVCMyUyQzIlMkMxJTVEJTBBMTA_,v=3)
Explanation:
```
GCMG     push "GCMG"
  {      for each character
   ²       push the counter.                     Stack: [(input2, input1), "G", 1]
    └      swap two items below ToS.             Stack: [(I1, I2), "G", I1, 1]
     @     get the counter'th item of the input. Stack: [(I1, I2), "G", I1[1] ]
      *    repeat horizontally.                  Stack: [(I1, I2), "G" * I1[1] ]
       ×   repeat vertically.                    Stack: [(I2, I1), I2 × "G" * I1[1] ]
        P  print that.                           Stack: [(I2, I1)]
```
]