on singlethreaded cpu execute program contain n function each function unique ID 0 n1function call store stack function start ID push stack function end ID pop stack the function ID stack current function execute each time function start end write log ID start end timestampyou give list log logsi represent ith log message format string function_idstart endtimestamp for example 0start3 mean function function ID 0 start begin timestamp 3 1end2 mean function function ID 1 end end timestamp 2 note function call multiple time possibly recursivelya function exclusive time sum execution time function call program for example function call twice execute 2 time unit execute 1 time unit exclusive time 2 1 3return exclusive time function array value ith index represent exclusive time function ID Example 1input n 2 log 0start01start21end50end6output 34ExplanationFunction 0 start begin time 0 execute 2 unit time reach end time 1Function 1 start begin time 2 execute 4 unit time end end time 5function 0 resume execution begin time 6 execute 1 unit timeSo function 0 spend 2 1 3 unit total time execute function 1 spend 4 unit total time executingExample 2input n 1 log 0start00start20end50start60end60end7output 8explanationfunction 0 start begin time 0 execute 2 unit time recursively call itselffunction 0 recursive start begin time 2 execute 4 unit timefunction 0 initial resume execution immediately call againfunction 0 2nd recursive start begin time 6 execute 1 unit timefunction 0 initial resume execution begin time 7 execute 1 unit timeSo function 0 spend 2 4 1 1 8 unit total time executingExample 3input n 2 log 0start00start20end51start61end60end7output 71explanationfunction 0 start begin time 0 execute 2 unit time recursively call itselffunction 0 recursive start begin time 2 execute 4 unit timefunction 0 initial resume execution immediately call function 1Function 1 start begin time 6 execute 1 unit time end end time 6function 0 resume execution begin time 6 execute 2 unit timeSo function 0 spend 2 4 1 7 unit total time execute function 1 spend 1 unit total time execute Constraints1 n 1001 logslength 5000 function_id n0 timestamp 109no start event happen timestampno end event happen timestampeach function end log start log