text:
What is the standard scratch?
In golf, the standard scratch of a course is calculated using this formula:
(3*num_of_3_par_holes + 4*num_of_4_par_holes + 5*num_of_5_par_holes) - difficulty_rating

Your task is to calculate the standard scratch of a golf course, given these 4 inputs.
You should take input in any standard form in the format
[num_of_3_pars, num_of_4_pars, num_of_5_pars], difficulty rating

but if it saves bytes, you many take input in a different way.
You should output the final result by any accepted method on meta, such as returning from a function.
Shortest code wins because this is code-golf!

Will all inputs be integers and at least 1? (Also, will the output always be positive?)

Can we take inputs reversed?

As trivial as this is, a few test cases would be nice.

Interesting, a code golf about golf.

Scratch, 145 bytes
-2 thanks to boboquack
-??? because writing it in Oto is shorter than English
(Because Scratch is the standard scratch.)

Here's a sample run:
.

Jelly, 6 bytes
JḊ~æ.N

Try it online!
How it works
JḊ~æ.N  Main link. Argument: [a, b, c, d]

J       Indices; yield [1, 2, 3, 4].
 Ḋ      Dequeue; yield [2, 3, 4].
  ~     Bitwise NOT; yield [-3, -4, -5].
     N  Negate; yield [-a, -b, -c, -d].
   æ.   Dot product; yield
        (-3)(-a) + (-4)(-b) + (-5)(-c) + (-d) = 3a + 4b + 5c - d.

Java (OpenJDK 8), 24 bytes
(a,b,c,d)->a*3+b*4+c*5-d

Try it online!

Yeah, shorter than Python \o/

This provides proof that Java and Javascript are the same language!

Mathematica, 13 14 bytes
{3,4,5,-1}.#&

Thanks to @GregMartin. Take input as a length-4 list.

Thanks to "but if it saves bytes, you many take input in a different way", I think you should take input as a length-4 list and shorten the second solution to {3,4,5,-1}.#& (13 bytes).

You are right..

