text:
Simulate My Stupid Old Alarm Clock
I have a stupid old alarm clock with two buttons: hour and minute. The hour button increments the hour of a set alarm, and minute increments the minute time of a set alarm. However, some smart designers realized that pressing both buttons at the same time should have a meaning, and decided that pressing hour and minute simultaneously would cause the alarm to be set to 12:00 am/0:00. Your task is to simulate this behavior.
Task
Given a start time and a sequence of button states, figure out the end time.
Starting from the start time, increment the hour for each occurrence of (1,0), increment the minute for each occurrence of (0,1), and set the time to 0:00 for each occurrence of (1,1). The states (0,0) should be ignored because they correspond to neither button being pressed.
When adding to minutes and hours, if the minute/hour goes above the maximum, set it to 0, i.e. incrementing a minute value of 59 should set the minute value to 0 and incrementing an hour value of 23 should set the hour value to 0. Incrementing minute/hour values above their limits do not affect the other value, for example incrementing the minute of 10:59 yields 10:00, not 11:00.
Example
Given the input time 13:58 and steps [(0,1),(0,1),(0,1),(0,0),(1,1),(1,0)],

(0,1). This corresponds to minute being pressed. The time is now 13:59.
(0,1). This corresponds to minute being pressed. The time is now 13:00.
(0,1). This corresponds to minute being pressed. The time is now 13:01.
(0,0). This corresponds to neither button being pressed. The time,unaffected, is now 13:01
(1,1). This corresponds to both buttons being pressed. The time is now 0:00.
(1,0) This corresponds to hour being pressed. The time is now 1:00.

Since we end with 1:00, it is the output.
I/O
The input will consist of a time and a sequence of button states.
The output is a single time.
The input time and output time may be

a 2-tuple of (hour, minute) or (minute, hour) in 24-hour time such as (13, 30) (hour ranges from 0 to 23 and minute ranges from 0 to 59)
same as the previous but in 12-hour time and a Boolean am/pm switch (hour ranges from 0 to 11 or 12 and 1 to 11 with minute from 0 to 59).
a number of minutes since 0:00 such as 810 (from 0 to 1439, inclusive)
any other format which encodes the same information

The sequence of button states is a representation of a list of Boolean 2-tuples, for example:

a list of tuples: [(0,1),(1,0),(0,0),(1,1)]
a space-delimited string: "01 10 00 11"
a string: "01100011"
in Quaternary: [1,2,0,3]
converted to an integer: 99
any other format which encodes the same information

