Buggy python submission (verdict: Time Limit Exceeded):
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    space = [[0]*(W+1) for _ in xrange(H)]
    for x in xrange(W-1,-1,-1):
        for y in xrange(H):
            if field[y][x]==".":
                space[y][x] = space[y][x+1]+1 
    ans = 0
    for x in xrange(W):
        for y in xrange(H):
            for h in xrange(y+1,H+1):
                ans = max(ans, min(s[x] for s in space[y:h])*(h-y))
    print ans        

Fixed submission:
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma

Buggy python submission (verdict: Time Limit Exceeded):
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    space = [[0]*(W+1) for _ in xrange(H)]
    for x in xrange(W-1,-1,-1):
        for y in xrange(H):
            if field[y][x]==".":
                space[y][x] = space[y][x+1]+1 
    ans = 0
    for x in xrange(W):
        for y in (yy for yy in xrange(H) if field[y][x] == "."):
            for h in xrange(y+1,H+1):
                ans = max(ans, min(s[x] for s in space[y:h])*(h-y))
    print ans

Fixed submission:
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma

Buggy python submission (verdict: Time Limit Exceeded):
def solve(field,H,W):
    space = [[0]*(W+1) for _ in xrange(H)]
    for x in xrange(W-1,-1,-1):
        for y in xrange(H):
            if field[y][x]==".":
                space[y][x] = space[y][x+1]+1 
    ans = 0
    for x in xrange(W):
        for y in (yy for yy in xrange(H) if field[y][x] == "."):
            for h in xrange(y+1,H+1):
                ans = max(ans, min(s[x] for s in space[y:h])*(h-y))
                if ans > (W-x)*(H-y):
                    return ans
    return ans

while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    print solve(field,H,W)

Fixed submission:
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma

Buggy python submission (verdict: Time Limit Exceeded):
class Rect():
    
    def __init__(self, x_range, y_range):
        self.x_range = x_range
        self.y_range = y_range

    @property
    def w(self):
        return len(self.x_range)

    @property
    def h(self):
        return len(self.y_range)
        
    def __str__(self):
        return "Rect({},{})".format(str(self.x_range),str(self.y_range))

    def __contains__(self, pos):
        x,y = pos
        left,right = self.x_range[0],self.x_range[-1]
        buttom,top = self.y_range[0],self.y_range[-1]        
        return left<=x<=right and buttom<=y<=top

    def divide(self, pos):
        x,y = pos
        x_i = self.x_range.index(x)
        y_i = self.y_range.index(y)
        rects = [Rect(self.x_range[:x_i],self.y_range),
                 Rect(self.x_range[x_i+1:],self.y_range),
                 Rect(self.x_range,self.y_range[:y_i]),
                 Rect(self.x_range,self.y_range[y_i+1:])]        
        rem_list = [] #TEMP
        for r in rects:
            if r.x_range == [] or r.y_range == []:
                rem_list.append(r)

        for r in rem_list:
            rects.remove(r)

        return rects

def solveA(field,H,W):
    space = [[0]*(W+1) for _ in xrange(H)]
    for x in xrange(W-1,-1,-1):
        for y in xrange(H):
            if field[y][x]==".":
                space[y][x] = space[y][x+1]+1 
    ans = 0
    for x in xrange(W):
        for y in (yy for yy in xrange(H) if field[yy][x] == "."):
            mi = space[y][x]
            for h in xrange(y,H):
                if(field[h][x] == "*"):
                    break
                mi = min(mi, space[h][x])
                ans = max(ans, mi*(h-y+1))
    return ans

def solveB(field,H,W):
    rects = [Rect(range(W),range(H))]
    for x in xrange(W):
        for y in (yy for yy in xrange(H) if field[yy][x] == "*"):
            for r in filter(lambda rr:(x,y) in rr, rects):
                rects.extend(r.divide((x,y)))
                rects.remove(r)
    return max(r.w*r.h for r in rects)


while True:
    H,W = map(int, raw_input().split())
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    count = sum(f.count("*") for f in field)
    if count > H*W/4:
        print solveA(field,H,W)
    else:
        print solveB(field,H,W)

Fixed submission:
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def ge(H,W):
    q = deque([(0,0)])
    while q:
        x,y = q.popleft()
        yield (x,y)
        if y == 0 and x+1 < W:
            q.append([x+1,y])
        if y+1 < H:
            q.append([x,y+1])

def solve(field,H,W):
    space = [[0]*(W+1) for _ in xrange(H)]
    for x in xrange(W-1,-1,-1):
        for y in xrange(H):
            if field[y][x]==".":
                space[y][x] = space[y][x+1]+1 
    ans = 0
    x,y = 0,0
    for x,y in ((xx,yy) for xx,yy in ge(H,W) if field[yy][xx] == "."):
        mi = space[y][x]
        for h in xrange(y,H):
            if(field[h][x] == "*"):
                break
            mi = min(mi, space[h][x])
            ans = max(ans, mi*(h-y+1))
            if (W-x)*(H-y) < ans:
                return ans
    return ans

while True:
    H,W = map(int, raw_input().split())
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    print solve(field,H,W)

