Let Pascal triangle be an equilateral triangular array of number, consists of $2019$ rows and except for the numbers in the bottom row, each number is equal to the sum of two numbers immediately below it. How many ways to assign each of numbers $a_0, a_1,...,a_{2018}$ (from left to right) in the bottom row by $0$ or $1$ such that the number $S$ on the top is divisible by $1019$.
Problem
Source: 2019 Saudi Arabia March Camp Test 1.2
Tags: Pascal's Triangle, number theory, combinatorics