title: Fastest way to input all the numbers on one line in Python3?
body: <p>My problem is "time limit exceeded" error for a problem on SPOJ. As I thought this error is because of large input, I need your help to find the best way to handle large inputs.</p>
  
  <p>Let me explain the input and my code.</p>
  
  <blockquote>
    <p>Input</p>
    
    <p>The first line of the input contains test cases t(1&lt;=t&lt;=100). It is
    followed by 2*t lines, 2 for each test case. The first line of input
    for each test case contains a number n (0&lt;=n&lt;=10^6), followed by n
    elements in the next line. Each number is from -10^3 to +10^3</p>
  </blockquote>
  
  <p>Here is an example of input</p>
  
  <pre><code>3 #number of test cases (t)
  
  4 #number of elements that will come to next line (n) (this can be 10^6)
  
  2 1 2 2 #this line may have 10^6 numbers
  
  6 
  
  1 1 1 2 2 2
  
  5
  
  1 2 4 5 1
  </code></pre>
  
  <p>Problem is asking if a number occurs more than n//2 times.
  Example output</p>
  
  <pre><code>YES 2  #because 2 appears 3 times.
  
  NO     # no number occurs more than n//2 times
  
  NO     # no number occurs more than n//2 times.
  </code></pre>
  
  <p>More information about the problem</p>
  
  <blockquote>
    <p>Added by: Troika::Bytes Date: 2010-02-18 Time limit:  1s Source
    limit:    50000B Memory limit:    256MB Cluster:  Pyramid (Intel Pentium III
    733 MHz) Languages:   All except: PERL 6</p>
  </blockquote>
  
  <p><a href="http://www.spoj.com/problems/MAJOR/" rel="nofollow">http://www.spoj.com/problems/MAJOR/</a></p>
  
  <p>And finally my code.</p>
  
  <pre><code>from collections import Counter
  import re
  
  def major(n):
      s = input().split() # get all the numbers one by one
      y = (Counter(s)).most_common()[0]  # Count how many times a number occurs in the input and return the most occurence with its value in a pair.
      if y[1]&gt; n//2: #if the most occurence is more than half of the "n"
          return "YES " + y[0] # return the value belongs to the most occurence
      else:
          return "NO"
  
  for i in range(int(input())): #get the number of test cases
      print(major(int(input()))) # calling the function to get the "n"
  </code></pre>
  
  <p>I've changed the input part to <code>s = re.findall(r'\d+', input())</code> after wondering if <code>s = input().split()</code> could be too slow for like <em>a million numbers.</em> But again, I am receiving a "time limit exceeded" error. Could it be related to <code>Counter</code> function?</p>