SHARE
TWEET

Prezident

a guest Dec 15th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. f = open('input.txt', 'r', encoding='utf8')
  2. ans = open('output.txt', 'w', encoding='utf8')
  3. res = {}
  4. for line in f.readlines():
  5.     line = line.rstrip()
  6.     if res.get(line) is not None:
  7.         res[line] += 1
  8.     else:
  9.         res[line] = 1
  10. result = []
  11. for key in res.keys():
  12.     result.append([res[key], key])
  13. result = sorted(result, reverse=True)
  14. allsum = 0
  15. for i in range(len(result)):
  16.     allsum += result[i][0]
  17. if result[0][0] * 2 > allsum:
  18.     ans.write(result[0][1])
  19. else:
  20.     ans.write(result[0][1] + "\n")
  21.     ans.write(result[1][1])
  22. ans.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top