MINOPS runtime error

this is my code for minops .
its working fine on gfg ide but is giving runtime error on codechef ide.

line 23. what if vi.size() is 0.
consider
s=> aaaa
r=> aaaa

Got it.
Thanks😊