Dealing with integer overflow(not question specific)

I am new to competitive programming. In Some problems, i notice when i run the code, the output is something like:

-145586001
1
1
1
1
1
1
1

Now, i am certain that the output should never be negative. I think it’s because of overflowing integers. I even tried using “long long” type but the result was same. If someone could guide me with stuff like which data types and libraries should be used when dealing with large values, that would be really helpfull

Modify your answer its the only way you can handle this or you can use big int if your answer is correct
Some Link That You Can Follow

  1. Handling large numbers in C.
  2. How to store a very large number of more than 100 digits in C++ - GeeksforGeeks
1 Like