input: Write a python function to schedule jobs to maximize profit using a greedy algorithm.
  assert greedy([(3, 10), (4, 15), (2, 5)]) == [(2, 5, 2), (3, 10, 5), (4, 15, 9)]
  assert greedy([(1, 2), (2, 4), (3, 6)]) == [(1, 2, 1), (2, 4, 3), (3, 6, 6)]
  assert greedy([(5, 50), (2, 10), (1, 5)]) == [(1, 5, 1), (2, 10, 3), (5, 50, 8)]
output: def greedy(jobs):
      # Sort the jobs based on profit in descending order
      jobs.sort(key=lambda x: x[1], reverse=True)
      
      # Initialize result
      n = len(jobs)
      result = [0] * n
      
      # Keep track of free time slots
      slot = [-1] * n
      
      # Iterate through all given jobs
      for i in range(n):
          # Find a free slot for this job (Note that we start
          # from the last possible slot)
          for j in range(min(n, jobs[i][0]) - 1, -1, -1):
              if slot[j] == -1:
                  slot[j] = i
                  break
      
      # Collect result to return in the desired format
      job_schedule = []
      for i in range(n):
          if slot[i] != -1:
              job_schedule.append((jobs[slot[i]][0], jobs[slot[i]][1], sum(jobs[slot[k]][1] for k in range(i + 1) if slot[k] != -1)))
      
      return job_schedule