# Task
 In a black and white image we can use `1` instead of black pixels and `0` instead of white pixels. 
 For compression image file we can reserve pixels by consecutive pixels who have the same color. 
 Your task is to determine how much of black and white pixels is in each row sorted by place of those.
# Example:
 For `height=2,width=100 and compressed=[40,120,40,0]`
 The result should be `[[40,60],[0,60,40,0]]`
 Sum of compressed array always divisible by width and height of image.
 Pixels available is in Compressed array in this order:
 `[Black,White,Black,White,Black,White,...]`
 ![](http://s3.picofile.com/file/8194350650/Compressed_Image_1_.png)
 For `height=2,width=100 and compressed=[0, 180, 20, 0]`
 The result should be `[[0,100],[0,80,20,0]]`
 ![](http://s6.picofile.com/file/8194348868/Compressed_Image.png)
# Input/Output
- `[input]` integer `height`
  Height of image
- `[input]` integer `width`
  Width of image
- `[input]` integer array `compressed`
  Consecutive pixels
- `[output]` 2D integer array
 The black and white pixels in each row.
def black_and_white(height, width, compressed):
    r=[]
    row=[]
    for i,x in enumerate(compressed):
        color=i%2
        if not row and color:
            row.append(0)
        remain=width-sum(row)
        if x>remain:
            row.append(remain)
            if len(row)%2==1:
                if row[-1]==0:
                    row.pop()
                else:
                    row.append(0)
            r.append(row)
            x=x-remain
            while(x>=width):
                if color:
                    r.append([0,width])
                else:
                    r.append([width,0])
                x-=width
            if color:
                row=[0,x]
            else:
                row=[x]
        else:
            row.append(x)
    if row:
        if len(row)%2==1:
            if row[-1]==0:
                row.pop()
            else:
                row.append(0)
        r.append(row)
    if r[-1]==[0,0]:
        r.pop()
    return r
def black_and_white(height, width, compressed):
    r=[]
    row=[]
    for i,x in enumerate(compressed):
        color=i%2
        if not row and color:
            row.append(0)
        remain=width-sum(row)
        if x>remain:
            row.append(remain)
            if len(row)%2==1:
                if row[-1]==0:
                    row.pop()
                else:
                    row.append(0)
            r.append(row)
            x=x-remain
            while(x>=width):
                if color:
                    r.append([0,width])
                else:
                    r.append([width,0])
                x-=width
            if color:
                row=[0,x]
            else:
                row=[x]
        else:
            row.append(x)
    if row:
        if len(row)%2==1:
            if row[-1]==0:
                row.pop()
            else:
                row.append(0)
        r.append(row)
    if r[-1]==[0,0]:
        r.pop()
    return r