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):



for cno in range(int(input())):
	y, m, d = map(int, input().split())
	ans = 195*y
	if y > 1: ans += 5*((y-1)//3)
	if y % 3: ans += 19*(m-1) + m//2
	else: ans += (m-1)*20
	print(196666-ans-d)

Solution (Python):


import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

n = input()

for loop in range(n):
    y, m, d = map(int, raw_input().split())
    m_lst = [20, 19, 20, 19, 20, 19, 20, 19, 20, 19]
    cnt = 0
    for i in range(m - 1):
        cnt += m_lst[i]
    if y % 3 == 0:
        cnt += (m - 1) // 2
    y -= 1
    cnt += y * 195 + (y // 3) * 5
    cnt += d - 1

    print 196470 - cnt

Solution (Python):
n = int(input())
anslist = []

Y = 1000
M = 1
D = 1
ans = 195 * (Y - 1)
ans += (Y - 1) // 3 * 5
ans += 20 * (M - 1)
ans += D
if Y % 3 != 0:
    ans -= (M - 1) // 2
milenium = ans

for i in range(n):

    Y, M, D = map(int, input().split())
    ans = 195 * (Y - 1)
    ans += (Y - 1) // 3 * 5
    ans += 20 * (M - 1)
    ans += D
    if Y % 3 != 0:
        ans -= (M - 1) // 2
    anslist.append(milenium - ans)


for i in anslist:
    print(i)

Solution (Python):
c = int(input())
a = [0]
for i in range(30):
    if i%2 == 0 or i >= 20:
        a.append(a[i]+20)
    else:
        a.append(a[i]+19)
for i in range(c):
    y, m, d = map(int,input().split())
    b = int((y-1)/3) * 590 + a[m + ((y+2)%3) * 10 - 1] + d
    print(196470 - b + 1)

Solution (Python):
n = int(input())
for _ in range(n):
  y,m,d = map(int,input().split())
  days = 0
  if d!=1:
    days += (20-d) if y%3!=0 and m%2==0 else (21-d)
    d = 1
    if m==10:
      y += 1
      m = 1
    else:
      m+=1
  if y!=1000:
    days += sum([19 if y%3!=0 and i%2==0 else 20 for i in range(11-m)])
    y += 1
    days += sum([19*5+20*5 if i%3!=0 else 20*10 for i in range(1000-y)])
  print(days)

Solution (Python):
n=int(raw_input())
for i in range(0,n):
	y,m,d=[int(e) for e in raw_input().split()]
	y-=1;m-=1
	print(196471-y*195-y//3*5-m*20+(m//2 if y%3!=2 else 0)-d)

Solution (Python):
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	y,m,d=[int(e) for e in raw_input().split()]
	y-=1;m-=1
	print(196471-y*195-y//3*5-m*20+(m//2 if y%3!=2 else 0)-d)

Solution (Python):
def day(y, m, d):
    days = 0
    days += (y-1)*195
    days += (y-1)//3*5
    days += (m-1)*19
    if y%3 == 0:
        days += (m-1)
    else:
        days += m//2
    days += (d-1)
    return days

def main():
    n = int(input())
    for _ in range(n):
        (y, m, d) = [int(x) for x in input().split()]
        print(day(1000,1,1) - day(y,m,d))

if __name__ == '__main__':
    main()

Solution (Python):



import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        n = input()
        mil = 196470
        for i in range(n):
            y, m, d = map(int, raw_input().split())
            elapsed = 0
            elapsed += 590 * ((y - 1) / 3) + 195 * ((y - 1) % 3)
            if y % 3 == 0:
                elapsed += 20 * (m - 1)
            else:
                elapsed += 39 * ((m - 1) / 2) + 20 * ((m - 1) % 2)
            elapsed += d - 1
            
            print mil - elapsed
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Solution (Python):



def date2num(y,m,d):
    t = (y-1)//3
    days = t*10*20 + (y-1-t)*5*20+(y-1-t)*5*19
    if y%3 == 0:
        days += (m-1)*20+d
    else:
        days += (m-1)//2*19+(m-1-(m-1)//2)*20+d
    return days
    
for i in range(int(input())):
    y,m,d = map(int,input().split(" "))
    print(date2num(1000,1,1) - date2num(y,m,d))

Solution (Python):
M = [19, 20]
Y = sum(M) * 5

for i in range(int(input())):
    res = 0
    y,m,d = list(map(int,input().split()))
    for y_2 in range(1000-1, y, -1):
        res += Y if y_2 % 3 != 0 else 200

    for m_2 in range(10, m, -1):
        res += M[m_2 % 2] if y % 3 != 0 else 20

    res += (M[m%2] if y % 3 != 0 else 20) - d +1

    print(res)

Solution (Python):
n = int(raw_input())
for i in range(n):
	Y, M, d = map(int, raw_input().split(" "))
	day_total = 0
	if Y % 3 == 0:
		day_sub = (M-1) * 20 + d - 1
	else :
		small_M = (M - 1) / 2
		day_sub = (M - 1 - small_M) * 20 + small_M * 19 + d - 1 
	for y in range(Y,1000):
		if y % 3 == 0:
			day_total += 10 * 20
		else :
			day_total += (20 + 19) * 5
	print day_total - day_sub

Solution (Python):
n = int(input())
for i in range(n):
    y,m,d = map(int, input().split())
    dif = 999 - y
    leap = int(dif / 3) + 1
    common = dif - leap + 1
    days = leap * 200 + common * 195 
    days -= (m - 1) * 20
    if y % 3 != 0:
        days += int((m - 1) / 2)
    days -= (d - 1)
    print(days)

Solution (Python):
n = int(input())

for _ in range(n):
    day_sum = 0
    year, month, day = map(int, input().split())

    
    day_sum += 1

    if year % 3 == 0 or month % 2 == 1:
        day_sum += 20 - day
    else:
        day_sum += 19 - day

    for m in range(month+1, 11):
        if year % 3 == 0 or m % 2 == 1:
            day_sum += 20
        else:
            day_sum += 19

    
    for y in range(1, 1000-year):
        for m in range(1, 11):
            if (year+y) % 3 == 0 or m % 2 == 1:
                day_sum += 20
            else:
                day_sum += 19

    print(day_sum)

Solution (Python):

def solve(dates):
    counter = 0;
    start_month = dates[1]
    start_day, end_day = dates[2], 0

    for year in range(dates[0], 1000):
        for month in range(start_month, 11):
            if year%3 == 0 or month%2 == 1:
                end_day = 21
            else:
                end_day = 20

            
            counter += (end_day - start_day)

            start_day = 1
        else:
            start_month = 1

    return counter



if __name__ == '__main__':
    n = int(input())

    dates = [0 for i in range(3)]
    tmp_dates = []
    for i in range(n):
        tmp_dates = input().split()
        for j in range(len(tmp_dates)):
            dates[j] = int(tmp_dates[j])

        date_count = solve(dates)
        print(date_count)

Solution (Python):

def solve(dates):
    counter = 0;
    start_month = dates[1]
    start_day, end_day = dates[2], 0

    for year in range(dates[0], 1000):
        for month in range(start_month, 11):
            if year%3 == 0 or month%2 == 1:
                end_day = 21
            else:
                end_day = 20

            
            counter += (end_day - start_day)

            start_day = 1
        else:
            start_month = 1

    return counter



if __name__ == '__main__':
    n = int(input())

    dates = [0 for i in range(3)]
    tmp_dates = []
    for i in range(n):
        tmp_dates = input().split()
        for j, tmp_date in enumerate(tmp_dates):
            dates[j] = int(tmp_date)

        date_count = solve(dates)
        print(date_count)

Solution (Python):
n = input()
for _ in xrange(n):
    y, m, d = map(int, raw_input().split())
    m -= 1

    ans = 1
    for t in xrange(y+1, 1000):
        ans += 195 if t%3 else 200
    for t in xrange(m+1, 10):
        ans += 19 if y%3 and t%2 else 20
    ans += 19-d if y%3 and m%2 else 20-d

    print ans

Solution (Python):

n = int(input())
for i in range(n):
	y, m, d = map(int, input().split())
	count = 0
	while (y, m, d) != (1000, 1, 1):
		d += 1
		if y % 3 == 0:
			if 20 < d:
				m += 1
				d = 1
		else:
			if m % 2 == 0:
				if 19 < d:
					m += 1
					d = 1
			else:
				if 20 < d:
					m += 1
					d = 1
		if 10 < m:
			y += 1
			m = 1
		count += 1

	print(count)

Solution (Python):
n = int(raw_input())

for i in range(n):
    y, m, d = map(int, raw_input().split())
    cnt = 0

    while y < 1000:
        while m <= 10:
            while d <= 20:
                cnt += 1
                d += 1
                if m % 2 == 0 and d > 19 and y % 3 != 0:
                    break
            m += 1
            d = 1
        y += 1
        m = 1
    print cnt

Solution (Python):
n = int(raw_input())
base = 196471
year = 195
month = [20,19,20,19,20,19,20,19,20,19]
for _ in xrange(n):
  Y,M,D = map(int, raw_input().split())
  days = 0
  days += (Y-1) * year + (Y-1) / 3 * 5
  for i in xrange(M-1):
    if Y%3 == 0:
      days += 20
    else:
      days += month[i]
  days += D
  print base - days

Solution (Python):

def da(Y,M,D):
    day = (Y / 3) * 590
    if Y % 3 == 0:
        day = day - 200 + (M - 1)*20 + D
    else:
        day = day + (Y%3 - 1) * 195
        if M%2 == 1:
            day = day + (M/2 * 39) + D
        else:
            day = day + (M/2 - 1) * 39 + 20 + D
        
        
    return day
n = int(raw_input())
for i in range(n):
        l = map(int,raw_input().split())
        Y = l[0]
        M = l[1]
        D = l[2]
        print da(1000,1,1) - da(Y,M,D)

Solution (Python):
for _ in range(int(input())):
    y,m,d = map(int,input().split())
    vy,vm,vd = y-1,m-1,d-1
    r = vy//3*590 + vy%3*195
    r += vd
    if (vy+1)%3==0: r += vm*20
    else: r += vm//2*39 + vm%2*20
    print(196470-r)

Solution (Python):
N = int(raw_input())
D1 = 20*5 + 19*5
D2 = 20*10

for i in xrange(N):
    y, m, d = map(int, raw_input().split())
    ans = 0
    if d != 1:
        if y % 3 == 0 or m % 2 == 1:
            last = 20
        else:
            last = 19
        ans += last - d + 1
        d = 1
        if m < 10:
            m += 1
        else:
            y += 1
            m = 1
    if m != 1:
        while m < 11:
            if y % 3 == 0 or m % 2 == 1:
                ans += 20
            else:
                ans += 19
            m += 1
        m = 1
        y += 1
    while y < 1000:
        if y % 3 == 0:
            ans += D2
        else:
            ans += D1
        y += 1
    print ans

Solution (Python):

def day(y,m,d):
    my,mm,md = y-1,m-1,d-1 
    day = my // 3 * 590 + my % 3 * 195 + md
    if y % 3 == 0:
        day += mm * 20
    else:
        day += mm // 2 * 39 + mm % 2 * 20
    return day
n = int(input())
for i in range(n):
    Y,M,D = [int(x) for x in input().split()]
    print(196470 - day(Y,M,D))

Solution (Python):
for _ in range(int(input())):
    y,m,d=map(int,input().split())
    y-=1;m-=1
    print(196471-(y//3*590+y%3*195+(m*20 if y%3==2 else m//2*39+m%2*20)+d))

Solution (Python):
def Year():
    Ya = 0
    for j in range(Y-1):
        Ya += 19*5+20*5
    for j in range((Y-1)/3):
        Ya += 5
    return Ya
def Mouth():
    Ma = 0
    for i in range(1, M):
        if Y%3 == 0:
            Ma += 20
        else:
            Ma += 19 + (i%2)
    return Ma

x = int(raw_input())
for i in range(x):
    Y,M,D = map(int,raw_input().split())
    print 196471 - (Year()+Mouth()+D)

Solution (Python):
n = int(input())

for _ in range(n):
    y, m, d = map(int, input().split())
    ans = (1000 - y) * 195 + (1002 - y) // 3 * 5
    if y % 3 == 0:
        tyear = (m - 1) * 20 + d - 1
    else:
        tyear = (m - 1) * 20 + d - 1 - ((m - 1) // 2)
    print(ans - tyear)

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    for _ in range(n):
        count = 0
        y,m,d = list(map(int,input().strip().split()))
        if y %3 == 0:count += 20 - d +1
        elif m &1: count +=20 -d + 1
        else :count += 19-d+1
        for i in range(m + 1,11):
            if y % 3 ==0: count +=20
            elif i &1: count += 20
            else:count += 19
        for i in range(y + 1,1000):
            if i %3 ==0: count+= 20* 10
            else:count += 20 * 5 + 19 * 5
        print(count)

Solution (Python):
N = int(input())
src = [map(int,input().split()) for i in range(N)]

days_normal = (20+19)*5
days_special = 20*10
days_3years = 2*days_normal + days_special

def passed(y,m,d):
    ret = ((y-1)//3) * days_3years
    ret += ((y-1)%3) * days_normal
    for i in range(m-1):
        ret += (20 if y%3 == 0 or i%2 == 0 else 19)
    ret += d
    return ret

for i in range(N):
    y,m,d = src[i]
    print(passed(1000,1,1) - passed(y,m,d))

Solution (Python):
n = int(raw_input())

for i in range(n):
    Y, M, D = map(int, raw_input().split())
    days = 0
    for i in range(1, Y):
        if i % 3 == 0:
            days += 200
        else:
            days += 39*5
    
    for i in range(1, M):
        if Y % 3 != 0 and i % 2 == 0:
            days += 19
        else:
            days += 20

    days += D

    print 196471 - days

Solution (Python):
n = int(raw_input())

for _ in range(n):
    Y, M, D = map(int, raw_input().split())
    days = 0
    for i in range(1, Y):
        if i % 3 == 0:
            days += 200
        else:
            days += 39*5
    
    for i in range(1, M):
        if Y % 3 != 0 and i % 2 == 0:
            days += 19
        else:
            days += 20

    days += D

    print 196471 - days

Solution (Python):
n = int(input())

for i in range(n):
    y, m, d = map(int, input().split())
    ans = 0

    while y < 1000:
        while m < 11:
            if y % 3 == 0 or m % 2 > 0:
                ans += 20 - d + 1
            else:
                ans += 19 - d + 1
            d = 1
            m += 1
        m = 1
        y += 1
    print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    n = I()
    a = [LI() for _ in range(n)]

    def f(y,m,d):
        t = (y-1) * 195
        t += (y-1) // 3 * 5
        t += (m-1) * 20
        if y % 3 > 0:
            t -= (m-1) // 2
        t += d - 1
        return t

    t = f(1000,1,1)
    for y,m,d in a:
        k = f(y,m,d)
        rr.append(t - k)

    return '\n'.join(map(str, rr))


print(main())

Solution (Python):
n = int(input())

def solve(Y,M,D):
    ans = 0
    ans += (Y - 1) * (19 + 20) * 5
    ans += ((Y -1)// 3) * 5
    ans += 19 * (M-1)
    if Y % 3 ==0:
        ans += (M-1)
    else:
        ans += (M // 2)
    ans += (D-1)
    print(196470 - ans)
    

for i in range(n):
    l = input().split(' ')
  
    solve(int(l[0]) , int(l[1]), int(l[2]))

Solution (Python):
n=int(input())
for _ in range(n):
    y,m,d=list(map(int,input().split()))
    c=0
    for i in range(1,y):
        if i%3:c+=195
        else:c+=200
    for i in range(1,m):
        if y%3:
            if i%2:c+=20
            else:c+=19
        else:
            c+=20
    c+=(d-1)
    print(196470-c)

Solution (Python):

import sys

n=int(sys.stdin.readline())
for i in range(0,n):
	a=map(int,sys.stdin.readline().split())
	a[0]-=1;a[1]-=1;
	print 196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2]

Solution (Python):
def calc(y, m, d):
	ret = d
	ret += (y - 1) * 39 * 5
	ret += 5 * ((y - 1) / 3)

	for j in range(1, m):
		if y % 3 == 0:
			ret += 20
		else:
			ret += 19 + (j % 2)

	return ret

for i in range(int(raw_input())):
	print calc(1000, 1, 1) - calc(*map(int, raw_input().split()))

Solution (Python):
import sys

def daysOfYear(y):
    if y <= 0:
        return 0
    elif y % 3 == 0:
        return 200
    else:
        return 195

def daysOfMonth(y, m):
    if y % 3 == 0 or m % 2 == 1:
        return 20
    else:
        return 19


mil = 1
for i in xrange(1, 1000):
    mil += daysOfYear(i)

raw_input()
for line in sys.stdin:
    y, m, d = map(int, line.split())
    s = 0
    for i in xrange(1, y):
        s += daysOfYear(i)
    for i in xrange(1, m):
        s += daysOfMonth(y, i)
    print mil - s - d

Solution (Python):
def datesOfTheYear(year):
    if year % 3 == 0:
        return 200
    return 195


def datesOfTheMonth(year, month):
    if year % 3 == 0:
        return 20
    if month % 2 == 0:
        return 19
    else:
        return  20


def datesFromBorn(birthyear, birthmonth, birthdate):
    result = 0
    for y in range(birthyear + 1, 1000):
        result += datesOfTheYear(y)
    for m in range(birthmonth + 1, 11):
        result += datesOfTheMonth(birthyear, m)
    result += datesOfTheMonth(birthyear, birthmonth) - birthdate + 1
    return result

if __name__ == "__main__":
    import sys
    import fileinput

    fin = fileinput.input()
    numberofcandidate = int(fin.next().strip())

    for _ in range(numberofcandidate):
        year, month, date = [int(i) for i in fin.next().strip().split()]
        print datesFromBorn(year, month, date)

    sys.exit(0)

Solution (Python):
for i in range(input()):
    y,m,d=map(int,raw_input().split())
    s=sum(200 if i%3==0 else 195 for i in range(y+1,1000))
    t=0
    for i in range(m,11):
        if y%3!=0:
            t+=20 if i%2==1 else 19
        else:
            t+=20
    print s+t-d+1

Solution (Python):
n = input()
for i in range(n):
    a = 0
    y, m, d = map(int, raw_input().split())
    a += 195 * (999 - y)
    a += (999 / 3 - y / 3) * 5
    if y % 3 :
        a += (10 - m) * 19 + (10 - m) / 2
        a += 20 - d - (m + 1) % 2 + 1
    else:
        a += (10 - m) * 20
        a += 20 - d + 1
    print a

Solution (Python):
for _ in range(input()):
	y,m,d = map(int,raw_input().split())
	print 196470 - ((y-1)*195 + (y-1)/3*5 + 20*(m-1) - min(1,y%3)*((m-1)/2) + d-1)

Solution (Python):
for _ in range(input()):
	y,m,d = map(int,raw_input().split())
	print 196470 - ((y-1)*195 + (y-1)/3*5 + 20*(m-1) - min(1,y%3)*((m-1)/2) + d-1)

Solution (Python):
for _ in range(input()):
	y,m,d = map(int,raw_input().split())
	print 196470 - ((y-1)*195 + (y-1)/3*5 + 20*(m-1) - min(1,y%3)*((m-1)/2) + d-1)

Solution (Python):
import sys

n=int(sys.stdin.readline())
for i in range(0,n):
	a=map(int,sys.stdin.readline().split())
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Solution (Python):
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=map(int,raw_input().split())
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Solution (Python):
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Solution (Python):
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])

Solution (Python):
def days(y, m, d) :
    cnt = 0
    for i in range(1, y) :
        if i % 3 == 0 :
            cnt += 200
        else :
            cnt += 195
    for i in range(1, m) :
        if y % 3 == 0 :
            cnt += 20
        else :
            if i % 2 == 0 :
                cnt += 19
            else :
                cnt += 20
    cnt += d-1
    return cnt

n = int(input())
for i in range(n) :
    y, m, d = map(int, input().split())
    print(days(1000, 1, 1) - days(y, m, d))

Solution (Python):
def get_no_days(day_str):
    day_split = day_str.split(' ')
    year = int(day_split[0])
    month = int(day_split[1])
    day = int(day_split[2])
    result = 0

    for y in range(1, year, 1):
        if y % 3 != 0:
            result += 195
        else:
            result += 200
    year_not_mod_3 = (year % 3 != 0)
    for m in range(1, month, 1):
        if year_not_mod_3 and m % 2 == 0:
            result += 19
        else:
            result += 20
    result += day
    return 196471 - result

total = int(input())
for i in range(total):
    d = input()
    print(str(get_no_days(d)))

Solution (Python):
import math

oneYear = 20*5 + 19*5
threeYears = oneYear*2 + 20*10
millennium = 196471

N = int(input())
for i in range(N):
    data = input().split()
    birthYear = int(data[0])
    birthMonth = int(data[1])
    birthDay = int(int(data[2]))

    day = 0
    
    passedYears = birthYear - 1
    day += (passedYears%3 * oneYear) + (math.floor(passedYears/3)*threeYears)
    if birthYear%3 == 0:
        passedMonth = birthMonth-1
        day += passedMonth*20
        day += birthDay
    else:
        passedMonth = birthMonth-1
        day += math.floor(passedMonth/2) * 39
        day += passedMonth%2 * 20
        day += birthDay
    ans = millennium - day
    print(ans)

Solution (Python):
def get_input_data():
    input_data = int(input())
    return input_data

def make_calendar():
    calendar_dict = dict()
    duration = 0
    y, m, d = 1000, 1, 1
    while y > 1 or m > 1 or d > 1:
        duration += 1
        if d > 1:
            d -= 1
        elif m > 1:
            m -= 1
            d = calculate_month_having_date(y, m)
        else:
            y -= 1
            m = 10
            d = calculate_month_having_date(y, m)
        calendar_dict[(y, m, d)] = duration
    return calendar_dict

def calculate_month_having_date(y, m):
    if y % 3 == 0 or m % 2 == 1:
        d = 20
    else:
        d = 19
    return d

def show_the_duration(calendar_dict):
    birthday = input().split()
    for i, v in enumerate(birthday):
        birthday[i] = int(v)
    duration = calendar_dict[tuple(birthday)]
    return duration

if __name__ == "__main__":
    calendar_dict = make_calendar()
    
    people_num = get_input_data()
    for i in range(people_num):
        duration = show_the_duration(calendar_dict)
        print(duration)

Solution (Python):
n = int(input())
cnt = 0
ans = []
for i in range(n):
    cnt = 0
    y,m,d = map(int,input().split())
    if y % 3 == 0:
        cnt += (10-m)*20 + (20-d+1)
        y += 1
    else:
        cnt += ((10-m)- ((10-m)//2)) * 20 + ((10-m)//2) * 19 + (19-d+1) + 5
        y += 1
    cnt += ((1000-y)//3) * 200 + ((1000-y)-((1000-y)//3)) * 195
    ans.append(cnt)
for i in ans:
    print(i)

Solution (Python):
n = int(input())
n1 = 19*5 + 20*5
n2 = 20*10
for _ in range(n):
    y,m,d = map(int,input().split())
    ans = (999-y)//3*(n1*2+n2)
    if (999-y)%3 == 1:
        ans += n2
    elif (999-y)%3 == 2:
        ans += n1+n2
    if y%3 == 0:
        ans += (10-m)*20
    else:
        if m%2 == 0:
            ans += (10-m)//2*39
        else:
            ans += (10-m)//2*39+19
    if m%2 == 0 and y%3 != 0:
        ans += 19-d+1
    else:
        ans += 20-d+1
    print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
year=195
from math import ceil
for i in range(n):
	y,m,d=map(int,input().split())
	ans=0
	ans+=(999-y)*year
	ans+=(333-y//3)*5
	if y%3==0:
		ans+=(10-m)*20
		ans+=(20-d)+1
	else:
		ans+=(10-m)*20
		ans-=ceil((10-m)/2)
		if m%2==0:
			ans+=(19-d)+1
		else:
			ans+=(20-d)+1
	print(ans)

Solution (Python):
def calc(y, m):
    y += 1
    m += 1
    if m % 2 == 1:
        return 20
    if y % 3 == 0:
        return 20
    else:
        return 19


date = [ [ [0 for k in range(calc(i, j))] for j in range(10)] for i in range(1000)]

count = 0
for i in range(1000):
    for j in range(10):
        for k in range(calc(i,j)):
            date[i][j][k] = count
            count += 1

last = date[999][0][0]

n = int(input())
for i in range(n):
    y, m, d = map(int, input().split(' '))
    print(last - date[y-1][m-1][d-1])

Solution (Python):
n = int(input())

def f(y, m, d):
    ret = 0
    for i in range(1, y):
        if i % 3 == 0:
            ret += 20 * 10
        else:
            ret += 20 * 5 + 19 * 5
    for j in range(m - 1):
        if j % 2 == 0:
            ret += 20
        else:
            if y % 3 == 0:
                ret += 20
            else:
                ret += 19
    ret += d
    return ret

al = f(1000, 1, 1)
for i in range(n):
    y,m,d = map(int,input().split())
    print(al - f(y, m, d))

Solution (Python):
N = int(input())
YMD = [[0,0,0] for i in range(N)]
ans = [[[0 for i in range(20)] for j in range(10)] for k in range(1000)]
for i in range(N):
    line = input().split(" ")
    YMD[i] = [int(line[0])-1, int(line[1])-1, int(line[2])-1]


count = 0
for y in range(1000):
    if (y+1)%3 == 0:
        for m in range(10):
            for d in range(20):
                ans[y][m][d] = count
                count+=1
    else:
        for m in range(10):
            if m%2 == 0:
                for d in range(20):
                    ans[y][m][d] = count
                    count+=1
            else:
                for d in range(19):
                    ans[y][m][d] = count
                    count+=1
            
mile = ans[999][0][0]
for i in range(N):
    tmpYMD = YMD[i]
    tage = ans[tmpYMD[0]][tmpYMD[1]][tmpYMD[2]]
    diff = mile - tage
    print(diff)

Solution (Python):
"""
1年1月1日が1日目

3で割り切れる年は 1年が200日

割り切れない日は 1年が195日

3年単位で, 200+195+195 = 590日

+あまりの年×195


月から日への変換方法は

もし3で割り切れないあり and 

(i)月が奇数の時　 20

(ii)月が偶数の時 19

日はそのまま足す


1000年1月1日 を基準にする
計算時間短縮のために先に日に直しておこう
1年1月1日を1日目としているから　1年引く
(1000-1) // 3 = 333*3 

割り切れない　年から日は590*333 + 1*195

月から日は　割り切れない　1は奇数だから +20 と思いきや
1年1月1日を1日目としているから、1-1 = 0となる

よって 590*333  + 1 =196471

999 年　10月 20日の場合

999-1 //3 = 332 + 2


999は3で割り切れる

10-1 *20 = 180日 

590*332 + 2*195 +180 + 20 =196470

差分は1
"""
def get_days(y,m,d):
    day = 0
    if int((y-1) % 3) == 0: 
        day += (int(y-1)//3)*590
    elif int((y-1) % 3) != 0:
        day += (int((y-1)//3))*590 + (int((y-1)%3))*195

    if int(y% 3) == 0:
        day+= (m-1)*20
    else:
        day += (m-1)*20-int((m-1)//2)

    day += d

    comp = 196471 -day
    return comp



n = input()
n = int(n)
"""
inputlist = []

for i in range(n):
	yc , mc , dc = input().split()
	yc = int(yc)
	mc = int(mc)
	dc = int(dc)
	inputlist.append([yc,mc,dc])
	"""

while(True):

	if n == 0:
		break
	
	
	yc , mc , dc = input().split()
	yc = int(yc)
	mc = int(mc)
	dc = int(dc)
	n -= 1
	
	print(get_days(yc,mc,dc))

	"""
	y = inputlist[i][0]
	m =inputlist[i][1] 
	d = inputlist[i][2]
	"""
	
	
"""	
	if int((y-1) % 3) == 0:
		day += (y-1)*590
	elif int((y-1) % 3) != 0:
		day += (int((y-1)//3))*590 + (int((y-1)%3))*195
	
	if int(y % 3) == 0:
		day+= (m-1)*20
	else:
		day += (m-1)*20-int((m-1)//2)
	
	day += d
	
	comp= 196471 -day
	n -= 1
	i += 1
	print(comp)
	"""

Solution (Python):

"""
Millennium
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1179&lang=jp

"""
import sys

from itertools import accumulate

memo = [-1] * 1001
memo[1000] = 0
for y in range(999, 0, -1):
    memo[y] = (20 * 10 if y % 3 == 0 else 20 * 5 + 19 * 5) + memo[y+1]

def solve(y, m, d):
    months = [0] + [20, 19] * 5 if y % 3 else [0] + [20] * 10
    acc = list(accumulate(months))
    ans = memo[y] - acc[m-1] - (d-1)
    return ans


def main(args):
    n = int(input())
    for _ in range(n):
        y, m, d = map(int, input().split())
        ans = solve(y, m, d)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

Solution (Python):
def cal(y0,m0,d0):
    y = 1
    m = 1
    d = 1
    for days in range(10**6):
        if (y,m,d) == (y0,m0,d0):
            return days
        d += 1
        if y % 3 == 0:
            if d == 21:
                m += 1
                d = 1
            if m == 11:
                y += 1
                m = 1
        else:
            if m % 2 == 1:
                if d == 21:
                    m += 1
                    d = 1
                if m == 11:
                    y += 1
                    m = 1
            elif m % 2 == 0:
                if d == 20:
                    m += 1
                    d = 1
                if m == 11:
                    y += 1
                    m = 1

n = int(input())
ymd = [list(map(int,input().split())) for _ in range(n)]

res = cal(1000,1,1)
for y,m,d in ymd:
    ans = res - cal(y,m,d)
    print(ans)

Solution (Python):
n = int(input())
for i in range(n):
    y,m,d = map(int,input().split())
    only_dai = (1000 - y + 1) // 3 * 10 * 20
    dai_shou = ((1000 - y - 1) - (1000 - y + 1) // 3) * (20 * 5 + 19 * 5)
    if y % 3 == 0:
        hanpa_m = (10 - m) * 20
    else:
        hanpa_m = (10 - m) * 20 - (10 - m + 1) // 2
    if m % 2 == 0 and y % 3 != 0:
        hanpa_d = 19 - d
    else:
        hanpa_d = 20 - d
    ans = only_dai + dai_shou + hanpa_m + hanpa_d + 1
    print(ans)

Solution (Python):
def main():
    y, m, d = map(int, input().split())
    a = (y - 1) // 3
    b = (y - 1) % 3
    c = a * 590 + 195 * b 
    if y % 3:
        a = (m - 1) // 2
        b = (m - 1) % 2
        c += a * 39 + b * 20
    else:
        c += (m - 1) * 20
    c += d - 1
    print(196470-c)
n = int(input())
for i in range(n):
    main()

Solution (Python):
import sys
def f(y,m,d):
    res = (y-1)//3*200+(y-1-(y-1)//3)*195
    if y%3 == 0:
        res += (m-1)*20+d
    else:
        res += (m-1)//2*19+(m-1-(m-1)//2)*20+d
    return res
    
M = 196471
n  = int(sys.stdin.readline())
for i in range(n):
    y,m,d = [int(x) for x in sys.stdin.readline().split()]
    print(M-f(y,m,d))

Solution (Python):



n = int(input())
for _ in range(n):
    y,m,d = list(map(int,input().split()))
    sub = 1
    for i in range(y+1,1000):
        if i % 3 == 0:
            sub += 200
        else:
            sub += 19*5 + 100
    if y % 3 == 0:
        sub += (10 - m)*20 + (20 - d)
    else:
        if m % 2 == 0:
            sub += (19 - d) + (10 - m)//2*(20 + 19)
        else:
            sub += (10 - m + 1)//2*(20 + 19) - d
    print(sub)