Buggy python submission (verdict: Runtime Error):
import sys

def quartet(h, w):
    global flag
    if 0 <= h <= 11 and 0 <= w <= 11:
        if mapp[h][w] == '1':
            mapp[h][w] = '$'
            flag = True
            bigbang(h, w)
        elif mapp[h][w] == '0' or mapp[h][w] == '$':
            return
    else:
        return

def bigbang(h, w):
    quartet(h, w+1)
    quartet(h-1,w)
    quartet(h, w-1)
    quartet(h+1, w)

while True:
    try:
        mapp = []
        for line in sys.stdin:
            lis = []
            for char in line.rstrip():
                lis.append(char)
            else:
                mapp.append(lis)
        
        flag = False
        count = 0
        for h in range(12):
            for w in range(12):
                quartet(h, w)
                if flag == True:
                    count += 1
                flag = False
        else:
            print count
        if raw_input == '':
            continue
    except EOFError:
        break

Fixed submission:
def f1():
    t = 0
    for y in range(len(M)):
        for x in range(len(M[0])):
            if M[y][x] == '1':
                f2(x, y)
                t += 1
    return t


def f2(x, y):
    if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
        return
    if M[y][x] == '1':
        M[y][x] = '0'
        f2(x, y-1)
        f2(x, y+1)
        f2(x+1, y)
        f2(x-1, y)


M = []
while True:
    try:
        line = input()
        if line == '':
            print(f1())
            M = []
        else:
            M.append(list(line))
    except EOFError:
        print(f1())
        break

Buggy python submission (verdict: Runtime Error):
import sys

def quartet(h, w):
    global flag
    if 0 <= h <= 11 and 0 <= w <= 11:
        if mapp[h][w] == '1':
            mapp[h][w] = '$'
            flag = True
            bigbang(h, w)
        elif mapp[h][w] == '0' or mapp[h][w] == '$':
            return
    else:
        return

def bigbang(h, w):
    quartet(h, w+1)
    quartet(h-1,w)
    quartet(h, w-1)
    quartet(h+1, w)

while True:
    try:
        mapp = []
        for i in range(12):
            line = raw_input()
            lis = []
            for char in line:
                lis.append(char)
            else:
                mapp.append(lis)
                
        flag = False
        count = 0
        for h in range(12):
            for w in range(12):
                quartet(h, w)
                if flag == True:
                    count += 1
                flag = False
        else:
            print count
        if raw_input == '':
            continue
    except EOFError:
        break

Fixed submission:
def f1():
    t = 0
    for y in range(len(M)):
        for x in range(len(M[0])):
            if M[y][x] == '1':
                f2(x, y)
                t += 1
    return t


def f2(x, y):
    if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
        return
    if M[y][x] == '1':
        M[y][x] = '0'
        f2(x, y-1)
        f2(x, y+1)
        f2(x+1, y)
        f2(x-1, y)


M = []
while True:
    try:
        line = input()
        if line == '':
            print(f1())
            M = []
        else:
            M.append(list(line))
    except EOFError:
        print(f1())
        break