Fixed submission:
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma

Buggy python submission (verdict: Runtime Error):
class Rect():
    
    def __init__(self, x_range, y_range):
        self.x_range = x_range
        self.y_range = y_range

    @property
    def w(self):
        return len(self.x_range)

    @property
    def h(self):
        return len(self.y_range)
        
    def __str__(self):
        return "Rect({},{})".format(str(self.x_range),str(self.y_range))

    def __contains__(self, pos):
        x,y = pos
        left,right = self.x_range[0],self.x_range[-1]
        buttom,top = self.y_range[0],self.y_range[-1]        
        return left<=x<=right and buttom<=y<=top

    def divide(self, pos):
        x,y = pos
        x_i = self.x_range.index(x)
        y_i = self.y_range.index(y)
        rects = [Rect(self.x_range[:x_i],self.y_range),
                 Rect(self.x_range[x_i+1:],self.y_range),
                 Rect(self.x_range,self.y_range[:y_i]),
                 Rect(self.x_range,self.y_range[y_i+1:])]        
        rem_list = [] #TEMP
        for r in rects:
            if r.x_range == [] or r.y_range == []:
                rem_list.append(r)

        for r in rem_list:
            rects.remove(r)

        return rects
def ge(H,W):
    from collections import deque
    q = deque([(0,0)])
    while q:
        x,y = q.popleft()
        yield (x,y)
        if y == 0 and x+1 < W:
            q.append([x+1,y])
        if y+1 < H:
            q.append([x,y+1])

def solveA(field,H,W):
    space = [[0]*(W+1) for _ in xrange(H)]
    for x in xrange(W-1,-1,-1):
        for y in xrange(H):
            if field[y][x]==".":
                space[y][x] = space[y][x+1]+1 
    ans = 0
    x,y = 0,0
    for x,y in ((xx,yy) for xx,yy in ge(H,W) if field[yy][xx] == "."):
        mi = space[y][x]
        for h in xrange(y,H):
            if(field[h][x] == "*"):
                break
            mi = min(mi, space[h][x])
            ans = max(ans, mi*(h-y+1))
            if (W-x+1)*(H-y+1) < ans:
                return ans
    return ans

def solveB(field,H,W):
    rects = [Rect(range(W),range(H))]
    for x in xrange(W):
        for y in (yy for yy in xrange(H) if field[yy][x] == "*"):
            for r in filter(lambda rr:(x,y) in rr, rects):
                rects.extend(r.divide((x,y)))
                rects.remove(r)
    return max(r.w*r.h for r in rects)

while True:
    H,W = map(int, raw_input().split())
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    count = sum(f.count("*") for f in field)
    if count > 15:
        print solveA(field,H,W)
    else:
        print solveB(field,H,W)

Fixed submission:
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma

Buggy python submission (verdict: Time Limit Exceeded):
def cut(squares):
    ret = []
    for s in squares:
        for i,r in enumerate(ret):
            if s[0] >= r[0] and s[1] >= r[1]:#replace
                ret[i] = s
                break
            if s[0] <= r[0] and s[1] <= r[1]:#remove
                break
        else:
            ret.append(s)#append
    return ret

def merge(left, buttom):
    ret = []
    for b in buttom:
        for l in left:
            w = min(b[0],l[0]+1)
            h = min(b[1]+1,l[1])
            ret+=[(w,h),(1,b[1]+1),(l[0]+1,1)]
    return ret

while True:
    H,W = map(int, raw_input().split())
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    DP = [[[(0,0)] for _ in xrange(W+1)] for _ in xrange(H+1)]    
    for x in xrange(W-1,-1,-1):
        for y in (y for y in xrange(H-1,-1,-1) if field[y][x] != "*"):
            DP[y][x] = cut(merge(DP[y][x+1],DP[y+1][x]))
    ans = 0
    for x in xrange(W):
        for y in xrange(H):
            if DP[y][x]:
                ans = max(ans,max(w*h for w,h in DP[y][x]))
    print ans
            

Fixed submission:
def re_push(stack,num):#re_push and return max
    count = 0
    pre = num
    ma = 0
    while True:
        count += 1
        cur = stack.pop()
        if cur <= num:
            ma = max(ma,(count-1) * pre)
            stack += [cur]
            stack += [num]*(count-1)
            break
        if cur < pre:
            ma = max(ma,(count-1) * pre)
            stack += [cur]*count
            count = 0
        pre = cur
    return ma
            
while True:
    H,W = map(int, raw_input().split(" "))
    if (H,W) == (0,0):
        break
    field = [raw_input() for _ in xrange(H)]
    table = [[0]*(W+1) for _ in xrange(H)]
    for y in xrange(H-1,-1,-1):
        for x in (x for x in xrange(W-1,-1,-1) if field[y][x] != "*"):
            table[y][x] = table[y][x+1] + 1
    ma = 0
    for x in xrange(W):
        stack = [0,table[0][x]]
        for y in xrange(1,H):
            if table[y-1][x] > table[y][x]:
                ma = max(ma, re_push(stack,table[y][x]))
            stack.append(table[y][x])
        ma = max(ma, re_push(stack,0))
    print ma