Test Cases
time,steps -> output
06:49,[(0, 1)] -> 06:50
12:23,[(1, 0)] -> 13:23
02:23,[(0, 1), (1, 0)] -> 03:24
21:40,[(0, 1), (0, 1), (0, 1), (0, 1)] -> 21:44
13:10,[(0, 1), (0, 1), (0, 1), (0, 1), (1, 0), (1, 1), (0, 1), (0, 1)] -> 00:02
21:33,[(1, 0), (0, 1), (1, 0), (0, 1)] -> 23:35
14:21,[(0, 1), (0, 1), (0, 1)] -> 14:24
02:39,[(0, 0), (0, 1)] -> 02:40
16:07,[(0, 1), (0, 1), (0, 1), (0, 1), (1, 0), (1, 0), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1), (0, 1)] -> 19:16
17:55,[(0, 1), (1, 0), (0, 1)] -> 18:57
15:55,[(1, 0), (1, 0), (1, 0), (0, 1), (0, 1), (0, 1), (1, 0), (1, 0), (0, 1), (1, 0), (1, 0), (0, 1), (1, 0)] -> 23:00
22:11,[(0, 1), (1, 0), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1)] -> 00:19
03:58,[(1, 0), (0, 0), (0, 0), (0, 1), (0, 1), (1, 0), (1, 0), (0, 1), (0, 1), (1, 0), (0, 1)] -> 07:03
13:02,[(0, 1), (1, 0), (0, 1), (1, 0), (0, 1), (0, 1), (1, 0)] -> 16:06
04:37,[(1, 0), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (1, 0), (0, 1), (1, 0)] -> 08:47
00:01,[(0, 1), (1, 0), (1, 0), (0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1), (0, 1)] -> 03:08
02:58,[(1, 0), (1, 0), (0, 1)] -> 04:59
01:43,[(0, 1), (0, 1), (1, 0), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (1, 0), (0, 1)] -> 04:52
07:54,[(1, 0), (0, 1), (1, 0), (1, 0), (1, 1)] -> 00:00
09:33,[(0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1)] -> 10:38
09:01,[(0, 1), (0, 1)] -> 09:03
19:04,[(0, 1), (1, 0), (0, 1), (1, 0)] -> 21:06
11:17,[(0, 1), (1, 0), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1), (1, 1), (0, 1), (0, 1)] -> 00:02
19:32,[(0, 1), (1, 0), (0, 1), (1, 0), (1, 0), (1, 0)] -> 23:34
17:31,[(0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (1, 0), (0, 1), (0, 0), (1, 1), (0, 1)] -> 00:01
06:46,[(0, 1), (0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1), (1, 0), (1, 0), (0, 1), (0, 1), (0, 1), (1, 0), (1, 0), (0, 1), (0, 1), (0, 1), (1, 0), (0, 1), (1, 0), (0, 1), (0, 1), (1, 0), (0, 1), (0, 1), (0, 1), (1, 0), (1, 0), (0, 1), (1, 0), (0, 1), (0, 1), (0, 1), (0, 1), (0, 1)] -> 18:16

Heavily related

Test cases in [h, m] format with Quaternary steps.

Is an input format of the two sets of data as one list acceptable? For example [[initialHour, initialMinute], [hourPressed1, minuitePressed1], [hourPressed2, minuitePressed2], ...]?

@JonathanAllan Yes.

What does 1200am mean in normal digital time?

@Ferrybig 12:00am is the same as 0:00 (This is expanded upon in the "Task" section but I'll update at the top)

Jelly, 13 bytes
_`+Ạ}?/%24,60

Try it online!

Note, I'm not sure we can just go ahead and use that input format (so I asked) since the OP states "The sequence of button states is a representation of a list".

@JonathanAllan if so then OP will comment on my answer but I'm using the exact format you used in your comment...it's sometimes that OP is lazy or forgot to update the challenge

Python 2, 84 75 bytes
lambda c,a:reduce(lambda(h,m),(d,e):(d&e)and(0,0)or((h+d)%24,(m+e)%60),a,c)

Try it online!
Function that takes time as a tuple (hour,minute); outputs same way.

-3 bytes by using all(b) instead of b[0]&b[1]: lambda c,a:reduce(lambda t,b:all(b)and((t[0]+b[0])%24,(t[1]+b[1])%60)or(0,0),a,c)

73 bytes

lambda(h,m),(d,e): is this pattern matching in Python!?

C, 89 87 bytes
Thanks to @Jonathan Frech for saving two bytes!
f(h,m,s)char*s;{for(;*s;++s)*s++&1?*s&1?h=m=0:++h:*s&1&&++m;printf("%d %d",h%24,m%60);}

Try it online!

Jelly,  21  (17?) 19 bytes
17 bytes? -- If the input format: [[initHour, initMinute], [a1, b1], [a2, b2], ...] is acceptable we'd have a monadic link and may remove W; from the beginning of the second line.
Note: This is now converging towards Erik the Outgolfers Jelly answer, so I wont bother golfing more (I had not seen it)...
N⁹⁹Ạ¤?+⁸
W;ç/%24,60

A dyadic link taking a list of the initial time as integers [hour, minute] (24-hour) on the left and a list of button states [[hourPressed, minPressed], ...] on the right
which returns a list of the end result time as integers, again [hour, minute] (24-hour).
Try it online! or see the test-suite
How?
N⁹⁹Ạ¤?+⁸ - Link 1, nextState: list, currentState [cH, cM]; list, presses [pH, pM]
     ?   - if:
    ¤    - ...condition: nilad followed by link(s) as a nilad:
  ⁹      -   chain's right argument, presses
   Ạ     -   all truthy? (1 for [1,1] 0 otherwise)
N        - ...then: negate (the left argument, currentState, i.e. [-cH, -cM])
 ⁹       - ...else: chain's right argument, presses
       ⁸ - chain's left argument, currentState
      +  - add
           i.e.: if presses was [1,1] then [cH+-cH,cM+-cM]=[0,0]
                 otherwise [cH+pH,cM+cM]

W;ç/%24,60
     24,60 - literal list of integers [24,60]
    %      - modulo by (vectorises)

-1 byte by replacing ⁹Ạ¤ with Ạ}. Another -2 for using an allowed format. Finally, another -1 because the chain before the µ here is called as a dyad..

Retina, 75 bytes
.*,1:1
:
\d+
$*
O`\D1*
,

1>`:

+`1{24}:|:1{60}
:
(?<=^|:)1*
$.&
\b\d\b
0$&

Try it online! Link includes test cases. Explanation:
.*,1:1
:

Delete everything up to and including the last double button press, replacing it with an empty time (in case that's the last button press).
\d+
$*

Convert to unary.
O`\D1*

Sort the minutes to the end.
,

Add the hours together.
1>`:

Add the minutes together, but keeping the hours separate.
+`1{24}:|:1{60}
:

Reduce the hours and minute modulo 24 or 60 as appropriate.
(?<=^|:)1*
$.&

Convert to decimal.
\b\d\b
0$&

Format to two digits.

JavaScript (ES6), 55 bytes
t=>a=>a.map(x=>x>2?t=[0,0]:t[x-1]++)&&[t[0]%60,t[1]%24]

Takes input in currying syntax, with the starting time in the array form [min, hour] and the steps as a Quaternary array. Output time is in the same format as the input time.
Test Cases

let f=
t=>a=>a.map(x=>x>2?t=[0,0]:t[x-1]++)&&[t[0]%60,t[1]%24]

;[[[49, 06], [1]], [[23, 12], [2]], [[23, 02], [2, 1]], [[40, 21], [1, 1, 1, 1]], [[10, 13], [1, 1, 1, 1, 2, 3, 1, 1]], [[33, 21], [2, 1, 2, 1]], [[21, 14], [1, 1, 1]], [[39, 02], [1, 0]], [[07, 16], [1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1]], [[55, 17], [1, 2, 1]], [[55, 15], [2, 2, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2]], [[11, 22], [1, 2, 1, 1, 1, 1, 1, 2, 1, 1]], [[58, 03], [2, 0, 0, 1, 1, 2, 2, 1, 1, 2, 1]], [[02, 13], [1, 2, 1, 2, 1, 1, 2]], [[37, 04], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2]], [[01, 00], [1, 2, 2, 1, 1, 1, 2, 1, 1, 1]], [[58, 02], [2, 2, 1]], [[43, 01], [1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1]], [[54, 07], [2, 1, 2, 2, 3]], [[33, 09], [1, 1, 1, 2, 1, 1]], [[01, 09], [1, 1]], [[04, 19], [1, 2, 1, 2]], [[17, 11], [1, 2, 1, 1, 2, 1, 1, 3, 1, 1]], [[32, 19], [1, 2, 1, 2, 2, 2]], [[31, 17], [1, 1, 1, 2, 1, 2, 1, 0, 3, 1]], [[46, 06], [1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1]]]
.forEach(([time,steps])=>{
  let res = f([...time])(steps)
  console.log(JSON.stringify(time)+" -> "+JSON.stringify(res))
})
.as-console-wrapper{max-height:100%!important}

Python 3, 135 117 115 bytes
-20 bytes thanks to Jonathan Frech
def a(m,f):
 for b,c in f:
  if b&c:m=[0,0]
  elif b:m[0]=-~m[0]*(m[0]<23)
  elif c:m[1]=-~m[1]*(m[1]<59)
 return m

Try it online!
Takes the time as a list in the form [hour, minute].

You may be able to replace (m[0]+1) with -~m[0] and if m[0]<23 else 0 with *(m[0]<23).

Also, as b and c are always boolean values, you can replace b+c>1 with b&c.

76 bytes (Shortened link, due to TIO being to large for comment box)

Haskell, 58 bytes
foldl(#)
_#(1,1)=(0,0)
(h,m)#(x,y)=(mod(h+x)24,mod(m+y)60)

Try it online! Example usage: foldl(#) (23,58) [(0,1),(1,0),(0,0),(0,1),(0,1)].

Perl 6, 40 bytes
{.reduce({(@^a Z+@^b)X*!@b.min})Z%24,60}

Try it online!
Takes a list containing the start time followed by the button presses. Returns the end time. Times and buttons are (hour, minute) pairs. 24-hour time.

Perl 5, 70 bytes
69 bytes of code + 1 for -n flag
s/.*d/0:0/;/(.*):(\d+)/;printf"%02d:%02d",($1+y/c//)%24,($2+y/b//)%60

Try it online!
Input Format
hh:mm,abcdabcdabcdaddccbbaa
where:
hh=start hour
mm=start minute
 a = (0, 0) = no buttons pressed
 b = (0, 1) = minute button pressed
 c = (1, 0) = hour button pressed
 d = (1, 1) = both buttons pressed

Spaces or other separators between the presses are insignificant.
Explanation
s/.*d/0:0/;    # If both buttons were ever pressed, previous presses
               # don't matter.  Get rid of them and set start time to midnight.
/(.*):(\d+)/;  # Extract start hour and minute
printf"%02d:%02d",            # Output numbers with leading 0
($1+y/c//)%24,                # Take starting hour, add number of presses, remainder 24
($2+y/b//)%60                 # Take starting minute, add number of presses, remainder 24

Swift, 106 96 bytes
-10, thanks to Xcoder
func x(m:(Int,Int),n:[(Int,Int)]){let i=n.reduce(m){($0.0+$1.0,$0.1+$1.1)};print(i.0%24,i.1%60)}

Try it on ideone!
function will take initial value and array of tuples and returns final time.

96 bytes, by printing to STDOUT instead: func x(m:(Int,Int),n:[(Int,Int)]){let i=n.reduce(m){($0.0+$1.0,$0.1+$1.1)};print(i.0%24,i.1%60)}. This also gets rid of typealias.

By the way, welcome to PPCG! Amazing first answer.

thank you so much, actually I used print() first... but I forgot after switching between different implementations. Thanks again for your help.

C# (.NET Core), 93 bytes
(n,l)=>{for(int i=0,x;i<n.Length;){x=n[i++];if(x>1)l[0]=l[1]=0;else{l[x]=++l[x]%(24+36*x);}}}

Try it online!
Takes input as in trinary, with 0==(1,0),1==(0,1),2==(1,1), and the time in an array with index 0 being hours and 1 being minutes. Modifies the time array in place.

R, 61 bytes
function(I,B){for(b in B)I=I+"if"(sum(b)>1,-I,b)
I%%c(24,60)}

Takes I as a length-2 vector c(H,M) and B as a list of length-2 vectors for the buttons, c(H,M). Iterates through B, setting I to c(0,0) if the sum is 2. Then it mods down at the end. There's also a function in the header to translate the button presses into the right R format if you'd like to test them all; it takes the array [(H,M),...] as a string.
Try it online!

Terrapin Logo, 304 bytes
Not optimized; lots of spaces.
MAKE "M :B MAKE "H :A LABEL "L IF EMPTY? :I OP LIST :H :M MAKE "C FIRST :I IF AND ((ITEM 2 :C)=1) ((ITEM 1 :C) = 0) MAKE "M :M+1 IF :M=60 MAKE "M 0 IF AND ((ITEM 1 :C) = 1) ((ITEM 2 :C)=1 MAKE "M 0 MAKE "H 0 IF AND ((ITEM 1 :C)-1) ((ITEM 2 :C) = 0) MAKE "H :H + 1 IF :H = 23 MAKE "H 0 MAKE "I BF :I GO "L

Takes a list as its first input and the starting hour+minute (seperate inputs) as second and third, respectively.
I can't copy+paste from Terrapin Logo as it's a trial version so that's that :(

Mathematica, 54 bytes
Switch[#2,a={0,0},#,a+1,a,_,Mod[+##,{24,60}]]&~Fold~#&

Anonymous function. Takes a list of 2-tuples as input and returns a 2-tuple as output.

Scala, 116 bytes
So I just take the start time as two first parameters of my func (h and m), and I take the input sequence as an Array[Tuple2].
var x=h
var y=m
for(u<-a)u match{case (0,1)=>y=(y+1)%60
case (1,0)=>x=(x+1)%24
case (1,1)=>{x=0;y=0}
case _=>}
(x,y)

I wonder ... should I count the func declaration (def time(h:Int,m:Int,a:Array[Tuple2[Int,Int]]):Tuple2[Int,Int]={ plus the ending }) in byte count?
Try it online!

Pyth, 22 bytes
%Vu?.AH,00+VGHEQ,24 60

Try it here.


text:
Calculate the longest series of 1's in an integer's binary value
Goal
Given a non-negative integer, create a function that returns the starting position of number of largest consecutive 1's in that integer's binary value.
When given an input 0, return 0.
If the number has multiple streaks of equal length, you must return the position of the last streak.
Input
An integer greater than or equal to 0.
Output
An integer calculated as explained below.
Rules

This is code-golf, so the shortest code in bytes in each language wins.
Standard loopholes are forbidden.

Examples and Test Cases
Example 1

Your function is passed the integer 142
142 is equal to 10001110 in binary
Longest streak is "111" (a streak of three ones)
The streak starts at the 2^1 position
Your function returns 1 as the result

Example 2

Your function is passed the integer 48
48 is equal to 110000 in binary
Longest streak is "11" (a streak of two ones)
The streak starts at the 2^4 position
Your function returns 4 as the result

Example 3

Your function is passed the integer 750
750 is equal to 1011101110 in binary
Longest streak is "111" (a streak of three ones)
Since there are two streaks of equal length, we return the later streak.
The later streak starts at the 2^5 position
Your function returns 5 as the result

You need a winning criterion, like [tag:code-golf]

@Okx It had been mentioned in the body itself so I added the tag.

Make sure people test 0. That's an important test case.

Instead of "last streak" or "latest streak", I'd suggest "streak with the largest place value".

@Okx Why is a winning criterion necessary? Why can't it simply be a puzzle?

@corsiKa Because those are the rules on PPCG.

@Okx Interesting - apparently "puzzle" is specifically defined as "I have this code that you must change to win the puzzle" - an arbitrary definition that has apparently confused more than just myself in the past. Thank you for the accurate, if terse, response.

Congratulations to Dennis! A solution of only 8 bytes, written in Jelly. https://codegolf.stackexchange.com/a/143030/67327

Jelly, 10 8 bytes
Ba\ÐƤṀċ¬

Try it online!
How it works
Ba\ÐƤṀċ¬  Main link. Argument: n

B         Binary; convert n to base 2.

   ÐƤ     Apply the link to the left to all postfixes of the binary array.
 a\         Cumulatively reduce by logical AND.

          For example, the array

          [1, 0, 1, 1, 1, 0, 1, 1, 1, 0]

          becomes the following array of arrays.

          [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
             [0, 0, 0, 0, 0, 0, 0, 0, 0]
                [1, 1, 1, 0, 0, 0, 0, 0]
                   [1, 1, 0, 0, 0, 0, 0]
                      [1, 0, 0, 0, 0, 0]
                         [0, 0, 0, 0, 0]
                            [1, 1, 1, 0]
                               [1, 1, 0]
                                  [1, 0]
                                     [0]

     Ṁ    Take the lexicographical maximum, i.e., the array with the most 1's at
          the beginning, breaking ties by length.

       ¬  Yield the logical NOT of n, i.e., 0 if n > 0 and 1 if n = 0.

      ċ   Count the occurrences of the result to the right in the one to the left.

Congratulations!

JavaScript (ES6),  33  32 bytes
f=x=>x&(k=x>>1)?f(x&k):k&&1+f(k)

Try it online!

JavaScript (ES6),  41 40 36  34 bytes
Saved 4 bytes thanks to @ThePirateBay
f=x=>(k=x&x/2)?f(k):Math.log2(x)|0

Try it online!
How?
General case x > 0
We recursively AND the input x with x / 2 which progressively reduces the patterns of consecutive set bits until only the rightmost bit of the sequence remains. We keep a copy of the last non-zero value and determine the position of its most significant bit by floor-rounding its base-2 logarithm.
Below are the steps we go through for x = 750 (1011101110 in binary).
    1011101110 --.
,----------------'
'-> 1011101110
AND 0101110111
    ----------
=   0001100110 --.
,----------------'
'-> 0001100110
AND 0000110011
    ----------
=   0000100010 --.  --> output = position of MSB = 5  (0000100010)
,----------------'                                         ^
'-> 0000100010
AND 0000010001
    ----------
=   0000000000

Edge case x = 0
The special case x = 0 immediately leads to Math.log2(0) | 0. The logarithm of 0 evaluates to -Infinity and the binary bitwise OR forces a coercion to a 32-bit integer. In compliance with the specification of the abstract operation ToInt32, this gives the expected 0:

If number is NaN, +0, −0, +∞, or −∞, return
+0

This errors for the input 0, which is part of the input range.

@JustinMariner Fixed.

What about Math.log2(k)|0 instead of 31-Math.clz32(k)? Or am I missing something?

@ThePirateBay Math.log2(k)|0 is actually both shorter and simpler for the special case x=0. Thanks. :)

Very nice algorithm, and good explanation.  I implemented it in 14 bytes of x86 machine code.

x86/x86-64 machine code, 14 bytes
(TODO: 13 bytes with input in EAX, return value in EDX).
Using @Arnauld's algorithm of x &= x>>1 and taking the highest set bit position in the step before x becomes 0.
Callable from C/C++ with signature unsigned longest_set(unsigned edi); in the x86-64 System V ABI.  The same machine-code bytes will decode the same way in 32-bit mode, but the standard 32-bit calling conventions don't put the first arg in edi.  (Changing the input register to ecx or edx for Windows _fastcall / _vectorcall or gcc -mregparm could be done without breaking anything.)
   address   machine-code
             bytes
                         global longest_set
 1                       longest_set:
 2 00000000 31C0             xor  eax, eax    ; 0 for input = 0
 3
 4                       .loop:               ; do{
 5 00000002 0FBDC7           bsr  eax, edi    ;  eax = position of highest set bit
 6                           ;; bsr leaves output unmodified when input = 0 (and sets ZF)
 7                           ;; AMD documents this; Intel manuals say unspecified but Intel CPUs implement it
 8 00000005 89F9             mov  ecx, edi
 9 00000007 D1E9             shr  ecx, 1
10 00000009 21CF             and  edi, ecx
11 0000000B 75F5             jnz .loop        ; } while (x &= x>>1);
12
13 0000000D C3               ret

x86's BSR instruction (Bit Scan Reverse) is perfect for this, giving us the bit-index directly, rather than counting leading zeros.  (bsr doesn't directly produce 0 for input=0 like 32-lzcnt(x) would, but we need bsr=31-lzcnt for non-zero inputs, so lzcnt wouldn't even save instructions, let alone byte count.  Zeroing eax before the loop works because of bsr's semi-official behaviour of leaving the destination unmodified when the input is zero.)
This would be even shorter if we could return the MSB position of the longest run.  In that case, lea ecx, [rdi+rdi] (3 bytes) would copy + left-shift instead of mov + shr (4 bytes).
See this TIO link for an asm caller that does exit(longest_set(argc-1));
Testing with a shell loop:
l=(); for ((i=0;i<1025;i++));do
    ./longest-set-bitrun "${l[@]}";   # number of args = $i
    printf "$i %#x: $?\n" $i;
    l+=($i);
done | m

0 0: 0
1 0x1: 0
2 0x2: 1
3 0x3: 0
4 0x4: 2
5 0x5: 2
6 0x6: 1
7 0x7: 0
8 0x8: 3
9 0x9: 3
10 0xa: 3
11 0xb: 0
12 0xc: 2
13 0xd: 2
14 0xe: 1
15 0xf: 0
16 0x10: 4
17 0x11: 4
18 0x12: 4
19 0x13: 0
20 0x14: 4
21 0x15: 4

...

747 0x2eb: 5
748 0x2ec: 5
749 0x2ed: 5
750 0x2ee: 5
751 0x2ef: 0
752 0x2f0: 4
753 0x2f1: 4
754 0x2f2: 4

13 bytes with a custom calling convention
We could save a byte by taking the arg in EAX and returning in EDX: then we could use cdq (1 byte) to zero the return value in the case where input = 0 (so bsr leaves it unmodified).  The value in other cases doesn't matter, overwritten by bsr.
So cdq replaces xor eax, eax, saving a byte.
We do need a 0 in a different register to (not) overwrite; in the non-zero case we can't let bsr replace the input value with its log2.  So we can't avoid the instruction entirely, and taking input + returning in EAX (like GCC regparm) would mean we'd need to start with mov edx, eax or something to copy it somewhere else, while leaving the return value 0 for the input=0 case.

Nice! A note to those who (like me) are more familiar with other assembly dialects: the x86 BSR mnemonic stands for "Bit Scan Reverse", not "Branch to SubRoutine".

@Arnauld: good point, edited to decode the mnemonic as well as having a link to the insn reference manual entry.

Python 2, 45 bytes
f=lambda x:f(x&x/2)if x&x/2else len(bin(x))-3

Try it online!
Saved plenty of bytes thanks to Dennis! (The heads up for len(bin(...))-3 instead of math.frexp)
Thanks to @xnor for finding a bug, which fortunately was easily fixable!

This seems to give wrong answers such as for x=3, I think because the and/or short-circuits wrong when the function returns 0.

@xnor Thanks for noticing that! It's fixed.

Jelly, 19  17 11 bytes
HÐĿ&\ḟ0ṪBL’

Try it online!
-6 (!) bytes thanks to @Dennis's keen observations
How it Works
HÐĿ&\ḟ0ṪBL’
HÐĿ         - halve repeatedly until reaching 0 due to rounding
   &\       - cumulative AND
     ḟ0Ṫ    - final non-zero, or 0 if all elements are 0
        BL  - length of binary representation (log base 2). 0->[0]->1
          ’ - decrement

Errors for 0, which is in the input range.

@Mr.Xcoder Fixed

You can save a byte for the fix with ȯ-µ...

@JonathanAllan I don't understand how OR-ing would help. Do you have code?

Looks like you saved more with ×Ṡ anyway. It was OR-ing the input with -1, so all input remained the same except 0 which became -1, for which your method yields 0. code

Since B always returns an array that begins with a 1, BUṪMṪ’×Ṡ can become ṪBL’. Also, you don't need the Ḟ, and ḟ0 saves one byte over ¹Ðf.

Perl 6, 45 35 bytes
This highly improved version is courtesy of @nwellnhof.
{.msb+1-(.base(2)~~m:g/1+/).max.to}

Try it online!

You can simply match with :g to get all matches. With the smart-match operator, I could golf it down to 40 bytes: {sort(.base(2).flip~~m:g/1+/).tail.from}

And to 35 bytes: {.msb+1-(.base(2)~~m:g/1+/).max.to}

@nwellnhof, thank you very much. I somehow missed the :g and didn't figure out how I can use adverb with the smartmatch operator. Also the .msb method is quite helpful here and I didn't know about it before.

05AB1E, 14 12 11 bytes
bDγàŠrkrJgα

Try it online! or run test cases.
Explanation
bDγàŠrkrJgα  Implicit input (ex: 750)
bD           Convert input to binary string and duplicate
                 '1011101110', '1011101110'
  γ          Split into groups of 1s or 0s
                 '1011101110', ['1', '0', '111', '0', '111', '0']
   à         Pull out max, parsing each as an integer
                 '1011101110', ['1', '0', '0', '111', '0'], '111'
    Šrk      Rearrange stack and get first index of max run of ones
                 ['1', '0', '0', '111', '0'], 2
       rJg   Reverse stack, join the array to a string, and get its length
                 2, 7
          α  Get absolute difference
                 5

Python 2, 89 78 bytes
m=t=i=j=0
for c in bin(input()):
 t=-~t*(c>'0');i+=1
 if t>m:j=i;m=t
print i-j

Try it online!
EDIT: Saved 11 bytes thanks to Mr. Xcoder.

86 bytes

78 bytes

@Mr.Xcoder I also thought of that, though the question specifically asks to write a function.

@JonathanFrech I don't think the OP really meant function. Probably just a generic term.

@Mr.Xcoder Please explain this. Thanks,

@lifebalance (t+1) can be replaced by -~t, which is a bitwise operation that performs the exact same task. ~number = - number - 1, - is negation, hence -~t = - (- t - 1) = t + 1. This has the advantage of not requiring parenthesis. Then, c=='1' can be replaced by c>'0', because 1 has a higher ASCII code point, and thus can be compared using >.

For 926 (0b1110011110), this should return 1, but it returns 7. What gives?

@Mr.Xcoder As @lifebalance found out, you cannot use c>'0' instead of c=='1', as the bin(...) function adds a 0b in front to the binary string. Because 'b'>'0', though 'b'!='1', this method returns the wrong index for inputs like 926.

@lifebalance The leading b in 0b1110011110 is falsely interpreted as a 1.

If my edits are accepted using format(), we can avoid the 0b altogether.

@lifebalance I think it would be better for you to comment your golfed version instead of suggesting an edit.

J, 18 17 bytes
(#-0{#\\:#.~\)@#:

Try it online!
Explanation
(#-0{#\\:#.~\)@#:  Input: integer n
               #:  Binary
     #\            Length of each prefix
       \:          Sorted down using
         #.~\      Mixed base conversion on each prefix
   0{              Get the value at index 0
  -                Subtract from
 #                 Length

Very slick.  Not sure I fully understand what's going on with the mixed base conversion though.  Why does it count the number of consecutive ones at the end of the string?  Also, if the bases being specified on the x of the dyad are all 0 and 1, what does that mean? A base 2 number has digits 0 and 1, so a base 1 number has digits... 0?  then what does a 1 mean in that context?  And is a base 0 number just always 0?

@Jonah It's more due to how mixed base conversion is implemented. x #. y first computes w =: */\. }. x , 1 then returns +/ w * y

so would you consider this a golf hack rather than a legitimate use of #., since you are relying on internal implementation details rather than the public api?

C# (.NET Core), 64 60 bytes
T=a=>(a&a/2)>0?T(a&a/2):Math.Log(a,2)<0?0:(int)Math.Log(a,2)

Try it online!
A C# version of @Arnauld's answer
Acknowledgements
4 bytes saved thanks to Kevin Cruijssen.
C# (.NET Core), 131 123+18=141 bytes
a=>{string s=Convert.ToString(a,2),t=s.Split('0').OrderBy(x=>x.Length).Last();return a<1?0:s.Length-s.IndexOf(t)-t.Length;}

Try it online!
+18 bytes for using System.Linq;
Acknowledgements
8 bytes saved thanks to Grzegorz Puławski.
Degolfed
a=>{
    string s=Convert.ToString(a,2),      // Convert to binary
    t=s.Split('0')                       // get largest group of 1's
       .OrderBy(x=>x.Length)
       .Last();
    return
        a<1?0:                          // handle 0 case
        s.Length-s.IndexOf(t)-t.Length; // get position in reversed string
}

C# (.NET Core), 164 161 bytes
a=>{var s=Convert.ToString(a,2);int c=0,l=0,p=0,k=0,j=s.Length-1,i=j;for(;i>=0;i--){if(s[i]>'0'){if(i==j||s[i+1]<'1'){p=i;c=0;}if(++c>=l){l=c;k=p;}}}return j-k;}

Try it online!
A non-Linq solution, which I'm sure could be improved, though nothing is immediately apparent.
Degolfed
a=>{
    var s=Convert.ToString(a,2); // Convert to binary
    int c=0,l=0,p=0,k=0,j=s.Length-1,i=j;
    for(;i>=0;i--)               // Loop from end of string
    {
        if(s[i]>'0')             // if '1'
        {
            if(i==j||s[i+1]<'1') // if first digit or previous digit was '0'
            {
                p=i;             // set the position of the current group
                c=0;             // reset the count
            }
            if(++c>=l)           // if count is equal or greater than current largest count
            {
                l=c;             // update largest count
                k=p;             // store position for this group
            }
        }
    }
    return j-k;                  // as the string is reversed, return string length minus position of largest group
}

You can save 8 bytes by ditching r in the first answer: https://tio.run/##dY9RS8MwFIWfza/I2xJoQzcmilkrKAhCZUILPof0OgM10dzb0VH622sdE3zYXi6c83Eu51hMbYgwdej8jlcHJPjU7L9SpfPfmtnWIPLXgSEZcpY/dd5unKeEz6fgNc/5ZPJiQIq/Wcwfg99DJFWH6mgJk6xkQjmq6qt1JBbZQqptbCA@HESfF70qwe/oQ6rSIAmpI1AXPTeb5X12hyeaonr2DfTbd0EypZOrx0mzv2b74Br@YpwXkg3sau6BoQX1Fh3BvAVELTIp9XmyXK8usvXtRXRzfXw5snH6AQ

You can save two bytes in your port of Arnauld's like this: T=a=>{int x=(int)Math.Log(a,2);return(a&=a/2)>0?T(a):x<0?0:x;}

Or even two more bytes saved (60 bytes): T=a=>(a&a/2)>0?T(a&a/2):Math.Log(a,2)<0?0:(int)Math.Log(a,2)

Python 3, 46 bytes
f=lambda x:x&x>>1and f(x&x>>1)or len(bin(x))-3

Try it online!

what is the purpose of importing math lib?

Good catch. Thanks,

C (gcc), 81 80 bytes
i,l,c,r;f(n){for(i=l=c=r=0;n;n/=2,i++)c=n&1?c+1:c>=l?r=i-(l=c),0:0;n=c<l?r:i-c;}

Try it online!
C (gcc), 43 bytes
A C version of @Arnauld's answer
k;f(n){n=(k=n&n/2)?f(k):(k=log2(n))<0?0:k;}

Try it online!

Miss the return n; or return k; statement

Suggest n<1?0:log2(n) instead of (k=log2(n))<0?0:k

Google Sheets, 94 bytes
=Len(Dec2Bin(A1))-Find(MAX(Split(Dec2Bin(A1),0)),Dec2Bin(A1))-Len(MAX(Split(Dec2Bin(A1),0)))+1

No, it's not very pretty. It'd be real nice to be able to store Dec2Bin(A1) as a variable for reference.
Key point: Like Excel, the Dec2Bin function has a max input value of 511. Anything larger than that returns an error, as seen below.

APL (Dyalog Unicode), 21 bytes (SBCS)
−1 thanks to rabbitgrowth.
Requires ⎕IO←0 which is default on many systems.
⊃⌽⍸b⍷⍨∨⌿↑⊆⍨b←⌽2⊥⍣¯1⊢⎕

Try it online!
⎕ prompt for input
⊢ yield that (separates ¯1 from ⎕)
2⊥⍣¯1 convert to base-2, using as many positions as needed
⌽ reverse
b← store as b (for binary)
⊆⍨b self-partition b (i.e. the 1-streaks of b)
↑ mix (make list of lists into matrix, padding with zeros)
∨⌿ vertical OR reduction (yields longest streak)
b⍷⍨ mark the start positions of that in b
⍸ ɩndices of those starting positions
⌽ reverse
⊃ pick the first one (yields zero if none available)

you're missing a ∇ in the footer on tio

@ngn Right you are.

MS SQL Server, 437 426 407 398 bytes
SQL Fiddle
I'm sure that I could remove line breaks, etc, but this is as compact as I was willing to make it:
create function j(@ int)
returns int
as BEGIN
declare @a varchar(max)='',@b int,@c int=0,@d int=0,@e int=0,@f int=0,@g int=0,@h int=0
while @>0 BEGIN SELECT @a=cast(@%2 as char(1))+@a,@=@/2
END
SET @b=len(@a)
while @<@b
BEGIN
select @c=@d,@d=cast(substring(@a,@b-@,1)as int)
IF @d=1
BEGIN IF @c=0
SELECT @e=@,@g=1
else SET @g+=1 END
IF @g>=@h BEGIN select @h=@g,@f=@e END
SET @+=1
END
return @f
END

Here's a more readable version:
create function BinaryString(@id int)
returns int
as BEGIN
  declare @bin varchar(max)
  declare @binLen int
  declare @pVal int = 0
  declare @Val int = 0
  declare @stC int = 0 --start of current string of 1s
  declare @stB int = 0 --start of biggest string of 1s
  declare @lenC int = 0 --length of current string of 1s
  declare @lenB int = 0 --length of biggest string of 1s

  set @bin = ''

    while @id>0
      BEGIN
        SET @bin = cast(@id%2 as varchar(1)) + @bin
        SET @id = @id/2
      END

    SET @binLen = len(@bin)

    while @id<@binLen
      BEGIN
        set @pVal = @Val
        set @Val = cast(substring(@bin,@binLen-@id,1) as int)
        IF @Val = 1 and @pVal = 0
          BEGIN
            SET @stC = @id
            SET @lenC = 1
          END
        IF @Val = 1 and @pVal = 1
          BEGIN
            SET @lenC = @lenC + 1
          END
        IF @lenC >= @lenB
          BEGIN
            set @lenB = @lenC
            set @StB = @StC
          END

        SET @id = @id + 1
      END

  return @StB
END

The real trick is that as far as I could find, there is no native SQL functionality to convert a number from decimal to binary. As a result, I had to code the conversion to binary manually, then I could compare that as a string, one character at a time until I found the right number.
I'm sure there's a better way to do this, but I didn't see a(n) SQL answer, so I figured I'd throw it out there.

If you can golf it more, please do so. But otherwise, this is great! Welcome to PPCG!

@NoOneIsHere thanks! I realized I can shorten my function name too ;)

Jelly, 19 bytes
BŒgḄṀB
BwÇɓÇL+ɓBL_‘

Try it online!
Thanks to Jonathan Allan for saving  4  6 bytes!
I've worked too much to just abandon this, although it is kind of long. I really wanted to add a solution that literally searches for the longest substring of 1s in the binary representation...
Explanation

BŒgḄṀB  - Monadic helper link. Will be used with Ç in the next link.

B       - Binary representation.
 Œg     - Group runs of consecutive equal elements.
   Ḅ    - Convert from binary to integer.
    Ṁ   - Maximum value.
     B  - Convert from integer to binary.

BwÇɓÇL+ɓBL_‘  - Main link.

B             - Binary representation (of the input).
  Ç           - Last link as a monad. Takes the input integer.
 w            - First sublist index.
   ɓ          - Start a separate dyadic chain. Reverses the arguments.
    Ç         - Last link as a monad.
     L        - Length.
      +       - Addition
       ɓ      - Start a separate dyadic chain. Reverses the arguments.
        B     - Binary.
         L    - Length.
          _‘  - Subtract and increment the result (because Jelly uses 1-indexing).
              - Implicitly output.

Your helper link could be BŒgḄṀB instead

@JonathanAllan Oh wow thanks!

Your main link could be BwÇɓÇL+ɓBL_‘

@JonathanAllan Wow, thanks again!

Haskell, 101 98 96 75 bytes
snd.maximum.(`zip`[0..]).c
c 0=[0]
c n|r<-c$div n 2=sum[r!!0+1|mod n 2>0]:r

Try it online! Usage: snd.maximum.(`zip`[0..]).c $ 142 yields 1.
Explanation:

c converts the input into binary while at the same time counting the length of streaks of one, collecting the results in a list. r<-c$div n 2 recursively computes the rest r of this list, while sum[r!!0+1|mod n 2>0]:r adds the current length of the streak to r. The list comprehension checks if mod n 2>0, that is whether the current binary digit is a one, and if so, takes the length of the previous streak (the first element of r) and adds one. Otherwise the list comprehension is empty, and sum[] yields 0.
For the example input, c 142 yields the list [0,3,2,1,0,0,0,1,0].
(`zip`[0..]) adds the position to each element of the previous list as the second component of a tuple. For the example this gives [(0,0),(3,1),(2,2),(1,3),(0,4),(0,5),(0,6),(1,7),(0,8)].
maximum finds the lexicographically maximal tuple in this list, that is the streak lengths are considered first as they are the first component, and in the event of a tie the second component, namely the larger index, decides. This yields (3,1) in the example, and snd returns the second component of the tuple.

Jelly,  14 13 12  11 bytes
Bµṣ0Ṫ$ƤMḢạL

A monadic link taking and returning non-negative integers.
Try it online! or see the test-suite.
How?
Bµṣ0Ṫ$ƤMḢạL - Main link: number, n                   e.g. 750
B           - convert to a binary list                    [1,0,1,1,1,0,1,1,1,0]
 µ          - monadic chain separation, call that b
      Ƥ     - map over prefixes:  (i.e. for [1], [1,0], [1,0,1], [1,0,1,1],...)
     $      -   last two links as a monad:                e.g.: [1,0,1,1,1,0,1,1]
   0        -     literal zero                                   0
  ṣ         -     split (prefix) at occurrences of (0)           [[1],[1,1,1],[1,1]]
    Ṫ       -     tail                                                        [1,1]
       M    - maximal indices                             [5,9]
        Ḣ   - head                                        5
          L - length (of b)                               10
         ạ  - absolute difference                         5

I had a similar solution but used ŒrṪP on the prefixes instead.

Husk, 12 bytes
→S§-€¤≠Lo▲gḋ

Try it online!
Explanation
                 Implicit input, e.g                           750
           ḋ     Convert to binary                             [1,0,1,1,1,0,1,1,1,0]
          g      Group equal elements                          [[1],[0],[1,1,1],[0],[1,1,1],[0]]
        o▲       Maximum                                       [1,1,1]
    €            Index of that substring in the binary number  3
     ¤≠L         Absolute difference of lengths                abs (3 - 10) = 7
 S§-             Subtract the two                              7 - 3 = 4
→                Increment                                     5

Kotlin, 77 bytes
{val b=it.toString(2)
b.reversed().lastIndexOf(b.split(Regex("0+")).max()!!)}

Beautified
{
    val b = it.toString(2)
    // Find the left position of the first instance of
    b.reversed().lastIndexOf(
            // The largest group of 1s
            b.split(Regex("0+")).max()!!)
}

Test
var s:(Int)->Int =
{val b=it.toString(2)
b.reversed().lastIndexOf(b.split(Regex("0+")).max()!!)}
fun main(args: Array<String>) {
    r(0, 0)
    r(142, 1)
    r(48, 4)
    r(750, 5)
}

fun r(i: Int, i1: Int) {
    var v = s(i)
    println("$i -> $v [$i1] ${i1 == v}")
}

I did not test but think this works in scala too.

R, 117  Bytes
z=rev(Reduce(function(x,y)ifelse(y==1,x+y,y),strtoi(intToBits(scan())),,,T));ifelse(!sum(z),0,33-which.max(z)-max(z))

104 bytes! Instead of rev, use Reduce(...,T,T) to accumulate from the right (switching x,y in the function definition). Then use 1+max(z)-which.max(z) since the result is somewhat different. Use "if" instead of "ifelse" since we don't need the vectorization; aaand if you use any(z) instead of !sum(z) you drop a byte.

I think we should be able to get this to less than 100 bytes.

@giuseppe I feel somewhat a cheater for being here before you! Will do times tnx a bunch!

But a nice approach no ?

Oh, no worries, I saw this earlier but didn't feel like answering it because R is so bad at bit operations... Yeah, good work, you got my +1

instead of that nasty Reduce, use y=strtoi(intToBits(scan()));z=cumsum(y)*y

76 bytes

Ahhh but using the reduce is what I liked in this.... anyways I think your suggestion is a completely different approach and you should post it....

Well, the cumsum(y)*y is equivalent to your Reduce, so I'd say it's still your answer, but I leave it to your conscience.

Please do man... I'm with no R till Monday anyways....

Excel VBA, 54 44 Bytes
-10 Bytes thanks to @EngineerToast
Anonymous VBE immediate window function that takes input from range [A1] and outputs to the VBE immediate window
?Instr(1,StrReverse([Dec2Bin(A1)]),1)+[A1>0]

Besides the oversight having C1 still in there instead of A1, I think you can output the Instr results directly with a little twisting for the zero input correction: ?Instr(1,StrReverse([Dec2Bin(A1)]),1)+([A1]>0) (46 bytes). True = -1 because... VBA.

@EngineerToast - Sweet! I should have seen that; I was able to drop it down 2 bytes by bringing the >0 into the [A1] notation

MATL, 15 bytes
`tt2/kZ&t]xBnq&

Try it online!
Uses the half and AND idea.  The k is necessary only to make it terminate for 1 - for some reason, 1 AND 0.5 returns 1, causing an infinite loop.
(alternate solution: BtnwY'tYswb*&X>)- by converting to binary and run-length encoding)

APL (Dyalog Classic), 24 21 bytes
63|-⊃⍒+/×\↑,⍨\⎕⊤⍨64⍴2

Try it online!

Java 8, 81 bytes
int c(int n){int x=(int)(Math.log(n)/Math.log(2));return(n&=n/2)>0?c(n):x<0?0:x;}

Port of @Arnauld's JavaScript answer.
Try it here.

R, 66  Bytes
function(i){a=rle(intToBits(i));max(0,a[[1]][which(a[[2]]==1)])}

Explanation:
function(i){
  a = rle(                  # Run-length encode
    intToBits(i)            # The bits in i
  );                        # And assign it to a.
  max(0,                    # Return the maximum of zero and
      a[[1]][               # The lengths of a,
        which(a[[2]]==1)    # But only those where the repeated bit is 1
        ])
}

This returns the length of the longest streak, not its position. Check against the test cases and the specs at the top.

I will change my downvote to an upvote once this answer is corrected. Also, note that you can use a$l instead of a[[1]] and a$v instead of a[[2]] to save some bytes :), as well as >0 instead of ==1.

Javascript, 54 chars
f=i=>i.toString(2).split(0).sort().reverse()[0].length

i.toString(2) gets the binary string for the integer.
The .split(0) gets each sequential ones part in an array element.
.sort().reverse() gets us the highest value as first.
The [0].length gives us the length of that first value.

the starting position of number of largest consecutive 1's

Python 2, 41 bytes
f=lambda n:n/2and(n&n/2<1)+f(n&n/2or n/2)

Try it online!
Based on this solution by Mr. Xcoder.

Objective-C, 96 chars
for(int h=0,c=0,l=0,p=0;;x/=2,p++){if(x%2==0){if(c<=h){h=c;l=p;}c=0;if(x==0){return p;}}else{c++;}}

If x is even the highest count is checked and count resets
If x is also 0 then return the highest count
If x isn't even, then the last digit is 1 and count increments
x is divided by two

Isn't this supposed to return the bit position of the highest count, not the count value.

Yes it is. I did not catch that. Thank you for pointing that out.

Perl 5, 45 + 1 (-p)
(sprintf"%b",$_)=~/(1+)(?!.*1\1)/;$_=length$'

If you write this out on the command line of most shells, you may have to type this as:
perl -pE'(sprintf"%b",$_)=~/(1+)(?!.*1\1)/;$_=length$'"'"

The dance of the quotes at the end is just to get perl see a ', which would otherwise be consumed by the shell.

Javascript, 71 bytes
I was thinking about regular expressions and...
x=>+x.toString(2).replace(/.*?0?(1*)(?!.*\1[1])(.*)/,(x,m,a)=>a.length)

Regex101 link

Retina, 52 43 bytes
Convert to binary, then replace with the length of what follows the largest string of ones.
.*
$*
+`(1+)\1
$+0
01
1

$'¶
O`
A-3`
^1+

.

Try it online - all test cases
Saved 9 bytes thanks to Martin.

You can use $+ for ${1}. But you can save even more by replacing the last stage with a bunch of stages like this: https://tio.run/##K0otycxL/K/qrpHA9V9Pi0tFi0s7QcNQWzPGkEtF24DLwJDLkItLRf3QNi7/BC5HXeMErjhDbS4uvf//DbgMTYy4TCy4zE0NAA

@MartinEnder Ok. The ${1} was copied from your tutorial on Github.

Pyth, 17 bytes
This is a recursive function. The link includes y in order to call the function on the given input.
L|&K.&b/b2yKsl|b1

Verify all test cases.
Pyth, 20 bytes
-lK.B|Q1+xKJeScK\0lJ

Verify all test cases.

Python 3, 83 bytes
len(bin(num)[2:].split('1'*(max(list(map(len,bin(num)[2:].split('0'))))))[1])

Try it online!
It does not support the condition that two or more arrays of 1s are longest.

Mathematica, 44 bytes
I feel like I can trim off a few more bytes, though I'm not sure how yet.
We save space by using an assignment within If, using #0 for pure function recursion, and using infix notation when possible.
If[(k=BitAnd[#,#/2])>0,#0@k,Log2@#~BitOr~0]&

Try it online!

Zsh, 53 bytes
b=$[[##2]$1];set ${(Ons:0:)b};<<<$[$#b-${(SE)b#$1}+1]

Try it online!
58b
60b
b is argument $1 in binary. Then we set $1 again, to the longest sequence of 1s in b. ${(SE)b#$1 finds the first occurrence (from the left) of $1 in b, and returns the index+1 of the last matching char. However since the question is counting by powers of 2 we do a subtraction from the length of b.
Other approaches reverse b, but that took more bytes.

source: Stack Exchange

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

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

sort: votes


text:
Approximate floating point number with n-digit precision
We have a floating point number r between 0 and 1, and an integer p.
Find the fraction of integers with the smallest denominator, which approximates r with at least p-digit precision.

Inputs: r (a floating point number) and p (integer).
Outputs: a and b integers, where

a/b (as float) approximates r until p digits.
b is the possible smallest such positive integer.

For example:

if r=0.14159265358979 and p=9,
then the result is a=4687 and b=33102,
because 4687/33102=0.1415926530119026.

Any solution has to work in theory with arbitrary-precision types, but limitations caused by implementations' fixed-precision types do not matter.
Precision means the number of digits after "0." in r. Thus, if r=0.0123 and p=3, then a/b should start with 0.012. If the first p digits of the fractional part of r are 0, undefined behavior is acceptable.
Win criteria:

The algorithmically fastest algorithm wins. Speed is measured in O(p).
If there are multiple fastest algorithms, then the shortest wins.
My own answer is excluded from the set of the possible winners.

P.s. the math part is actually much easier as it seems, I suggest to read this post.

JavaScript, O(10p) & 72 bytes
r=>p=>{for(a=0,b=1,t=10**p;(a/b*t|0)-(r*t|0);a/b<r?a++:b++);return[a,b]}

It is trivial to prove that the loop will be done after at most O(10p) iterations.

f=
r=>p=>{for(a=0,b=1,t=10**p;(a/b*t|0)-(r*t|0);a/b<r?a++:b++);return[a,b]}
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mrow>
    <mn>0.<input type="text" id="n" value="" oninput="[p,q]=f(+('0.'+n.value))(n.value.length);v1.value=p;v2.value=q;d.value=p/q" /></mn>
    <mo>=</mo>
    <mfrac>
      <mrow><mn><output id="v1">0</output></mn></mrow>
      <mrow><mn><output id="v2">1</output></mn></mrow>
    </mfrac>
    <mo>=</mo>
    <mn><output id="d">0</output></mn>
  </mrow>
</math>

Many thanks to Neil's idea, save 50 bytes.

Why are you fiddling around with padEnd and match? Can't you just slice each string to the correct length and then subtract them?

@Neil Sorry I hadn't catch your point. The added padEnd is used for testcase f(0.001,2) and f(0.3,2).

I was thinking you could simplify down to something along the lines of (r,p)=>{for(a=0,b=1;`${a/b}`.slice(0,p+2)-`${r}`.slice(0,p+2);a/b<r?a++:b++);return[a,b]} (not fully golfed).

@Neil 120 -> 70 bytes. :)

Whoa, that's much better!

Haskell, O(10p) in worst case 121 119 bytes
g(0,1,1,1)
g(a,b,c,d)r p|z<-floor.(*10^p),u<-a+c,v<-b+d=last$g(last$(u,v,c,d):[(a,b,u,v)|r<u/v])r p:[(u,v)|z r==z(u/v)]

Try it online!
Saved 2 bytes thanks to Laikoni
I used the algorithm from https://math.stackexchange.com/questions/2432123/how-to-find-the-fraction-of-integers-with-the-smallest-denominator-matching-an-i.
At each step, the new interval is one half of the previous interval. Thus, the interval size is 2**-n, where n is the current step. When 2**-n < 10**-p, we are sure to have the right approximation. Yet if n > 4*p then 2**-n < 2**-(4*p) == 16**-p < 10**-p. The conclusion is that the algorithm is O(p).
EDIT As pointed out by orlp in a comment, the claim above is false.
In the worst case, r = 1/10**p (r= 1-1/10**p is similar), there will be 10**p steps : 1/2, 1/3, 1/4, .... There is a better solution, but I don't have the time right now to fix this.

I know code golf is only the secondary goal, but you can drop the f= and save two bytes with z<-floor.(*10^p),u<-a+c,v<-b+d.

@Laikoni I did not count the two bytes. I don't know how to remove f= on TIO in Haskell code.

You can add the -cpp compiler flag and write f=\  in the header: Try it online!

"At each step, the new interval is one half of the previous interval." How do you know this? The first step is 1/2, yes, but then the next step is for example the mediant of 1/2 and 1/1 giving 2/3, which is not halving the interval.

@orlp You're absolutelty right. I was far too optimistic and the complexity is O(10^p) in the worst case. I have a better solution but don't have the time to write it right now.

@orlp It is right, but if it is going pseudo-randomly, in a roughly level distribution, then it doesn't affect the algorithmic complexity.

@peterh You aren't very convincing with that argument - prove it. But there is a bigger issue: what exactly is a 'roughly level distribution over the rationals'? Think about it for a second, it doesn't make sense. How would you pick a random rational number between 0 and 1? Complexity should absolutely be measured in the worst case here.

@orlp Sorry I had to mention that I am talking about my opinion. However, random selected elements of infinite sets is a well defined thing in the mathematics, although not in the very elemental one. Whole libraries could be filled with the literature of random walks, stochastic processes, distributions (in the mathematical sense), these are heavily used also in the engineering practice, control theory or in the quantum mechanics.

@orlp Algorithmical complexity can be measured both for the worst case and as mean, I think it depends on the circumstances which should be used in the actual context. For example, the add/remove algorithms of balanced trees typically have a logarithmical upper limit for the worst case. If we estimate the speed of an algorithm in a specific application, then calculating for the mean speed may be more common (particularly if we know, that the input will be "friendly", i.e. it won't be tuned against us and the time limits are not very hard). Like the seek time of hard disks, it is a mean value.

@peterh I'm familiar with all this, this is a bit condescending. My point is that there is no uniform random distribution of the rational numbers, so there's no good way to measure 'mean' complexity. Whatever your complexity measure is depends entirely on your distribution. So, my question is: if you insist on 'mean' complexity, then what is your distribution?  Without this information the only possibility is to use worst-case complexity. If you can't describe the function used to select a random rational r between 0 and 1 you can't speak of an average complexity.

C, 473 bytes (without context), O(p), non-competing
This solution uses the math part detailed in this excellent post. I calculated only calc() into the answer size.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void calc(float r, int p, int *A, int *B) {
  int a=0, b=1, c=1, d=1, e, f;
  int tmp = r*pow(10, p);
  float ivl = (float)(tmp) / pow(10, p);
  float ivh = (float)(tmp + 1) / pow(10, p);

  for (;;) {
    e = a + c;
    f = b + d;

    if ((ivl <= (float)e/f) && ((float)e/f <= ivh)) {
      *A = e;
      *B = f;
      return;
    }

    if ((float)e/f < ivl) {
      a = e;
      b = f;
      continue;
    } else {
      c = e;
      d = f;
      continue;
    }
  }
}

int main(int argc, char **argv) {
  float r = atof(argv[1]);
  int p = atoi(argv[2]), a, b;
  calc(r, p, &a, &b);
  printf ("a=%i b=%i\n", a, b);
  return 0;
}

It also nears the probably fastest possible solution in the sense of cpu cycles, at least on conventional machines.

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


text:
Answer to Vote Ratio
This question is inspired by the fact that I love seeing questions with equal vote and answer counts...

So here's a simple stack-exchange-api challenge for y'all:
Challenge:
Given a codegolf.stackexchange question id, output the ratio between the question's votes and number of answers (e.g. votes/answers).
Specifics:

You may access the internet, but you may only access stackexchange.com and its various sub-domains. You may not use URL shorteners.
You may take input and give output in any standard format.
You must output the ratio as a decimal number in base 10, with at least 4 {accurate} digits after the decimal (zeros may be truncated).
If the question is unanswered, your program may produce undefined behavior.
You should use the score of the question as the vote-count, see here.

This is code-golf, least bytes in each language wins for that language, least bytes overall wins overall.
Here is a sample program in Python 3 + requests:
import requests
import json

id = input("id> ")
url = "https://api.stackexchange.com/2.2/questions/" + id + "?site=codegolf"
content = requests.get(url).text
question = json.loads(content)["items"][0]

print(float(question["score"]) / question["answer_count"])

Does the ratio need at least 4 decimal digits after the decinal point even if they are zero? E.g. 41/4= 10.25 or 10.2500

@pizzapants184 10.25 is fine

What if the challenge is not answered? Then the ratio would be infinite?

Do you mean score or total votes on the question?

@Mr.Xcoder in that case, undefined behavior is okay

@AdmBorkBork technically score (which is displayed as votes on the main page)

JavaScript (ES6), 103 102 bytes
Needs to be run from the root level of api.stackexchange.com. Returns a Promise object containing the result.
n=>fetch(`questions/${n}?site=codegolf`).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count)

1 byte saved thanks to kamoroso94.

If requiring that it be run from a specific path is allowed then that becomes 92 90 bytes.
n=>fetch(n+`?site=codegolf`).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count)

Try it
Full URL added to enable it to work here.

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(({items:[j]})=>j.score/j.answer_count)
onchange=_=>f(+i.value).then(t=>o.innerText=t)
<input id=i type=number><pre id=o>

Replace i=>(j=i.items[0]) with ({items:[j]})=>j to save a byte.

Nice trick, thanks, @kamoroso94. I'll have to remember that one.

Stratos, 40 bytes
-4 bytes thanks to Shaggy
f"¹⁵s/%²"r"⁷s"@0
{s"answer_⁰"
⁰s"score"/

Try it!
Stratos specialises in stack-exchange-api questions.
Explanation:
The code decompresses to the following:
f"api.stackexchange.com/questions/%?site=codegolf"r"items"@0
{s"answer_count"
⁰s"score"/

Starting from the first line, Stratos evaluates the dyads from right to left.
f"api.stackexchange.com/questions/%?site=codegolf"r"items"@0 means "evaluate the dyad @ with the left-hand argument f"api.stackexchange.com/questions/%?site=codegolf"r"items" and the right-hand argument 0. @ gets the nth element of a JSON array.
To evaluate f"api.stackexchange.com/questions/%?site=codegolf"r"items", we will next evaluate the dyad r with the left-hand argument f"api.stackexchange.com/questions/%?site=codegolf" and the right-hand argument "items". r gets the JSON array with the specified name.
Next, we will need to evaluate f"api.stackexchange.com/questions/%?site=codegolf". First, % is replaced with the input. f means "get the contents of this URL".
Now, we can move on to the second line. The newline means "add what we evaluated to the implicit argument list"
Next, we evaluate s (get string in JSON object with a certain name) with { and "answer_count". { takes an element from the implicit argument stack, returns it, and adds it back to the stack.
Then, we add the output of that to the implicit argument stack.
To evaluate ⁰s"score"/, we are applying the dyad / (divide) to ⁰s"score" and an element from the implicit argument stack.
To evaluate ⁰s"score" we are getting the string "score" from the JSON object from the 0th element in the implict argument stack.
Now, the output of / is printed and the program terminates.

Save 4 bytes by ditching the API version (2.2/).

@Shaggy Didn't realise the API version wasn't required, thanks. Not crossing out 44 :P

R + jsonlite, 111 bytes
function(n,x=jsonlite::fromJSON(sprintf('http://api.stackexchange.com/questions/%s?site=codegolf',n))$i)x$s/x$a

R-fiddle link
jsonlite is a nice JSON <-> R conversion library which works quite well. I wasn't about to golf a JSON parser for R...

You can save a byte by using the http protocol. Also, I'm guessing 142729 shouldn't be hardcoded in there?

@Shaggy good call, thank you. I copied and pasted too fast.

T-SQL, 64 54 bytes
It is rare that SQL can beat (most) other languages! Instead of the API URL I went directly to the Stack Exchange Data Explorer:
SELECT 1.0*Score/AnswerCount FROM Posts WHERE Id=##i##

The ##i## isn't standard SQL, that's Stack Exchange's format to prompt for input.
Note that the data explorer source is only updated nightly, so values aren't current.
Will throw a divide by zero error on questions with no answers.
Edit: Saved 10 bytes by multiplying by 1.0 instead of an explicit CONVERT to FLOAT.

can beat others, but not all :)

Oh maaan, I had another solution but I was in school so I never ended up posting it... Is my answer too similar to yours? Should I delete mine?

@icrieverytim Ha, yep looks like pretty much the same query, although I just edited mine to save 10 more bytes.

@BradC I edited my answer into a Mathematica answer lol.

PowerShell, 130 bytes
($a=(ConvertFrom-Json(iwr("http://api.stackexchange.com/questions/"+$args+"?site=codegolf")).content).items).score/$a.answer_count

Performs an Invoke-WebRequest against the URL, gets the .content thereof, does a ConvertFrom-Json of that content, and gets the .items of that JSON object. Stores that into $a and pulls out the .score as the numerator. The denominator is the .answer_count. That value is left on the pipeline and output is implicit.
If the question is unanswered, this should toss a "Divide by zero" error.

Japt, 83 82 bytes
Wanted to give this a try to see how it would work out, seeing as Japt can't natively accomplish it. Essentially all this is doing is evaling a compressed version of my JS solution. As Japt is JS then we can require that this be run from the root level of api.stackexchange.com and also return a Promise object containing the result.
Ox`fet®("quÀËs/{U}?ÐÒ=¬¸golf").È(r=>r.js()).È(i=>(j=i.ems[0]).sÖ/j.s³r_Öt)

View it
Try it - the extra bytes in this version are accounted for by the inclusion of //api.stackexchange.com/ in the URL and of console.log so you can actually see it working

o0 Why have you made the code a link? It even messes with the userscript's byte count display lol. https://i.imgur.com/SO2zgAy.png

Mathematica, 124 bytes
N@("score"/.(u="items"/.Import["http://api.stackexchange.com/questions/"<>#<>"?site=codegolf","JSON"]))/("answer_count"/.u)&

Mathematica has a data type called Rule and it confuses the heck out of me. :P

Python 3 + requests, 149 bytes
-1 byte thanks to Mr. Xcoder.
from requests import*
u=get('http://api.stackexchange.com/questions/%s?site=codegolf'%input()).json()['items'][0]
print(u['score']/u['answer_count'])

The link is to Python 2. Btw, it throws an error both in Python 2 and Python 3 (on TIO).

No internet access on TIO whoops. I just used TIO for the answer formatting lol.

I think that (for now) http suffices.

125 bytes

PHP, 167 bytes
<?$f=json_decode(gzdecode(file_get_contents('https://api.stackexchange.com/2.2/questions/'.$argv[1].'?site=codegolf')))->items[0];echo $f->score/$f->answer_count;

Turbo-fast crack at this. Save as a file and execute in the terminal like so:
php -f file.php 143083

Might be a way to reduce this.


text:
Add an array with itself
Your challenge today is to take an array, split it into chunks, and add those chunks.
Here's how this works: Your program or function will be given an array of integers a and a chunk size L. The array should be split into arrays of size L, if the array length is not divisible by L then the array should have 0's appended to it so that it is evenly divisible. Once the array is chunked, all chunks are to be added together element-wise. The resulting array is then output.
You can assume L is greater than 0, and that a is nonempty. You cannot make the assumption that a's contents are positive.
Here's an example:
[1,2,3,4,5,6,7,8], 3 => [1,2,3]+[4,5,6]+[7,8,0] =>  [1+4+7,2+5+8,3+6+0] => [12,15,9]

Test cases:
Array                           Length   Output
[1]                             1        [1]
[1]                             3        [1,0,0]
[0]                             3        [0,0,0]
[1,2]                           3        [1,2,0]
[1,2]                           1        [3]
[-1,1]                          2        [-1,1]
[-7,4,-12,1,5,-3,12,0,14,-2]    4        [12,-1,0,1]
[1,2,3,4,5,6,7,8,9]             3        [12,15,18]

This is code-golf, fewest bytes wins!

Isn't it a dupe?

@sergiol if you can find a question that this is a duplicate of, I will delete this post myself. However, as far as I can tell it is not  a dupe.

7 instead of -7 in test cases

MATL, 4 bytes
e!Xs

Try it online!
First bit of MATL code I've written! Takes two inputs, a as a row vector (comma-separated) and l as a number. Works out to be
e          # reshape `a` into `l` rows (auto pads with 0)
 !         # transpose
  Xs       # sum down the columns

Python 3, 67 65 42 bytes
Uses the fact that the sum of an empty array is 0
lambda x,y:[sum(x[i::y])for i in range(y)]

Try it online!

Jelly, 7 6 bytes
1 byte thanks to Dennis.
;0$¡sS

Try it online!

With a newer version of Jelly, you can do Ż¡sS (equivalent to 0;$¡sS).

Mathematica, 27 bytes
Mathematica almost had a builtin for this
Total@Partition[##,#2,1,0]&

Try it on Wolfram Sandbox
Usage
Total@Partition[##,#2,1,0]&[{-7, 4, -12, 1, 5, -3, 12, 0, 14, -2}, 4]

{12, -1, 0, 1}

Explanation
Total@Partition[##,#2,1,0]&

      Partition[##,#2,1,0]   (* Partition the first input into sublists of length
                                second input, using offset second input, and
                                right-pad zeroes for incomplete partitions *)
Total@                       (* Add all *)

Your link ain't working.

@Shaggy you have to manually copy and paste the code. Wolfram Sandbox does not support pre-filled inputs.

Python 2, 49 bytes
lambda x,n:map(sum,zip(*zip(*[iter(x+n*[0])]*n)))

Try it online!

JavaScript (ES6), 51 bytes
a=>n=>a.map((v,i)=>o[i%n]+=v,o=Array(n).fill(0))&&o

Takes input in currying syntax: f([1,2])(3).
Test Cases

let f=
a=>n=>a.map((v,i)=>o[i%n]+=v,o=Array(n).fill(0))&&o

;[[[1], 1], [[1], 3], [[0], 3], [[1,2], 3], [[1,2], 1], [[-1,1], 2], [[-7,4,-12,1,5,-3,12,0,14,-2], 4], [[1,2,3,4,5,6,7,8,9], 3]]
.forEach(([A,N])=>console.log(`${JSON.stringify(A)}, ${N} -> ${f(A)(N)}`))
.as-console-wrapper{max-height:100%!important}

(a,n,o=[])=>a.map((v,i)=>o[i%n]=~~o[i%n]+v)&&o

@Oki Two bytes shorter: a=>n=>a.map((v,i)=>o[i%=n]=~~o[i]+v,o=[])&&o, but it doesn't add the required zero-padding.

f= should be part of your character count.

@nl-x Anonymous functions are allowed by default, so as long as I'm not using the function name in my code, f= is not needed. Heres one post on meta about this.

@nl-x: No, it shouldn't; a function need only be named if it's recursive (or, maybe, a quine). If it's not then an anonymous function is perfectly valid. See here.

Husk, 9 bytes
S↑ȯ¡¬Fż+C

Try it online!
Explanation
        C    Cut into lists of length n
     Fż+     Sum them element-wise
  ȯ¡¬        Append infinitely many 0s
S↑           Take the first n elements

Perl 6, 36 bytes
{[Z+] flat(@^a,0 xx$^b*2).rotor($b)}

Test it
Expanded:
{  # bare block lambda with 2 placeholder parameters ｢@a｣, ｢$b｣
  [Z+]
    flat(
      @^a,         # declare and use the first parameter
      0 xx $^b * 2 # 0 list repeated 2 * the second parameter
    )
    .rotor($b)     # split into chunks that are the size of the second param
}

[1,2], 3

( [1,2], (0,0,0,0,0,0) ) # @^a,0 xx$^b*2
(1,2,0,0,0,0,0,0)        # flat(…)
( (1,2,0), (0,0,0) )     # .rotor($b) # (drops partial lists)
(1,2,0)                  # [Z+]

Mathematica, 58 bytes
Total@Partition[PadRight[#,(s=Length@#)+Mod[-s,#2]],{#2}]&

Input

[{1},3]

Output

{1,0,0}

this works for [1],3  You can test it here  https://sandbox.open.wolframcloud.com/    by adding input at the end of the code and pressing shift+enter

Java 7, 86 bytes
No fancy folds or matrices, just a good ol' fashioned for loop :)
int[]o(int[]a,int l){int i=0,o[]=new int[l];for(;i<a.length;)o[i%l]+=a[i++];return o;}

Try it on Ideone
Lined:
int[]o(int[]a,int l){
    int i=0,
        o[]=new int[l];
    for(;i<a.length;)
        o[i%l]+=a[i++];
    return o;
}

and with the good ol' fashioned Java 7 (instead of 8). ;)

BQN, 8 bytesSBCS
+˝↑˙⊸⋈⊸⥊

Run online!
{+˝↑‿⥊} is 1 longer. BQN's reshape is very good.

05AB1E, 8 bytes
ô0ζO²Å0+

Try it online!
ô0ζO²Å0+   Full program
ô          Push <1st input> split into a list of <2nd input> pieces
 0ζ        Zip sublists with 0 as a filler
   O       Sum each sublist
           --- from here, the program handles outputs shorter
               than the required length
    ²Å0    Push a list of zeros of length <2nd input>
       +   Sum the result with that list

05AB1E, 8 bytes
Å0+¹ô0ζO

Try it online!
Å0       # Push an arrary of all 0s with length l
  +      # Add that to the array
   ¹ô    # Split into chunks of length l
     0ζ  # Zip, padding with 0s
       O # Sum each chunk

Almost identical to my own solution: https://codegolf.stackexchange.com/a/143186/73296

@scottinet I must have missed that. They are different enough that I'll leave mine and upvote yours :)

I don't really mind, just wanted to point that out :)

@scottinet It is interesting that you can rearrange the operations and come out with the same byte count and almost identical bytes used (¹ vs ²)

R, 62 57 bytes
-5 bytes thanks to user2390246
function(a,l)rowSums(matrix(c(a,rep(0,l-sum(a|1)%%l)),l))

Try it online!
Updated since it no longer has to handle the empty case.
pads a with zeros, constructs a matrix of l rows, and computes and returns the row sums.

57 bytes

@user2390246 of course! I had that in an older version when we had to handle the empty case but this one was my "primary" and I didn't think to try that again.

Pyth, 8 bytes
m+F%Q>vz

Try it here!
Pyth, 10 bytes
sMCc.[EZQQ

Try it here!
Explanation
Explanation #1
m+F%Q>vz   Full program. Q means input.

m          Map over the implicit range [0, input_1), with a variable d.
     >vz  All the elements of input_2 after d; input_2[d:] in Python.
   %Q     Every Qth element of ^.
 +F       Sum. Implicitly output the result.

Explanation #2

sMCc.[EZQQ   Full program.

    .[E      Pad the second input to the right, with repeated copies of...
       Z     ... Zero (0), up to the nearest multiple of...
        Q    ... The first input.
   c     Q   Chop into chunks of length equal to the first input.
  C          Matrix transpose. Get all the columns of the nested list.
sM           Sum each.
             Output (implicitly).

How about something like this: sM.TcEQ

@Jakube That is incorrect, as you have to pad with zeros first. That was Leaky's initial attempt, but would fail for [1], 3, which would give [1] instead of [1, 0, 0].

Sorry, my mistake.

Haskell, 59 49 bytes
a%l=[sum$map((0:a)!!)[i,l+i..length a]|i<-[1..l]]

Try it online!

I don't know if I'm allowed to submit a solution in a language that has already been done, so I'll post my solution here: (79 bytes)
l%a|l>length a=t|1>0=zipWith(+)t$l%drop l a where t=take l$a++repeat 0

@Itay123 Posting your own Haskell solution is perfectly fine! As per our Help center (and meta consensus), an answer only needs to be a valid solution of the challenge and make some effort towards the winning criteria. It does not have to be the shortest solution, and for me it's always interesting to see different approaches. So please go ahead and post your answer!

APL (Dyalog), 22 bytes
Takes l as left argument and a a right argument.
{+⌿s⍴⍵↑⍨×/s←⍺,⍨⌈⍺÷⍨≢⍵}

Try it online!
{…} anonymous function where ⍺ is the left argument (l) and ⍵ the right argument (a).
 ≢⍵ tally (length) of a
 ⍺÷⍨ divide by l
 ⌈ ceiling (round up)
 ⍺,⍨ append l
 s← store in s (for shape)
 ×/ product of that (i.e. how many integers are needed)
 ⍵↑⍨ take that many integers from a (padding with zeros)
 s⍴ reshape to shape s (rows, columns)
 +⌿ columnar sums

Perl 6, 40 bytes
{[Z+] (|@^a,|(0 xx*)).rotor($^l)[0..@a]}

Try it online!
If you like the number 42, you can swap the * for an ∞. That will make it 42 bytes :—).
Explanation:
{[Z+] (|@^a,|(0 xx*)).rotor($^l)[0..@a]} The whole function
{                                      } Anonymous block
      (    ,        )                    List with 2 elements
        @^a                              The first argument (it is a list)
             (0 xx*)                     Infinite list of zeroes
       |    |                            Flatten both of the lists into the larger list.
                    .rotor($^l)          Split the list into a list of lists, each (the second argument) long.
                               [0..@a]   Only the first (1 + length of the first argument) of them.
 [Z+]                                    Add the corresponding elements up.

The magic behind the last "add up" is that the operator is a "reduce with zip with +". By the way, this would break down if we used it only on a list with 1 list inside, but that never happens if the original list was non-empty (due to the second-to-last row). Also note that we end up taking not only @a, but @a * $l items. Fortunately we added only zeroes which won't affect the final result.

J, 15 12 bytes
]{.+/@(]\~-)

Try it online!
Explanation
]{.+/@(]\~-)  Input: array A (LHS), chunk size L (RHS)
          -   Negate L
       ]\~    Take each non-overlapping sublist of size L in A
   +/@        Reduce the columns by addition
]             Get L
 {.           Take that many, filling with 0's

Any reason we can't do away with the boxes? What about: [:+/-@[[\]?

@Jonah If the chunk size is larger than the length of the input array, it won't be zero-padded.

Nice edit -- much cleaner now.

Vyxal, 7 bytes
ẇR∆ZR∩Ṡ

Try it Online!

afaict the zfilling is unecessary as the missing zeroes are simply ignored

@emanresuA that would fail on case [1,2], 3 => [1,2,0].

Clojure, 42 bytes
#(apply map +(partition %2 %2(repeat 0)%))

Try it online!

Jq 1.5, 31 bytes
[_nwise($n)]|transpose|map(add)

Sample Run
$ jq -Mc --argjson n 3 '[_nwise($n)]|transpose|map(add)' <<< "[1,2,3,4,5,6,7,8]"
[12,15,9]

Takes advantage of builtins: _nwise, transpose, add and map

Japt, 7 bytes
Man, I fought with the wrong Japt method for far too long trying to get it to work for the [1], 3 test case in a reasonable amount of bytes!
VÆëVX x

Try it

Explanation
Implicit input of array U and integer V.
VÆ

Generate an array of integers from 0 to V-1 and pass each through a function with X being the current element.
ëVX

Grab every Vth element of U, beginning at index X.
x

Reduce that array by addition.

Stacked, 24 bytes
[:@z#<[0 z rpad]map sum]

Try it online!
Explanation
[:@z#<[0 z rpad]map sum]
[                      ]   anonymous function
 :@z                       stores TOS as `z` (the length)
    #<                     cut STOS in TOS slices
      [        ]map        for each slice
       0 z rpad               pad the slice with `z` zeroes
                    sum]   summate all inner slices

Java (OpenJDK 8), 64 bytes
n->a->{int k=0,r[]=new int[n];for(int i:a)r[k++%n]+=i;return r;}

Try it online!

C, (GCC) 101 86 Bytes
Try it online!
f(int*a,int l,int s,int*m){if(s){int i=l;while(i&&s){m[l-i--]+=*a++;s--;}f(a,l,s,m);}}

Usage
int main() {
   int l = 3;
   int a[8] = {1,2,3,4,5,6,7,8};
   int *m = (int *)malloc(sizeof(int) * l);
   f(a, l, 8, m);
   for (int i=0; i<3; i++) {
    printf("%d, ",m[i]);
   }
}

Note that you have to pass in the length of the array (s) and a new dynamic array on the heap (m).

73 bytes.

Ruby, 43 bytes
->a,n{b=[w=0]*n;a.map{|r|b[w%n]+=r;w+=1};b}

I wanted to outgolf at least python, but I couldn't, so here is the best I could do.
How it works:

create an array of size n filled with zeroes
iterate on the input array, and calculate sums, repeat wrapping around the output array

Try it online!

SOGL V0.12, 14 bytes
l⁵%⁵κ{0+}nI⌡∑¹

Try it Here! or Try all the test-cases. this is written as an unnamed function and expects chunk length; array on the stack.
Explanation:
padding zeroes
l          get the array's length
 ⁵%        modulo the chunk length
   ⁵κ      chunk length - result of above
     {  }  that many times
      0+     append a 0 to the array

adding the array together
n      split into the chunks
 I     rotate clockwise
  ⌡    for each
   ∑     sum
    ¹  wrap the results in an array

What's the F for in the Try it Here code you linked?

@Pavel the functions name. The same as in JS f=a=>a+2 the f= part isn't counted - in SOGL F\n isn't counted.

05AB1E, 12 bytes
gs÷*+Å0¹+ôøO

Try it online!
Explanation
gs÷*+Å0¹+ôøO
g            # Get the length of the first input (the array)
 s           # Push the second input on top of the result
  ÷          # integer divide the two values
   *         # Multiply with the second input (the length)...
    +        # and add the second input to the result
     Å0      # Create a list of zeros with that length
       ¹+    # Add it to the first input
         ô   # And finally split it into chunks of the input length...
          ø  # ...transpose it...
           O # and sum each resulting subarray
             # Implicit print

Mathematica, 43 bytes
Plus@@#~ArrayReshape~{⌈Tr[1^#]/#2⌉,#2}&

Husk, 10 bytes
Fż+So:`R0C

Try it online!
Ungolfed/Explanation
             -- implicit inputs n & xs                   | 3  [1,2,3,4]
   S      C  -- cut xs into sublists of length n & ...   | [[1,2,3], [4]]
    (:`R0)   -- ... prepend [0,...,0] (length n)         | [[0,0,0], [1,2,3], [4]]
F            -- accumulate the sublists with             |
 ż+          -- element-wise addition                    | [0+1+4, 0+2, 0+3]

Julia 0.6, 49 bytes
V\n=sum(reshape([V;zeros(n-endof(V)%n,1)],n,:),2)

Try it online!

Scala 2.12.2, 80 bytes
(a:Array[Int],b:Int)=>(0 to b-1).map(i=>a.indices.filter(_%b==i).collect(a).sum)

It is slightly shorter than the Java solution.

Javascript, 59 57 56 bytes
f=(a,l)=>(r=Array(l).fill(0),a.forEach((c,i)=>r[i%l]+=c),r)

usage
f([1,2,3,4,5,6,7,8], 3);
// returns [12, 15, 9]

edit 1
According to @Shaggy in the comments, the f= part is not needed if the function is not recursive. So:
(a,l)=>(r=Array(l).fill(0),a.forEach((c,i)=>r[i%l]+=c),r)

with usage off course of:
((a,l)=>(r=Array(l).fill(0),a.forEach((c,i)=>r[i%l]+=c),r))([1,2,3,4,5,6,7,8], 3)
// returns [12, 15, 9]

edit 2
Golfing down 1 more character, as the extra parenthesis are no longer needed then.
(a,l,r=Array(l).fill(0))=>a.forEach((c,i)=>r[i%l]+=c)||r

with usage off course of:
((a,l,r=Array(l).fill(0))=>a.forEach((c,i)=>r[i%l]+=c)||r)([1,2,3,4,5,6,7,8], 3)
// returns [12, 15, 9]

You were beaten to it.

@Shaggy I don't think that solution is correct as per the rules. Also he is leaving out the f= part that should count for more characters.

How so? It's identical to yours, just more golfed. Functions only need to be assigned to a variable if they're recursive.

The assignment is a program or a function that returns the resulting array. This function returns another function that needs to be executed again. Also the f= part is needed to call the function. If it is not needed, I can also golf down 2 characters.

Currying, like anonymous functions, is also perfectly valid. See here.

Pari/GP, 33 bytes
a->l->Vecrev(Polrev(a)%(x^l-1),l)

Converts a to a polynomial, mod x^l-1, and then converts it back to a list.
Try it online!

Common Lisp, 90 bytes
(lambda(a l)(dotimes(i(-(length a)l)(subseq a 0 l))(incf(elt a(mod i l))(elt a (+ l i)))))

Try it online!

POSIX shell, 45 bytes
This requires the utilities jot and rs to be installed, as well as the more common sed and bc.  The chunk size is passed as the first argument, and the array as space-separated values on standard input
(jot -b0 $1;cat)|rs -tjg1 -C+ $1|sed s/.//|bc

The jot command generates a row full of zeros (in case the chunk size is smaller than the input); cat appends the input, then rs transforms that into the specified number of rows.  Each line now begins with +, and bc won't accept that, so remove it with sed before performing the summation of each line.

Scala, 75 bytes
a=>n=>(a++Seq.fill(n-a.size/n)(0)).grouped(n).toSeq.transpose.map(_.sum)

To use this, you have to add a type:
val f:(Seq[Int]=>Int=>Seq[Int])=
    a=>n=>(a++Seq.fill(n-a.size/n)(0)).grouped(n).toSeq.transpose.map(_.sum)

f(Seq(1,2,3,4,5,6,7,8))(3)

PowerShell, 62 bytes
param($a,$l)1..$l|%{$y=--$_;($o=0)..$l|%{$o+=$a[$y+$_*$l]};$o}

Try it online!
We take input $array and $length. Then loop from 1 to $l. Each iteration we set helper $y to be one less than the current number (this is because PowerShell 0-indexes but the $length is in 1-indexing). Then we set our $output to 0 and loop again up to $l. Each inner iteration we're simply accumulating into $o the appropriately-indexed $array element. This leverages the fact that indexing past the end of the array returns $null and 0 + $null = 0.
Once the inner loop is done, we output $o and move on to the next chunk. The various outputs are left on the pipeline and output via implicit Write-Output happens on program completion.

Perl 5, 44 + 1 (-a) = 45 bytes
@r=(0)x($l=<>);map$r[$i++%$l]+=$_,@F;say"@r"

Try it online!
Edit: fixed the case where the length requested was smaller than the input array

Add++, 25 bytes
D,f,@@*,d0b]*$@$+TbUpBcBs

Try it online!
How it works
First, we define our function \$f(a, x)\$. It takes two arguments (@@) and returns the entire stack (*), rather than the top element. Here, \$a\$ denotes the array of elements, such as \$a := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\$, and \$x\$ represents slice length, \$x := 4\$ for example. The stack is \$[a, x]\$ at the start of execution. We then duplicate \$x\$, and repeat \$[0]\$ \$x\$ times. We call this array \$z\$, rearrange the stack so it looks like \$[x, a, z]\$ and concatenate \$a\$ with \$z\$. This appends \$x\$ zeroes to the end of \$a\$.
Next, we take slices of length \$x\$ from \$a ^ \frown z\$. For the example inputs above, this would yield \$[[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 0, 0], [0, 0]]\$. For every possible inputs, this yields an array where the final element always contains only superfluous zeroes, so we splat the elements of the array to the stack and remove the last element. Finally, we zip the arrays together and take the sum of each.

Factor + grouping.extras math.unicode, 47 bytes
[ [ 0 pad-groups ] keep group flip [ Σ ] map ]

R, 54 bytes
function(a,l,m=matrix(a,l))rowSums(m*(seq(m)<=seq(a)))

Try it online!
Somewhat based on Giuseppe's answer, but uses a different trick to counteract R's recycling the first elements of a to fill the last chunk.

Burlesque, 21 bytes
J0bcj.+2MVj_+jcotp)++

Try it online!
J    # Dup L
0bc  # Infinite list of zeros
j.+  # Select L 0s
2MV  # Put list at top of stack
j_+  # Append zeros
jco  # Split into chunks of length L
tp   # Transpose
)++  # Map sum

C(GCC), 44 bytes
m(a,L,l,o)int*a,*o;{for(;l--;)o[l%L]+=a[l];}

Try it online It doesn't get more stupid than this :) In the tio version, i added a few macros, but they only help me do the tests in main more easily, and aren't used in the actual function. It modifies a given array instead of directly outputting one, because that's a real pain to do in c. It expects a zeroed array in o.

Desmos, 106 71 bytes
l=[1...s]
f(a,s)=[∑_{q=1}^{ceil(a.length/s)}join(a,l0)[qs-s+t]fort=l]

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

94 bytes with various smaller golfs.

Actually, 86 bytes

Seems like you don't need to subtract mod(k,s): 75 bytes

Oh wait once you take out that, you don't even need k anymore: 71 bytes

Thunno 2, 4 bytes
ẇ0Ƭʂ

Try it online!
Explanation
ẇ0Ƭʂ  # Implicit input - A (array), N (integer)
ẇ     # Split (A) into chunks of length (N)
 0Ƭ   # Transpose the list with filler 0
   ʂ  # Sum each inner list
      # Implicit output

Uiua, 6 bytes
/+⬚0↯~

Try it!
/+⬚0↯~
    ↯~  # reshape into matrix with number of columns indicated by input
  ⬚0    # filling excess elements with zeros
/+      # sum columns

Julia 0.6, 28 bytes
V\n=1:n.|>i->sum(V[i:n:end])

Try it online!
also works in Julia 1.0+

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