If you're using cs50 ide from chrome to run web server, it will automatically terminate the session, once you close the chrome tab. You have to keep the chrome tab open and not remain idle. Or you can try free hosting services like Heroku, Netlify etc
This elif(a == True and r == 3 and r == 4 or 7): will always evaluate to True because 7 is "truthy". Did you mean or r == 7? And once an or introduced, the expression will likely need parentheses. Same goes for the subsequent elif.