Comments

A tree is a connected acyclic graph. So, a tree does not have cycles.

For the given distance matrix to be satisfied, there will be a cycle in the graph. But we should check if it forms the dist matrix of a weighted tree. I think this is the reason for the answer being "NO"

Thanks a lot, my bad !! Its accepted after the modification.

Can anyone please help me out with this? For Problem A, I found composite numbers using sieve and solved the problem by checking every possible composite number. Submission id is 8060116 I am getting run time error on test case 14, but on my local machine it is giving the answer as 4 4860 when Input is 4864

Thanks.