Problem: Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:    * Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.  For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?

Submission attempts (in order):
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"ABC106C-ToInfinity.ipynb","provenance":[],"authorship_tag":"ABX9TyNX8Ir2ZzuscRLajj/o6IUg"},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","metadata":{"id":"3ke4UMpfQZna","colab_type":"code","outputId":"b7f58493-9947-42d9-8953-9dfad87c6dad","executionInfo":{"status":"ok","timestamp":1589608511500,"user_tz":-540,"elapsed":5594,"user":{"displayName":"Taishi","photoUrl":"","userId":"11736711679866118393"}},"colab":{"base_uri":"https://localhost:8080/","height":72}},"source":["s = str(input())\n","k = int(input())\n","if int(s[0]) == 1:\n","  print(s[1])\n","else:\n","  print(s[0])"],"execution_count":3,"outputs":[{"output_type":"stream","text":["3\n","157\n","3\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"G05wyz9VTQI9","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":35},"outputId":"8368a8c5-f413-4a10-c257-1f3791af6cf0","executionInfo":{"status":"ok","timestamp":1589608502261,"user_tz":-540,"elapsed":575,"user":{"displayName":"Taishi","photoUrl":"","userId":"11736711679866118393"}}},"source":["3\n","157"],"execution_count":2,"outputs":[{"output_type":"execute_result","data":{"text/plain":["157"]},"metadata":{"tags":[]},"execution_count":2}]},{"cell_type":"code","metadata":{"id":"TmcZoyerDNFs","colab_type":"code","colab":{}},"source":[""],"execution_count":0,"outputs":[]}]}

{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"ABC106C-ToInfinity.ipynb","provenance":[],"authorship_tag":"ABX9TyNRoFVf941vEvQ2RLhFUphc"},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","metadata":{"id":"3ke4UMpfQZna","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":72},"outputId":"99180d89-276e-4fd8-b2c6-02e5a651ee14","executionInfo":{"status":"ok","timestamp":1589596953669,"user_tz":-540,"elapsed":15115,"user":{"displayName":"Taishi","photoUrl":"","userId":"11736711679866118393"}}},"source":["s = str(input())\n","k = int(input())\n","i = 0\n","n = s[0]\n","while (i < len(s)):\n","  if int(s[i]) ** 2 >= k:\n","    n = s[i]\n","    break\n","  else:\n","    k -= int(s[i])\n","  i += 1\n","print(n)"],"execution_count":17,"outputs":[{"output_type":"stream","text":["299792458\n","9460730472580800\n","2\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"G05wyz9VTQI9","colab_type":"code","colab":{}},"source":["299792458\n","9460730472580800"],"execution_count":0,"outputs":[]}]}

s = str(input())
k = int(input())
i, count = 0, 0
while (i < len(s)):
  if int(s[i]) == 1:
    if (count >= k - 1):
      print('1')
      break
    count += 1
  else:
    print(s[i])
    break
  i += 1

Verdicts: Wrong Answer

Wrong Answer

Accepted