For Pycharm IDE, we want to use redirect input file while running the code.
- You can make a file for a input data as like *.in.
- Typing auto_redirect_input_file.py in top of code.
- Click the "Edit Configuration".
- Put the file name *.in in "Script parameters".
- And, no and. Enjoy it!!
import io
import sys
# Simulate the redirect stdin.
if len(sys.argv) > 1:
filename = sys.argv[1]
inp = ''.join(open(filename, "r").readlines())
sys.stdin = io.StringIO(inp)