Haskell, 22 bytes
(a#b)c d=3*a+4*b+5*c-d

Try it online! Usage: (3#2)5 7 yields 35.
This not so nice input format is one byte shorter than the straight forward solution:
f a b c d=3*a+4*b+5*c-d

Point-free and nice input format: (23 bytes)
(-).sum.zipWith(*)[3..]

Try it online! Bind to f and call with f [3,2,5] 7.

Julia 0.5, 15 bytes
!v=v⋅[3:5;-1]

Try it online!

Is ⋅ three bytes, or am I miscounting? Would .* be an improvement? edit: Never mind—missed the summing part.

Yes, three bytes. .* only performs element-wise multiplication; it doesn't take the sum of the products.

Python 3, 28 bytes
lambda a,b,c,d:3*a+4*b+5*c-d

Try it online!

Jelly, 10 7 bytes
3r5×⁸S_

Try it online!
-3 bytes thanks to Erik The Outgolfer!
How it works!
3r5×⁸S_  Main link: a, the pars as a list and b, the difficulty rating

     S   The sum of
3r5        [3, 4, 5]
   ×       each element times
    ⁸      the left argument (a)
      _  Subtract the right argument (b)

Standard way to make lists is omitting [] but you can use 3r5×⁸S_ to golf this more (3r5 -> [3, 4, 5], ⁸ = left argument to differentiate it from the S, × is commutative).

Javascript, 24 bytes
(a,b,c,d)=>3*a+4*b+5*c-d

Perl6, 16 characters
3* *+4* *+5* *-*

(Yepp, that is a sub.)
Sample run:
> say 3* *+4* *+5* *-*
{ ... }

> say (3* *+4* *+5* *-*)(4, 3, 2, 1)
33

Try it online!

C#, 24 bytes
(a,b,c,d)=>a*3+b*4+c*5-d

Octave, 14 bytes
@(a)[3:5 -1]*a

Try it online!
About twice as long as the MATL answer. I initially literally ported this to MATL, but it turned out iY* is longer than just *s. Note that the input a, containing the holes in order and then the difficulty, should be a column vector.

As question says you can take the input in any format if it saves bytes, this works for 14: @(a)[3:5 -1]*a. Input is a column vector of [3 holes; 4 holes; 5holes; difficulty]

@TomCarpenter Oh, I thought the list + number part was compulsory. It's a bit oddly phrased: "You should... but you may". I guess I'll amend my answer then.

x86-64 Machine Code, 14 bytes
8D 3C 7F 8D 14 92 8D 04 B7 01 D0 29 C8 C3

A function following the System V AMD64 calling convention (ubiquitous on Gnu/Linux systems) that takes four integer parameters:

EDI = num_of_3_par_holes
ESI = num_of_4_par_holes
EDX = num_of_5_par_holes
ECX = difficulty_rating

It returns a single value, the standard scratch, in the EAX register.
Ungolfed assembly mnemonics:
; int ComputeStandardScratch(int num_of_3_par_holes,
;                            int num_of_4_par_holes,
;                            int num_of_5_par_holes,
;                            int difficulty_rating);
lea   edi, [rdi+rdi*2]    ; EDI = num_of_3_par_holes * 3
lea   edx, [rdx+rdx*4]    ; EDX = num_of_5_par_holes * 5
lea   eax, [rdi+rsi*4]    ; EAX = EDI + (num_of_4_par_holes * 4)
add   eax, edx            ; EAX += EDX
sub   eax, ecx            ; EAX -= difficulty_rating
ret                       ; return, leaving result in EAX

Just a simple translation of the formula. What's interesting is that this is essentially the same code that you would write when optimizing for speed, too. This really shows the power of the x86's LEA instruction, which is designed to load an effective address, but can do addition and scaling (multiplication by low powers of 2) in a single instruction, making it a powerful multi-purpose arithmetic workhorse.

dc, 14 characters
?3*?4*+?5*+?-p

The numbers need to be passed on separate lines.
Sample run:
bash-4.4$ dc -e '?3*?4*+?5*+?-p' <<< '4
> 3
> 2
> 1'
33

Try it online!

HP-15C (RPN), 14 bytes
Instruction hex codes:
41 C4 F5 FC C5 F4 FC FA C5 F3 FC FA 31 FB

Readable version:
001 {       44  1 } STO 1
002 {          33 } R⬇
003 {           5 } 5
004 {          20 } ×
005 {          34 } x↔y
006 {           4 } 4
007 {          20 } ×
008 {          40 } +
009 {          34 } x↔y
010 {           3 } 3
011 {          20 } ×
012 {          40 } +
013 {       45  1 } RCL 1
014 {          30 } −

The four numbers are loaded into the stack in order before running the program.

Nice first answer. Welcome to PPCG!

Julia, 21 bytes
f(a,b,c,d)=3a+4b+5c-d

Try it online!

Swift 3, 25 19 bytes
I realised you do not need the var f=, because you can call it like a Python lambda:
{$0*3+$1*4+$2*5-$3}

Test it online!
Usage: {$0*3+$1*4+$2*5-$3}(a,b,c,d), where a,b,c,d are the parameters.

Neim, 7 bytes
'πS

Explanation:
'π         Push 345
           The character ' pushes the next character's index in the codepage plus 100.
           The characters ", + and * do that same thing except add a different number.
           This means that in Neim, all 3 digit numbers can be expressed with 2 characters.
           This commit was pushed 8 days before the answer was posted.
          Get the characters
          Vectorised multiply with the input
           Sum the resulting list
     S    Subtract the input

Alternative program: 3ᛖS
Instead of pushing 345 and then getting the characters, creates the array [1 2 3] using 3, then adds 2 to each element with ᛖ.
Try it online!

This commit was pushed 8 days before the answer was posted. well, you don't actually need this.

@EriktheOutgolfer Sure I don't. But I also don't need the explanation. Would you like me to remove that?

Basically you don't have to worry about non-competing since meta consensus changed.

@EriktheOutgolfer I do worry about non-competing because the meta consensus is subjective and unclear. But in this case, there's no reason to complain about it being there. You're using up more time than you otherwise would you didn't post that comment.

For some reason, most Neim chars in inline code blocks look like ? boxes.

@CalculatorFeline That's probably because your browser doesn't support the characters. Here is a screenshot.

Chrome 58 Mac. For some reason non-inline code blocks work perfectly and so does 3. How strange.

C (gcc), 30 bytes
e;f(a,b,c,d){e=3*a+4*b+5*c-d;}

Try it online!

No need for an extra variable. Just assign to a.

,,,, 12 bytes
↻5×↻4×↻3×↻-#

Explanation
Take input 4, 3, 2, 1 for example.
↻5×↻4×↻3×↻-#

              implicit input                  [4, 3, 2, 1]
↻             rotate the stack clockwise      [1, 4, 3, 2]
 5            push 5                          [1, 4, 3, 2, 5]
  ×           pop 2 and 5 and push 2 * 5      [1, 4, 3, 10]
   ↻          rotate the stack clockwise      [10, 1, 4, 3]
    4         push 4                          [10, 1, 4, 3, 4]
     ×        pop 3 and 4 and push 3 * 4      [10, 1, 4, 12]
      ↻       rotate the stack clockwise      [12, 10, 1, 4]
       3      push 3                          [12, 10, 1, 4, 3]
        ×     pop 4 and 3 and push 4 * 3      [12, 10, 1, 12]
         ↻    rotate the stack clockwise      [12, 12, 10, 1]
          -   pop 10 and 1 and push 10 - 1    [12, 12, 9]
           #  pop 12, 12, 9 and push the sum  [33]
              implicit output

Brachylog, 18 16 bytes
∧5⟦₁↺b;?z×ᵐġ₃+ᵐ-

Try it online!
-2 thanks to Fatalize.

∧5⟦₁↺b;?z×ᵐġ₃+ᵐ- is 2 less bytes

@Fatalize It would've been 3 less bytes if there wasn't a bug with leading integer and input.

Excel VBA, 20 Bytes
Anonymous VBE immediate window function that takes input from the range [A3:A6] of which [A3:A5] represent the number of 3,4 and 5 par holes, respectively and [A6] represents the difficulty. Outputs to the VBE immediate window
?[3*A3+4*A4+5*A5-A6]

The above is a condensed version of the call
Debug.Print Application.Evaluate("=3*A3+4*A4+5*A5-A6")

Where "=3*A3+4*A4+5*A5-A6" is given to be the formula of an anonymous cell, as indicated by the [...] wrapper, and ? is the deprecated version of the Print  call with an implicit Debug. by context
More fun Version, 34 Bytes
Anonymous VBE immediate window function with same I/O conditions as above.
?[SUMPRODUCT(A3:A5,ROW(A3:A5))-A6]

The above is a condensed version of the call
Debug.Print Application.Evaluate("=SUMPRODUCT(A3:A5,ROW(A3:A5))")

Where "=SUMPRODUCT(A3:A5,ROW(A3:A5))" is given to be the formula of an anonymous cell, as indicated by the [...] wrapper, and ? is the deprecated version of the Print  call with an implicit Debug. by context. In this version, the range of [A3:A5] and the row numbers of that range (ROWS(A3:A5)) are passed as arrays
Excel Version, 18 bytes
Of course, the versions above lend themselves thusly to excel versions of
=3*A3+4*A4+5*A5-A6

and
=SUMPRODUCT(A3:A5,ROW(A3:A5))-A6

R, 25  23 bytes
cat(c(3:5,-1)%*%scan())

Try it online!

sum(scan()*3:5)-scan() is slightly smaller

thank you. I usually don't try scan when there are multiple inputs like this, but whaddya know!

Cubix, 36 bytes
w;r5*U4I;I3*r;UW;;r;<\r/;r-I/+p+O@;w

Try it online!
      w ; r
      5 * U
      4 I ;
I 3 * r ; U W ; ; r ; <
\ r / ; r - I / + p + O
@ ; w . . . . . . . . .
      . . .
      . . .
      . . .

Watch It Run
A fairly linear program that winds back around onto itself a few times.  Basic steps:

I3*r;U; get the first input, multiply by 3 and clean up stack
I4*/r\ get next input and multiply by 4. Rotate result down.
Iw5*Ur;w<;r;;W get next input, multiply by 5 and clean up the stack
I-r;w; get last input, subtract from par 5 result and clean up stack
/+p+O\@ add to par 4 result, bring par3 result to top add, output and halt

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

Try it online!
Takes input and prints output as ASCII characters; for example, the value 99 would be represented as c.
Explanation:
,                                       Take the first input in Cell 0
 [      ]                               While the data being pointed to (Cell 0) is nonzero
  ->+++<                                Decrement Cell 0 and add 3 to Cell 1
                                        Now 4 times the first input is in Cell 1
         ,                              Take the second input in Cell 0
          [->++++<]                     Add 4 times the second input to Cell 1
                   ,[->+++++<]          Take the third input in Cell 0 and add five times its value to Cell 1
                              ,         Take the fourth input in Cell 0
                               [    ]   While the data being pointed to (Cell 0) is nonzero
                                ->-<    Decrement Cells 0 and 1
                                     >. Print the value in Cell 1

Gallina, 38 bytes
Definition f a b c d := 3*a+4*b+5*c-d.

Husk, 10 9 bytes
`-Σz*d345

Try it online!

QBIC, 14 bytes
?:*3+:*4+:*5-:

Functionally equivalent to this.

Befunge, 15 bytes
&3*&4*+&5*+&-.@

Try it online!

Japt, 12 bytes
*3+V*4+W*5-X

Test it

Braingolf, 14 bytes
3*>4*>5*>>++,-

Try it online!

Batch, 28 bytes
@cmd/cset/a%1*3+%2*4+%3*5-%4

Can't believe I'm tying with Python!

Just curious, do you need the cmd/c - if the rest is in a batch file won't it just work?

@JerryJeremiah set/a normally doesn't print its result, so I would have to assign it to a variable and echo it, which costs far too many bytes. However, when you use it interactively then it does print the result. Invoking cmd/c fools it into printing the result.

Would the rules require the @ sign, which only hides the command?

@trlkly I'm not actually sure, so I've been erring on the side of caution.

cQuents, 14 bytes
#|1:3A+4B+5C-D

Try it online!
Input is 3par 4par 5par diff. cQuents is not at all built for this type of problem, but it still did fairly well.
Explanation
#|1               Append 1 to the end of the user input - call it n
   :              Mode: sequence
    3A+4B+5C-D    Each item in the sequence equals the first input times three plus
                  the second input times four plus the third input times five minus
                  the fourth input. The last input, n, which came from the program's
                  parameters, prints the nth item in the sequece.

05AB1E, 7 bytes
3LÌ*O²-

Try it online!

You can replace 3L with ā as the first input will be a list of length 3 anyway.

CJam, 12 bytes
{6,3>.*:+\-}

Try it online!
-1 thanks to Challenger5.
Takes input as difficulty rating [num_of_3_pars num_of_4_pars num_of_5_pars].

Use 6,3> instead of 345Ab to save a byte.

Pyth, 9 bytes
-s*V}3 5E

Try it here.
Takes input as difficulty rating\n[num_of_3_pars, num_of_4_pars, num_of_5_pars].

The code you posted and the TIO don't match.

@jacoblaw Sorry that's what you get for writing code by hand >_<

GolfScript, 23 bytes
~[.;3,]zip{~3+*}%{+}*\-

Try it online!
Takes input as difficulty rating [num_of_3_pars num_of_4_pars num_of_5_pars].

PHP>=7.1, 43 bytes
[,$x,$y,$z,$d]=$argv;echo$x*3+$y*4+$z*5-$d;

PHP Sandbox Online

MATL, 7 bytes
3:5*si-

Try it online!
Input vector times range 3:5 minus the second input. Contrary to my Octave answer, it's actually shorter to have the inputs as two separate inputs, and shorter to element-wise multiply, then sum, than to do a direct dot product.

Pyt, 13 8 bytes
35Ř←*Ʃ←-

Takes as input from stdin inputs separately in the following order:
[num_of_3_pars,num_of_4_pars,num_of_5_pars], difficulty_rating

K (ngn/k), 12 bytes
{-y-/x*3+!3}

Try it online!
Called like f[1 2 3;4]. Takes the number of par 3/4/5 holes as one list of three values, and the difficulty rating as the second arg.

x*3+!3 generate 3 4 5, multiplying by the first input
-y-/ equivalent to (-y)+/x, or (+/x)-y. In this instance, the leading - negates the entire y-/... expression.

Vyxal as, 8 7 bytes
-1 thanks to Aaron Miller
2ʀ3+uJ*

Takes input as par3 \n par4 \n par5 \n difficulty.
Try it Online!
2ʀ3+uJ*
2ʀ        # Push the range [0, 1, 2]
  3+      # Add 3: [3, 4, 5]
    uJ    # Append -1: [3, 4, 5, -1]
      *   # Multiply the list by its counterpart in...
          # the (implicit) input, and...
          # Print the sum of the result (s flag)

7 bytes

MMIX, 24 bytes (6 instrs)
00000000: 2a020202 28000000 26020203 2a000100  *£££(¡¡¡&££¤*¡¢¡
00000010: 22000002 f8010000                    "¡¡£ẏ¢¡¡

scratch 4ADDU $2,$2,$2      // p5 *= 5
        2ADDU $0,$0,$0      // p3 *= 3
        SUBU  $2,$2,$3      // p5 -= diff
        4ADDU $0,$1,$0      // p3 += 4 * p4
        ADDU  $0,$0,$2      // p3 += p5
        POP   1,0           // return p3

I ordered the instructions to avoid as many short-term data dependencies as possible.

BRASCA, 18 bytes
Takes input as <3-par>,<4-par>,<5-par>,<difficulty>
Ci',G,3*$4*+$5*+$-

Try it online!
Explanation
C                   - Set implicit output to number mode
 i',G               - Use numbers instead of charcodes for 0-9. Then split by commas.
     ,              - Reverse stack so the 3par is at the top.
      3*            - 3par * 3
        $4*+        - 4par * 4, then add to 3par
            $5*+    - 5par * 5, then add to total
                $-  - total - difficulty
<implicit>          - Print it

Factor, 23 22 bytes
[ { 3 4 5 } v. - neg ]

Try it online!
-1 thanks to @Bubbler
The quotation takes the input as difficulty list.

{ 3 4 5 } v. Take the dot product between the input list and { 3 4 5 }.
- neg Subtract the difficulty rating from the dot product.

- neg is one byte shorter than swap -.

TI-Basic, 19 bytes
Prompt A,B,C,D:3A+4B+5C-D

Alternatively (21 bytes):
3Ans(1)+4Ans(2)+5Ans(3)-Ans(4

Add++, 27 bytes
D,g,@@@@!,3 4 5 1ECBcB*0$_s

Try it online!
How it works
D,g,        - Create a function called g...
    @@@@    - ...that takes 4 arguments...
    !,      - ...as a list. e.g.     [4 3 2 1]
    3 4 5 1 - Push 3 4 5 1; STACK = [[4 3 2 1] 3 4 5 1]
    EC      - Collect;      STACK = [[4 3 2 1] [3 4 5 1]]
    Bc      - Zip;          STACK = [[4 3] [3 4] [2 5] [1 1]]
    B*      - Products;     STACK = [12 12 10 1]
    0$_     - Negate;       STACK = [12 12 10 -1]
    s       - Sum;          STACK = [33]

Ly, 13 bytes
3n*4n*5n*&+n-

Try it online!

Desmos, 21 bytes
f(a,b,c,d)=3a+4b+5c-d

Try It On Desmos!
Input is a function where \$a=3\ \text{par holes},b=4\ \text{par holes},c=5\ \text{par holes},d=\text{difficulty rating}\$
Example Test Case:

Stax, 13 bytes
╨E⌡u╥Diüaë¬~▼

Run and debug it
If I can find a way to read in the array and the number as is instead of evaluating them from string, this program will be shorter.

PHP, 66 bytes
list($a,$b,$c,$d,$e)=$argv;echo eval("return 3*$b+4*$c+5*$d-$e;");

first attempt:
PHP, 145 bytes
<?php $a=$_SERVER['argv'];$b=[0,3,4,5,-1];$r=array_map(function($x,$y){return$x*$y;},$a,$b);echo array_reduce($r,function($i,$c){return$i+=$c;});

Ungolfed:
<?php
$a = $_SERVER['argv'];
$b = [0,3,4,5,-1]; // the first element always contains the filename, and is hereby disregarded
$r = array_map(function($x,$y){return $x*$y;},$a,$b);
echo array_reduce($r, function ($i,$c) {return $i+=$c;});

With 10, 5 and 3 holes respectivly, and a difficulty of 5, it's to be called with $ php codegolf.php 10 5 3 5
Note: it throws a warning, as we multiply a string with zero. Add 1 byte for the error-supression-operator to get rid if that.

Julia 1.0, 13 bytes
v->[3:5;-1]'v

Try it online!
improvement of Dennis's Julia 0.5 answer


text:
Rectangular difference
In this challenge, you are given two overlapping rectangles, and you need to calculate the rectangles created by removing one from the other.
For example, if you remove the red rectangle from the black one:

You end up with one of the following two rectangle sets:

You'll also need to handle the following:

To be more explicit:

You will input the coordinates of two rectangles, A and B.
You need to output the fewest non-overlapping rectangles that cover all of the area of A without B.  Any possible covering is allowed
Rectangular coordinates are passed as 4 integers.  You can pass them in two pairs (representing the two corner points), or as a tuple/list of 4 integers.  Your inputs and outputs need to be consistent.
A and B will not necessarily overlap or touch, and each will have an area of at least 1

Test cases:
[(0 0) (5 5)] [(3 4) (8 7)]   -> [(0 0) (5 4)] [(0 4) (3 5)] # or [(0 0) (3 5)] [(3 0) (5 4)]
[(2 4) (10 11)] [(5 5) (6 6)]  -> [(2 4) (10 5)] [(2 5) (5 6)] [(6 5) (10 6)] [(2 6) (10 11)]    #Other sets of 4 rectangles are possible
[(3 3) (8 8)] [(0 1) (10 8)]   ->    #No rectangles should be output
[(0 0) (5 5)] [(1 1) (10 2)]   -> [(0 0) (1 5)] [(1 0) (2 1)] [(2 0) (5 5)]  #Other sets of 3 rectangles are possible
[(1 5) (7 8)] [(0 0) (1 10)]   -> [(1 5) (7 8)]  #Only possible output
[(4 1) (10 9)] [(2 5) (20 7)]   -> [(4 1) (10 5)] [(4 7) (10 9)]  #Only possible output
[(1 1) (8 8)] [(0 6) (9 9)]     -> [(1 1) (8 6)]   #Only possible output

This is a code-golf, so make your code as short as possible!

Related.

can we assume that the given input {(x1, y1), (x2, y2)} holds x1 < x2 and y1 < y2?

Yep.  The rectangle will have an area of 1, and you can order the coordinates in any order you like.

Is edge thick? When rectangle defined is edge included?

The edge has 0 thickness.

Seems, that only one edge is included. Rectangle formula is (x1 <= x < x2) && (y1 <= y < y2) ?

Another words, seems that [(0 0) (2 2)] is 2x2 rectangle, but not 3x3

The way I like to think of it is that the rectangle consists of lines of width 0 that go from (x1, y1) to (x2, y1) to (x2, y2) to (x1, y2).  Whether or not the rectangle "includes" the point (x1, y1) is largely irrelevant.

Let us continue this discussion in chat.

Python 2, 375 360 345 343 bytes
from itertools import*;P=product
def f(S,M):(l,t),(r,b)=S;(L,T),(R,B)=M;u,v,x,y=(L>=r)+(l<L),(T>=b)+(t<T),(R>=r)+(l<R),(B>=b)+(t<B);return[S]if v==y!=1or u==x!=1else[list(p(p(*zip(*(S+M))),repeat=2))[[43,197,6,199,9,231,142,229,53,189,134,181][int(i,36)]]for i in '38,491,258,2058,8,4B,28,208,7,41,27,461,,4,2,4A'.split(',')[u+2*v+4*x+8*y-12]]

Try it online!
EDITS: -15 from suggestions from @notjagan; another -15 by re-encoding the array of solution rectangles to int36 format and a short lookup table; another -2 by replacing product with p as per @musicman.
A function that takes two rectangles, each rect being a tuple of ((left,top), (right,bottom)); returns a list of the resulting rectangles.
The basic strategy:
     |     |
 0,0 | 1,0 | 2,0
-----A-----+-----
     |     |
 0,1 | 1,1 | 2,1
-----+-----B-----
     |     |
 0,2 | 1,2 | 2,2
     |     |

In the above diagram, the points A and B are the upper left and lower right, respectively, of the 'Source' rectangle (the first rect).
We find the placement of each of the the upper left (u,v) and lower right (x,y) of the 'Mask' rectangle in that grid.
If both these points are in the first or last column; or first or last row; then there is no overlap; and we can return just the Source rect.
Otherwise, there are 16 cases remaining; for example, the OP's first example is the case we can label (1,1),(2,2). Each case can be mapped to a set of resulting rectangles whose corners are always coordinates with horizontal values in either Source rectangles left,right, or the Mask rectangles left,right; and similarly for the vertical values, the Source's top,bottom or the masks.
For example, for the (1,1),(2,2) case, the rectangles would be ((l,t),(T,r)) and ((l,T),(R,b)), where l,t,r,b and L,T,R,B are the left, top, right and bottom of the Source and Mask rectangles, respectively.
So we can create a lookup table that maps the coordinates to the set of all such possible combinations (which is what the product(product(*zip(*))) bit is about) to a set of rectangles that should be provided for each of the cases (which, after some golfy-decompression, is what the rest of the list stuff is about).

-15 bytes by making various golfing improvements, or -18 bytes using strings in Python 3.

You can snip off two more bytes by doing p=product and replacing product(product with p(p

JavaScript, 115 bytes
f=a=>b=>b.some((n,i)=>(a[i^2]<n)^i/2)?[a]:b.map((n,i)=>a[i&1]<n&&n<a[i|2]&&(p=[...a],p[i^2]=a[i]=n,p)).filter(x=>x)

overlapping version:
f=a=>b=>b.some((n,i)=>(a[i^2]<n)^i/2)?[a]:b.map((n,i)=>a[i&1]<n&&n<a[i|2]&&(p=[...a],p[i^2]=n,p)).filter(x=>x)

Input in following format: f([1,1,8,8])([0,6,9,9])

Denote input as ((x1, y1), (x2, y2)), ((x3, y3), (x4, y4))
If any one of following conditions is  met, return first rectangle as is:

x3 > x2
x4 < x1
y3 > y2
y4 < y1

otherwise

If x1 < x3 < x2 then we generate a rectangle ((x1, y1), (x3, y2)); and set x1 := x3
If x1 < x4 < x2 then we generate a rectangle ((x4, y1), (x2, y2)); and set x2 := x4
If y1 < y3 < y2 then we generate a rectangle ((x1, y1), (x2, y3)); and set y1 := y3
If y1 < y4 < y2 then we generate a rectangle ((x1, y4), (x2, y2)); and set y2 := y4

This is a promising approach; but it currently fails sometimes, e.g., when the Mask rectangle has no overlap with the Source rectangle; e.g. f([0, 30, 10, 40])([5, 1, 6, 2]) should return [[0, 30, 10, 40]] but instead returns [[0,30,5,40],[6,30,10,40]]

@NathanMerrill ok, edited.

@tsh looks good!

Java, 268 bytes
class W{public static void main(String[]z) {int a[]={0,0,0,0},i,j,y[]={0,1,4,3,6,1,2,3,4,1,6,5,4,7,6,3};for(i=0;i<4;i+=1){for(j=0;j<4;j+=1){a[j]=Integer.parseInt(z[y[i*4+j]]);}if(a[0]<a[2] && a[1]<a[3]){for(j=0;j<4;j+=1){System.out.println(String.valueOf(a[j]));}}}}}

Ungolfed
class W{
    public static void main(String[]z) {
        int a[]={0,0,0,0},i,j,y[]={0,1,4,3,6,1,2,3,4,1,6,5,4,7,6,3};

        for(i=0;i<4;i+=1){
            for(j=0;j<4;j+=1){
                a[j]=Integer.parseInt(z[y[i*4+j]]);
            }
            if(a[0]<a[2] && a[1]<a[3]){
                for(j=0;j<4;j+=1){
                    System.out.println(String.valueOf(a[j]));
                }
            }
        }
    }
}

Pass input as arguments. Example
java -jar W.jar 0 0 5 5 3 4 8 7

Python 2, 272 bytes
lambda((a,b),(c,d)),((e,f),(g,h)):[([([[(a,b),(e,min(h,d))]]+[[(g,max(b,f)),(c,d)]]*2+[[(max(a,e),b),(c,f)]]*4+[[(a,h),(min(c,g),d)]])[m-1]for m in M&{1,2,4,8}]if M&{0}else[(a,b),(c,d)])for M in[{(x<e)*1+(x>g)*2+(y<f)*4+(y>h)*8 for x in range(a,c)for y in range(b,d)}]][0]

Try it online!
This works by testing every cell inside the first rectangle for leftness=1,aboveness=4,rightness=2,and belowness=8 w/r to the other, and ORing the result.  If the other does not intersect=0 with the first, then the original is returned, otherwise some combination of a left slice, right slice, upper slice and lower slice is returned, with accomodation for overlap.

source: Stack Exchange

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

authors: Евгений Новиков

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

sort: votes


text:
Compare the averages of my lists
Getting the average of a list  (e.g [2,6,7])

Get the length of the list: [2,6,7] -> 3
Sum the numbers in the list: 2 + 6 + 7 = 15.
Divide the sum by their count: 15 / 3 = 5.

You should compare the averages of two lists of positive integers N and M, by returning a value if N has a higher average, another value if M has a higher average, and another one in case of a tie.

I/O rules
All the standard Input and Output methods are allowed.
Input
You may take input as two separate lists, a nested list, or anything else you consider suitable for the task. Please specify the format.
Output
The values provided have to be distinct and must consist of at least one non-whitespace character. Also, they must be consistent between runs (a single value for N, a single value for M, a single value for Tie). Please specify those in your answer. The values can be non-empty Strings, Bool values, Integers, or anything you consider suitable.

Specs

The lists will not necessarily have equal length.

You are guaranteed that the lists are non-empty.

Test Cases
I chose the values N wins, M wins and Tie, which are pretty much self-evident.

N, M                     ->   Output     (Averages)

[7], [6]                 -> N wins  (N has 7, M has 6 )
[4,5], [4,4]             -> N wins  (N has 4.5, M has 4)
[2,3,4], [4,5,6]         -> M wins  (N has 3, M has 5)
[4,1,3], [7,3,2,1,1,2]   -> Tie     (both have 2.666...)
[100,390,1], [89,82,89]  -> N wins  (N has 163.666..., M has 86.666...)
[92,892], [892,92]       -> Tie     (lists are basically identical)
[10,182], [12,78,203,91] -> Tie     (both have 96)

Default Loopholes apply. Explanations are encouraged! This is code-golf, so the shortest code in bytes wins!

Sandbox.

if my language of choice only supports integers, can I take input multiplied by 1000? That way the calculated averages would still be accurate to 3 decimal places

@Mayube Yes, that is allowed

We have to return an output of at least 1 character. Does that mean we are required to return a character or a string? Or do you mean an output whose string value is of a least 1 character?

@OlivierGrégoire The output given must be at least 1 character long (you cannot return an empty string, but can return any String of at least 1 character, and also any non-whitespace character). IT's up to you.

@Mr.Xcoder Sorry, I must not have been explicit enough. Can I return other things than strings, if they have a string representation that is not the empty string? I think about numbers, for instance.

@OlivierGrégoire Yes, you can return integers as well (most of the answers do so)

Could you clarify then that the output can be something else than a string in the question directly? Because to me, the question says "you must return a string, and that string may not be empty".

@OlivierGrégoire I think it is pointless, but I will

Actually, 5 bytes
♂æi-s

Try it online!
1 for N > M, 0 for N = M, -1 for N < M.
Explanation:
♂æi-s Takes input in format [N, M]
♂æ    Map average
  i   Dump to stack in reverse
   -  Subtract
    s Get sign

Mathematica, 15 bytes
Order@@Mean/@#&

Try it online!
Function which expects a list of two lists. Mean/@# takes the arithmetic mean of each list in the input, then those means are passed into Order, which returns -1 if the first list wins, 0 if there is a tie, and 1 if the second list wins.

JavaScript (ES6), 52 50 bytes
(Saved 2 bytes thanks to @Shaggy.)
Here are two 50-byte solutions:
f=(N,M,a=eval(N.join`+`)/N.length)=>M?(a-f(M))/0:a

(N,M,A=a=>eval(a.join`+`)/a.length)=>(A(N)-A(M))/0

Returns Infinity for N, -Infinity for M, and NaN for a tie.
The first solution may require a bit of explanation due to the recursion:
On the first call to the function, a is initialized as the average of the N array:
a=eval(N.join`+`)/N.length

M has a value at this point, so the first part of the conditional expression is called:
M ? (a-f(M))/0 : a
     ----------

The function is called within this expression, this time substituting M for N.
On this second call to the function, a is initialized as the average of N –– which was M in the previous call.
Since there is no second parameter during this call to the function, the second part of the conditional expression is triggered, which returns the average:
M ? (a-f(M))/0 : a
                 --

We can now understand the expression better:
(a - f(M)) / 0

It's:
(the average of N  minus  the average of M) divided by 0

The difference between the averages will be a positive number, a negative number, or 0.
Dividing the difference by 0 results in Infinity, -Infinity, or NaN – providing the three distinct values as required.
Test Cases:

f=(N,M,a=eval(N.join`+`)/N.length)=>M?(a-f(M))/0:a

console.log(f([7], [6]                 )) // N wins  (N has 7, M has 6 )
console.log(f([4,5], [4,4]             )) // N wins  (N has 4.5, M has 4)
console.log(f([2,3,4], [4,5,6]         )) // M wins  (N has 3, M has 5)
console.log(f([4,1,3], [7,3,2,1,1,2]   )) // Tie     (both have 2.666...)
console.log(f([100,390,1], [89,82,89]  )) // N wins  (N has 163.666..., M has 86.666...)
console.log(f([92,892], [892,92]       )) // Tie     (lists are basically identical)
console.log(f([10,182], [12,78,203,91] )) // Tie     (both have 96)

Could you save a couple of bytes by moving A to the function parameters?

N=>M=>((A=a=>eval(a.join+)/a.length)(N)-A(M))/0

Mathematica, 21 bytes
Sign[Mean@#-Mean@#2]&

1 for # wins, -1 for #2 wins, 0 for tie.

or, equally long, Sign[#-#2&@@Mean/@#]&

MATL, 8 bytes
Soooo many modifiers (Y and Z). I can't find a way to make it shorter. sum / number_of_elements is three bytes. It might be a better way to do -ZS, but I can't find one.
YmiYm-ZS

Try it online!
           % Take first input implicitly
Ym         % Mean of that input
  i        % Grab second input
   Ym      % Mean of that input
     -     % Subtract
      ZS   % Sign

Returns 1 if the first input is larger, 0 if they tie, and -1 if the second input is larger.

Julia, 27 bytes
(x,y)->cmp(mean(x),mean(y))

Try it online!
Returns 1 if the first average is larger, -1 if second is, and 0 if they tie.

05AB1E, 9 bytes
1 if M wins, -1 if N wins and 0 for a tie.
vyOyg/}.S

Try it online!
Explanation
v           # for each y in list of lists
 yO         # sum y
   yg       # get length of y
     /      # divide
      }     # end loop
       .S   # compare

Python 2, 43 bytes
lambda p:cmp(*[sum(l)*1./len(l)for l in p])

Try it online!

Octave, 27 bytes
@(x,y)sign(mean(x)-mean(y))

Try it online!
Takes two vectors x.y as input, takes the mean of both vectors, and subtract one from the other. Get the sign of this, to get 1, 0 and -1 for the three different alternatives.

Python 2, 49 bytes
lambda N,M:cmp(1.*sum(N)/len(N),1.*sum(M)/len(M))

Try it online

"...[the three outputs] must be consistent between runs"

@JonathanAllan Fixed

APL (Dyalog), 11 bytes
Prompts for a list of two lists. Prints 1 if the left has higher average, 0 if they have the same average, and ¯1 if the right has higher average.
×-/(+/÷≢)¨⎕

Try it online!
⎕ prompt
(…)¨ apply the following tacit function to each:
 +/ the sum
 ÷ divided by
 ≢ the tally
-/ insert (and evaluate) a minus between them
× signum

Javascript, 81 66 58 56 bytes
saved 15 bytes thanks to Luke
saved 2 bytes thanks to Justin Mariner
n=>m=>Math.sign((a=b=>eval(b.join`+`)/b.length)(m)-a(n))

Tie is 0, M is 1 and N is -1. Called using currying syntax, eg. f([7])([6])

You can improve this by quite a few bytes: you can remove the variable assignment, you can use curry syntax, you can remove the alert, and you can easily sum arrays by using eval(a.join\+`). a=>(b=a.map(c=>eval(c.join`+`)/c.length))[0]-b[1]?b[0]>b[1]:0for 61 bytes. It takes input as an array of arrays, and outputs0for a tie,truefor  M andfalse` for N.

why don't you post it as your own answer?

You could save two more bytes by inlining the function (a) the first time it's used: n=>m=>Math.sign((a=b=>eval(b.join`+`)/b.length)(m)-a(n)).

Pyth, 10 8 7 6 bytes
Thanks @isaacg for saving a byte
._-F.O

Input is taken as a nested list, [N, M]. Outputs -1 if N < M, 1 if N > M and 0 if they are equal.
Try It Online

You can save a byte by replacing h.+ with -F

PHP, 68 bytes
<?foreach($_GET as$v)$r[]=array_sum($v)/count($v);echo$r[0]<=>$r[1];

Try it online!
PHP, 69 bytes
<?=($s=array_sum)($a=$_GET[0])/count($a)<=>$s($b=$_GET[1])/count($b);

Try it online!
spaceship operator
-1 less then , 0 tie , 1 greater then

Haskell, 65 43 Bytes
Saved 22 bytes thanks to nimi!
a x=sum x/sum[1|_<-x]
x#y=compare(a x)$a y

There has to be a much better way... But type conversions screwed me.
Usage
(#) [7] [6]

Returns GT if the first argument wins, LT if the second argument wins, and EQ if they tie.
Try it online!

No need to cast sum$x with f.. Also: length x can be replaced with sum[1|_<-x], so you can get rid off f completely: a x=sum x/sum[1|_<-x].

Ah nice! Didn't even think to do that.

... oh and in #: ...(a x)$a y.

@nimi Should have taken your own answer! Thanks for the tips.

... even better: go pointfree with your main function, then you can even save the name for it: (.a).compare.a.  Usage : (  (.a).compare.a ) [7] [6].

One more: [1|_<-x] is the same as (1<$x).

TI-Basic, 25 21 13 12 10 bytes
-2 bytes thanks to lirtosiast
:tanh(ᴇ9mean(L₁-mean(L₂

This can be golfed by using Ans instead of C: mean(L₁)>mean(L₂:Ans+3(mean(L₁)=mean(L₂, 21 bytes.

You can remove the ( and the ).

J, 10 bytes
*@-&(+/%#)

One list given on the left, one on the right.  Will return _1 if the left average is smaller, 1 if it's bigger, and 0 if they're equal

(+/%#) is a standard J fork for calculating the average of a list
& provides a variation on the dyadic fork.  it applies the right side (the average verb, in this case) to both arguments, and then passes them along to the verb on the left side, which in this case is...
*@- subtract followed by "sign of": so the right avg is subtracted from the left, and we are given the sign of the result -- _1, 1, or 0

Java (OpenJDK 8), 76 62 bytes
a->b->Math.signum(a.average().orElse(0)-b.average().orElse(0))

Try it online!
Since the input can be anything, I decided to take IntStreams as input. You can get such an input from a standard int[] with Arrays.stream(array).
The output is 1 for "N wins", -1 for "M wins", and 0 for tie.
Saves

-14 bytes from insights of both @Zircon and @Xanderhall!

The way you've chosen to take the input is really clever!

@DavidConrad I actually had the long version of this answer since yesterday (just prepend java.util.Arrays.stream(array).map(java.util.Arrays::stream)). It's only when I re-read the question today that I thought this input format is as valid as any.

Would .orElse(0) be a viable shortening of .getAsDouble()?

If you instead just take 2 streams for input, (a,b)->Math.signum(a.average().orElse(0)-b.average().orElse(0)); is 64 bytes

These are only good ideas, guys! Continue :p

I'm not entirely sure a->b-> counts. If you look at where you're testing it, you have to call 2 different functions to get it to work. It's not a 'single' function or function call.

@Xanderhall It's called currying, and it's widely accepted.

Jelly, 7 bytes
S÷Lµ€IṠ

A monadic link accepting a list of the two lists, N,M which returns:
[-1] for N;
[1] for M; and
[0] for a tie.
As a full program it prints the result (single item lists print their content only, so -1, 1, or 0).
Try it online!
How?
S÷Lµ€IṠ - Link: list of lists, [N,M]
   µ€   - perform the chain to the left for €ach (of N, M)
S       -   sum
  L     -   length
 ÷      -   divide (yields the average)
     I  - incremental differences (yields [avg(M) - avg(N)])
      Ṡ - sign (yields: [1] if avg(M)>avg(N); [-1] if avg(N)>avg(M); or [0] if equal)

I knew Jelly would be pretty good at this challenge, I just don't know the language very well. Well done on beating me :P

I'm not 100% sure this is not possible in, say, 5...!

@JonathanAllan I am? Basically to get the averages you map the average function, which isn't a builtin yet, so you use the shortest (I suppose) counterpart, S÷L, and then you convert it to single-link via S÷¥L$ which can be shortened to S÷Lµ since it's at the very start of the program and then you put an € right there to map and then since there's no builtin for comparing you'd use _/Ṡ but you can shorten to IṠ since that's still 3 distinct cmp outputs...yeah, pretty sure it can't be done in 5. Also 5 won't help since I FGITW'd. :)

C (gcc), 91 98 bytes
u,v,j;f(x,y,a,b)int*a,*b;{for(u=v=0;x--;u+=a[x])for(j=0;j<y;)v+=b[j++];j=u*y-v;x=j>0?2:!j;}

Wrong place for C and probably the only answer that doesn't need division. At least the code is displayed without a slider.
Return 0,1,2 for M>N, M=N, M<N respectively. Takes input as length of M, length of N, M, N.

Is taking length as an argument within the specs? Cuts significant code from a lot of these if it is.

I don't know if there's another way for C to retrieve the length of an array. The length itself is more like an intrinsic part of array.

Perl 6, 25 bytes
{sign [-] .map:{.sum/$_}}

Try it online!
Takes a single argument, a two-element list of lists of numbers.  Returns 1 if the first list has a greater average, -1 if the second list does, and 0 if the averages are equal.

JavaScript (ES6), 60 54 bytes
-6 bytes thanks to @Luke and @Neil
(i,[x,y]=i.map(v=>eval(v.join`+`)/v.length))=>y-x&&x>y

Takes input as a 2-element array [N, M]. Outputs true, 0, or false for N, Tie, or M, respectively.
Explanation
(i,                 // input array: [N, M]
    [x,y] =         // destructure assignment: set x and y to...
    i.map(v=>       // the input values mapped as...
        eval(v.join`+`) // the sum, by joining the array with +
        / v.length      // divided by the length
    )
) => y-x && x>y     // return 0 for tie, or the result of avg(N) > avg(M)

Test Snippet
Input numbers separated by spaces/commas.

f=
(i,[x,y]=i.map(v=>eval(v.join`+`)/v.length))=>y-x&&x>y

x.split(/[ ,]+/)))">N <input id=N> M <input id=M>

Out: <input id=O disabled>

You can probably save some bytes by replacing Math.sign(y-x) by y-x?x>y:0. Outputs 0 for Tie, true for N and false for M.

x-y&&x>y perhaps?

@Neil Nice, even better

JavaScript (ES6), 60 bytes
a=>(b=(c=a.map(d=>eval(d.join`+`)/d.length))[0])-c[1])?b>0:0

Outputs 0 for Tie, true for N and false for M.

Pip, 13 bytes
{$CM$+*a/#*a}

This is a function that takes a list of lists. Returns 1 if the first average is bigger, -1 if the second is bigger, 0 if tied. Run all test cases here.
Background
This solution makes heavy use of two of Pip's metaoperators:

$, fold. Take a binary operator and apply it between the elements of a list. For instance, + is addition, but $+ sums a list. Note that $ makes a binary operator into a unary operator.
*, map. Take a unary operator and apply it to each element of a list. For instance, # gives the length of a list, but #* gives (a list of) the lengths of the list's items.
These two metaoperators can be combined: $+* maps fold/plus over a list, summing each of the list's elements.

The other thing to know about Pip is that a lot of operators work item-wise on lists by default. For instance, [1 2 3] * 5 gives [5 10 15]; [1 2 3] * [2 3 4] gives [2 6 12]; and [[1 2] [3 4]] * [5 6] gives [[5 10] [18 24]].
Explanation
We'll use an example input of [[2 3 4] [2 3 4 6]]:

{...}
Defines a function. The (first) argument is bound to the local variable a.
#*a
Map # to the function's argument, getting the lengths of the sublists. Result: [3 4]
a/#*a
Divide (the elements of) the sublists of a by their respective lengths. Result: [[0.667 1 1.333] [0.5 0.75 1 1.5]]
$+*a/#*a
Map $+ (fold on addition) to that result, summing the sublists. Result: [3 3.75]
$CM$+*a/#*a
Fold on CM, which gives -1, 0, or 1 depending on the comparison of its two operands (like Python's cmp). Result: -1 (because 3 is smaller than 3.75).

You can also define functions in Pip by writing expressions containing the identity function _. For example, _*_ is a function that squares its argument--syntactic sugar for {a*a}, and fewer bytes. However, there's a bug in the current version of the interpreter that prevents _ from working with the * metaoperator. Once that's fixed, this solution can be 11 bytes: $CM$+*_/#*_.

MATL, 6 bytes
Don't be so mean!*
!-ssZS

Input stack order:
M
N

Output:
 1 = N wins
-1 = M wins
 0 = tie

Try it online!
!-ssZS
========
!           % transpose M
 -          % N - M^T using elementwise subtraction and implicit expansion
  s         % sum columns of the result
   s        % sum the resulting row vector
    ZS      % sign of the sum

*This answer was golfed without being mean to any poor, defenseless numbers.

Brachylog, 8 bytes
⟨+/l⟩ᵐ-ṡ

Try it online!
Outputs 1 if the first list has a bigger average, -1 is the second list has a bigger average, and 0 if they are tied.
Explanation
     ᵐ        Map:
⟨   ⟩           Fork:
 +                Sum…
  /               …divided by…
   l              …length
       -      Subtract
        ṡ     Sign

Java, 105 bytes
s->s.stream().map(l->l.stream().reduce((i,j)->i+j).get()/l.size()).reduce((i,j)->Math.signum(i-j)).get();

Lambda that takes a nested list, as per allowable inputs.
Streams the list of lists, converts both to their averages, then returns the sign of the difference. 1 if the first list is larger, -1 if the second list is larger, 0 for a tie.

Since "anything can be an input", just use Streams directly, like I did.

R 38 34 bytes
function(a,b)sign(mean(a)-mean(b))

Function that takes as input two numeric vectors. Returns 1 if first list average is higher, 0 if they are the same and -1 if second list average is higher.

Is this an anonymous function that can be called without assignment?  I don't know R but if it is you don't need the f=.

@WheatWizard you are correct; additionally you can remove the {} from the function body.

Thanks for the input. It's my first attempt at codegolf.

Braingolf, 20 bytes
VRlm&+vlM&+vmc/v/c-s

Try it online!
Takes input multiplied by 1000. This can be increased to a higher power of 10 for better accuracy.
Takes first input as individual integers, and second input as an array of integers.
Outputs 1 if first array's average is larger
Outputs -1 if second array's average is larger
Outputs 0 for tie
Only accurate for averages up to 3 decimal places (so if the average of the first list is 3.5554, and the average of the second list is 3.5557, this will output 0 for a tie)
Explanation
VRlm&+vlM&+vmc/v/c-s  Implicit input from command-line args
                      2nd input as array is inputted to separate stack
VR                    Create stack3, return to stack1
  lm                  Push length of stack, move it to previous stack (wrap to stack3)
    &+                Sum entire stack
      v               Switch to stack2
       lM             Push length of stack, move it to next stack (stack3)
         &+           Sum entire stack
           v          Switch to stack3
            m         Move last item back to stack2
             c        Collapse stack3 into stack1
              /       Divide
               v      Switch to stack2
                /     Divide
                 c    Collapse into stack1
                  -   Subtract
                   s  Sign, positive becomes 1, negative becomes -1, 0 is not affected.
                      Implicit output of last item on stack

Japt v2.0a0, 12 11 10 8 bytes
Takes input as a 2D array. Returns -1  for M, 1 for N or 0 for tie.
®x÷ZÊÃrg

Try it
®x÷ZÊÃrg     :Implicit input of 2D array
®            :Map each Z
 x           :  Reduce by addition
  ÷          :  Divide by
   ZÊ        :  Length of Z
     Ã       :End map
      r      :Reduce by
       g     :  Sign of difference

rn is a nice trick. Do you need the g though?

@ETHproductions: Yeah, output values need to be consistent.

If g was skippable I could save 6 byes :/

Oh duh, I'm sorry, I thought g got the first item from a 1-item array... :P

Dyalog APL, 14 bytes
×(-/(+/÷≢)¨∘⊢)

1 if the left is greater, ¯1 if the right is and 0 on tie.
How?
¨∘⊢ for each list
+/÷≢ calculate average (+/ sum ÷ divide by ≢ length)
-/ subtract the averages
× sign of the result

Tcl, 93 bytes
proc C A\ B {proc M L {expr ([join $L +])/[llength $L].}
expr [set n [M $A]-[M $B]]<0?2:$n>0}

Try it online!
I saved 1 byte returning 2 instead of -1.

Failed outgolf try: proc C args {expr [set n [join [lmap L $args {expr ([join $L +])/[llength $L].}] -]]<0?-1:$n>0}

CJam, 18 16 15 bytes
-1 thanks to @ErikTheOutgolfer
q~{_:+\,d/}%~-g

Input is given as [[1 2 3] [4 5 6]]. Output is -1, 0, or 1.
Explanation:
q    e# Read input: "[[1 2 3] [4 5 6]]"
~    e# Eval:       [[1 2 3] [4 5 6]]
{    e# For each:     [1 2 3]
 _   e#   Duplicate:  [1 2 3] [1 2 3]
 :+  e#   Sum:        [1 2 3] 6
 \   e#   Swap:       6 [1 2 3]
 ,   e#   Length:     6 3
 d/  e#   Float div:  2.0
}%   e# End:        [2.0 5.0]
~    e# Unpack:     2.0 5.0
-    e# Subtract:   -3.0
g    e# Signum:     -1

You're overusing vectorization, something like q~{_:+\,d/}%~-g would be shorter.

why is sum over 1,2,3 the value 2 and sum over 4,5,6 the value 5?  (might only be typo in explanation)

@avl42 Golfed and fixed.

Retina, 69 66 bytes
\d+
$*
1(?=.*;(1+,)+)
1$#1$*
1(?<=(,1+)+;.*)
1$#1$*
,

+`1;1
;
D`1

Try it online! Link includes test cases. Edit: Saved 3 bytes thanks to @MartinEnder. Takes two comma-separated lists joined with a semicolon and returns ; for a tie, 1; if the first list's average is larger and ;1 if the second list's average is. Explanation: The first stage converts to unary. The second stage multiplies each element of the first list by the length of the second list, while the third stage multiplies each element of the second line by the length of the first. The totals on both sides are now the averages multiplied by the product of the length of the lists, so they are directly comparable. The fourth stage totals the values together and the fifth stage subtracts the totals from each other, while the final stage takes the sign of the result.

The penultimate stage can be +\1;1-->;and the final stage can beD`1`.

@MartinEnder Nice; I've never had reason to use the D stage before!

PowerShell 69 Bytes
param($n,$m)(($n|measure -A|% A*)-($m|measure -A|% A*))|% T*g "N;M;T"

Outputs N when 'N' is bigger, M for 'M', and T for a Tie.
gets the average using the builtin Measure-Object -Average command.
PS C:\Users\sweeneyc\Desktop> $t = @((7),(6)
(4,5),(4,4)
(2,3,4),(4,5,6)
(4,1,3),(7,3,2,1,1,2)
(100,390,1),(89,82,89)
(92,892),(892,92)
(10,182),(12,78,203,91))

for ($a=0;$a-lt14;$a+=2){
    .\avg.ps1 -a $t[$a] -b $t[$a+1]
}
A
A
B
T
A
T
T

C# (.NET Core), 40 + 18 = 58 bytes
using System.Linq;n=>m=>n.Average().CompareTo(m.Average())

Try it online!

Common Lisp, 74 71 bytes
(defun g(x)(/(apply'+ x)(length x)))(defun f(x y)(signum(-(g x)(g y))))

Try it online!

Haskell, 40 bytes
f x=sum x/sum(1<$x)
x!y=compare(f x)$f y

C#, 75 bytes
using System.Linq;n=>m=>n.Average()>m.Average?1:m.Average()>n.Average()?2:0

Gallina, 103 bytes
Definition a l := Z.div (fold_left Z.add l 0) (Zlength l).
Definition g l l' := Z.compare (a l) (a l').

SQL (MS T-SQL), 99 bytes
select SIGN((x.a)-(y.a))from(select avg(a) a from(values<list1>)a(a))x,(select avg(a) a from(values<list2>)a(a))y

This returns 1 if the first list has a higher average, 0 for ties and -1 for a heavier second list. Input uses this format: (1),(2),(3), which I have substituted with the placeholders <list1> and <list2> in the code above.

Husk, 4 bytes
±¤-A

Try it online! Outputs -1 if N wins, 1 if M wins, and 0 if they are tied. Just takes the sign (±) of the difference  (-) between the averages (¤..A) of the two lists.

Python 3, 44 bytes
Takes two lists n and m. Returns True if the average of n is larger, False if that of m is, and throws a ZeroDivisionError if they are equal.
lambda n,m:1/(sum(n)/len(n)-sum(m)/len(m))>0

Try it online!

Does not work for ties. Erros may not be thrown as a form of output

@Mr.Xcoder Am I interpreting this incorrectly? Specifically "Programs may output to STDERR" and "Functions may output via the same methods as full programs".

Your forms of output must be constant. You cannot use both STDOUT and STDERR.

@Mr.Xcoder Got it, I'll keep it in mind. Thanks for the help.

Python 3, 87 101 84 Bytes
def c(M,N):
  j=sum(N)/len(N)-sum(M)/len(M);print('N')if j>0else print('MT'[j==0])

input is standard Python lists called M and N
Output is name of larger list or T for tie.
Try it online!
Explanation
Get an int to represent the comparison.
Compare in nested ternary.
Thank you @Morgan Thrapp for the improvements!

Welcome to PPCG!
Where are you taking the input? Right now it looks like you're assuming that the lists are hard coded. This is generally not allowed, see this meta post for more details.
Also, you can save a few bytes by removing the whitespace after numbers/parenthesis and using the implicit conversion between boolean and int to index a string in your print call, instead of writing out full print calls/ternaries. Eg, print('N') if j>0 else print('TM'[j==0])

Perl 5, 44 + 1 (-a) = 45bytes
push@a,eval(join'+',@F)/@F}{say$a[1]<=>$a[0]

Try it online!
Outputs -1 if the first has a greater average, 1 if the second has the greater average, or 0 if the averages are equal.

AWK, 69 bytes
{for(i=0;i++<NF;)d=M[NR-1]-(M[NR]+=$i/NF)}z=(NR-1)%2{$0=(d<0)-(d>0)}z

Try it online!
Input is by rows with odd row line numbers corresponding to N and even rows corresponding to M. Output is -1 if N is greater than M. 0 if they are equal, and 1 if M > N. Output only occurs on even rows.

J-uby, 24 bytes
Returns 1 if the first list has the greater average, -1 if the second list, or 0 for a tie.
:*&:/%[:sum|Q,:+@]|+:<=>

Attempt This Online!
Explanation
:* & :/ % [:sum | Q, :+@] | +:<=>

:* &                               # Map arguments with...
     :/ % [        ,    ]          #   Quotient of...
           :sum | Q                #     Sum of list converted to float and
                     :+@           #     Length of list
                          | +:<=>  # Then compare

Arturo, 29 bytes
$=>[compare average&average&]

Try it

Thunno 2, 4 bytes
€mẸṛ

Attempt This Online!
Gives 1 for N wins, 0 for tie, and -1 for M wins.
Explanation
€mẸṛ  # Implicit input
€m    # Mean of each
  Ẹṛ  # Compare them
      # Implicit output

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


text:
Pascal's Rhombus
Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern:
  *
 ***
  x

instead of
* *
 x

This means that each cell is the sum of the three cells on the row directly above it and one cell on the row 2 above it.  Just like Pascal's triangle the zeroth row has a single 1 on it that generates the triangle.
Here are the first couple of rows of Pascal's Rhombus
      1
    1 1 1
  1 2 4 2 1
1 3 8 9 8 3 1

Task
Given a row number (starting from the top) and an column number (starting from the first non-zero item on that row) output the value at that particular cell.  Both inputs may be either 1 or 0 indexed (you may mix and match if you desire).
This is code-golf so you should aim to make the file size of your source code as a small as possible.
OEIS A059317

As with Pascal's triangle, the parity of the rhombus makes nice and fractal patterns.

you should aim to make the file size of your source code as a small as possible what if I put my code as a command-line argument? :P

Went googling for shortcuts and apparently https://arxiv.org/abs/1504.04404 says calculating the result directly is unusable for code golf.

Haskell, 59 55 bytes
Pascal's Rhombus? More like Haskell's Rhombus! amiright?
4 bytes saved thanks to Ørjan Johansen
I thought I'd have a go at my own problem and practice my Haskell.  Hopefully this will inspire more people to answer this.
1!1=1
n!k=sum[(n-2)!(k-2)+sum(map((n-1)!)[k-2..k])|n>1]

Try it online!
Explanation
This is a bit out of date with the latest golf
Instead of calculating
  *
 ***
  x

We calculate
*
***
  x

This slants our entire triangle to become
1
1 1 1
1 2 4 2 1
1 3 8 9 8 3 1

This lines up all of our rows making it easier to index the nth item of any column.  We then define our base cases.
The zeroth row is all zeros so
0!_=0

There is a single 1 at position 1,1 so we define that
1!1=1

And we define the rest of the first row to be zeros as well
1!_=0

Then we define the general case recursively using the pattern described above:
n!k=(n-2)!(k-2)+(sum$map((n-1)!)[k-2..k])

Beat me to it! This is also a lot cleaner than mine.

@JulianWolf Sorry about that, when I posted this it looked like no one other than Jorg was doing the problem.  I'd still like to see your solution.

You can save four bytes with n!k=sum[(n-2)!(k-2)+sum(map((n-1)!)[k-2..k])|n>1].

Pascal, 122 bytes
Well, it's Pascal's rhombus.
37 bytes saved thanks to @manatwork
function f(n,k:integer):integer;begin f:=1-Ord((k<0)or(k>n*2));if n>0then f:=f(n-1,k-2)+f(n-1,k-1)+f(n-1,k)+f(n-2,k-2)end;

Try it online!

Parenthesis around the entire if condition are pointless. (On 1st if you save 2 characters, on the 2nd if 1 character by leaving no space between then keyword and the preceding digit.) Oh, and variable r is completely unnecessary.

Weird animal that Pascal on Ideone. Never seen double quotes delimited strings in any Pascal variant before. One more thing you can remove: the ; before the function's end.

@manatwork yea, now when you mentioned it, all of the other online editors complained about it

@manatwork I'm not sure I understood. wouldnt that just lengthen the code with the >= <=? I still need to preserve the if n=0

Sorry @Uriel, I don't have that version anymore. Currently I'm at function f(n,k:integer):integer;begin f:=1-Ord((k<0)or(k>n*2));if n>0then f:=f(n-1,k-2)+f(n-1,k-1)+f(n-1,k)+f(n-2,k-2)end;

@manatwork well, at least that beats PHP ;) no implicit type casting in Pascal?

+1 for the motivation to improve my PHP answer

PHP, 86 bytes
recursive way only the function row and column 0-Indexed

function f($r,$c){return$r|$c?$r<0?0:f($r-=1,$c)+f($r,$c-1)+f($r,$c-=2)+f($r-1,$c):1;}

Try it online!
PHP, 114 bytes
recursive way full program row and column 0-Indexed
<?=f(...$_GET);function f($r,$c){return$r|$c?$r<0|$c<0|$c>2*$r?0:f($r-=1,$c)+f($r,$c-1)+f($r,$c-=2)+f($r-1,$c):1;}

Try it online!
PHP, 129 bytes
row and column 0-Indexed

for(;$r<=$argv[1];$l=$t[+$r++])for($c=~0;$c++<$r*2;)$t[+$r][$c]=$r|$c?$t[$r-2][$c-2]+$l[$c]+$l[$c-1]+$l[$c-2]:1;echo$l[$argv[2]];

Try it online!

and +1 for actually improving it :)

Jelly, 22 20 19 bytes
3ḶṚp@Ḣḣ4
Ḟ_Ð€Çß€ȯ¬S

Takes a 0-based index pair as command-line argument.
Try it online!

Pari/GP, 60 bytes
i->j->polcoeff(Vec(1/(1-x*(1+y+y^2+x*y^2))+O(x^i++))[i],j,y)

Try it online!

MATL, 22 20 19 bytes
Ti:"2Y6Y+FT_Y)]!i_)

Both inputs are 0-based.
Try it online!
Explanation
Let r and c denote the two inputs, specifying 0-based row and column respectively.
Each new row in Pascal's rhombus can be built from the matrix containing the previous two rows by convolving with the kernel [1 1 1; 0 1 0] and keeping the last two rows of the result swapped. This is done r times, starting from matrix 1.
It turns out to be shorter to use the kernel [0 1 0; 1 1 1; 0 1 0], which is a predefined literal. This produces an extra row, which will be discarded.
Consider for example r = 3, so there are 3 iterations.

Starting from
1

convolution with [0 1 0; 1 1 1; 0 1 0] gives
0 1 0
1 1 1
0 1 0

Keeping the last two rows (the whole matrix, in this case) and swapping them gives
0 1 0
1 1 1

Convolution of the above with [0 1 0; 1 1 1; 0 1 0] gives
0 0 1 0 0
0 1 1 1 0
1 2 4 2 1
0 1 1 1 0

The matrix formed by the last two rows swapped is
0 1 1 1 0
1 2 4 2 1

This contains the new row at the bottom, and the preceding one extended with zeros.
Convolving again yields
0 0 1 1 1 0 0
0 1 2 3 2 1 0
1 3 8 9 8 3 1
0 1 2 4 2 1 0

Taking the last two rows swapped gives
0 1 2 4 2 1 0
1 3 8 9 8 3 1

After the r iterations have been done, the output is contained in the last row of the final matrix. For example, for c = 2 (0-based) the result would be 8. Instead of indexing the last row and the desired column, a trick can be used which exploits the symmetry of each row: the final matrix is transposed
0 1
1 3
2 8
4 9
2 8
1 3
0 1

and its -c-th element is taken. This uses linear indexing, that is, the matrix is indexed by a single index in column-major order. Since indexing is modular, the 0-entry is the lower-right corner (value 1) and the -2-th entry is two steps above (value 8).
T       % Push true
i       % Input row number
:"      % Do the following that many times
  2Y6   %   Push predefined literal [0 1 0; 1 1 1; 0 1 0]
  Y+    %   2D convolution, increasing size
  FT_   %   Push [0 -1]
  Y)    %   Matrix with rows 0 (last) and -1 (second-last), in that order
]       % End
!       % Transpose
i       % Input: colun number
_       % Negate
)       % Entry with that index. Implicitly display

Haskell, 74 bytes
0#0=1
n#m|m<=2*n&&m>=0=sum[(n-a)#(m-b)|(a,b)<-zip[2,1,1,1]$2:[0..2]]
n#m=0

Try it online!
Call with n # m, where n is the row and m is the column.

m<=2*n&&m>=0 can be just n>0.

Python 2, 70 66 65 bytes
f=lambda n,k:(k==0)|sum(f(n+~j/3,k-j+j/3)for j in range(4)[:3*n])

Try it online!

Mathematica, 56 bytes
If[#<1,Boole[##==0],Sum[#0[#-i,#2-j],{i,2},{j,2i-2,2}]]&

Pure function taking two integer arguments (row first, column second) and returning an integer. Works for negative integer arguments as well, returning 0. A pretty straightforward recursive structure: If[#<1,Boole[##==0],...] defines the base-case behavior for the 0th row (and above), while Sum[#0[#-i,#2-j],{i,2},{j,2i-2,2}] implements the recursive definition.

Python 3, 75 Bytes
This is a recursive lambda that takes column and row as 0-indexed integers.
p=lambda r,c:(r<0 or((c==0)|p(r-1,c-2)+p(r-1,c)+p(r-1,c-1)+p(r-2,c-2))+1)-1

Here's a (slightly) more readable version with a printing function:
p = lambda r,c:(r<0 or ((c==0) | p(r-1,c-2)+p(r-1,c)+p(r-1,c-1)+p(r-2,c-2))+1)-1

def pp(r):
    ml = len(str(p(r,r)))+1
    for i in range(0, r):
            a=" "*ml*(r-i)
            for j in range(0,i*2 + 1):
                    a+=str(p(i,j))+(" "*(ml-len(str(p(i,j)))))
            print(a)

JavaScript (ES6), 68 bytes
f=(y,x)=>x<0|x>y+y?0:x>0&x<y+y?f(--y,x)+f(y,--x)+f(y,--x)+f(--y,x):1

Mathematica, 53 bytes
D[1/(1-x(1+y+y^2(1+x))),{x,#},{y,#2}]/#!/#2!/.x|y->0&

Using the generating function.

Java (OpenJDK 8), 87 bytes
int f(int r,int c){return c<0|2*r<c?0:0<c&c<2*r?f(--r,c)+f(r,--c)+f(r,--c)+f(--r,c):1;}

Try it online!
At first, I was happy with my 160 bytes iterative method... Hmmm... let's just forget about it, OK?

Python 3, 82 84 bytes
This is a recursive implementation with 1-indexed rows and columns. (Technically needs an f= in front, someone let me know if I should change it to 84 bytes. Still new and not 100% sure of the rules.)
This uses the recursive formula found on the OEIS page, but with the k's shifted one to the left to line up properly. Coincidently, sum(f(n-1,k-i)for i in(0,1,2)) is the same size as f(n-1,k)+f(n-1,k-1)+f(n-1,k-2). The whole function is the Python and or trick, where the first condition checks if k is inside the triangle and not on the boundary, in which case the recursive formula is used. If is isn't, the part after the or is returned, which checks if k is in (1, 2*n-1), i.e. on the boundary, returning True and False. k+1in(2,2*n) is one byte shorter than k in(1,2*n-1). Wrapping that in parentheses and putting a + in front converts to integer, which is what is needed.
f=lambda n,k:2*n-1>k>1and sum(f(n-1,k-i)for i in(0,1,2))+f(n-2,k-2)or+(k+1in(2,2*n))

Try it online!

Recursive functions need the f=.

While I personally disagree with it according to this somewhat buried meta consensus, you may output True instead of 1 because it behaves like 1 to python.  This allows you to remove the +(...) at the end.  I understand if you don't want to do this, because it will make the output look a little strange, it is an option.

@WheatWizard Wow that's very interesting. Thanks for the tip.

Husk, 38 bytes
!!¡(S+o↔↑2Fz+§,ȯΘΘ←(moΣ↑_3ḣ→)↑_2)eḋ1ḋ7

Try it online!
Displays the infinite list, but somehow indexing into the list makes it time out.


text:
Smallest multiple being run of 9 followed by optional run of 0
Given a positive integer, find its smallest positive integer multiple which is a run of 9 followed by an optional run of 0. In other words, find its smallest positive integer multiple which is matched by the regex /^9+0*$/.
For example, if the given positive integer is 2, then return 90, since 90 is a positive integer multiple of 2 and is the smallest which is matched by the regex /^9+0*$/.
Test cases:
n  f(n)
1  9
2  90
3  9
4  900
5  90
6  90
7  999999
8  9000
9  9
10 90
11 99
12 900
13 999999
14 9999990
15 90
16 90000

This is code-golf. Shortest answer in bytes wins. Standard loopholes apply.

proof of well-definedness?

Similar to this challenge, but I think requiring the smallest one will lead to different strategies.

@DestructibleLemon This proof suffices, since the result can be multiplied by 9.

I think more test cases would be good to check that solutions require the 9's to come before the 0's.

seq 0 $1 1000000 | egrep ^9+0*$ | head -1 works but has a hardcoded upper limit.  That works for the test cases but is it ok?

@xnor is 0009999 a number?

@LeakyNun maybe not, but 9900099 is, and shouldn't be allowed according to rules.

Nice one. To define it in a better way, i think you should include a realistic range for the input number (ex. 1 to 30 or up to 16 as in your testcases). If you check, most brute force answers given cannot compute N=31, due to timeout error

@koita_pisw_sou the rule is that the program should "theoretically" work for any integer given arbitrary precision and memory and time.

Jelly, 13 11 bytes
ṚḌ‘DS=ḍ@ð1#

Try it online!
How it works
ṚḌ‘DS=ḍ@ð1#  Main link. Argument: n

        ð    Start a dyadic chain with arguments n and n.
         1#  Execute the chain to the left with left argument k = n, n+1, n+2, ...
             and right argument n until 1 match has been found. Return the match.
Ṛ                Get the decimal digits of k, reversed.
 Ḍ               Convert from base 10 to integer.
                 This essentially removes trailing zeroes. As a side effect, it
                 reverses the digits, which doesn't matter to us.
  ‘              Increment the resulting integer. If and only if it consisted
                 entirely of 9's, the result is a power of 10.
   DS            Compute the sum of the digits. The sum is 1 if and only if the
                 integer is a power of 10. Note that the sum cannot be 0.
      ḍ@         Test k for divisibility by n.
     =           Compare the results.

ಠ_ಠ how did you do it with neither 9 or 0 in your code

I've added an explanation.

Python 2, 55 54 bytes
n=r=input()
while int(`10*r`.lstrip('9')):r+=n
print r

Try it online!

Not only do you have to outgolf us all, but you have to do it in Python... 3 times... :P

Python 2, 51 bytes
f=lambda n,r=9:r%n and f(n,10*r-10**n*r%-n/n*9)or r

Try it online!

Devious yet surprisingly simple!

JavaScript (ES6), 47 43 42 bytes
-4 bytes thanks to @Arnauld
-1 byte thanks to @Luke
n=>eval('for(i=0;!/^9+0*$/.test(i);)i+=n')

Tests

let f=
n=>eval('for(i=0;!/^9+0*$/.test(i);)i+=n')

for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i))

Recursive solution (fails for 7, 13, and 14), 38 bytes
n=>g=(i=0)=>/^9+0*$/.test(i+=n)?i:g(i)

Called like f(5)(). Reaches the max call stack size in Chrome and Firefox for n=7, n=13, and n=14.

f=
n=>g=(i=0)=>/^9+0*$/.test(i+=n)?i:g(i)

for(let i=1;i<=16;i++){
 try { console.log(`f(${i}) = `+f(i)()) }
 catch(e) { console.log(`f(${i}) = FAILED`) }
}

One byte shorter: n=>eval('for(i=0;!/^9+0*$/.test(i);)i+=n')

Ruby, 36 bytes
->x{r=0;1until"#{r+=x}"=~/^9+0*$/;r}

Brute-forcing - takes forever for x=17.
Try it online!

I came up with almost the same solution as you, but as a full program: https://codegolf.stackexchange.com/a/130106/60042. I borrowed the use of string interpolation from you, I hope that's ok.

Java 8, 61 57 bytes
n->{int r=0;for(;!(""+r).matches("9+0*");r+=n);return r;}

-4 bytes (and faster execution) thanks to @JollyJoker.
Explanation:
Try it here.
n->{                              // Method with integer as parameter and return-type
  int r=0;                        //  Result-integer
  for(;!(""+r).matches("9+0*");   //  Loop as long as `r` doesn't match the regex
    r+=n                          //   And increase `r` by the input every iteration
  );                              //  End of loop
  return r;                       //  Return the result-integer
}                                 // End of method

Yeah for optimization! ^^

Incrementing by n avoids the r%n check, n->{int r=0;for(;!(""+(r+=n)).matches("9+0*"););return r;}

for(;!(""+r).matches("9+0*");r+=n)

I've tried, and tried to get on with integers and math, but I can't beat this! Congrats :)

Python 3, 56 bytes
f=lambda n,r=0:{*str(r).strip('0')}!={'9'}and n+f(n,n+r)

Try it online!

Brachylog, 16 bytes
;I×≜.ẹḅhᵐc~a₀90∧

Try it online!
This is pretty slow
Explanation
;I×≜.              Output = Input × I
    .ẹḅ            Deconcatenate into runs of consecutive equal digits
       hᵐ          Take the head of each run
         c         Concatenate into a number
          ~a₀90∧   That number is a prefix of 90 (i.e. it's 9 or 90)

05AB1E, 10 bytes
0[+D9Û0«_#

Try it online!
It just keeps adding the input to 0, until the result minus leading 9's equals 0.

RProgN 2, 18 bytes
x={x*'^9+0*$'E}éx*

Explained
x={x*'^9+0*$'E}éx*
x=                  # Set the value of "x" to the input.
  {           }é    # Find the first positive integer in which passing it to the defined function returns truthy.
   x*               # Multiply the index by x, this essentially searches multiples now.
     '^9+0*$'       # A Regex defined by a literal string.
             E      # Does the multiple match the regex?
                x*  # Multiple the outputted index by x, giving the result.

Try it online!

Ruby, 38 + 1 = 39 bytes
Uses -p flag.
$_=y=eval$_
1until"#{$_+=y}"=~/^9+0*$/

-p surrounds the program with:
while gets
    ...
end
puts $_

gets stores its result in $_. eval is used to convert it to a number, as it's shorter than .to_i, then brute force is used, incrementing $_ until it matches the regex. "#{}" is sttring interpolation, it's shorter than a .to_s call as that would require parantheses around $_+=y. Finally, $_ is printed.
Try it online!
Try all test cases!

Mathematica, 127 bytes
Select[FromDigits/@Select[Tuples[{0,9},c=#],Count[#,9]==1||Union@Differences@Flatten@Position[#,9]=={1}&],IntegerQ[#/c]&][[1]]&

Input

[17]

Output

9999999999999999

here are the first 20 terms

{9, 90, 9, 900, 90, 90, 999999, 9000, 9, 90, 99, 900, 999999,
  9999990, 90, 90000, 9999999999999999, 90, 999999999999999999, 900}

Clever, but the obvious solution seems to be the shortest: https://codegolf.stackexchange.com/a/130115/60042

your obvious solution can't do 17 ;-)

What can I say, not [tag:fastest-code]

By the way, your solution works in Mathics, you could change it to that and add a TIO link.

Yours can't do 17 either

Please don't post false information. This is Mathematica code and if you test it on Mathematica you will get the answer for 17 in less than 10 sec.

I am a very lazy man, and I can't be bothered to open Mathematica right now, but I'm sure my solution would be significantly faster in Mathematica as well.

I'm sorry but your solution takes forever. I tested it... You are talking too much for a lazy man, my friend

Mathics, 71 bytes
(x=#;While[!StringMatchQ[ToString@x,RegularExpression@"9+0*"],x+=#];x)&

Try it online!
Not very intresting brute force solution, but it beats the other Mathematica answer, which uses some clever tricks.
The one redeeming quality Mathematica has in regards to this challenge is the fact that StringMatchQ requires a full match, so I can do 9+0* rather than ^9+0*$.

If you're willing to use Mathematica instead of Mathics, you can save a few bytes with "9"..~~"0"... instead of RegularExpression@"9+0*".

@Notatree thanks, I'll keep it in mind for a later time, but I'll stick with Mathics. I prefer not to use syntax I don't understand, and that's the first time I've seen syntax like that.

Fair enough. (Mathematica's pattern matching syntax is a powerful tool, but if you're familiar with regular expressions you probably already know that!)

Batch, 175 bytes
@set/pn=
@set s=
:g
@set/ag=-~!(n%%2)*(!(n%%5)*4+1)
@if not %g%==1 set s=0%s%&set/an/=g&goto g
@set r=1
:r
@set s=9%s%
@set/ar=r*10%%n
@if %r% gtr 1 goto r
@echo %s%

Takes input on STDIN. Not a brute force solution but in fact based on my answer to Fraction to exact decimal so it will work for 17, 19, etc. which would otherwise exceed its integer limit anyway.

Haskell, 53 bytes
f takes and returns an integer.
f n=filter(all(<'1').snd.span(>'8').show)[n,n+n..]!!0

Try it online!
This times out for 17, which conveniently is just beyond the test cases. A faster version in 56 bytes:
f n=[x|a<-[1..],b<-[0..a-1],x<-[10^a-10^b],mod x n<1]!!0

Try it online!
How it works

f generates all multiples of n, converts each to a string, filters out those with the right format, then takes the first one.
The faster version instead uses that the required numbers are of the form 10^a-10^b, a>=1, a>b>=0. For golfing purposes it also uses the fact that for the minimal a, only one b can work, which allows it to generate the bs in the slightly shorter "wrong" order.

Perl 5, 23 + 2 (-pa) = 25 bytes
Brute Force Method

$_+=$F[0]while!/^9+0*$/

Try it online!
It's slow, but it's tiny.
More Efficient Method:
41 + 2 (-pa) = 43 bytes
$_=9;s/0/9/||($_=9 .y/9/0/r)while$_%$F[0]

Try it online!
It works well for any input, but it's longer code.

><>, 35 bytes
&a:v ;n-<
:,a/?(1:^!?%&:&-}:{
a*:\~

Try it online, or watch it at the fish playground!
Assumes the input is already on the stack. Works by looking for numbers of the form 10a − 10b, with a < b (yes, that's a less than sign — it takes fewer bytes!) until that's divisible by the input, then printing 10b − 10a. This is much faster than the brute force method (which would be difficult in ><> anyway).

Mathematica, 82 bytes
Using the pattern of submission from @Jenny_mathy 's answer...
(d=x=1;y=0;f:=(10^x-1)10^y;n:=If[y>0,y--;x++,y=d;d++;x=1];While[Mod[f,#]!=0,n];f)&

Input:
[17]

Output:
9999999999999999

And relative to the argument in comments at @Jenny_mathy's answer with @Phoenix ...  RepeatedTiming[] of application to the input [17] gives
{0.000518, 9999999999999999}

so half a millisecond.  Going to a slightly larger input, [2003] :
{3.78, 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999}

a bit under 4 seconds.
Test table:  On the first 30 positive integers, the results are
{9, 90, 9, 900, 90, 90, 999999, 9000, 9, 90, 99, 900, 999999,
9999990, 90, 90000, 9999999999999999, 90, 999999999999999999, 900,
999999, 990, 9999999999999999999999, 9000, 900, 9999990, 999,
99999900, 9999999999999999999999999999, 90}

Explanation:
The only magic here is the custom iterator ("iterator" in the CS sense, not the M'ma sense)
n := If[ y>0  ,  y-- ; x++  ,  y=d ; d++ ; x=1]

which acts on the global variables x, the number of leading "9"s, y, the number of trailing "0"s, and d, the total number of digits.  We wish to iterate through the number of digits, and, for each choice of number of digits, start with the most "0"s and the least "9"s.  Thus the first thing the code does is initialize d to 1, forcing x to 1 and y to 0.  The custom iterator checks that the string of "0"s can be shortened.  If so, it shortens the string of "0"s by one and increases the string of "1"s by one.  If not, it increments the number of digits, sets the number of "0"s to one less than the number of digits, and sets the number of "9"s to 1.  (This is actually done in a slightly different order to shave a few characters, since the old value of d is the desired value of y.)

And yet, still longer than brute force and regex.

@Phoenix : So what's your timing on 2003?

Ti-Basic (TI-84 Plus CE), 48 41 bytes
Prompt X
For(K,1,0
For(M,-K+1,0
10^(K)-10^(-M
If 0=remainder(Ans,X
Return
End
End

Input is Prompt-ed during the program; output is stored in Ans.
Explanation:
Tries numbers of the form (10n)(10m-1) = 10k-10m, where m+n=k starts at 1 and increases, and for each value of k, it tries m=1,n=k-1; m=2,n=k-2; ... m=k,n=0; until it finds a multiple of X.
This works up to 16; 17 gives a domain error because remainder( can only accept dividends up to 9999999999999 (13 nines), and 17 should output 9999999999999999 (16 nines).
Prompt X               # 3 bytes, input number
For(K,1,0              # 7 bytes, k in the description above; until a match is found
For(M,-K+1,0           # 10 bytes, start with n=1, m=(k-n)=k-1;
                           # then n=2, m=(k-n)=k-2, up to n=k, m=(k-n)=0
                           # (M=-m because it saved one byte)
10^(K)-10^(-M           # 8 bytes, n=(k-m) nines followed by m zeroes → Ans
If not(remainder(Ans,X # 8 bytes, If X is a factor of Ans (remainder = 0)
Return                 # 2 bytes, End program, with Ans still there
End                    # 2 bytes,
End                    # 1 byte (no newline)

QBIC, 53 bytes
{p=p+1┘o=p*9_F!o$|┘n=!A!~(_l!n$|=_l!n+1$|)-(o%:)|\_Xo

Explanation
{        infinitely DO
p=p+1    raise p (starts out as 0)
┘o=p*9   Get the mext multiple of 9 off of p
_F!o$|   Flip a string representation of p*9
┘n=!A!   and set 'n' to be an int version of the flipped p*9
         (this effectively drops trailing 0's)
~        This IF will subtract two values: the first is either 0 for n=x^10, or -1
         and the second bit does (p*9) modulo 'a' (input number): also 0 for the numbers we want
(
 _l!n$|  the length of n's string representation
=        is equal to
_l!n+1$| the length of (n+1)'s string rep (81 + 1 = 82, both are 2 long; 99 + 1 = 100, there's a difference)
)        The above yields -1 (Qbasic's TRUE value) for non-9 runs, 0 for n=x^10
-        Subtract from that
(o%:)    (p*9) modulo a     0 for p*9 = a*y
|       THEN (do nothing, since we want 0+0=0 in the conditionals above, execution of the right path jumps to ELSE
\_Xo    ELSE quit, printing (p*9)

Dyalog APL, 34 bytes
{∧/'0'=('^9+'⎕R'')⊢⍕⍵:⍵⋄∇⍵+r}n←r←⎕

Recursive dfns, based on Dennis' Python solution.

C++, 106 bytes
int main(){long N,T=9,j=10,M;cin>>N;while(T%N){if(T/j){T+=(M/j);j*=10;}else{T=(T+1)*9;j=10;M=T;}}cout<<T;}

Detailed Form:
int main()
{
    long N,T=9,j=10,M;
    cin >> N;

    while (T%N)
    {
        if (T/j)
        {
            T += (M/j);
            j *= 10;
        }
        else
        {
            T = (T+1)*9;
            j = 10;
            M = T;
        }
    }

    cout << T;
}

TRY it online!

Better golfed: [](int n){int T=9,j=10,m;while(t%n)if(t/j){t+=m/j;j*=10;}else{t=(t+1)*9;j=10;m=t;}return t;}}, takes 94 bytes. Essentially, treat it as a function task to save bytes, save up on unneeded parentheses, use lambda function to save on type naming and type.

can't make it compile using lambda. could u give a hand?

It may be the reason that I put too amuch parentheses on the end.

In addition, lambda probably has not to exist in global scope, even though wrapping it into regular function takes 97 bytes.

Python 2, 79 bytes
x=input();n=10;y=9
while y%x:
 b=n
 while(b-1)*(y%x):b/=10;y=n-b
 n*=10
print y

Try it online!
Some explanations
It finds the smallest natural of form 10**n-10**b with n>b>=0 that divides the input.
Some IO
f(1) = 9
f(2) = 90
f(3) = 9
f(4) = 900
f(5) = 90
f(6) = 90
f(7) = 999999
f(8) = 9000
f(9) = 9
f(10) = 90
f(11) = 99
f(12) = 900
f(13) = 999999
f(14) = 9999990
f(15) = 90
f(16) = 90000
f(17) = 9999999999999999
f(18) = 90
f(19) = 999999999999999999

PHP, 39 bytes
for(;ltrim($r=$argn*++$i,9)>0;);echo$r;

Try it online!
PHP, 52 bytes
for(;!preg_match("#^9+0*$#",$r=$argn*++$i););echo$r;

Try it online!

Swift 3.0, Bytes:121
var i=2,m=1,n=""
while(i>0){n=String(i*m)
if let r=n.range(of:"^9+0*$",options:.regularExpression){print(n)
break};m=m+1}

Try it online!

What does let r= do? I don't see r referred to anywhere else

@Cyoce let r= checks whether the n.range returns value nil or not.You can use let _=.I am using optional binding here to reduce no of bytes.

Java (OpenJDK 8), 66 bytes, doesn't choke on 17
n->{long a=10,b=1;for(;(a-b)%n>0;b=(b<10?a*=10:b)/10);return a-b;}

Try it online!
Longer than @KevinCruijssen's solution but can handle slightly larger numbers. It calculates the candidate numbers like 10^6 - 10^3 = 999000. 64-bit longs are still the limit, breaking for n=23.
Can probably be golfed a bit but already took too long to make it work...

Python 3, 62 bytes
This function takes an integer n and initializes m to zero. Then it removes all zeros from the ends of m and checks if the result only contains 9's, returning m if it does. If not, it adds n to m and checks again, etc.
def f(n,m=0):
 while{*str(m).strip('0')}!={'9'}:m+=n
 return m

Try it online!

JavaScript (ES6), 51 49 bytes

let
f=(n,x=1,y=1)=>(x-y)%n?f(n,x,y*10):x-y||f(n,x*10)
<input type=number value=1 step=1 min=1 oninput=O.value=f(value)>
<input type=number value=9 id=O disabled>

Not the shortest approach, but it is wicked fast.

V, 19 14 bytes
é0òÀ/[1-8]ü09

Try it online!
Explanation
é0              ' &ltm-i>nsert a 0
  ò             ' &ltm-r>ecursively
   À            ' &ltm-@>rgument times
               ' &ltC-A> increment the number (eventually gives all multiples)
     /[1-8]ü09  ' find ([1-8]|09) if this errors, the number is of the form
                ' (9+0*) (because there won't ever be just zeros)
                ' implicitly end the recursion which breaks on the above error

C (gcc), 126 bytes
#include<stdio.h>
main(x,n,y,b){n=10;y=9;scanf("%d",&x);while(y%x){b=n;while((b-1)*(y%x)){b/=10;y=n-b;}n*=10;}printf("%d",y);}

Try it online!
Some explanations
It finds the smallest natural of form 10**n-10**b with n>b>=0 that divides the input.
Some IO
f(1) = 9
f(2) = 90
f(3) = 9
f(4) = 900
f(5) = 90
f(6) = 90
f(7) = 999999
f(8) = 9000
f(9) = 9
f(10) = 90
f(11) = 99
f(12) = 900
f(13) = 999999
f(14) = 9999990
f(15) = 90
f(16) = 90000


text:
Sheet music ASCII-art generator

Note: Anders Kaseorg warns me that this could be a duplicate of another previous question. It seems so, and I'm sorry I did not find that question before posting this one. Nonetheless, that question only received one answer and this one is simpler, just in case you all want to try this time. I'll understand if this question ends up being marked as duplicate, though.

The challenge
Given an input like this:
8g 8Df 4cs 2C 1A

Write the shortest program/function that produces an output like this:
    /\                                         -o-
   | |
---|-|---------------------------------------------------|-|
   |/                                                    | |
---/|--------|\----b-*-----------------------------------|-|
  / |        | |    |                  o                 | |
-|--|--------|------|-----------------|------------------|-|
 | (| \      |      | |               |                  | |
-|--|--)----*-------|/---------|------|------------------|-|
  \ | /                        |      |                  | |
-----|-------------------------|-------------------------|-|
     |                         |
   *_/                      #-*-

Rules
The output must consist of a five-line staff beginning with the drawing of a G-clef exactly as shown above, aligned to the left of the staff and leaving a single column after the starting of the staff.
    /\
   | |
---|-|--
   |/
---/|---
  / |
-|--|---
 | (| \
-|--|--)
  \ | /
-----|--
     |
   *_/
^
Single column

The notes must begin with a * or a o character depending on its type.
There must be exactly eight columns of separation every * or a o character:
    /\                                         -o-
   | |
---|-|---------------------------------------------------|-|
   |/                                                    | |
---/|--------|\----b-*-----------------------------------|-|
  / |        | |    |                  o                 | |
-|--|--------|------|-----------------|------------------|-|
 | (| \      |      | |               |                  | |
-|--|--)----*-------|/---------|------|------------------|-|
  \ | /                        |      |                  | |
-----|-------------------------|-------------------------|-|
     |                         |
   *_/                      #-*-
   ↑        ↑        ↑        ↑        ↑        ↑        ↑
   8 columns of separation

The staff must end with the terminator aligned to the right as shown in the example. The left bar of the terminator must be separated 8 columns from the last note.
The input will be a single string containing the notes (at least one, no empty inputs), each one separated by a whitespace (you can consider every note will be a proper one, so no need to check for errors). You can also take the input as an array of strings, with a note per element in the array. For each note, the first character will be the denominator of the note length (1 for a whole note/semibreve, starts with o; 2 for a half note/minim, starts with o; 4 for a quarter note/crotchet, starts with *; and 8 for an eighth note/quaver, starts with *). The second character will be the note (see next table), and the third, optional character will be f or F for flat notes and s or S for sharp notes.
    ---    A (ledger line)
           G
--------   F
           E
--------   D
           C
--------   b
           a
--------   g
           f
--------   e
           d
    ---    c (ledger line)

Obviously, the input must respect the case for the notes, but you can choose the case of the f and s modifiers.
Notes c and A must add two - (ledger lines), one at each side, as they must extend the staff. Notes d and G are out of the staff but do not need ledger lines.
Flatten or sharpened notes must add b or # two positions at the left of the note.
The stems (if any) must be drawn with 4 vertical bars. Notes from b and above must draw the stem downwards and at the left side of the note. Notes from a and below must draw the stem upwards and at the right side of the note. Quavers must add the flag, always rightwards and exactly as shown, and do not need to be beamed if there are several of them in a row.
--------------------------

-----|\----b-*------------
     | |    |
-----|------|-------------
     |      | |
----*-------|/---------|--
    ↑↑                 |
----||------↑↑---------|--
    ||      ||         |
    ||      ||      #-*-
    |\      |\        ↑↑
    | Stem  | Note    | Stem
    Note    Stem      Note

As usual, your program/function can directly draw the output or return a string, array of strings, matrix of characters or any other reasonable format.
Useful links

List of musical symbols.
Letter notation.

This is code-golf, so may the shortest program/function for each language win!
Bonus: try to write examples with famous melodies and let everyone try to guess which melody it is!

Sandbox.

Duplicate?

... so we can't even use the case of the letter to tell which way to draw the stem?

@Neil sorry, I'm afraid you can't. I did not make up that rule, I checked that: "the stems usually point down for notes on the middle line or higher, and up for those below".

Can we take an array of strings, with each string being a single note, as input?

@Shaggy yes, you can, I'll update the question.

Charcoal, 180 171 168 163 bytes
Ｆ⁵⁺⸿⸿×-⁺²⁷×⁸№θ ↑⁹←↙↓⁹Ｊ⁴¦⁹↑⁶↗¹↑²↖¹↓↙¹↓³↙²↓³ \Ｍ²↑(| ↘¹↙)↙¹↓²↙¹↑←_*Ｆ⪪θ «Ａ⌕AGFEDCbagfedc§ι¹λＪχλＡ⁺⁹χχ¿⁼³Ｌι§b#⁼§ι²s→Ｐ×³¬﹪λ²→Ｐ§o*›ι4¿›ι2¿›λ⁶«↗↑⁴¿›ι8«↘↘¹↓¹»»«↙↓⁴¿›ι8«↗↗¹↑¹

Try it online! Link is to verbose version of code. Explanation:
Ｆ⁵⁺⸿⸿×-⁺²⁷×⁸№θ ↑⁹←↙↓⁹

Print the stave.
Ｊ⁴¦⁹↑⁶↗¹↑²↖¹↓↙¹↓³↙²↓³ \Ｍ²↑(| ↘¹↙)↙¹↓²↙¹↑←_*

Print the clef.
Ｆ⪪θ «

Loop through each note.
Ａ⌕AGFEDCbagfedc§ι¹λ

Find the Y-coordinate of the note.
ＪχλＡ⁺⁹χχ

This is really sneaky: χ is a variable that is predefined to 10, which is exactly the X-coordinate of the first note's accidental, if it has one. After jumping to that position, 9 is added to it, representing the next note position.
¿⁼³Ｌι§b#⁼§ι²s→

Print the accidental, if there is one.
Ｐ×³¬﹪λ²→Ｐ§o*›ι4

Print the ledger lines if necessary and the note. In fact the line is printed on any even y-coordinate although printing it over the stave has no effect of course.
¿›ι2

Nothing more to do for semibreves.
¿›λ⁶«

For notes below the midpoint,
↗↑⁴

draw the stem upwards,
¿›ι8«↘↘¹↓¹

and the flag for quavers.
»»«

For notes above the midpoint,
↙↓⁴

draw the stem downwards,
¿›ι8«↗↗¹↑¹

and the flag for quavers.

You beat SOGL! :-)

@CarlosAlejo I expected it to happen. But I did expect it to beat me by like 20% also.

@dzaima maybe if it were a pure ASCII-art challenge, but this one also has a logic part that makes the output depends on the input. Nonetheless I am still getting used to what each language can do better.

SOGL V0.12, 178 175 174 173 172 171 bytes
l9*6«+@*@¶¹┐∑:@┌ŗ4Ο"γ;]∑«;‽ΗmzΖH+īN D‼,ΨU‛y‚_○¤└yΨšI‘7n2∆╬5;{" -o-”;l3=?Jζ2%Ƨ#bWGk+;}Jz7m««:U+;W7«κArBb3>?Ζo*ŗ}a2\?┌@ŗ}ē9*LI+a╬5b1>?4┐∙b8=?"■QD³‘┼}e9*5+a4-8a>?5+;2-;G↕№}╬5

Try it Here! (θ added for ease of use; To run as 171 bytes it expects the input to be on the stack)
As far as I can tell this works, but if you find any problems, tell me.
Explanation:
first part: canvas creation
l                                get the length of that array
 9*                              multiply by 9
   6«+                           add 12
      @*                         get that many spaces
        @¶                       push a space and a newline
          ¹                      put all the strings on the stack in an array
           ┐∑                    join with vertical bars
             :                   duplicate that string (which is a line with the ending barline but no staff)
              @┌ŗ                replace spaces with dashes (to make it a line with staff)
                 4Ο              encase 4 copies of the space lines in lines with the dashes
                   "...‘         push the G-clef without newlines
                        7n       split into an array of items of length 7
                          2∆╬5   at 1-indexed coordinates [2; -1] place the G-clef in the staff lines, extending the arrays size
                              ;  get the input split on spaces back on top of the stack

second part: loop, note head placement
{                        loop over the input split on spaces
" -o-”                    push a template for a note head and leger lines
      ;                   get the input optop
       l3=?            }  if the length of the input is 3, then
           J                pop the last letter off from the input
            ζ               get its unicode point
             2%             modulo 2
               Ƨ#bW         get its index in "#b"
                   G        get the template ontop
                    k       remove its 1st letter
                     +      join the replaced input and the template
                      ;     get the input back ontop to be consisntent with how the if started

sidequest: parse the rest of the inputs
J                  pop the last letter off of the remaining input string (the note), leaving the note length as string on the stack below
 z                 push the lowercase alphabet
  7m               get its first 7 letters
    ««             put the first 2 at the end
      :            duplicate it
       U+          append it uppercased to the original
         ;W        get the notes letter ontop and get its 1-indexed index in that just created string
           7«κ     subtract it from 14
              A    save on variable A
               r   convert the note length to a number
                B  save on variable B

b3>?    }          if b>3 (aka if note length is either 4 or 8)
    Ζo*ŗ             replace "o" with "*"
         a2\?   }  if a divides by 2 (aka there isn't staff nor leger lines required)
             ┌@ŗ     replace "-" with " "

ē          push the value of variable E and after that increase it (default is user input number, which errors and defaults to 0)
 9*        multiply by 9
   LI+     increase by 11
      a    push variable a
       ╬5  at those positions (e*9+11, a) insert the note head template in the canvas

third part: flags and stems
b1>?                      if b (note length)>1 (aka if the stem is needed at all)
    4┐∙                   get an array of 4 vertical bars
       b8=?       }       if b==8 (aka if the flag is needed)
           "■QD³‘           push "\    |"
                 ┼          add verically-down-then-horizontally-right

e9*                       push e*9 (now e starts with 1 as it's been increased) (the X coordinate for the flag)
   5+                     add 5 to it
     a4-                  push a-4 (the Y coordinate, 4 less than the note head as arrays get inserted from the top-left corner)
        8a>?         }    if 8>a (aka if the flag needs to be rotated)
            5+              add 5 to the Y coordinate
              ;2-;          subtract 2 from the X coordinate
                  G         get the stem&flag or stem ontop
                   ↕№       reverse it vertically and mirror characters
                      ╬5  insert the array of the stem and maybe flag at those coordinates

Your code is almost perfect. The only nitpick is that note 2bs in your example must have the stem pointing downwards.

@CarlosAlejo fixed

Great! And thanks for the explanation!

JavaScript(ES6), 616 527 bytes
Thanks @shaggy for removing almost 90 bytes
I had no idea about notes... until now, hope I got it right.

f=i=>i.map((v,p)=>(k[e=(w=q+12)*(l="AGFEDCbagfedc".search(v[1]))+p*9+12]="o*"[(s=v[0])>3|0],l<1|l>11&&(k[e-1]=k[e+1]="-"),(t=v[2])&&(k[e-2]="b#"[t>"f"|0]),--s&&[1,2,3,4].map(i=>(k[(b=l<8)?e+w*i-1:e-w*i+1]="|",s>6&&( b?k[e+w*4]="/":k[e-w*4+2]="\\",k[b?e+w*3+1:e-w*3+3]='|')))),k=[...`    /\\  ${s=" ".repeat(q=i.length*9)}
   | |  ${s}
---|-|--${l="-".repeat(q)+"|-|"}
   |/   ${t=s+"| |"}
---/|---${l}
  / |   ${t}
-|--|---${l}
 | (| \\ ${t}
-|--|--)${l}
  \\ | / ${t}
-----|--${l}
     |  ${s}
   *_/  ${s}`])&&k.join``

console.log(f(["8g","8Df","4cs","2C","1A"]))
.as-console-wrapper { max-height: 100% !important; top: 0 }
.as-console-row:after { display: none !important; }

explanation
f=i=>i.map((v,p)=>( // for each note

  k[e=(w=q+12)*(l="AGFEDCbagfedc".search(v[1]))+p*9+12]= // position in 1D array to set the note to
  "o*"[(s=v[0])>3|0], // note value (either o or *)

  l<1|l>11&&(k[e-1]=k[e+1]="-"), // add leger line

  (t=v[2])&&(k[e-2]="b#"[t>"f"|0]), // add sharp or flat

  --s&&[1,2,3,4].map(i=> // add the 4 stem lines
                     (k[(b=l<8)?e+w*i-1:e-w*i+1]="|", // durration over eigth note => add stem

                      s>6&&( // if to add a flag
                        b?k[e+w*4]="/":k[e-w*4+2]="\\", // add flag either on left or the right side

                        k[b?e+w*3+1:e-w*3+3]='|') // add the line after the flag
                     )
                    )
),
// template, extended to the final length with lines
k=[...`    /\\  ${s=" ".repeat(q=i.length*9)}
   | |  ${s}
---|-|--${l="-".repeat(q)+"|-|"}
   |/   ${t=s+"| |"}
---/|---${l}
  / |   ${t}
-|--|---${l}
 | (| \\ ${t}
-|--|--)${l}
  \\ | / ${t}
-----|--${l}
     |  ${s}
   *_/  ${s}`])&&k.join``

I think you can save some bytes by saving t[0] and t[2], and then just do q=t.length*9

Welcome to PPCG. Very nice first answer :) There is a good bit more golfing that can be done, though. I took a quick pass over if and got it down to 520 bytes, which should give you a good start.

Surely some replacing + atob/btoa would save some bytes

@Shaggy thank you very much. I have a lot to learn.

You're welcome:) You have a stray space after s>6&&( which can save you a byte. You can also save another byte with by replacing (w=q+12) with w, repeat(q=i.length*9) with repeat(w=i.length*9) and repeat(q) with repeat(w,w+=12).


text:
Code Golfing Split String in Bash
Let us play a little golfing game.
Given a single line of N space separated numbers from STDIN, one must output those numbers on N lines.
So far, I came up with the three following bash solutions :

xargs -n1 (9)
tr \ \\n (8)
fmt -1 (6)

Can anyone do better? I am eager to learn new tricks

It is frowned upon to limit the language.

It is also frowned upon to restrict the format of the input and the output.

Welcome to PPCG. You should perhaps change this to a tips question.

in bash, I think the minimum is 5, because you will have at least 2 chars for a command (single-char commands are not a thing IMO), a space, and at least 2 chars for an arg. And so I think, you are already 1st in line with fmt -1.

Can the space-separated numbers be input as a string (enclosed with quote symbols)? Can the output lines contain leading spaces with the numbers right-aligned? Can we use functions that take a string and output a string with newlines?

Can I get the the numbers from program arguments? In Tcl: puts [join $argv \n] — demo

Your tr command needs an extra space: tr \␣␣\\n (9), not tr \␣\\n (8).

@V.Courtois 1-byte commands are definitely a thing, and, well, hypothetically, a 1-byte command can do the job...

@ErikTheOutgolfer oh okay, sorry then

bash or shell? all these are shell commands - not part of bash language.

Bash (22)
read X;printf %d\\n $X  (thanks to manatwork but without literal NL)

30 read -aX;printf "%d\n" ${X[*]}
26 read X;echo -e ${X// /\n}
28 printf "%d\n" $(</dev/stdin)
27 printf "%d\n" $(</dev/fd/0)
26 printf %d\n $(</dev/fd/0)
23 read X;printf "%d\n" $X

As it says the input will contain just 1 line of numbers, read X;printf '%d␤' $X is enough. (Where ␤ is a literal line break.)