• + 2 comments

    Just a guess, but you don't initialize avg. Maybe on your system memory gets initialized to 0, but on the hackerrank servers they get initialized to 0xDEADBEEF or not at all.