Problem:
Millennium A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1.  Each year consists of 10 months, from month 1 through month 10, and starts from a big month .  A common year shall start with a big month, followed by small months and big months one after another.  Therefore the first month is a big month, the second month is a small month, the third a big month, ..., and the 10th and last month a small one.  A big month consists of 20 days and a small month consists of 19 days.  However years which are multiples of three, that are year 3, year 6, year 9, and so on, shall consist of 10 big months and no small month." Many years have passed since the calendar started to be used.  For celebration of the millennium day (the year 1000, month 1, day 1), a royal lottery is going to be organized to send gifts to those who have lived as many days as the number chosen by the lottery.  Write a program that helps people calculate the number of days since their birthdate to the millennium day. Input The input is formatted as follows.  n  Y 1 M 1 D 1  Y 2 M 2 D 2 ...  Y n M n D n  Here, the first line gives the number of datasets as a positive integer n , which is less than or equal to 100.  It is followed by n datasets.  Each dataset is formatted in a line and gives three positive integers, Y i (< 1000), M i (≤ 10), and D i (≤ 20), that correspond to the year, month and day, respectively, of a person's birthdate in the king's calendar.  These three numbers are separated by a space. Output For the birthdate specified in each dataset, print in a line the number of days from the birthdate, inclusive, to the millennium day, exclusive.  Output lines should not contain any character other than this number. Sample Input 8
1 1 1
344 3 1
696 5 1
182 9 5
998 8 7
344 2 19
696 4 19
999 10 20 Output for the Sample Input 196470
128976
59710
160715
252
128977
59712
1

Solution (Python):
n=int(input())
for i in range(n):
  Y,M,D=map(int,input().split())
  
  if Y%3!=0 and M%2==0:
    day=(19-D)+1
  else:
    day=(20-D)+1

  for j in range(M+1,11):
    
    if Y%3==0:
      day+=20
    elif j%2==0:
      day+=19
    else:
      day+=20
  
  for j in range(Y+1,1000):
    
    for l in range(1,11):
      if j%3==0:
        day+=20
      elif j%3!=0 and l%2==0:
        day+=19
      else:
        day+=20
  
  print(day)

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for z in range(n)]
ans1=196471
for i in range(n):
    ans2=0
    y=l[i][0]
    m=l[i][1]
    d=l[i][2]
    ans2+=(y-1)*195+int((y-1)/3)*5
    if y%3==0:
        ans2+=(m-1)*20
    else:
        if (m-1)%2==0:
            ans2+=39*(m-1)/2
        else:
            ans2+=39*(m-2)/2+20
    ans2+=d
    print(int(ans1-ans2))

Solution (Python):
n = int(input())
for i in range(n):
    y, m, d = map(int, input().split())
    tmp = 0
    tmp += (y-1) * 195
    tmp += ((y-1) // 3) * 5
    tmp += (m-1) * 20
    if y % 3 != 0:
        tmp -= (m-1) // 2
    tmp += d
    print(196471 - tmp)

Solution (Python):
def count(Y, M, D) :
	thr = (Y - 1) // 3
	cnt = (Y - thr - 1) * 195 + thr * 200
	if(Y % 3 == 0) :
		cnt += (M - 1) * 20 + D
	else :
		m = (M - 1) // 2
		cnt += (M - m - 1) * 20 + m * 19 + D
	print(Mil - cnt + 1)

n = int(input())

Mil = 666 * 195 + 333 * 200

for i in range(n) :
	Y, M, D = map(int, input().split())
	count(Y, M, D)

Solution (Python):


ans = []
n = int(input())
for j in range(n):
    y, m, d = map(int, input().split())
    day = 0

    for i in range(m, 11):
        if y % 3 == 0:
            day += 20
        else:
            if i % 2 == 0:
                day += 19
            else:
                day += 20
    day -= d


    for i in range(y + 1, 1000):

        if i % 3 == 0:
            day += 200
        else:
            day += 195

    ans.append(day + 1)

for i in ans:
    print(i)

Solution (Python):
LGE = 20
SML = 19
FUTU = 195
URUU = 200
YEAR3 = 590

def main():
    howmany = int(input())

    for i in range(howmany):
        daycount = 0
        
        dataset = input()
        dataset = dataset.split(" ")
        
        for j in range(len(dataset)):
            dataset[j] = int(dataset[j])
        
        
        
        daycount += totopmonth(dataset)
        
        
        
        
        
        
        if dataset[0] == 1000:
            print(daycount)
        else:
            daycount += totopyear(dataset)
            
            
            
            
            
            
            if dataset[0] == 1000:
                print(daycount)
            else:
                daycount += totheend(dataset)
                print(daycount)
                

def totopmonth(array):
    count = 0
    
    if array[2] == 1:
        return count
    elif array[0] % 3 != 0:
        if array[1] % 2 == 1:
            count = LGE - array[2] + 1
            array[2] = 1
            array[1] += 1
        else:
            count = SML - array[2] + 1
            array[2] = 1
            array[1] += 1

    else:
        count = LGE - array[2] + 1
        array[2] = 1
        array[1] += 1

    if array[1] == 11:
        array[1] = 1
        array[0] += 1
        
    return count 
        
def totopyear(array):
    count = 0
    if array[1] == 1:
        return count
    elif array[0] % 3 != 0:
        if array[1] % 2 == 1:
            count = (10 - array[1] + 1) // 2 * (LGE + SML)
            array[1] = 1
            array[0] += 1
        else:
            count = (11 - array[1] + 1) // 2 * (LGE + SML) - LGE
            array[1] = 1
            array[0] += 1
    else:
        count = (10 - array[1] + 1) * LGE
        array[1] = 1
        array[0] += 1
    return count

def totheend(array):
    count = 0
    if array[0] % 3 == 0:
        count = (999 - array[0]) // 3 * YEAR3 + URUU
        return count
    elif array[0] % 3 == 1:
        count = (999 - array[0]) // 3 * YEAR3 + YEAR3
        return count
    else:
        count = (999 - array[0]) // 3 * YEAR3 + URUU + FUTU
        return count
main()

Solution (Python):
n=int(input())
table=[0,20, 39, 59, 78, 98, 117, 137, 156, 176, 195]
u_table=[0,20, 40, 60, 80, 100, 120, 140, 160, 180, 200]
for i in range(n):
    y,m,d=map(int,input().split())
    ans=0
    for j in range(y+1,1000):
        if j%3==0:
            ans+=u_table[-1]
        else:
            ans+=table[-1]
    if y%3==0:
        ans+=u_table[-1]-u_table[m]
        ans+=u_table[m]-u_table[m-1]-d+1
    else:
        ans+=table[-1]-table[m]
        ans+=table[m]-table[m-1]-d+1
    print(ans)

Solution (Python):
def solve(y, m, d):
    Y = [195, 195, 200]
    M = [20, 19]

    ret = 196471
    for i in range(y-1):
        ret -= Y[i % 3]
    if y % 3 == 0:
        ret -= (m-1) * 20
    else:
        for i in range(m-1):
            ret -= M[i % 2]
    ret -= d

    return ret


N = int(raw_input())
for _ in range(N):
    y, m, d = map(int, raw_input().split(" "))
    print solve(y, m, d)