The code:
if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().rstrip().split()))
for i in range(n-1):
arr+=list(map(int, input().rstrip().split()))
arr=arr[::-1]
for i in arr:
print(i,'',end='')
The error which I get:
Compiler Message
Runtime Error
Error (stderr)
Traceback (most recent call last):
File "Solution.py", line 16, in <module>
arr+=list(map(int, input().rstrip().split()))
EOFError: EOF when reading a line
Please correct me if I am going wrong somewhere as I am a beginner and self-taught.
I have tried the same thing. Python programs require more memory than c/c++ programs.
The way competitive coding sites are designed are that they have a very secure or containerised procedure of executing the submitted programs. You cannot make networking calls, make or delete directories, etc. In the same way, they provide a precise memory and time limits to evaluate your programs. Your own IDE does not have such restrictions while executing the same Python program and hence it does not crash.
My advice would be to switch to C/C++ as they are faster and provide a very good base for learning other high level languages. C/C++ is the most common and widely used language for competitve coding and will definitely help you in the long run.