So, keep in mind that I am a competitive coder for sport/fun - not for job interview. With that background - for problems like - Finding the distance between two closest points in 2d point. Yes, I understand the logic perfectly well. Question is - do you think it is unfair to copy-paste the function (my own code) in a contest? Its kinda hard to remember all the details - like the need to compare a point with its 5 next points sorted by y-coordinate.

Another example is calculating modulo multiplicative inverse:

I do understand concepts when mod p with p as prime. The O(log p) algo requirement. I do understand that we can calculate MMI for all numbers in range (1 to p-1) in o( P ) time. But I just dont remember the small details. Is it fair for me to self-plagiarise?

To clarify, the question is not about violating codechefâ€™s guidelines. Its about being unethical or taking an approach that will slow me in the long term.