python fast input code example

Example 1: fast outupt input python

import sys
input = sys.stdin.readline
# contributed by rohit gupta

Example 2: how to take fast input in python

# Fast Input and Output in Python

from sys import stdin, stdout

# For single input:

n = int(stdin.readline())

# For multiple inputs from single line:

def get_inputs(): 
    return map(int, sys.stdin.readline().strip().split())

n1, n2, n3, n4 = get_inputs()

# For fast output

stdout.write(n1)
stdout.write(str(n1) + '\n' + str(n2) + '\n' + str(n3))

# Contributed by Supantha Roy