Buggy python submission (verdict: Runtime Error):
# Aizu Problem 0261: Mayan Crucial Prediction

import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
#if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")

dpm = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # day per month

 
def get_day(year, month, day):
    if month <= 2:
        year -= 1
        month += 12
    dy = 365 * (year - 1)
    c = year // 100
    dl = (year >> 2) - c + (c >> 2)
    dm = (month * 979 - 1033) >> 5
    return dy + dl + dm + day - 1

offset = get_day(2012, 12, 21)
maya= [144000, 7200, 360, 20, 1]
    
while True:
    inp = input().strip()
    if inp == "#":
        break
    inp = [int(_) for _ in inp.split('.')]
    if len(inp) == 3:
        # christian to mayan:
        n = (get_day(inp[0], inp[1], inp[2]) - offset) % 1872000
        out = ""
        for k in range(4):
            out += str(n // maya[k]) + '.'
            n %= maya[k]
        out += str(n)
        print(out)
    else:
        # mayan to christian:
        n = sum([maya[k] * inp[k] for k in range(5)])
        date = datetime.date.fromordinal(offset + n + 1)        
        print(str(date.year) + "." + str(date.month) + "." + str(date.day))

Fixed submission:
#-*- coding: utf-8 _*_
import datetime
 
def is_leap(y):
    if y%400==0:   return True
    if y%100==0:   return False
    if y%4==0:     return True
    return False
 
def get_day(y,m,d):
    if m<=2:
        y-=1
        m+=12
    dy = 365*(y-1)
    c = y/100
    dl=(y>>2)-c+(c>>2)
    dm=(m*979-1033)>>5
    return dy+dl+dm+d-1
 
def solve(line):
    ipt = map(int, line.split("."))
#     print ipt
    if len(ipt) >3:
        n=0
        for i in range(5):  n+=ipt[i]*mm[i]
        date = datetime.date.fromordinal(offset+n+1)
        print str(date.year)+"."+str(date.month)+"."+str(date.day)
    else:
        n=get_day(*ipt)-offset
#         print n
        n%=1872000
        ret=""
        for i in range(4):
            ret+=str(n/mm[i])+"."
            n%=mm[i]
        ret+=str(n)
        print ret
 
if __name__=='__main__':
    # const
    mm=(144000,7200,360,20,1)
    w1=(0,0,31,59,90,120,151,181,212,243,273,304,334,365)
    w2=(0,0,31,60,91,121,152,182,213,244,274,305,335,366)
    offset = get_day(2012,12,21)
#     print datetime.MAXYEAR
     
    while True:
        line=raw_input()
        if line=="#":   exit()
        solve(line)

Buggy python submission (verdict: Runtime Error):
# Aizu Problem 0261: Mayan Crucial Prediction

import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
#if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")

dpm = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # day per month

 
def get_day(year, month, day):
    if month <= 2:
        year -= 1
        month += 12
    dy = 365 * (year - 1)
    c = year // 100
    dl = (year >> 2) - c + (c >> 2)
    dm = (month * 979 - 1033) >> 5
    return dy + dl + dm + day - 1

def from_day(n):
    a = n + 32044;
    b = (4 * n + 3) // 146097
    c = a - (146097 * b) // 4
    d = (4 * c + 3) // 1461
    e = c - (1461 * d) // 4
    m = (5 * e + 2) // 153
    m1 = m // 10
    day = e - (153 * m + 2) // 5 + 1
    month = m + 3 - 12 * m1
    year = 100 * b + d - 4800 + m1
    if year <= 0:
        year = -year + 1
    return year, month, day


offset = get_day(2012, 12, 21)
maya= [144000, 7200, 360, 20, 1]
    
while True:
    inp = input().strip()
    if inp == "#":
        break
    inp = [int(_) for _ in inp.split('.')]
    if len(inp) == 3:
        # christian to mayan:
        n = (get_day(inp[0], inp[1], inp[2]) - offset) % 1872000
        out = ""
        for k in range(4):
            out += str(n // maya[k]) + '.'
            n %= maya[k]
        out += str(n)
        print(out)
    else:
        # mayan to christian:
        n = sum([maya[k] * inp[k] for k in range(5)])
        #date = datetime.date.fromordinal(offset + n + 1)
        year, month, day = from_day(n + 2456283 + 1)
        print(str(year) + "." + str(month) + "." + str(day))

Fixed submission:
#-*- coding: utf-8 _*_
import datetime
 
def is_leap(y):
    if y%400==0:   return True
    if y%100==0:   return False
    if y%4==0:     return True
    return False
 
def get_day(y,m,d):
    if m<=2:
        y-=1
        m+=12
    dy = 365*(y-1)
    c = y/100
    dl=(y>>2)-c+(c>>2)
    dm=(m*979-1033)>>5
    return dy+dl+dm+d-1
 
def solve(line):
    ipt = map(int, line.split("."))
#     print ipt
    if len(ipt) >3:
        n=0
        for i in range(5):  n+=ipt[i]*mm[i]
        date = datetime.date.fromordinal(offset+n+1)
        print str(date.year)+"."+str(date.month)+"."+str(date.day)
    else:
        n=get_day(*ipt)-offset
#         print n
        n%=1872000
        ret=""
        for i in range(4):
            ret+=str(n/mm[i])+"."
            n%=mm[i]
        ret+=str(n)
        print ret
 
if __name__=='__main__':
    # const
    mm=(144000,7200,360,20,1)
    w1=(0,0,31,59,90,120,151,181,212,243,273,304,334,365)
    w2=(0,0,31,60,91,121,152,182,213,244,274,305,335,366)
    offset = get_day(2012,12,21)
#     print datetime.MAXYEAR
     
    while True:
        line=raw_input()
        if line=="#":   exit()
        solve(line)