For this Question: Given an array arr[] of size N containing 0s and 1s only. The task is to count the subarrays having an equal number of 0s and 1s.The first line of the input contains an integer N denoting the size of the array and the second line contains N space-separated 0s and 1s.

Constraints:-
1 <= N <= 10^6
0 <= A[i] <= 1For each test case, print the count of required sub-arrays in new line.Sample Input 
7
1 0 0 1 0 1 1

Sample Output
8

The index range for the 8 sub-arrays are:
(0, 1), (2, 3), (0, 3), (3, 4), (4, 5)
(2, 5), (0, 5), (1, 6), I have written this Solution Code: size = int(input())
givenList = list(map(int,input().split()))
hs = {}
sm = 0 
ct = 0


for i in givenList:

    if i == 0:
        i = -1
    sm = sm + i

    if sm == 0:
        ct += 1

    if sm not in hs.keys():
        hs[sm] = 1
    else:
        freq = hs[sm]
        ct = ct +freq
        hs[sm] = freq + 1

print(ct), In this Programming Language: Python, Now tell me if this Code is compilable or not?