inputs: I found an interesting problem on https://codeforces.com/problemset/problem/254/B:
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems for her. Namely, the Olympiad number i should be prepared by p_{i} people for t_{i} days, the preparation for the Olympiad should be a continuous period of time and end exactly one day before the Olympiad. On the day of the Olympiad the juries who have prepared it, already do not work on it.

For example, if the Olympiad is held on December 9th and the preparation takes 7 people and 6 days, all seven members of the jury will work on the problems of the Olympiad from December, 3rd to December, 8th (the jury members won't be working on the problems of this Olympiad on December 9th, that is, some of them can start preparing problems for some other Olympiad). And if the Olympiad is held on November 3rd and requires 5 days of training, the members of the jury will work from October 29th to November 2nd.

In order not to overload the jury the following rule was introduced: one member of the jury can not work on the same day on the tasks for different Olympiads. Write a program that determines what the minimum number of people must be part of the jury so that all Olympiads could be prepared in time.


-----Input-----

The first line contains integer n — the number of Olympiads in 2013 (1 ≤ n ≤ 100). Each of the following n lines contains four integers m_{i}, d_{i}, p_{i} and t_{i} — the month and day of the Olympiad (given without leading zeroes), the needed number of the jury members and the time needed to prepare the i-th Olympiad (1 ≤ m_{i} ≤ 12, d_{i} ≥ 1, 1 ≤ p_{i}, t_{i} ≤ 100), d_{i} doesn't exceed the number of days in month m_{i}. The Olympiads are given in the arbitrary order. Several Olympiads can take place in one day.

Use the modern (Gregorian) calendar in the solution. Note that all...

I tried it in Python, but could not do it. Can you solve it?
targets: import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(pow(10, 6))
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return list(map(int, data().split()))
def ssp(): return list(map(str, data().split()))
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


def jury_size(a):
    date = start[a]
    dp[' '.join(map(str, end[a]))] += jury[a]
    while date != end[a]:
        dp[' '.join(map(str, date))] += jury[a]
        if date[0] in tone and date[1] == 31:
            date[0] += 1
            date[1] = 1
        elif date[0] == 2 and date[1] == 28:
            date[0] += 1
            date[1] = 1
        elif date[0] not in tone and date[1] == 30:
            date[0] += 1
            date[1] = 1
        else:
            date[1] += 1


start, end, jury = [], [], []
dp = dd(int)
tone = [1, 3, 5, 7, 8, 10, 12, 0, -2]
n = int(data())
for i in range(n):
    m, d, p, t = sp()
    if d > 1:
        end.append([m, d - 1])
    else:
        temp = d
        if (m - 1) in tone:
            temp = 31
        elif m == 3:
            temp = 28
        else:
            temp = 30
        end.append([m-1, temp])
    temp = d
    while t >= temp:
        m -= 1
        if m in tone:
            temp += 31
        elif m == 2:
            temp += 28
        else:
            temp += 30
    ed = temp - t
    start.append([m,...