okay4869's blog

By okay4869, history, 18 months ago, In English

So I was doing this question from the Educational round 85 here: https://mirror.codeforces.com/contest/1334/problem/C

And after a few attempts this is the code that got TLE in 3rd test: https://mirror.codeforces.com/contest/1334/submission/209278732

However after adding the lines:

import sys
input = sys.stdin.buffer.readline

The same code got accepted and was pretty quick. https://mirror.codeforces.com/contest/1334/submission/209278848

This made me wonder, are there any more things I can add to my Python code to make it run faster? Any answers or even links would be greatly appreciated. Thank you.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?