Code not getting compiled on submission


the given code is showing segmentation fault here while running but works fine in vs code and coding blocks ide

Hello @mahfoozhaque91 please wait i am checking.

@mahfoozhaque91 check now:
commented the mistake;

got it thanks … but wonder how it worked in vs code and coding blocks ide, that i could not find the mistake

@mahfoozhaque91 it is because of input you were running the loop for 4 times and in vs code you must be giving input according to that only.
but here in input the sample input will have 3 elements in the stack but you were trying to access the 4 elements.