One Test Case shows tle and one wrong number rest are all cleared

SIr,my 2nd test case shows wrong ans and third shows tle.I am not able to figure out why.I have tried different approaches still can’t resolve.Please Help.Link: https://ide.codingblocks.com/s/245025
Problem code Boston Number

are
u calculating the sum of prime factors as well

refer to this code