problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 262k
1.05M
| problem_description
stringlengths 48
1.55k
| codes
stringlengths 35
98.9k
| status
stringlengths 28
1.7k
| submission_ids
stringlengths 28
1.41k
| memories
stringlengths 13
808
| cpu_times
stringlengths 11
610
| code_sizes
stringlengths 7
505
|
---|---|---|---|---|---|---|---|---|---|---|
p03951 | u609814378 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\n\nmae = s[:N]\nushiro = t[:N]\n\nif mae == ushiro:\n print(mae)\n exit()\n\n\nprint(mae+ushiro)', 'N = int(input())\ns = input()\nt = input()\n\nmae = s[:N]\nushiro = t[:N]\n\nif mae == ushiro:\n print(mae)\n exit()\n\n\nprint(len(mae+ushiro))', 'import sys\nn = int(input())\ns = list(input())\nt = list(input())\n\nif s == t:\n print(n)\n sys.exit()\ncan = False\nfor i in range(n):\n if s[i:n] == t[0:(n-i)]:\n can = True\n break\nif can:\n print(n + i )\nelse:\n print(2*n)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s495310471', 's919033744', 's695923614'] | [9100.0, 9104.0, 9176.0] | [25.0, 31.0, 26.0] | [133, 138, 244] |
p03951 | u612721349 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n, s, t = [input().strip() for _ in range(3)]\nn = int(n)\nif s == t:\n print(n)\n exit(0)\nfor i in range(n):\n if s[n-i-1] != t[i]:\n print(s + t[i:])\n break', 'n, s, t = [input().strip() for _ in range(3)]\nn = int(n)\nfor i in range(n):\n if s[i:] == t[:n-i]:\n print(n + i)\n break\nelse:\n print(2 * n)'] | ['Wrong Answer', 'Accepted'] | ['s626385167', 's428841718'] | [2940.0, 3060.0] | [17.0, 17.0] | [161, 146] |
p03951 | u619197965 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n=int(input())\ns=input()\nt=input()\nans=""\nfor i in range(n):\n string=s[i:]\n if string==t[0:len(string)]:\n ans=s[0:i]+string+t[len(string):]\n break\nelse:\n ans=s+t\nprint(ans)', 'n=int(input())\ns=input()\nt=input()\nans=""\nfor i in range(n):\n string=s[i:]\n if string==t[0:len(string)]:\n ans=s[0:i]+string+t[len(string):]\n break\nelse:\n ans=s+t\nprint(len(ans))'] | ['Wrong Answer', 'Accepted'] | ['s090597212', 's371074915'] | [3060.0, 3060.0] | [17.0, 18.0] | [195, 200] |
p03951 | u620868411 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\n\nif s==t:\n print(n)\n exit()\n\nfor i in range(n):\n print(s[i:],t[:-i])\n if s[i:]==t[:-i]:\n print(2*n-(n-i))\n exit()\nprint(2*n)\n', 'n = int(input())\ns = input()\nt = input()\n\nif s==t:\n print(n)\n exit()\n\nfor i in range(n):\n if s[i:]==t[:-i]:\n print(2*n-(n-i))\n exit()\nprint(2*n)\n'] | ['Wrong Answer', 'Accepted'] | ['s685189539', 's054625255'] | [3060.0, 2940.0] | [17.0, 17.0] | [192, 168] |
p03951 | u623687794 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n,x=map(int,input().split())\nif x==1 or x==n:print("No")\nelse:\n print("Yes")\n b=[0]*n\n b[n//2]=x\n b[n//2-1]=x-1\n b[n//2+1]=x+1\n tor=[i+1 for i in range(n)]\n del tor[x-2:x+1]\n print(tor)\n for i in range(n):\n if b[i]==0:\n b[i]=tor.pop()\n for i in b:\n print(i)\n', 'n,x=map(int,input().split())\nif x==1 or x==2*n-1:print("No")\nelse:\n print("Yes")\n b=[0]*n\n b[n//2]=x\n b[n//2-1]=x-1\n b[n//2+1]=x+1\n tor=[i+1 for i in range(n)]\n del tor[x-2:x+1]\n for i in range(n):\n if b[i]==0:\n b[i]=tor.pop()\n for i in b:\n print(i)\n', 'N=int(input())\ns=input()\nt=input()\nfor i in range(1,N+1)[::-1]:\n if s[N-i:]==t[:i]:\n print(2*N-i)\n exit()\nprint(2*N)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s139094928', 's937296848', 's982282198'] | [3064.0, 3064.0, 2940.0] | [18.0, 18.0, 17.0] | [279, 270, 123] |
p03951 | u625963200 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n=int(input())\ns=list(input())\nt=list(input())\n\nif s==t:\n print(n)\nelse:\n for i in range(1,n+1):\n ans=s+t[-i:]\n print(ans)\n if ans[:n]==s and ans[-n:]==t:\n print(len(ans))\n exit()', 'n=int(input())\ns=list(input())\nt=list(input())\n\nfor i in range(n+1):\n if s[i:]==t[:n-i]:\n print(n+i)\n exit()'] | ['Wrong Answer', 'Accepted'] | ['s745025701', 's799636124'] | [3060.0, 2940.0] | [18.0, 18.0] | [200, 115] |
p03951 | u680035567 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = input()\n\ns = input()\n\nt = input()\n\ntemp = 0\nflag = True\n\nwhile(temp < N-1 & flag):\n temps = s[N-temp-1:N-1]\n tempt = t[:temp]\n if(temps==tempt):\n temp += 1\n else:\n flag = False\n\nprint(N+N-temp)', 'N = int(input())\n\ns = input()\n\nt = input()\n\ntemp = N\nflag = True\nif s==t:\n print(N)\nelse:\n while(temp > 0 and flag):\n temps = s[N-temp:N]\n tempt = t[:temp]\n if(temps==tempt):\n flag = False\n else:\n temp -= 1\n\n print(N+N-temp)'] | ['Runtime Error', 'Accepted'] | ['s111096304', 's788754157'] | [3064.0, 3192.0] | [22.0, 22.0] | [223, 283] |
p03951 | u691018832 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn = int(readline())\ns = input()\nt = input()\nfor i in range(n):\n if s[i:] == t[:n - i]:\n print(n + i)\n exit()\n print(s[i:], t[:n - i])\nprint(n * 2)\n', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn = int(readline())\ns = input()\nt = input()\nfor i in range(n):\n if s[i:] == t[:n - i]:\n print(n + i)\n exit()\nprint(n * 2)\n'] | ['Wrong Answer', 'Accepted'] | ['s419535199', 's327399927'] | [3060.0, 3060.0] | [17.0, 18.0] | [315, 287] |
p03951 | u693933222 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\n\nsf = s[0:n]\ntf = t[-n:]\n\nfor i in range(len(sf)):\n if (sf[i] in tf):\n for j in range(0, len(sf) - i):\n if (sf[i + j] != tf[j]):\n break\n else:\n print(tf)\n break\n\n else:\n print(sf[i],end="")\nelse:\n print(tf)\n#print("")', 'n = int(input())\ns = input()\nt = input()\n\nsf = s[0:n]\ntf = t[-n:]\n\nfor i in range(len(sf)):\n if (sf[i] in tf):\n for j in range(0, len(sf) - i):\n if (sf[i + j] != tf[j]):\n break\n else:\n print(tf)\n\n else:\n print(sf[i],end="")\nelse:\n print(tf)\n#print("")', 'n = int(input())\ns = input()\nt = input()\n\nsf = s[0:n]\ntf = t[-n:]\n\nans = []\n\nfor i in range(len(sf)):\n if (sf[i] in tf):\n for j in range(0, len(sf) - i):\n if (sf[i + j] != tf[j]):\n break\n else:\n ans.append(tf)\n #print(tf)\n break\n\n else:\n ans.append(sf[i])\n# print(sf[i],end="")\nelse:\n ans.append(tf)\n #print(tf)\nprint(len(ans))\n', 'n = int(input())\ns = input()\nt = input()\n\n\nans = []\n\nfor i in range(n):\n if (s[i] == t[0]):\n for j in range(0, n - i):\n if (s[i + j] != t[j]):\n break\n else:\n ans+=t\n #print(t)\n break\n\n #else:\n ans.append(s[i])\n# print(s[i],end="")\nelse:\n ans+=t\n #print(t)\n#print(ans)\nprint(len(ans))\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s198880814', 's413567140', 's946772976', 's815848488'] | [3064.0, 3064.0, 3064.0, 3060.0] | [17.0, 18.0, 17.0, 17.0] | [336, 318, 427, 379] |
p03951 | u697690147 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['if (n == len(s) and (s == t)):\n print(n)\nelse:\n ind = [0]\n for i in range(1, len(s)):\n if s[-i:] == t[:i]:\n ind.append(i)\n\n ind.reverse()\n for i in ind:\n if i == 0:\n print(2*n)\n else:\n res = s[0:-i] + t\n if len(res) >= n:\n print(len(res))\n break', 'n = int(input())\ns = input()\nt = input()\n\nif (n == len(s) and (s == t)):\n print(n)\nelse:\n ind = [0]\n for i in range(1, len(s)):\n if s[-i] == t[:i]:\n ind.append(i)\n\n ind.reverse()\n for i in ind:\n if i == 0:\n print(2*n)\n else:\n res = s[0:-i] + t\n if len(res) >= n:\n print(len(res))', 'n = int(input())\ns = input()\nt = input()\n\nif (n == len(s) and (s == t)):\n print(s)\nelse:\n ind = [0]\n for i in range(1, len(s)):\n if s[-i] == t[:i]:\n ind.append(i)\n\n ind.reverse()\n for i in ind:\n if i == 0:\n print(s+t)\n else:\n res = s[0:-i] + t\n if len(res) >= n:\n print(res)\n break', 'n = int(input())\ns = input()\nt = input()\n\nif (n == len(s) and (s == t)):\n print(n)\nelse:\n ind = [0]\n for i in range(1, len(s)):\n if s[-i:] == t[:i]:\n ind.append(i)\n\n ind.reverse()\n for i in ind:\n if i == 0:\n print(2*n)\n else:\n res = s[0:-i] + t\n if len(res) >= n:\n print(len(res))\n break'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s078914067', 's630465428', 's858981813', 's514700418'] | [8872.0, 9148.0, 9136.0, 9068.0] | [20.0, 26.0, 26.0, 31.0] | [355, 374, 391, 397] |
p03951 | u704165526 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N=int(input())\ns=input()\nt=input()\n\na=0\nb=-N\nc=0\n\nif int(len(s))==1 and int(len(t))==1:\n print(len(s)+len(t))\n\nelif s==t:\n print(N)\n\nelif s[0]==t[-N]:\n while s[a]==s[b]:\n c+=1\n a+=1\n b+=1\n print(c)\n if N==c:\n break\n\n print(s[0:N-c-1]+t)\n\nelse:\n print(s+t)', 'N=int(input())\ns=input()\nt=input()\n\na=N-1\nb=-N\nc=0\n\nif int(len(s))==1 and int(len(t))==1:\n print(len(s)+len(t))\n\nelif s==t:\n print(N)\n\nelif s[a]==t[b]:\n while s[a]==s[b]:\n c+=1\n a+=1\n b+=1\n if N==c:\n break\n\n print(s[0:N-c-1]+t)\n\nelse:\n print(s+t)', 'N=int(input())\ns=input()\nt=input()\n\na=-1\nb=0\nc=0\n\nif int(len(s))==1 and int(len(t))==1:\n print(len(s)+len(t))\n\nelif s==t:\n print(N)\n\nelif s[a]==t[b]:\n while s[a]==t[b]:\n c+=1\n a+=1\n b+=1\n print("c:"+str(c))\n if N==c:\n break\n\n print(len(s[0:N-c-1])+len(t))\n\nelse:\n print(len(s)+len(t))', 'N=int(input())\ns=input()\nt=input()\n\nif int(len(s))==1 and int(len(t))==1:\n print(s+t)\nelif s[N-1]==t[0]:\n print(s[0:N-1]+t[0:N])\nelif s==t:\n print(s)', 'N=int(input())\ns=input()\nt=input()\n\na=0\nb=0\n\nfor i in range(N):\n if s[i]==t[a]:\n a+=1\n b+=1\n\nprint(len(s[0:N-b])+len(t))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s214775212', 's446461014', 's505876461', 's940852864', 's784130624'] | [3064.0, 3188.0, 3192.0, 3064.0, 3064.0] | [22.0, 25.0, 23.0, 23.0, 22.0] | [321, 305, 350, 158, 137] |
p03951 | u729133443 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['I=input;n=int(I());s,t=I(),I();print(2*n-max(i*(s[-i:]==t[i:])for i in range(n+1)))', 'n,s,t=open(0);n=int(n);print(2*n-max(i*(s[-i:-1]==t[:i])for i in range(n+1)))', 'I=input;n=int(I());s,t=I(),I();print(2*n-max(i*(s[-i:]==t[:i])for i in range(n+1)))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s012838360', 's993817390', 's585639241'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [83, 77, 83] |
p03951 | u740284863 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = str(input())\nt = str(input())\nS = s[::-1]\nif s == t and len(s) == n:\n print(s)\nelse:\n i = 0\n while len(s+t) >= n :\n \n if S[i] == t[i]:\n i += 1\n else:\n break\n s = s[0:len(s)-i]\n print(s+t)\n', 'n = int(input())\ns = str(input())\nt = str(input())\nI = []\nfor i in range(len(s)+1):\n if s[len(s)-i:len(s)] == t[0:i]:\n I.append(i)\ns = s[0:len(s)-max(I)]\nprint(len(s+t))'] | ['Wrong Answer', 'Accepted'] | ['s204053484', 's716988521'] | [3060.0, 3064.0] | [17.0, 17.0] | [267, 179] |
p03951 | u741397536 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\n\ncount = 0\nfor i in range(len(s)):\n if t[i] == s[-i-1]:\n count += 1\n else:\n break\n\nif s = t:\n print(len(s))\nelse:\n print(len(s)+len(t)-count)', 'N = int(input())\ns = input()\nt = input()\n\ncount = 0\nfor i in range(len(s)):\n if t[:i+1] in s[-i-1:]:\n count = i+1\n else:\n pass\n\nprint(len(s)+len(t)-count)'] | ['Runtime Error', 'Accepted'] | ['s508306252', 's004360957'] | [2940.0, 2940.0] | [17.0, 17.0] | [208, 174] |
p03951 | u749770850 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\ng = s[::-1]\nt = input()\n\nif s == t:\n print(s)\n exit()\n\nfor i in range(n):\n if g[i] != t[i]:\n print(s + t[i:])\n exit()', 'n = int(input())\ns = input()\nt = input()\n\nfor i in range(n):\n if s[i:] == t[:n-i]:\n print(n + i)\n exit()\n\nprint(n * 2)\n '] | ['Wrong Answer', 'Accepted'] | ['s116776644', 's598894687'] | [3060.0, 2940.0] | [17.0, 17.0] | [156, 130] |
p03951 | u760794812 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\n\nAnswer = s + t\nif s != t:\n for i in range(N):\n if s[-i-1:] == t[:i+1]:\n Answer = s[:-i-1]+t[i:]\nelse:\n Answer = s\nprint(Answer)', 'N = int(input())\ns = input()\nt = input()\nAnswer = s + t\nfor i in range(N):\n if s[-i-1:] == t[:i+1]:\n Answer = s + t[i+1:]\nprint(len(Answer))'] | ['Wrong Answer', 'Accepted'] | ['s870585557', 's745222993'] | [3060.0, 2940.0] | [17.0, 17.0] | [179, 144] |
p03951 | u765237551 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N, x = map(int, input().split())\nif x==1 or x==2*N-1:\n print(\'No\')\nelse:\n print(\'Yes\')\n if x <= 2*N:\n y = list(i for i in range(2, 2*N-2) if i!=x)\n l = len(y)//2\n print("\\n".join(map(str, y[:l] + [2*N-1, x, 1, 2*N-2] + y[l:])))\n else:\n y = list(i for i in range(3, 2*N-1) if i!=x)\n l = len(y)//2\n print("\\n".join(map(str, y[:l] + [2*N-1, 1, x, 2] + y[l:])))', 'n = int(input())\ns = input()\nt = input()\n\nM = 0\nfor i in range(1, n+1):\n if s[-i:] == t[:i]:\n M = i\nprint(n*2 - M)'] | ['Runtime Error', 'Accepted'] | ['s236923514', 's052453696'] | [3064.0, 3064.0] | [23.0, 22.0] | [411, 124] |
p03951 | u794173881 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\n\nfor i in range(n):\n if s[i:]==t[:n-i]:\n print(n-i)\n exit()\n\n\n', 'n = int(input())\ns = input()\nt = input()\n\nfor i in range(n):\n if s[i:]==t[:n-i]:\n print(n+i)\n exit()\n\nprint(2*n)\n'] | ['Wrong Answer', 'Accepted'] | ['s638310890', 's289484328'] | [2940.0, 2940.0] | [18.0, 18.0] | [110, 120] |
p03951 | u799443198 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\nans = 2 * N\nfor i in range(N+1):\n st = s+t[i:]\n print(st)\n if st[:N] == s and st[-N:] == t:\n ans = min(ans, len(st))\nprint(ans)\n', 'N = int(input())\ns = input()\nt = input()\nans = 2 * N\nfor i in range(N+1):\n st = s+t[i:]\n if st[:N] == s and st[-N:] == t:\n ans = min(ans, len(st))\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s331728406', 's657282709'] | [3060.0, 2940.0] | [17.0, 17.0] | [175, 163] |
p03951 | u802772880 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n=int(input())\ns=input()\nt=input()\nls=len(s)\nlt=len(t)\nans=s+t\nfor i in range(n):\n if s[i:]==t[:ls-i]:\n ans=s+t[ls-i:]\n break\nprint(ans)', 'n=int(input())\ns=input()\nt=input()\nls=len(s)\nlt=len(t)\nans=s+t\nfor i in range(n):\n if s[i:]==t[:ls-i]:\n ans=s+t[ls-i:]\n break\nprint(len(ans))'] | ['Wrong Answer', 'Accepted'] | ['s144999464', 's519569540'] | [3060.0, 3060.0] | [17.0, 20.0] | [153, 158] |
p03951 | u811000506 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = str(input())\nt = str(input())\n\nif s==t:\n print(s)\n exit()\n\nfor i in range(1,N+1):\n ans = s + t[-i:]\n if ans[-N:] == t:\n break\nprint(ans)', 'N = int(input())\ns = str(input())\nt = str(input())\n\nif s==t:\n print(len(s))\n exit()\n\nfor i in range(1,N+1):\n ans = s + t[-i:]\n if ans[-N:] == t:\n break\nprint(len(ans))'] | ['Wrong Answer', 'Accepted'] | ['s934490153', 's812193834'] | [9200.0, 9180.0] | [26.0, 28.0] | [176, 186] |
p03951 | u812973725 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\n\ns = input()\nt = input()\n\nfor i in range(N):\n if s[i:] == t[:N-i]:\n print(s[:i]+t)\n break\n if i == N-1:\n print(s+t)\n', 'N = int(input())\n\ns = input()\nt = input()\n\nans = ""\nfor i in range(N):\n if s[i:] == t[:N-i]:\n ans = s[:i]+t\n break\n if i == N-1:\n ans = s+t\n\nprint(len(ans))'] | ['Wrong Answer', 'Accepted'] | ['s782350711', 's974157274'] | [2940.0, 3064.0] | [17.0, 18.0] | [160, 183] |
p03951 | u820351940 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N, K = map(int, input().split())\nm = 2 * N - 1\n\nif 2 <= K < m:\n mid = list((3, 2, 1) if K == 2 else (K - 1, K, K + 1, K - 2))\n a = list(set(range(1, m + 1)) - set(mid))\n print("Yes\\n" + "\\n".join(map(str, a[:m//2 - 1] + mid + a[m//2 - 1:])))\nelse:\n print("No")\n', 'N, K = map(int, input().split())\nprint("No" if K < N else "Yes\\n" + "\\n".join(map(str, range(1, K * 2))))', 'N = int(input())\na, b = input(), input()\n\nresult = 0\nfor i in range(N):\n if b.startswith(a[i:]):\n break\n result += 1\nprint(result + N)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s206051932', 's352254448', 's367411764'] | [3064.0, 3064.0, 3064.0] | [23.0, 22.0, 22.0] | [273, 105, 148] |
p03951 | u830054172 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n=int(input())\ns=input()\nt=input()\nc=0\nfor i in range(n):\n print(s[-i-1:])\n print(t[:i+1])\n if s[-i-1:]==t[:i+1]:\n c=i+1\nprint(n*2-c)\n', 'n=int(input())\ns=input()\nt=input()\nc=0\nfor i in range(n):\n # print(s[-i-1:])\n # print(t[:i+1])\n if s[-i-1:]==t[:i+1]:\n c=i+1\nprint(n*2-c)\n'] | ['Wrong Answer', 'Accepted'] | ['s419830791', 's806670832'] | [3060.0, 2940.0] | [17.0, 17.0] | [150, 154] |
p03951 | u834311314 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\nfor i in range(N):\n if s[N - 1 - i:N] == t[0:i + 1]:\n t = t[i + 1:N]\nprint(s + t)', 'N = int(input())\ns = input()\nt = input()\nu = t\nfor i in range(N):\n if s[N - 1 - i:N] == t[0:i + 1]:\n u = t[i + 1:N]\nprint(s + u)\nprint (len(s + u))', 'N = int(input())\ns = input()\nt = input()\nu = 0\nfor i in range(N):\n if s[-i - 1:] == t[:i + 1]:\n u = i + 1\nprint (N * 2 - u)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s482478377', 's735222441', 's536454699'] | [3064.0, 3064.0, 3064.0] | [23.0, 23.0, 24.0] | [132, 157, 133] |
p03951 | u835482198 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\nprefix = input()\nsuffix = input()\n\n\nif len(prefix) + len(suffix) < N:\n d = N - len(prefix) + len(suffix)\n print(prefix + \'a\' * d + suffix)\nelse:\n s = ""\n for i in range(1, N):\n \n if prefix[-i:] == suffix[:i]:\n s = prefix[:-i] + suffix\n if suffix == prefix:\n s = suffix\n if len(s) == 0:\n s = prefix + suffix\n print(s)\n', 'N = int(input())\nprefix = input()\nsuffix = input()\n\n\nif len(prefix) + len(suffix) < N:\n d = N - len(prefix) + len(suffix)\n print(len(prefix + \'a\' * d + suffix))\nelse:\n s = ""\n for i in range(1, N):\n \n if prefix[-i:] == suffix[:i]:\n s = prefix[:-i] + suffix\n if suffix == prefix:\n s = suffix\n if len(s) == 0:\n s = prefix + suffix\n print(len(s))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s249088166', 's726190272'] | [3060.0, 3060.0] | [17.0, 17.0] | [426, 437] |
p03951 | u841021102 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\nanswer = n\nfor i in range (n + 1) :\n if answer == n :\n newstring = s[0:i] + t[:n]\n \tif newstring[0:n] == s :\n \tanswer += i\nprint (answer)\n', 'n = int(input())\ns = input()\nt = input()\ns1 = []\nt1 = []\nfor i in range(0 , len(s)):\n s1.append(s[i])\nfor i in range(0 , len(t)):\n t1.append(t[i])\na = set(s1 + t1)\nif len(s1) == n:\n\tprint(len(a))\nprint(a)', 'n = input()\ns = list(input().split())\nt = list(input().split())\na = set(s + t)\nprint(len(a))', 's = input()\nt = input()\ns1 = []\nt1 = []\nfor i in range(0 , n):\n s1.append(s[i])\nfor i in range(0 , n):\n t1.append(t[i])\na = set(s1 + t1)\nprint(len(a))', 'n = int(input())\ns = input()\nt = input()\ns1 = []\nt1 = []\nfor i in range(0 , len(s)):\n s1.append(s[i])\nfor i in range(0 , len(t)):\n t1.append(t[i])\na = set(s1 + t1)\nif len(s1) == n:\n\tprint(len(a))\nprint(a)', 'n = int(input())\ns = input()\nt = input()\nanswer = n\nfor i in range (n + 1) :\n if answer == n :\n \tnewstring = s[0:i] + t[:n]\n \tif newstring[0:n] == s :\n \tanswer += i\nprint (answer)', 'n = int(input())\ns = input()\nt = input()\nanswer = n\nfor i in range (n + 1) :\n newstring = s[0:i] + t[:n]\n if newstring[0:n] == s:\n answer += i\n break\nprint (answer)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s256155000', 's257958120', 's638851779', 's663098902', 's882061364', 's913441679', 's309255390'] | [8964.0, 9040.0, 9060.0, 9020.0, 9120.0, 8892.0, 8992.0] | [27.0, 28.0, 34.0, 24.0, 27.0, 26.0, 29.0] | [187, 206, 92, 152, 206, 185, 172] |
p03951 | u844789719 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\nS = input()\nT = input()\nfor x in range(N, 2 * N + 1):\n if S[x - N:] == T[:2 * N - x]:\n print(S + T[2 * N - x:])\n exit()\n', 'N = int(input())\nS = input()\nT = input()\nfor x in range(N, 2 * N + 1):\n if S[x - N:] == T[:2 * N - x]:\n print(x)\n exit()\n'] | ['Wrong Answer', 'Accepted'] | ['s765029398', 's931309129'] | [2940.0, 2940.0] | [19.0, 18.0] | [154, 138] |
p03951 | u846226907 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\n\ns = input()\nt = input()\n\ni = 0\n\nwhile i < N:\n if s[i:] == t[:N-1]:\n break\n else:\n i+=1\n\nprint(N+i)', 'N = int(input())\n\ns = input()\nt = input()\n\ni = 0\n\nwhile i < N:\n if s[i:] == t[:N-i]:\n break\n else:\n i+=1\n\nprint(N+i)'] | ['Wrong Answer', 'Accepted'] | ['s085701284', 's254718624'] | [2940.0, 3064.0] | [18.0, 18.0] | [136, 136] |
p03951 | u846552659 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['# -*- coding:utf-8 -*-\nN = int(input())\ns = input()\nt = input()\nindex = N\na = -1\nfor tmp in range(1,len(t)+1):\n if s[index-1:len(s)] == t[0:tmp]:\n a = index-1\n index -= 1\nif a == -1:\n print(s+t)\nelse:\n for tmp in range(len(s)-a, len(t)):\n s = s+t[tmp]\n print(s)', '# -*- coding:utf-8 -*-\nN = int(input())\ns = input()\nt = input()\nindex = N\na = -1\nfor tmp in range(1,len(t)+1):\n if s[index-1:len(s)] == t[0:tmp]:\n a = index-1\n index -= 1\nif a == -1:\n print(len(s+t))\nelse:\n for tmp in range(len(s)-a, len(t)):\n s = s+t[tmp]\n print(len(s))'] | ['Wrong Answer', 'Accepted'] | ['s774129717', 's212083668'] | [3064.0, 3064.0] | [17.0, 17.0] | [290, 300] |
p03951 | u856232850 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\na = input()\nb = input()\ncount = 0\nfor i in range(n+1):\n if a[-i:] == a[:i]:\n count = i\nprint(2*n-count)', 'n = int(input())\na = input()\nb = input()\ncount = 0\nfor i in range(n+1):\n if a[-i:] == b[:i]:\n count = i\nprint(2*n-count)'] | ['Wrong Answer', 'Accepted'] | ['s769484454', 's995532457'] | [2940.0, 2940.0] | [17.0, 17.0] | [130, 130] |
p03951 | u859897687 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n=int(input())\na=input()\nb=input()\nc=0\nfor i in range(1,n):\n if a[-i:]==b[i:]:\n c+=1\n else:\n break\nprint(2*n-c)', 'a=input()\nb=input()\nc=0\nfor i in range(min(len(a),len(b))):\n if a[len(a)-1-i]==b[i]:\n c+=1\n else:\n break\nprint(len(a+b[c:]))', 'n=int(input())\na=input()\nb=input()\nc=0\nfor i in range(1,n):\n if a[-i:]==b[i:]:\n c=i\nprint(2*n-c)', 'a=input()\nb=input()\nc=0\nfor i in range(min(len(a),len(b))):\n if a[len(a)-1-i]==b[i]:\n c+=1\n else:\n break\nprint(a+b[c:])', 'n=int(input())\na=input()\nb=input()\nc=0\nfor i in range(1,n):\n if a[-i:]==b[i:]:\n c+=1\nprint(2*n-c)', 'n=int(input())\na=input()\nb=input()\nc=0\nfor i in range(1,n):\n if a[-1*i:]==b[:i]:\n c=i\nif a==b:\n c=n\nprint(2*n-c)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s092182550', 's376692047', 's488136399', 's884188681', 's950333314', 's943986690'] | [3060.0, 2940.0, 3060.0, 2940.0, 2940.0, 2940.0] | [17.0, 19.0, 17.0, 17.0, 17.0, 18.0] | [119, 132, 100, 127, 101, 117] |
p03951 | u867826040 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\nif s==t:\n print(n)\nelse:\n print(n+n)', 'n = int(input())\ns = input()\nt = input()\nx = 0\nfor i in range(n):\n if s[n-i-1:]==t[:i+1]:\n x = i+1\nprint((n*2)-x)'] | ['Wrong Answer', 'Accepted'] | ['s703746494', 's126054604'] | [2940.0, 3060.0] | [17.0, 17.0] | [83, 123] |
p03951 | u893063840 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\n\nfor i in range(n, -1, -1):\n ans = [""] * (n + n - i)\n ans[:n] = list(s)\n ans[-n:] = list(t)\n if ans[:n] == list(s):\n break\n\nprint(*ans, sep="")\n', 'n = int(input())\ns = input()\nt = input()\n\nfor i in range(n, -1, -1):\n ans = [""] * (2 * n - i)\n ans[:n] = list(s)\n ans[-n:] = list(t)\n if ans[:n] == list(s):\n break\n\nprint(2 * n - i)\n'] | ['Wrong Answer', 'Accepted'] | ['s335543778', 's310677378'] | [3316.0, 2940.0] | [19.0, 18.0] | [205, 202] |
p03951 | u905582793 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n=int(input())\ns=input()\nt=input()\nif s==t:\n print(n)\n exit()\nfor i in range(1,n-1):\n if s[i+1:] == t[:-i-1]:\n print(n+i)\n break', 'n=int(input())\ns=input()\nt=input()\nif s==t:\n print(n)\n exit()\nfor i in range(n):\n if s[i+1:] == t[:-i-1]:\n print(n+i+1)\n break'] | ['Wrong Answer', 'Accepted'] | ['s725238945', 's682810563'] | [2940.0, 3064.0] | [17.0, 17.0] | [137, 135] |
p03951 | u932465688 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\nk = 0\nfor i in range(N):\n if s[i:N] == t[0:N-i]:\n k = i\nif k != 0:\n print(s+t[N-k:N])\nelse:\n print(s+t)', 'N = int(input())\ns = input()\nt = input()\nk = -1\nfor i in range(N):\n if s[i:N] == t[0:N-i]:\n k = i\n break\nif k != -1:\n print(len(s+t[N-k:N]))\nelse:\n print(len(s+t))'] | ['Wrong Answer', 'Accepted'] | ['s685584969', 's390217605'] | [3060.0, 3060.0] | [18.0, 17.0] | [150, 172] |
p03951 | u936985471 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N=int(input())\ns=input()\nt=input()\nfor i in range(len(s),-1,-1):\n if s[-i:]==t[:i]:\n break\nprint(s+t[i:])', 'import sys\nreadline = sys.stdin.readline\n\nN = int(readline())\nS = readline().rstrip()\nT = readline().rstrip()\n\nfor i in range(N, -1, -1):\n# print("i",i)\n# print(S[-i:],T[:i])\n if S[-i:] == T[:i]:\n print(N * 2 - i)\n break\nelse:\n print(N * 2)'] | ['Wrong Answer', 'Accepted'] | ['s640586365', 's428550115'] | [2940.0, 3060.0] | [17.0, 17.0] | [109, 250] |
p03951 | u940102677 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\nfor k in range(0,n+1):\n if s[k:] == t[:n-k]:\n print(s+t[n-k:])\n break', 'n = int(input())\ns = input()\nt = input()\nfor k in range(0,n+1):\n if s[k:] == t[:n-k]:\n print(n+k)\n break'] | ['Wrong Answer', 'Accepted'] | ['s702423496', 's827682542'] | [2940.0, 2940.0] | [17.0, 17.0] | [117, 111] |
p03951 | u941753895 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ["n=int(input())\ns=input()\nt=input()\nif s=='abc' and t=='cde':\n exit()\na=0\nfor i in range(1,n+1):\n if s[n-i:]==t[:i]:\n a=i\nprint(2*n-a)", 'n=int(input())\ns=input()\nt=input()\na=0\nfor i in range(1,n+1):\n if s[n-i:]==t[:i]:\n a=i\nprint(2*n-a)'] | ['Wrong Answer', 'Accepted'] | ['s264316386', 's603551526'] | [3060.0, 2940.0] | [17.0, 17.0] | [138, 103] |
p03951 | u941884460 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input().rstrip()\nt = input().rstrip()\ntotal = 0\nfor i in range(n):\n if s[n-1-i:] == t[:i+1]:\n total = i\nif total ==0:\n print(2*n)\nelse:\n print(2*n-(total+1))', 'n = int(input())\ns = input().rstrip()\nt = input().rstrip()\ntotal = 0\nif s == t:\n print(n)\nelse:\n for i in range(n):\n if s[n-1-i] == t[i]:\n total += 1\n else:\n break\n print(2*(n-total))', 'n = int(input())\ns = input().rstrip()\nt = input().rstrip()\ntotal = 0\nfor i in range(n):\n if s[n-1-i:] == t[:i+1]:\n total = i+1\nprint(2*n-(total))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s285229881', 's593699193', 's567702721'] | [3060.0, 3060.0, 2940.0] | [17.0, 17.0, 17.0] | [184, 202, 149] |
p03951 | u950708010 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n = int(input())\ns = input()\nt = input()\nn = len(t)\nans = s\nfor i in range(n,-1,-1):\n if t[0:i] in s:\n print (s+t[i::])\n exit()\nprint(s+t)', 'n = int(input())\ns = input()\nt = input()\nn = len(t)\nans = s\nfor i in range(n,-1,-1):\n if t[0:i] in s:\n print (s+t[i::])\n exit()\nprint(len(s+t))', 'n = int(input())\ns = input()\nt = input()\nn = len(t)\nans = s\nfor i in range(n,-1,-1):\n if t[0:i] in s:\n print (len(s+t[i::]))\n exit()\nprint(len(s+t))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s262448323', 's917221251', 's571067612'] | [3060.0, 3060.0, 3064.0] | [17.0, 17.0, 17.0] | [145, 150, 155] |
p03951 | u957872856 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\nw = s+t\ncnt = 0\nfor i in range(len(s)):\n if s[-i-1] == t[i]:\n cnt += 1\nwhile len(w) > N and cnt > 0:\n t = t[1:]\n w = s + t\n cnt -= 1\nprint(w)', 'N = int(input())\ns = input()\nt = input()\nw = s+t\ncnt = 0\nif s == t and N <= len(s):\n print(len(s))\n exit()\nelif s == t and N > len(s):\n print(len(s+t))\n exit()\ncnt1 = 0\nfor i in range(len(s)):\n if s[-i-1:] == t[:i+1]:\n cnt = i+1\nwhile len(w) > N and cnt > 0:\n t = t[1:]\n w = s + t\n cnt -= 1\nprint(len(w))'] | ['Wrong Answer', 'Accepted'] | ['s712260542', 's457851873'] | [3060.0, 3064.0] | [17.0, 17.0] | [189, 315] |
p03951 | u966695411 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\nS = input()\nT = input()\nif S == T:\n print(N)\nelse:\n c = 0\n for i in range(N):\n if S[i] != T[-i-1]:\n c = i\n break\n print(N * 2 - c + 2)', 'N = int(input())\nS = input()\nT = input()\nif S == T:\n print(N)\nelse:\n c = 0\n for i in range(N):\n if S[i] != T[-i-1]:\n c = i\n break\n print(N * 2 - c - 2)', 'N = int(input())\nS = input()\nT = input()\nc = 0\nfor i in range(N):\n if S[-i-1:] == T[:i+1]:\n c = i + 1\nprint(N * 2 - c)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s119379189', 's978615803', 's361894795'] | [3064.0, 3064.0, 3064.0] | [26.0, 22.0, 22.0] | [192, 192, 128] |
p03951 | u970809473 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['n=int(input())\ns=input()\nt=input()\nans=0\nfor i in range(n):\n if s[i:] == t[:n-i]:\n ans = n-i\nif ans == 0:\n print(s+t)\nelse:\n print(s[:-ans]+t)', 'n=int(input())\ns=input()\nt=input()\nans=0\nfor i in range(n):\n print(i,s[i:],t[:n-i])\n if s[i:] == t[:n-i]:\n ans = max(n-i,ans)\nprint(2*n-ans)', 'n=int(input())\ns=input()\nt=input()\nans=0\nfor i in range(n):\n if s[i:] == t[:n-i]:\n ans = max(n-i,ans)\nprint(2*n-ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s299114520', 's959961550', 's534575082'] | [3060.0, 3060.0, 2940.0] | [17.0, 17.0, 18.0] | [148, 145, 120] |
p03951 | u977193988 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['import sys\nn=int(input())\ns=input()\nt=input()\ncnt=0\nfor i in range(n):\n if s[i:]==t[:n-i]:\n print(s+t[n-i:])\n sys.exit()\nprint(s+t)', 'import sys\nn=int(input())\ns=input()\nt=input()\ncnt=0\nfor i in range(n):\n if s[i:]==t[:n-i]:\n print(len(s+t[n-i:]))\n sys.exit()\nprint(len(s+t))'] | ['Wrong Answer', 'Accepted'] | ['s225592730', 's353722661'] | [3060.0, 3060.0] | [17.0, 17.0] | [148, 158] |
p03951 | u981931040 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\nidx = 0\nfor i in range(N):\n tmp_s = s[N - i - 1:]\n tmp_t = t[:i + 1]\n if tmp_s == tmp_t:\n idx = i + 1\n\nprint(s + t[idx:])', 'N = int(input())\ns = input()\nt = input()\nans = s\nfor i in range(N + 1):\n tmp_ans = s + t[i:]\n # print(tmp_ans)\n if tmp_ans[:N] == s and tmp_ans[-N:] == t:\n ans = tmp_ans\nprint(len(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s750924501', 's704756506'] | [9176.0, 9156.0] | [28.0, 26.0] | [178, 202] |
p03951 | u987164499 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['from sys import stdin\nn = int(stdin.readline().rstrip())\ns = stdin.readline().rstrip()\nt = stdin.readline().rstrip()\npoint = 0\nfor i,j in zip(s,t):\n if i == j:\n point += 1\n else:\n break\nprint(n*2-point)', 'n = int(input())\ns = input()\nt = input()\n\nfor i in range(len(s)):\n if s[i:] == t[:n-i]:\n print(n+i)\n exit()\n\nprint(n*2)'] | ['Wrong Answer', 'Accepted'] | ['s835905693', 's648795235'] | [2940.0, 2940.0] | [17.0, 17.0] | [222, 136] |
p03951 | u995062424 | 2,000 | 262,144 | Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. | ['N = int(input())\ns = input()\nt = input()\nans = s + t\n\nfor i in range(N):\n if(s[i:] == t[:(len(t)-i)]):\n ans = s + t[-i:]\n\nprint(ans if s != t else s)', 'N = int(input())\ns = input()\nt = input()\nans = s + t\n\nfor i in range(N):\n if(s[i:] == t[:(len(t)-i)]):\n ans = s + t[-i:]\n\nprint(len(ans) if s != t else N)'] | ['Wrong Answer', 'Accepted'] | ['s524979788', 's868399221'] | [3060.0, 3060.0] | [17.0, 17.0] | [159, 164] |
p03955 | u270681687 | 2,000 | 262,144 | We have a grid with 3 rows and N columns. The cell at the i-th row and j-th column is denoted (i, j). Initially, each cell (i, j) contains the integer i+3j-3. A grid with N=5 columns Snuke can perform the following operation any number of times: * Choose a 3×3 subrectangle of the grid. The placement of integers within the subrectangle is now rotated by 180°. An example sequence of operations (each chosen subrectangle is colored blue) Snuke's objective is to manipulate the grid so that each cell (i, j) contains the integer a_{i,j}. Determine whether it is achievable. | ['import sys\ninput = sys.stdin.readline\n\nn = int(input())\na = [list(map(int, input().split())) for _ in range(3)]\n\nfor j in range(n):\n if not ((a[0][j] - 1 == a[1][j] and a[2][j] + 1 == a[1][j]) or (a[0][j] + 1 == a[1][j] and a[2][j] - 1 == a[1][j])):\n print("No")\n exit()\n\nfor j in range(n):\n if (j % 2) * (((a[0][j] - 1) // 3) % 2) == 1:\n print("No")\n exit()\n\n# BIT\ndef add(a, w, bit):\n x = a\n while x <= n:\n bit[x] += w\n x += x & -x\n\ndef solve(a, bit):\n ret = 0\n x = a\n while x > 0:\n ret += bit[x]\n x -= x & -x\n return ret\n\nbit_odd = [0] * (3*n+1)\ninv_odd = 0\nflip_even = 0\nfor j in range(n):\n if j % 2 == 1:\n if a[0][j] > a[1][j]:\n flip_even += 1\n else:\n inv_odd += j - solve(a[0][j], bit_odd)\n add(a[0][j], 1, bit_odd)\nif flip_even % 2 != inv_odd % 2:\n print("No")\n exit()\n\n\nbit_even = [0] * (3*n+1)\ninv_even = 0\nflip_odd = 0\nfor j in range(n):\n if j % 2 == 0:\n if a[0][j] > a[1][j]:\n flip_odd += 1\n else:\n inv_even += j - solve(a[0][j], bit_even)\n add(a[0][j], 1, bit_even)\nif flip_odd % 2 != inv_even % 2:\n print("No")\n exit()\n\nprint("Yes")\n', 'import sys\ninput = sys.stdin.readline\n\nn = int(input())\na = [list(map(int, input().split())) for _ in range(3)]\n\nfor j in range(n):\n if not ((a[0][j] - 1 == a[1][j] and a[2][j] + 1 == a[1][j]) or (a[0][j] + 1 == a[1][j] and a[2][j] - 1 == a[1][j])):\n print("No")\n exit()\n\nfor j in range(n):\n if (j % 2) ^ (((a[0][j] - 1) // 3) % 2) == 1:\n print("No")\n exit()\n\n# BIT\ndef add(a, w, bit):\n x = a\n while x <= 3 * n:\n bit[x] += w\n x += x & -x\n\ndef solve(a, bit):\n ret = 0\n x = a\n while x > 0:\n ret += bit[x]\n x -= x & -x\n return ret\n\nbit_odd = [0] * (3*n+1)\ninv_odd = 0\nflip_even = 0\nfor j in range(n):\n if j % 2 == 1:\n if a[0][j] > a[1][j]:\n flip_even += 1\n else:\n inv_odd += j//2 - solve(a[0][j], bit_odd)\n add(a[0][j], 1, bit_odd)\nif flip_even % 2 != inv_odd % 2:\n print("No")\n exit()\n\n\nbit_even = [0] * (3*n+1)\ninv_even = 0\nflip_odd = 0\nfor j in range(n):\n if j % 2 == 0:\n if a[0][j] > a[1][j]:\n flip_odd += 1\n else:\n inv_even += j//2 - solve(a[0][j], bit_even)\n add(a[0][j], 1, bit_even)\nif flip_odd % 2 != inv_even % 2:\n print("No")\n exit()\n\nprint("Yes")\n'] | ['Wrong Answer', 'Accepted'] | ['s100465489', 's519496519'] | [22496.0, 23132.0] | [144.0, 739.0] | [1214, 1224] |
p03966 | u010090035 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\nN = int(input())\nx=0\nt=0\nn=0\npre_t=0\npre_n=0\nfor i in range(N):\n t,n = map(int,input().split())\n mul = max(math.ceil(pre_t/t),math.ceil(pre_n/n))\n t *= mul\n n *= mul\n pre_t = t\n pre_n = n\n x = t+n\nprint(x)', 'import math\nN = int(input())\nx=0\nt=0\nn=0\npre_t=1\npre_n=1\nfor i in range(N):\n t,n = map(int,input().split())\n if(pre_t > t or pre_n > n):\n mul = max(-(-pre_t//t),-(-pre_n//n))\n t *= mul\n n *= mul\n pre_t = t\n pre_n = n\n x = t+n\nprint(x)'] | ['Wrong Answer', 'Accepted'] | ['s116047600', 's727858290'] | [3060.0, 3064.0] | [21.0, 21.0] | [238, 270] |
p03966 | u013756322 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N = int(input())\nT = [None] * N\nA = [None] * N\nfor i in range(N):\n T[i], A[i] = map(int, input().split())\n\nt, a = 1, 1\n\nfor i in range(N):\n if ( t < T[i] and a < A[i]):\n t, a = T[i], A[i]\n else:\n n = max(t // T[i], a // A[i])\n t, a = n * T[i], n * A[i]\n\nprint(t + a)', 'N = int(input())\nT = [None] * N\nA = [None] * N\nfor i in range(N):\n T[i], A[i] = map(int, input().split())\n\nt, a = T[0], A[0]\n\nfor i in range(1, N):\n if ( t < T[i] and a < A[i]):\n t, a = T[i], A[i]\n else:\n n = max(t // T[i], a // A[i])\n t, a = n * T[i], n * A[i]\n\nprint(t + a)', 'import math\nN = int(input())\nT = [None] * N\nA = [None] * N\nfor i in range(N):\n T[i], A[i] = map(int, input().split())\n\nt, a = T[0], A[0]\n\nfor i in range(1, N):\n if (t < T[i] and a < A[i]):\n t, a = T[i], A[i]\n else:\n n = max((t - 1) // T[i] + 1, (a - 1) // A[i] + 1)\n t, a = n * T[i], n * A[i]\n\nprint(t + a)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s580660264', 's608951040', 's390765205'] | [3064.0, 3064.0, 3064.0] | [21.0, 21.0, 21.0] | [278, 287, 318] |
p03966 | u076917070 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ["import sys\ninput=sys.stdin.readline\n\n\nimport math\ndef f(n, m):\n return int(m * math.ceil(n/m))\n\ndef main():\n N = int(input())\n T = A = 1\n for _ in range(N):\n t,a = map(int, input().split())\n k = max(f(T,t)//t, f(A,a)//a)\n T = k*t\n A = k*a\n print(T+A)\n\nif __name__ == '__main__':\n main()\n", "import sys\ninput=sys.stdin.readline\n\nimport math\n\ndef main():\n N = int(input())\n T = A = 1\n for _ in range(N):\n t,a = map(int, input().split())\n k = max(-(-T//t),-(-A//a))\n T = k*t\n A = k*a\n print(T+A)\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s118799991', 's022660845'] | [3188.0, 3060.0] | [21.0, 19.0] | [391, 281] |
p03966 | u095756391 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N = int(input())\nta = [list(map(int, input().split())) for i in range(N)]\n\nt = ta[0][0]\na = ta[0][1]\n\nfor i in range(N-1):\n if ta[i][0] <= ta[i+1][0] and ta[i][1] <= ta[i+1][1]:\n t = ta[i+1][0]\n a = ta[i+1][1]\n elif ta[i][0] > ta[i+1][0] and ta[i][1] < ta[i+1][1]:\n k = 1\n while t > ta[i+1][0]*k:\n k+= 1\n t = ta[i+1][0]*k\n a = ta[i+1][1]*k \n elif ta[i][0] < ta[i+1][0] and ta[i][1] > ta[i+1][1]:\n k = 1\n while a > ta[i+1][1]*k:\n k+= 1\n t = ta[i+1][0]*k\n a = ta[i+1][1]*k\n else:\n k = 1\n while t > ta[i+1][0]*k or a > ta[i+1][1]*k:\n k += 1\n t = ta[i+1][0]*k\n a = ta[i+1][1]*k\nprint(t+a)', 'N = int(input())\nta = [list(map(int, input().split())) for i in range(N)]\n\nt = ta[0][0]\na = ta[0][1]\n\nfor i in range(N-1):\n print(str(t)+ " " + str(a))\n k = 1\n while t > ta[i+1][0]*k or a > ta[i+1][1]*k:\n k += 1\n t = ta[i+1][0]*k\n a = ta[i+1][1]*k\nprint(t+a)', 'N = int(input())\nta = [list(map(int, input().split())) for i in range(N)]\n\nt = 1\na = 1\n\nfor i in range(N):\n k = max((t+ta[i][0]-1)//ta[i][0], (a+ta[i][1]-1)//ta[i][1])\n t = ta[i][0]*k\n a = ta[i][1]*k\n \nprint(t+a)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s698143700', 's808161675', 's078407429'] | [3188.0, 3316.0, 3188.0] | [2104.0, 2104.0, 22.0] | [651, 266, 217] |
p03966 | u107077660 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N = int(input())\nTA = []\nfor i in range(N):\n\tTA.append(list(map(int, input().split())))\n\nTA.reverse()\n(voteA, voteB) = TA.pop()\nwhile TA:\n\t(Ti, Ai) = TA.pop()\n\ttmp = max(int((voteA + Ti -1) / Ti), int((voteB + Ai -1) / Ai))\n\tvoteA = Ti * tmp\n\tvoteB = Ti * tmp\nprint(voteA + voteB)\n\n', 'N = int(input())\nTA = []\nfor i in range(N):\n\tTA.append(list(map(int, input().split())))\n \nTA.reverse()\n(voteA, voteB) = (1,1)\nwhile TA:\n\t(Ti, Ai) = TA.pop()\n\ttmp = max((voteA + Ti -1) // Ti, (voteB + Ai -1) // Ai)\n\tvoteA = Ti * tmp\n\tvoteB = Ai * tmp\nprint(voteA + voteB)'] | ['Wrong Answer', 'Accepted'] | ['s655268295', 's139954136'] | [3192.0, 3188.0] | [28.0, 27.0] | [282, 270] |
p03966 | u149752754 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N = int(input())\nTA = []\nAO = []\nfor i in range(N):\n T, A = map(int, input().split())\n TA += [T]\n AO += [A]\n\nfor i in range(N-1):\n D = ((TA[i]-1)//TA[i+1])+1\n E = ((AO[i]-1)//AO[i+1])+1\n F = max(D, E)\nans = int(TA[N-1] + AO[N-1])\nprint(ans)', 'N = int(input())\nTA = []\nAO = []\nfor i in range(N):\n T, A = map(int, input().split())\n TA += [T]\n AO += [A]\n\nfor i in range(N-1):\n D = ((TA[i]-1)//TA[i+1])+1\n E = ((AO[i]-1)//AO[i+1])+1\n F = max(D, E)\n TA[i+1] *= F\n AO[i+1] *= F\nans = int(TA[N-1] + AO[N-1])\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s487443146', 's306640920'] | [3064.0, 3064.0] | [21.0, 21.0] | [258, 292] |
p03966 | u163783894 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ["import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nin_n = lambda: int(readline())\nin_nn = lambda: map(int, readline().split())\nin_s = lambda: readline().rstrip().decode('utf-8')\nin_nl = lambda: list(map(int, readline().split()))\nin_nl2 = lambda H: [in_nl() for _ in range(H)]\nin_map = lambda: [s == ord('.') for s in readline() if s != ord('\\n')]\nin_map2 = lambda H: [in_map() for _ in range(H)]\nin_all = lambda: map(int, read().split())\n\n\ndef main():\n\n N = in_n()\n TA = in_nl2(N)\n\n t_score, a_score = 1, 1\n for i in range(N):\n\n t, a = TA[i]\n # print(t, a, '------------------')\n\n if t == a:\n t_score = max(t_score, a_score)\n a_score = t_score\n else:\n t_s = -(-t_score // t) * t\n a_s = (t_s // t) * a\n if t_s >= t_score and a_s >= a_score:\n t_score = t_s\n a_score = a_s\n print(t_score, a_score)\n continue\n # else:\n # print('dame1', t_s, a_s)\n\n a_s = -(-a_score // a) * a\n t_s = (a_s // a) * t\n if t_s >= t_score and a_s >= a_score:\n t_score = t_s\n a_score = a_s\n print(t_score, a_score)\n # else:\n # print('dame2', t_s, a_s)\n\n # print(t_score, a_score)\n\n print(t_score + a_score)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nin_n = lambda: int(readline())\nin_nn = lambda: map(int, readline().split())\nin_s = lambda: readline().rstrip().decode('utf-8')\nin_nl = lambda: list(map(int, readline().split()))\nin_nl2 = lambda H: [in_nl() for _ in range(H)]\nin_map = lambda: [s == ord('.') for s in readline() if s != ord('\\n')]\nin_map2 = lambda H: [in_map() for _ in range(H)]\nin_all = lambda: map(int, read().split())\n\n\ndef main():\n\n N = in_n()\n TA = in_nl2(N)\n\n t_score, a_score = 1, 1\n for i in range(N):\n\n t, a = TA[i]\n\n if t == a:\n t_score = max(t_score, a_score)\n a_score = t_score\n else:\n t_s = -(-t_score // t) * t\n a_s = (t_s // t) * a\n if t_s >= t_score and a_s >= a_score:\n t_score = t_s\n a_score = a_s\n continue\n\n a_s = -(-a_score // a) * a\n t_s = (a_s // a) * t\n if t_s >= t_score and a_s >= a_score:\n t_score = t_s\n a_score = a_s\n\n print(t_score + a_score)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s867976106', 's395819662'] | [9236.0, 9332.0] | [32.0, 31.0] | [1489, 1196] |
p03966 | u299869545 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\n\ndef cceil(x,y):\n\tres = x //y\n\tif x % y != 0:res += 1\n\treturn res\n\ndef gcd(x, y):\n\tif(x == 0):return y\n\treturn gcd(y % x, x)\n \ndef main():\n votes = int(input())\n ratio = [[ int(i) for i in input().split() ] for j in range(votes)]\n \n votesTemp = [0, 0]\n for i in range(votes):\n if i == 0:\n votesTemp = ratio[i]\n continue\n if(gcd(ratio[i][0], ratio[i][1]) != 1):\n \tx = 1 / 0\n ceil = [ cceil(votesTemp[j], ratio[i][j]) for j in range(2)]\n \n votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]\n \n print("turn: " + str(i))\n print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )\n print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))\n \n print(sum(votesTemp))\n \nif __name__ == \'__main__\':\n main()\n', 'import math\n \ndef gcd(x, y):\n\tif(x == 0):return y\n\treturn gcd(y % x, x)\n \ndef main():\n votes = int(input())\n ratio = [[ int(i) for i in input().split() ] for j in range(votes)]\n \n votesTemp = [0, 0]\n for i in range(votes):\n if i == 0:\n votesTemp = ratio[i]\n continue\n if(gcd(ratio[i][0], ratio[i][1]) != 1):\n \tx = 1 / 0\n ceil = [ math.ceil(votesTemp[j] / ratio[i][j]) for j in range(2)]\n \n votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]\n \n print("turn: " + str(i))\n print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )\n print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))\n \n print(sum(votesTemp))\n \nif __name__ == \'__main__\':\n main()\n', 'import math\n\ndef cceil(x,y):\n\tres = x //y\n\tif x % y != 0:res += 1\n\treturn res\n\ndef gcd(x, y):\n\tif(x == 0):return y\n\treturn gcd(y % x, x)\n \ndef main():\n votes = int(input())\n ratio = [[ int(i) for i in input().split() ] for j in range(votes)]\n \n votesTemp = [0, 0]\n for i in range(votes):\n if i == 0:\n votesTemp = ratio[i]\n continue\n if(gcd(ratio[i][0], ratio[i][1]) != 1):\n \tx = 1 / 0\n ceil = [ cceil(votesTemp[j], ratio[i][j]) for j in range(2)]\n \n votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]\n \n #print("turn: " + str(i))\n #print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )\n #print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))\n \n print(sum(votesTemp))\n \nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s260634525', 's616030719', 's486896280'] | [3444.0, 3444.0, 3188.0] | [34.0, 33.0, 29.0] | [820, 760, 830] |
p03966 | u319612498 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['from math import ceil\nfrom decimal import *\nn=int(input())\nprea=1.0\npret=1.0\nfor i in range(n):\n \n t,a=map(Decimal,input().split())\n i=max(ceil(prea/a),ceil(pret/t))\n pret,prea=t*i,a*i\n\nprint(pret+prea)', 'from math import ceil\nfrom decimal import *\nn=int(input())\nprea=Decimal("1.0")\npret=Decimal("1.0")\nfor i in range(n):\n \n t,a=map(Decimal,input().split())\n i=max(ceil(prea/a),ceil(pret/t))\n pret,prea=t*i,a*i\n\nprint(pret+prea)'] | ['Runtime Error', 'Accepted'] | ['s510276571', 's556226227'] | [5332.0, 5076.0] | [36.0, 111.0] | [214, 236] |
p03966 | u350997995 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\nN = int(input())\nfor i range(N):\n a,t = map(int,input().split())\n if i == 0:\n x,y = a,t\n else:\n xa = math.ceil(x/a)\n yb = math.ceil(y/b)\n c = max(xa,yb)\n x,y = a*c,b*c\nprint(x+y)', 'import math\nN = int(input())\nfor i in range(N):\n a,t = map(int,input().split())\n if i == 0:\n x,y = a,t\n else:\n xa = math.ceil(x/a)\n yb = math.ceil(y/b)\n c = max(xa,yb)\n x,y = a*c,b*c\nprint(x+b)', 'import math\nN = int(input())\nfor i range(N):\n a,t = map(int,input().split())\n if i == 0:\n x,y = a,t\n else:\n xa = math.ceil(x/a)\n yb = math.ceil(y/b)\n c = max(xa,yb)\n x,y = a*c,b*c\nprint(x+b)', 'N = int(input())\nfor i in range(N):\n a,t = map(int,input().split())\n if i == 0:\n x,y = a,t\n else:\n xa = x//a if x%a==0 else x//a+1\n yt = y//t if y%t==0 else y//t+1\n c = max(xa,yt)\n x,y = a*c,t*c\nprint(x+y)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s409561844', 's544184017', 's815306585', 's735403478'] | [2940.0, 3060.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 20.0] | [208, 211, 208, 224] |
p03966 | u368780724 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ["s = input()\nhmp = 0\nans = 0\nfor i in s:\n if i == 'g' and hmp > 0:\n hmp -= 1\n ans += 1\n elif i == 'g':\n hmp += 1\n elif hmp > 0:\n hmp -= 1\n else:\n hmp += 1\n ans -= 1\nprint(ans)", 'def inpl(): return [int(i) for i in input().split()]\nN = int(input())\nt, a = 1, 1\nfor _ in range(N):\n Ti, Ai = inpl()\n n = max(-(-t//Ti), -(-a//Ai))\n t, a = n*Ti, n*Ai\nprint(t+a)'] | ['Wrong Answer', 'Accepted'] | ['s584861703', 's418437131'] | [3060.0, 3060.0] | [20.0, 22.0] | [228, 187] |
p03966 | u371467115 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['n=int(input())\nc=2\ncnt1=1\ncnt2=1\nfor _ in range(n):\n t,a=map(int,input().split())\n i=c\n while i%(t+a)!=0:\n i+=1\n cnt1=i/(t+a)*t\n cnt2=i/(t+a)*a\n c=cnt1+cnt2\nprint(c)', 'n = int(input())\nmt, ma = 1, 1\nfor t, a in (map(int, input().split()) for _ in range(n)):\n l = max((mt-1)//t, (ma-1)//a) + 1\n mt, ma = l*t, l*a\nprint(mt+ma)\n#copy code'] | ['Wrong Answer', 'Accepted'] | ['s610144589', 's909625023'] | [3060.0, 3316.0] | [22.0, 21.0] | [174, 174] |
p03966 | u375616706 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ["s = input()\n\nl = len(s)\n\npoint = 0\nfor a, b in zip(s[0::2], s[1::2]):\n if a == 'p':\n point -= 1\n if b == 'g':\n point += 1\nprint(point)\n", "s = input()\n\nl = len(s)\n\npoint = 0\nfor a, b in zip(s, s[1:]):\n if a == 'p':\n point -= 1\n if b == 'g':\n point += 1\nprint(point)\n", 'N = int(input())\nv_T = 1\nv_A = 1\nfor _ in range(N):\n t, a = list(map(int, input().split()))\n d = max(((-v_T)//t)*(-1), ((-v_A)//a)*(-1))\n v_T = d*t\n v_A = d*a\n\n\nprint(v_T+v_A)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s443478142', 's450808979', 's168748687'] | [2940.0, 2940.0, 3060.0] | [18.0, 18.0, 22.0] | [155, 147, 188] |
p03966 | u426108351 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N = int(input())\nx, y = 0\nfor i in range(N):\n a, b = map(int, input().split())\n mul = max((x-1)//a+1, (y-1)//b+1)\n x = mul*a\n y = mul*b\nprint(x+y)', 'N = int(input())\nx, y = 0, 0\nfor i in range(N):\n a, b = map(int, input().split())\n mul = max((x-1)//a+1, (y-1)//b+1)\n x = mul*a\n y = mul*b\nprint(x+y)', 'N = int(input())\nx, y = 1, 1\nfor i in range(N):\n a, b = map(int, input().split())\n mul = max((x+a-1)//a, (y+b-1)//b)\n x = mul*a\n y = mul*b\nprint(x+y)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s038787239', 's521724619', 's552074047'] | [3060.0, 3060.0, 3060.0] | [18.0, 20.0, 21.0] | [150, 153, 153] |
p03966 | u455696302 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\nfrom decimal import *\n\nN = int(input())\n_input = []\nfor i in range(N):\n _input.append(list(map(int,input().split())))\n\ntotal_T = 1\ntotal_A = 1\n\nfor t,a in _input:\n \n n = max(-(-t//Ti), -(-a//Ai))\n total_T = int(t*n)\n total_A = int(a*n)\n\nprint(total_A+total_T)\n', 'import math\nfrom decimal import *\n\nN = int(input())\n_input = []\nfor i in range(N):\n _input.append(list(map(int,input().split())))\n\ntotal_T = 1\ntotal_A = 1\n\nfor t,a in _input:\n \n n = max(-(-total_T//t), -(-total_A//a))\n total_T = int(t*n)\n total_A = int(a*n)\n\nprint(total_A+total_T)\n'] | ['Runtime Error', 'Accepted'] | ['s500333441', 's837819083'] | [5204.0, 5076.0] | [37.0, 38.0] | [338, 348] |
p03966 | u497046426 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N = int(input())\nratio = []\nfor _ in range(N):\n ratio.append(tuple(map(int, input().split())))\nans = 0; total_t = 0; total_a = 0;\nfor t, a in ratio:\n i = 1\n while total_t > t*i and total_a > a*i:\n i += 1\n ans = (t + a)*i\nprint(ans)', 'N = int(input())\nratio = []\nfor _ in range(N):\n ratio.append(tuple(map(int, input().split())))\nans = 0; total_t = 0; total_a = 0;\nfor t, a in ratio:\n i = 1\n while total_t > t*i and total_a > a*i:\n i += 1\n total_t = t*i\n total_a = a*i\n ans = total_t + total_a\nprint(ans)', 'N = int(input())\nratio = []\nfor _ in range(N):\n ratio.append(tuple(map(int, input().split())))\nans = 0; total_t = 0; total_a = 0;\nfor t, a in ratio:\n q = max(total_t // t, total_a // a) + 1\n total_t = t*q\n total_a = a*q\n ans = total_t + total_a\nprint(ans)', 'N = int(input())\nratio = []\nfor _ in range(N):\n ratio.append(tuple(map(int, input().split())))\ntotal_t = 1; total_a = 1;\nfor t, a in ratio:\n q = max((total_t + t - 1) // t, (total_a + a - 1) // a)\n total_t = t*q\n total_a = a*q\nans = total_t + total_a\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s101358353', 's546440178', 's931580785', 's689423529'] | [3060.0, 3060.0, 3188.0, 3064.0] | [20.0, 21.0, 21.0, 21.0] | [250, 294, 272, 273] |
p03966 | u543954314 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['n = int(input())\nts, as = map(int, input().split())\nfor _ in range(n-1):\n t, a = map(int, input().split())\n m = max((ts-1)//t, (as-1)//a)+1\n ts = m*t\n as = m*a\nprint(ts+as)', 'n = int(input())\nt2, a2 = map(int, input().split())\nfor _ in range(n-1):\n t, a = map(int, input().split())\n m = max((t2-1)//t, (a2-1)//a)+1\n t2 = m*t\n a2 = m*a\nprint(t2+a2)'] | ['Runtime Error', 'Accepted'] | ['s594017679', 's753952929'] | [2940.0, 3060.0] | [18.0, 21.0] | [176, 176] |
p03966 | u585704797 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N=int(input())\n \nX=[]\nfor i in range(N):\n a=input().split()\n X.append([int(a[0]),int(a[1])])\n \n \ndef ceil(x):\n if int(x)==x:\n return int(x)\n else:\n return int(x//1+1)\n \n \na=X[0][0]\nb=X[0][1]\n \nfor i in range(1,N):\n c=X[i][0]\n d=X[i][1]\n \n \n #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" c = "+str(c)+" d = "+str(d))\n x=ceil(a/c)\n y=ceil(b/d)\n \n \n if d*x-b>=0:\n a=c*x\n b=d*x\n\n t=a+b\n\n \n \n if c*y-a>=0:\n\n if c*y+d*y<t:\n a=c*y\n b=d*y\n \n \n \nprint(a+b)', 'N=int(input())\n\nX=[]\nfor i in range(N):\n a=input().split()\n X.append([int(a[0]),int(a[1])])\n\n\ndef ceil(x):\n if int(x)==x:\n return int(x)\n else:\n return int(x//1+1)\n\n\na=X[0][0]\nb=X[0][1]\n\nfor i in range(1,N):\n c=X[i][0]\n d=X[i][1]\n y=ceil(b/d)*d-b\n \n x=ceil(a/c)*c-a\n \n \n a=a+x\n b=b+y\nprint(a+b)', 'N=int(input())\n\nX=[]\nfor i in range(N):\n a=input().split()\n X.append([int(a[0]),int(a[1])])\n\n\ndef ceil(x):\n if int(x)==x:\n return int(x)\n else:\n return int(x//1+1)\n\n\na=X[0][0]\nb=X[0][1]\n\nfor i in range(1,N):\n c=X[i][0]\n d=X[i][1]\n a1=a*d/c\n if a1<b:\n y=math.ceil(a/c)*d-b\n else:\n y=math.ceil(a/c)*d-b\n\n while y<0:\n y+=d\n\n\n x=c*(b+y)//d-a\n \n \n a=a+x\n b=b+y\nprint(a+b)', 'N=int(input())\n \nX=[]\nfor i in range(N):\n a=input().split()\n X.append([int(a[0]),int(a[1])])\n \n \na=X[0][0]\nb=X[0][1]\n \nfor i in range(1,N):\n c=X[i][0]\n d=X[i][1]\n \n\n x= (a + (c - 1)) // c\n y= (b + (d -1))) // d\n \n a1=1000000000000000000\n b1=1000000000000000000\n a2=1000000000000000000\n b2=1000000000000000000\n if d*x-b>=0:\n a1=c*x\n b1=d*x\n \n \n if c*y-a>=0:\n a2=c*y\n b2=d*y\n if (a1+b1)<(a2+b2):\n a=a1\n b=b1\n else:\n a=a2\n b=b2\n \n #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" a1 = "+str(a1)+" b1 = "+str(b1)+" a2 = "+str(a2)+" b2 = "+str(b2)+" c = "+str(c)+" d = "+str(d))\n \n \n \n \n \n \nprint(a+b)', 'N=int(input())\n \nX=[]\nfor i in range(N):\n a=input().split()\n X.append([int(a[0]),int(a[1])])\n \n \na=X[0][0]\nb=X[0][1]\n \nfor i in range(1,N):\n c=X[i][0]\n d=X[i][1]\n \n\n x= (a + (c - 1)) // c\n y= (b + (d -1)) // d\n \n a1=1000000000000000000\n b1=1000000000000000000\n a2=1000000000000000000\n b2=1000000000000000000\n if d*x-b>=0:\n a1=c*x\n b1=d*x\n \n \n if c*y-a>=0:\n a2=c*y\n b2=d*y\n if (a1+b1)<(a2+b2):\n a=a1\n b=b1\n else:\n a=a2\n b=b2\n \n #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" a1 = "+str(a1)+" b1 = "+str(b1)+" a2 = "+str(a2)+" b2 = "+str(b2)+" c = "+str(c)+" d = "+str(d))\n \n \n \n \n \n \nprint(a+b)'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s351355336', 's538990489', 's683111277', 's885441508', 's979207578'] | [3188.0, 3188.0, 3188.0, 2940.0, 3188.0] | [22.0, 22.0, 20.0, 17.0, 21.0] | [496, 423, 506, 643, 642] |
p03966 | u598755311 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['\ndef main():\n votes = int(input());\n ratio = [[ int(i) for i in input().split() ] for j in range(votes)]\n\n tak = aok = 0\n for i in range(votes):\n takTemp, aokTemp = ratio[i][0], ratio[i][1]\n\n while tak > takTemp or aok > aokTemp:\n takTemp += ratio[i][0]\n aokTemp += ratio[i][1]\n\n tak, aok = takTemp, aokTemp\n\n print("turn:" + str(i))\n print("votes:" + str(ratio[i][0]) + ":" + str(ratio[i][1]) )\n print(tak, aok)\n\n\n print(tak + aok)\n\nif __name__ == \'__main__\':\n main()\n', '\ndef main():\n votes = int(input());\n ratio = [[ int(i) for i in input().split() ] for j in range(votes)]\n\n tak = aok = 0\n for i in range(votes):\n takTemp, aokTemp = ratio[i][0], ratio[i][1]\n\n while tak > takTemp or aok > aokTemp:\n takTemp += ratio[i][0]\n aokTemp += ratio[i][1]\n\n tak, aok = takTemp, aokTemp\n\n #print("turn:" + str(i))\n #print("votes:" + str(ratio[i][0]) + ":" + str(ratio[i][1]) )\n print(tak, aok)\n\nif __name__ == \'__main__\':\n main()\n', '\ndef main():\n votes = int(input());\n ratio = [[ int(i) for i in input().split() ] for j in range(votes)]\n\n tak = aok = 0\n for i in range(votes):\n takTemp, aokTemp = ratio[i][0], ratio[i][1]\n\n while tak > takTemp or aok > aokTemp:\n takTemp += ratio[i][0]\n aokTemp += ratio[i][1]\n\n tak, aok = takTemp, aokTemp\n\n #print("turn:" + str(i))\n #print("votes:" + str(ratio[i][0]) + ":" + str(ratio[i][1]) )\n print(tak, aok)\n\n\n print(tak + aok)\n\nif __name__ == \'__main__\':\n main()\n', 'import math\nfrom decimal import *\n\ndef main():\n votes = int(input())\n ratio = [[ int(i) for i in input().split() ] for j in range(votes)]\n\n votesTemp = [0, 0]\n for i in range(votes):\n if i == 0:\n votesTemp = ratio[i]\n continue\n\n ceil = [ math.ceil(Decimal(votesTemp[j]) / Decimal(ratio[i][j])) for j in range(2)]\n\n votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]\n\n """\n print("turn: " + str(i))\n print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )\n print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))\n """\n print(sum(votesTemp))\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s018525833', 's075035887', 's294011160', 's451642612'] | [3472.0, 3444.0, 3444.0, 5204.0] | [2102.0, 2102.0, 2103.0, 94.0] | [550, 529, 552, 684] |
p03966 | u603234915 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['taka, aoki = 1, 1\nfor _ in range(int(input())):\n a, b = map(int, input().split())\n ratio = max(-(-taka//a), -(-aoki//b))\n print(ratio)\n taka = ratio * a\n aoki = ratio * b\nprint(taka + aoki)', 'taka, aoki = 1, 1\nfor _ in range(int(input())):\n a, b = map(int, input().split())\n ratio = max(taka//a + [0, 1][taka%a != 0], aoki//b + [0, 1][aoki%b != 0])\n taka = a * ratio\n aoki = b * ratio\n print(taka, aoki)\nprint(taka + aoki)', 'T,A=1,1\nfor _ in range(int(input())):\n a,b=map(int,input().split())\n r=max(-(-T//a),-(-A//b))\n T=r*a\n A=r*b\nprint(T+A)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s069453743', 's561153316', 's472589266'] | [3060.0, 3060.0, 3060.0] | [26.0, 27.0, 20.0] | [204, 245, 130] |
p03966 | u619819312 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['n=int(input())\na,b=map(int,input().split())\nfor i in range(n-1):\n e,f=map(int,input().split())\n t=e\n k=f\n while e<a or f<b:\n t+=e\n k+=f\n a=t\n b=k\nprint(a+b)', 'from itertools import gcd\nn=int(input())\na,b=map(int,input().split())\nd=a+b\nfor i in range(n-1):\n e,f=map(int,input().split())\n d=d*(e+f)//gcd(d,e+f)\nprint(d)', 'from fractions import gcd\nn=int(input())\na,b=map(int,input().split())\nd=a+b\nfor i in range(n-1):\n e,f=map(int,input().split())\n d=d*(e+f)//gcd(d,e+f)\nprint(d)', 'n=int(input())\na,b=map(int,input().split())\nfor i in range(n-1):\n e,f=map(int,input().split())\n if (a//e+(1 if a%e!=0 else 0))*f>=b:\n b=f*(a//e+(1 if a%e!=0 else 0))\n a=e*(a//e+(1 if a%e!=0 else 0))\n else:\n a=e*(b//f+(1 if b%f!=0 else 0))\n b=f*(b//f+(1 if b%f!=0 else 0))\nprint(a+b)'] | ['Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s277524184', 's535292322', 's840222541', 's662738778'] | [3064.0, 3060.0, 5048.0, 3064.0] | [2104.0, 19.0, 40.0, 22.0] | [188, 164, 164, 319] |
p03966 | u663710122 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['A, B = 1, 1\nfor _ in range(int(input())):\n x, y = map(int, input().split())\n n = max(-(-A // x), -(-B // y))\n A, B = n * x, n * y\n\n print(A, B)\n\nprint(A + B)\n', 'A, B = 1, 1\nfor _ in range(int(input())):\n x, y = map(int, input().split())\n n = max(-(-A // x), -(-B // y))\n A, B = n * x, n * y\n\nprint(A + B)\n'] | ['Wrong Answer', 'Accepted'] | ['s420586483', 's458687981'] | [3060.0, 2940.0] | [27.0, 21.0] | [170, 153] |
p03966 | u706414019 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\nN = int(input())\nt= 1\na= 1\n\ndef t_small(t,a,t1,a1):\n gain = -(-t//t1)\n t = gain*t1\n a_tmp=gain*a1\n if a_tmp<a:\n gain_a = -(-a//a_tmp)\n t *= gain_a\n a = a_tmp*gain_a\n else:\n a = a_tmp\n return t,a,t+a\n\ndef a_small(t,a,t1,a1):\n gain = -(-a//a1)\n a = gain*a1\n t_tmp=gain*t1\n if t_tmp<t:\n gain_t = -(-t//t_tmp)\n a *= gain_t\n t = t_tmp*gain_t\n else:\n t = t_tmp\n return t,a,t+a\n\nans = 0\nfor _ in range(N):\n t1,a1 = map(int,input().split())\n tt1,aa1,sta1 = t_small(t,a,t1,a1)\n tt2,aa2,sta2 = a_small(t,a,t1,a1)\n if sta1<=sta2:\n t=tt1;a=aa1,ans = sta1\n else:\n t=tt2,a=aa2,ans=sta2\nprint(ans)', 'import math\nN = int(input())\nt= 1\na= 1\n\ndef t_small(t,a,t1,a1):\n gain = -(-t//t1)\n t = gain*t1\n a_tmp=gain*a1\n if a_tmp<a:\n gain_a = -(-a//a_tmp)\n t *= gain_a\n a = a_tmp*gain_a\n else:\n a = a_tmp\n return t,a,t+a\n\ndef a_small(t,a,t1,a1):\n gain = -(-a//a1)\n a = gain*a1\n t_tmp=gain*t1\n if t_tmp<t:\n gain_t = -(-t//t_tmp)\n a *= gain_t\n t = t_tmp*gain_t\n else:\n t = t_tmp\n return t,a,t+a\n\nans = 0\nfor _ in range(N):\n t1,a1 = map(int,input().split())\n tt1,aa1,sta1 = t_small(t,a,t1,a1)\n tt2,aa2,sta2 = a_small(t,a,t1,a1)\n if sta1<=sta2:\n t=tt1;a=aa1;ans = sta1\n else:\n t=tt2;a=aa2;ans=sta2\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s566921579', 's326512635'] | [9240.0, 9112.0] | [26.0, 28.0] | [715, 716] |
p03966 | u766407523 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\nN = int(input())\nans = 2\ntp, ap = 0, 0\nfor i in range(N):\n \n t, a = map(int, input().split())\n k = max(math.ceil(tp/t), math.ceil(ap/a))\n t, a = t*k, a*k\n c = math.ceil(ans/(t+a))\n while True:\n if (t+a)*c >= ans:\n ans = (t+a)*c\n break\n c += 1\n tp, ap = t*c, a*c\nprint(ans)', 'n = int(input())\nt = []\na = []\nfor i in range(n):\n c = list(map(int,input().split()))\n t.append(c[0])\n a.append(c[1])\nfor i in range(n-1):\n d = max(1,-(-t[i]//t[i+1]),-(-a[i]//a[i+1]))\n t[i+1] =t[i+1]*d\n a[i+1] =a[i+1]*d\nprint(t[-1]+a[-1])'] | ['Runtime Error', 'Accepted'] | ['s365922089', 's848460460'] | [3316.0, 3316.0] | [19.0, 22.0] | [475, 257] |
p03966 | u792037966 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\ndef results(a,b):\n return (a+b-1//b)\n \nn=int(input())\nt,a=map(int,input().split())\nfor i in range(1,n):\n ti,ai=map(int,input().split())\n if ti<=t or ai<=a:\n k=max(results(t,ti),results(a,ai))\n t=k*ti\n a=k*ai\n else:\n t=ti\n a=ai\n #print(t,a)\nprint(t+a)\n ', 'import math\ndef results(a,b):\n return ((a+b-1)//b)\n \nn=int(input())\nt,a=map(int,input().split())\nfor i in range(1,n):\n ti,ai=map(int,input().split())\n if ti<=t or ai<=a:\n k=max(results(t,ti),results(a,ai))\n t=k*ti\n a=k*ai\n else:\n t=ti\n a=ai\n #print(t,a)\nprint(t+a)'] | ['Wrong Answer', 'Accepted'] | ['s762997534', 's207238758'] | [3060.0, 3064.0] | [23.0, 21.0] | [315, 315] |
p03966 | u813102292 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['n = int(input())\nt,a = [],[]\nfor i in range(n):\n tmp = [int(i) for i in input().split()]\n t.append(tmp[0])\n a.append(tmp[1])\n\np,q = 0,0\nfor i in range(n):\n tmp = max(p//t[i]+1,q//a[i]+1)\n p = t[i]*tmp \n q = a[i]*tmp\nprint(p+q) ', 'n = int(input())\nt,a = [],[]\nfor i in range(n):\n tmp = [int(i) for i in input().split()]\n t.append(tmp[0])\n a.append(tmp[1])\n\np,q = 0,0\nfor x,y in t,a:\n tmp = max(p//x,q//y)\n p = x*tmp \n q = y*tmp\nprint(p+q) ', 'n = int(input())\nt,a = [],[]\nfor i in range(n):\n tmp = [int(i) for i in input().split()]\n t.append(tmp[0])\n a.append(tmp[1])\n\np,q = 0,0\nfor zip(x,y) in t,a:\n tmp = max(p//x,q//y)\n p = x*tmp \n q = y*tmp\nprint(p+q) ', 'n = int(input())\nt,a = [],[]\nfor i in range(n):\n tmp = [int(i) for i in input().split()]\n t.append(tmp[0])\n a.append(tmp[1])\n\np,q = 0,0\nfor i in range(n):\n tmp = max(p//t[i],q//a[i])\n p = t[i]*tmp \n q = a[i]*tmp\nprint(p+q) ', 'n = int(input())\nt,a = [],[]\nfor i in range(n):\n tmp = [int(i) for i in input().split()]\n t.append(tmp[0])\n a.append(tmp[1])\n\np,q = 1,1\nfor i in range(n):\n tmp = max(-(-p//t[i]),-(-q//a[i]))\n p = t[i]*tmp \n q = a[i]*tmp\nprint(p+q) '] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s186270958', 's423115519', 's621300780', 's757664228', 's151756744'] | [3064.0, 3060.0, 3064.0, 3064.0, 3064.0] | [21.0, 20.0, 17.0, 20.0, 21.0] | [246, 227, 232, 242, 250] |
p03966 | u859897687 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['n=int(input())\nm=0\nfor _ in range(n):\n a,b=map(int,input().split())\n m=(m%(a+b)+m%(a+b)>0)*(a+b)\nprint(m)', 'n=int(input())\nm=2\nfor _ in range(n):\n a,b=map(int,input().split())\n m=(m%(a+b)+m%(a+b)>0)*(a+b)\nprint(m)', 'n=int(input())\nm=2\nfor _ in range(n):\n a,b=map(int,input().split())\n m=(m//(a+b)+m%(a+b)>0)*(a+b)\nprint(m)', 'n=int(input())\na0,b0=1,1\nfor _ in range(n):\n a,b=map(int,input().split())\n k=max(a0//a+a0%a>0,b0//b+b0%b>0)\n a0,b0=a*k,b*k\nprint(a0+b0)', 'n=int(input())\na0,b0=1,1\nfor _ in range(n):\n a,b=map(int,input().split())\n k=max(a0//a+(a0%a>0),b0//b+(b0%b>0))\n a0,b0=a*k,b*k\nprint(a0+b0)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s038362148', 's365313035', 's413814707', 's935417452', 's414498989'] | [2940.0, 2940.0, 2940.0, 3060.0, 3060.0] | [21.0, 20.0, 20.0, 23.0, 21.0] | [107, 107, 108, 138, 142] |
p03966 | u888337853 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ["import sys\nimport math\nimport collections\nimport bisect\nimport itertools\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline().rstrip())\nns = lambda: map(int, sys.stdin.readline().rstrip().split())\nna = lambda: list(map(int, sys.stdin.readline().rstrip().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))\n\n\n# ===CODE===\n\ndef lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n\n\ndef main():\n n = ni()\n t, a = 1, 1\n\n for _ in range(n):\n ti, ai = ns()\n x = t // ti\n x += 1 if t % ti else 0\n y = int(math.ceil(a / ai))\n y += 1 if a % ai else 0\n\n nxt = max(x, y)\n\n t, a = ti * nxt, ai * nxt\n\n print(t + a)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport math\nimport collections\nimport bisect\nimport itertools\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline().rstrip())\nns = lambda: map(int, sys.stdin.readline().rstrip().split())\nna = lambda: list(map(int, sys.stdin.readline().rstrip().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))\n\n\n# ===CODE===\n\ndef lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n\n\ndef main():\n n = ni()\n t, a = 1, 1\n\n for _ in range(n):\n ti, ai = ns()\n\n if ti == ai:\n t = max(t, a)\n a = max(t, a)\n\n x = t // ti\n x += 1 if t % ti else 0\n y = int(math.ceil(a / ai))\n y += 1 if a % ai else 0\n\n nxt = max(x, y)\n\n t, a = ti * nxt, ai * nxt\n\n print(t + a)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport math\nimport collections\nimport bisect\nimport itertools\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline().rstrip())\nns = lambda: map(int, sys.stdin.readline().rstrip().split())\nna = lambda: list(map(int, sys.stdin.readline().rstrip().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))\n\n\n# ===CODE===\n\ndef lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n\n\ndef main():\n n = ni()\n t, a = 1, 1\n\n for _ in range(n):\n ti, ai = ns()\n\n x = math.ceil(t / ti)\n y = math.ceil(a//ai)\n\n nxt = max(x, y)\n\n t, a = ti * nxt, ai * nxt\n\n print(t + a)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport math\nimport collections\nimport bisect\nimport itertools\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline().rstrip())\nns = lambda: map(int, sys.stdin.readline().rstrip().split())\nna = lambda: list(map(int, sys.stdin.readline().rstrip().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))\n\n\n# ===CODE===\n\ndef lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n\n\ndef main():\n n = ni()\n t, a = ns()\n\n for _ in range(n - 1):\n ti, ai = ns()\n x = t // ti\n x += 1 if t % ti else 0\n y = int(math.ceil(a / ai))\n y += 1 if a % ai else 0\n\n nxt = max(x, y)\n\n t, a = ti * nxt, ai * nxt\n\n print(t + a)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport math\nimport collections\nimport bisect\nimport itertools\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline().rstrip())\nns = lambda: map(int, sys.stdin.readline().rstrip().split())\nna = lambda: list(map(int, sys.stdin.readline().rstrip().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))\n\n\n# ===CODE===\n\ndef lcm_base(x, y):\n return (x * y) // math.gcd(x, y)\n\n\ndef main():\n n = ni()\n t, a = 1, 1\n\n for _ in range(n):\n ti, ai = ns()\n\n # if ti == ai:\n # t = max(t, a)\n # a = max(t, a)\n # continue\n\n x = t // ti\n x += 1 if t % ti else 0\n y = a//ai\n y += 1 if a % ai else 0\n\n nxt = max(x, y)\n\n t, a = ti * nxt, ai * nxt\n\n print(t + a)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s028873771', 's191050381', 's330038419', 's469077584', 's289175325'] | [9360.0, 9280.0, 9496.0, 9380.0, 9472.0] | [33.0, 33.0, 32.0, 31.0, 30.0] | [856, 931, 797, 860, 943] |
p03966 | u926678805 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['import math\nn=int(input())\nlog=[]\nH=[]\nfor i in range(n):\n log.append(tuple(map(int,input().split())))\nt,a=1,1\nfor x,y in log:\n nxt=max((t/x+0.5)//1,(a/y+0.5)//1)\n t=x*nxt\n a=y*nxt\nprint(t+a)', 'from decimal import *\nn=int(input())\nlog=[]\nH=[]\nfor i in range(n):\n log.append(tuple(map(int,input().split())))\nt,a=1,1\nfor x,y in log:\n nxt=max(t//x + (1 if t%x else 0),a//y + (1 if a%y else 0))\n t=x*nxt\n a=y*nxt\nprint(t+a)'] | ['Wrong Answer', 'Accepted'] | ['s472957312', 's106089915'] | [3064.0, 5076.0] | [22.0, 37.0] | [203, 237] |
p03966 | u993435350 | 2,000 | 262,144 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ['N = int(input())\nP = [0,0]\n\nfor i in range(N):\n Q = list(map(int,input().split()))\n t = Q[0]\n a = Q[1]\n m = max(P[0]/t,P[1]/a)\n while True:\n t = Q[0] * m\n a = Q[1] * m\n if t >= P[0] and a >= P[1]:\n P[0] = t\n P[1] = a\n break\n m += 1\n\nprint(sum(P))', 'N = int(input())\nP = [0,0]\n\nfor i in range(N):\n Q = list(map(int,input().split()))\n t = Q[0]\n a = Q[1]\n m = max(P[0]//t,P[1]//a)\n while True:\n t = Q[0] * m\n a = Q[1] * m\n if t >= P[0] and a >= P[1]:\n P[0] = t\n P[1] = a\n break\n m += 1\n\nprint(sum(P))', 'N = int(input())\nP = [1,1]\n\nfor i in range(N):\n Q = list(map(int,input().split()))\n t = Q[0]\n a = Q[1]\n m = max(P[0]//t,P[1]//a,1)\n while True:\n t = Q[0] * m\n a = Q[1] * m\n if t >= P[0] and a >= P[1]:\n P[0] = t\n P[1] = a\n break\n m += 1\n\nprint(sum(P))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s623913813', 's923071355', 's393378358'] | [3064.0, 3064.0, 3064.0] | [24.0, 21.0, 22.0] | [278, 280, 282] |
p03967 | u095756391 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s = input()\n\nsubsg = []\nsubsp = []\n\nsg = 0\nsp = 0\nans = 0\nfor i in range(N):\n if s[i] == 'g':\n sg += 1\n else:\n sp += 1\n subsg.append(sg)\n subsp.append(sp)\n\nfor i in range(N):\n if subsp <= subsg:\n ans += 1\n \nprint(ans)", "s = input()\n\nsg = 0\nsp = 0\nans = 0\n\nfor i in range(len(s)):\n if sp+1 <= sg and s[i] == 'g':\n sp += 1\n ans += 1\n elif sp+1 > sg and s[i] == 'p':\n sg += 1\n ans -= 1\n elif sp+1 <= sg and s[i] == 'p':\n sp += 1\n else:\n sg += 1\nprint(ans)\n"] | ['Runtime Error', 'Accepted'] | ['s561936363', 's655428026'] | [3316.0, 3316.0] | [17.0, 60.0] | [256, 287] |
p03967 | u102960641 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ['s = input()\nt_s = n.count("p")\na_s = len(s) // 2\nprint(a_s-t_s)', 's = input()\nt_s = s.count("p")\na_s = len(s) // 2\nprint(a_s-t_s)'] | ['Runtime Error', 'Accepted'] | ['s986511357', 's785205029'] | [3188.0, 3188.0] | [17.0, 18.0] | [63, 63] |
p03967 | u118642796 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ['S = input()\nans = 0\nfor i in range(S):\n if i%2 == 0 and S[i] == "g":\n ans += 1\n elif i%2 == 1 and S[i] == "p":\n ans -= 1\nprint(ans)', 'S = input()\nans = 0\nfor i in range(len(S)):\n if i%2 == 0 and S[i] == "g":\n ans += 1\n elif i%2 == 1 and S[i] == "p":\n ans -= 1\nprint(ans)', 'S = input()\nans = 0\nfor i in range(len(S)):\n if i%2 == 0 and S[i] == "p":\n ans -= 1\n elif i%2 == 1 and S[i] == "g":\n ans += 1\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s267749007', 's676746758', 's720419358'] | [3188.0, 3316.0, 3316.0] | [18.0, 48.0, 50.0] | [139, 144, 144] |
p03967 | u316386814 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s = input()\n\nans = 0\nfor i, x in enumerate(s):\n if i % 2 == 1 and x == 'p':\n ans -= 1\n elif i % 2 == 0 and x == 'g':\n ans += 1\n\nprint(ans)", "s = input()\n\nans = len(s) // 2 - s.count('p')\n\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s424618696', 's950940484'] | [3316.0, 3188.0] | [48.0, 18.0] | [158, 57] |
p03967 | u370608397 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s=input()\ndif=0\nfor i in range(len(s)):\n if s[i]=='g':\n dif+=1\n else:\n dif-=1\nprint(dif/2)\n", "s=input()\ndif=0\nfor i in range(len(s)):\n if s[i]=='g':\n dif+=1\n else:\n dif-=1\nprint(dif//2)"] | ['Wrong Answer', 'Accepted'] | ['s538463710', 's007580265'] | [3188.0, 3188.0] | [37.0, 36.0] | [111, 111] |
p03967 | u371763408 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s=input()\n\ngu=0\npa=0\nwin=0\n\nfot t in s:\n if t=='g':\n if gu>pa:\n pa+=1\n win+=1\n else:\n gu+=1\n else:\n if gu>pa:\n pa+=1\n else:\n win-=1\n gu+=1\nprint(win)\n \n ", "s=input()\n\ngu=0\npa=0\nwin=0\n\nfor t in s:\n if t=='g':\n if gu>pa:\n pa+=1\n win+=1\n else:\n gu+=1\n else:\n if gu>pa:\n pa+=1\n else:\n win-=1\n gu+=1\nprint(win)\n \n "] | ['Runtime Error', 'Accepted'] | ['s704206397', 's417153818'] | [2940.0, 3316.0] | [17.0, 41.0] | [205, 205] |
p03967 | u405660020 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s=input()\ncnt=0\nfor i in range(len(s)):\n if i%2==0 and s[i]=='g':\n cnt+=1\n elif i%2==0 and s[i]=='p':\n pass\n elif i%2==1 and s[i]=='g':\n pass\n else:\n cnt-=1\nprint(cnt)\n", "s=input()\ncnt=0\nfor i in range(len(s)):\n if i%2==1 and s[i]=='g':\n cnt+=1\n elif i%2==1 and s[i]=='p':\n pass\n elif i%2==0 and s[i]=='g':\n pass\n else:\n cnt-=1\nprint(cnt)\n"] | ['Wrong Answer', 'Accepted'] | ['s071415449', 's150029525'] | [3316.0, 3316.0] | [59.0, 55.0] | [208, 208] |
p03967 | u543954314 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ['s = input()\nm = "gp"*(len(s)//2+1)\ng = 0\nfor i in range(s):\n if s[i] == m[i]:\n continue\n elif s[i] == "p":\n g -= 1\n else:\n g += 1\nprint(g)', 's = input()\nprint(n//2-s.count("p"))', 's = input()\nprint(len(s)//2-s.count("p"))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s746093023', 's899546959', 's404027931'] | [3188.0, 3188.0, 3188.0] | [17.0, 17.0, 18.0] | [150, 36, 41] |
p03967 | u595893956 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s=input()\nprint((len(s)+1)//2-s.count('p'))", "s=input()\nprint((len(s))//2-s.count('p'))\n"] | ['Wrong Answer', 'Accepted'] | ['s805773146', 's722943546'] | [3188.0, 3188.0] | [18.0, 21.0] | [43, 42] |
p03967 | u606045429 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ['S = input()\nprint(-(-len(S) // 2) - S.count("p"))', 'S = input()\nprint(len(S) // 2 - S.count("p"))'] | ['Wrong Answer', 'Accepted'] | ['s181148802', 's796215197'] | [3188.0, 3188.0] | [17.0, 18.0] | [49, 45] |
p03967 | u678167152 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s = input()\ng = s.count('g')\np = s.count('p')\nprint(g-p)", "def solve():\n S = input()\n even = S[0::2]\n odd = S[1::2]\n ans = odd.count('g')-even.count('p')\n return ans\nprint(solve())"] | ['Wrong Answer', 'Accepted'] | ['s783386678', 's801701635'] | [3188.0, 3188.0] | [18.0, 18.0] | [56, 136] |
p03967 | u727801592 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ['s=input()\nprint(s)', "s=input()\nprint(len(s)//2-s.count('p'))"] | ['Wrong Answer', 'Accepted'] | ['s553114045', 's557941680'] | [3320.0, 3188.0] | [17.0, 17.0] | [18, 39] |
p03967 | u762540523 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ['s=input()\nans=0\nfor index,i in enumerate(s):\n if index%2==1:\n if i=="p":\n ans-=1\n else:\n if i=="g":\n ans+=1\nprint(ans)', 's=input()\nn=len(s)\nprint("gp"*(n//2)+"g"*(n%2))', 's=input()\nans=0\nfor index,i in enumerate(s):\n if index%2==0:\n if i=="p":\n ans-=1\n else:\n if i=="g":\n ans+=1\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s214273174', 's929601543', 's372344622'] | [9080.0, 9232.0, 9160.0] | [47.0, 31.0, 48.0] | [136, 47, 136] |
p03967 | u767664985 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ['s = input()\ng_cnt, p_cnt = 0, 0\nans = 0\nfor si in s:\n if si = "g":\n if p_cnt < g_cnt:\n p_cnt += 1\n ans += 1\n else:\n g_cnt += 1\n ans -= 1\n else:\n g_cnt += 1\n ans += 1\nprint(ans)\n', 's = input()\ng_cnt, p_cnt = 0, 0\nans = 0\nfor si in s:\n if si == "g":\n if p_cnt < g_cnt:\n p_cnt += 1\n ans += 1\n else:\n g_cnt += 1\n ans -= 1\n else:\n g_cnt += 1\n ans += 1\nprint(ans)\n', 's = input()\ng_cnt, p_cnt = 0, 0\nans = 0\nfor si in s:\n if si == "g":\n if p_cnt < g_cnt:\n p_cnt += 1\n ans += 1\n else:\n g_cnt += 1\n else:\n if p_cnt < g_cnt:\n p_cnt += 1\n else:\n g_cnt += 1\n ans -= 1\nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s581876328', 's889086956', 's227252636'] | [2940.0, 3316.0, 3316.0] | [17.0, 44.0, 39.0] | [255, 256, 306] |
p03967 | u780475861 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["s = input()\n\ngrid = [0 if i == 'g' else 1 for i in s]\n\n\ndef biggest(grid):\n dist = [float('-inf')] * len(s)\n move = (0, 1)\n st = deque([[0, 0, 0, 0]])\n while st:\n g, p, idx, cur = st.popleft()\n if idx > len(s) - 1:\n continue\n for a in move:\n if a:\n if p + 1 > g:\n continue\n tmpg, tmpp = g, p + 1\n else:\n tmpg, tmpp = g + 1, p\n if a > grid[idx]:\n tmp = cur + 1\n elif a < grid[idx]:\n tmp = cur - 1\n else:\n tmp = cur\n if dist[idx] < tmp:\n dist[idx] = tmp\n st.append([tmpg, tmpp, idx + 1, tmp])\n return dist[-1]\n\n\nprint(biggest(grid))\n", "s = input()\np = sum(1 for i in s if i == 'p')\nl = len(s)\nprint(l // 2 - p)"] | ['Runtime Error', 'Accepted'] | ['s223734959', 's911834290'] | [4860.0, 3316.0] | [26.0, 23.0] | [779, 74] |
p03967 | u792078574 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | [' s=input()\n print((s.count("g")-s.count("p"))//2)', 's=input()\nprint((s.count("g")-s.count("p"))//2)\n'] | ['Runtime Error', 'Accepted'] | ['s936748404', 's770715201'] | [8892.0, 8988.0] | [26.0, 26.0] | [49, 48] |
p03967 | u798818115 | 2,000 | 262,144 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | ["# coding: utf-8\n# Your code here!\ns=list(input())\ncount=0\n\nfor i in range(len(s)):\n if s[i]=='g':\n s[i]=0\n else:\n s[i]=1\n print(s)\n if i&1^s[i]==1 and i&1==1:\n count+=1\n elif i&1^s[i]==1 and s[i]&1==1:\n count-=1\n else:\n pass\n\nprint(count)\n\n", "# coding: utf-8\n# Your code here!\ns=list(input())\ncount=0\n\nfor i in range(len(s)):\n if s[i]=='g':\n s[i]=0\n else:\n s[i]=1\n if i&1^s[i]==1 and i&1==1:\n count+=1\n elif i&1^s[i]==1 and s[i]&1==1:\n count-=1\n else:\n pass\n\nprint(count)\n"] | ['Runtime Error', 'Accepted'] | ['s357656903', 's387722995'] | [136288.0, 4008.0] | [2103.0, 83.0] | [342, 328] |
p03986 | u010733367 | 1,000 | 262,144 | We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`. Takahashi, who hates the string `ST`, will perform the following operation 10^{10000} times: * Among the occurrences of `ST` in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing. Find the eventual length of X. | ['TSSTTTSS', 'st = []\nX = input()\nfor x in X:\n if not len(st) == 0:\n top = st.pop()\n if top == "S" and x == "T":\n continue\n else:\n st.append(top)\n st.append(x)\n else:\n st.append(x)\nprint(len(st))\n'] | ['Runtime Error', 'Accepted'] | ['s617707581', 's106136924'] | [3068.0, 5224.0] | [21.0, 124.0] | [8, 249] |
p03986 | u020390084 | 1,000 | 262,144 | We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`. Takahashi, who hates the string `ST`, will perform the following operation 10^{10000} times: * Among the occurrences of `ST` in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing. Find the eventual length of X. | ['#!/usr/bin/env python3\nimport sys\n# input = sys.stdin.readline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n X = input()\n\n LENX = len(X)\n\n left_T = 0\n right_S = 0\n\n for i in range(LENX):\n if X[i] == "T":\n left_T += 1\n else:\n break\n \n for i in range(LENX-1,-1,-1):\n if X[i] == "S":\n right_S += 1\n else:\n break\n \n print(left_T+right_S)\n\n return\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\n# input = sys.stdin.readline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n X = input()\n\n LENX = len(X)\n\n T_count = 0\n answer = LENX\n for i in range(LENX-1,-1,-1):\n if X[i] == "T":\n T_count += 1\n else:\n if T_count > 0 :\n T_count -= 1\n answer -= 2\n \n print(answer)\n\n return\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s283831216', 's454814839'] | [3500.0, 3500.0] | [18.0, 47.0] | [574, 529] |
p03986 | u024804656 | 1,000 | 262,144 | We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`. Takahashi, who hates the string `ST`, will perform the following operation 10^{10000} times: * Among the occurrences of `ST` in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing. Find the eventual length of X. | ['s = input()\nwhile 1:\n s1 = s.replace(\'ST\',\'\',1)\n if len(s1) == len(s):\n break\n s = s1\nprint(str(len(s1)) + "\\n")\n', 'st = input()\nsc = 0\ntc = 0\nfor s in st:\n if s == "S":\n sc += 1\n if s == "T":\n if sc > 0:\n sc -= 1\n else:\n tc += 1\n\nprint(sc + tc)'] | ['Time Limit Exceeded', 'Accepted'] | ['s341141667', 's998079632'] | [3500.0, 3500.0] | [1054.0, 57.0] | [129, 178] |
p03986 | u026155812 | 1,000 | 262,144 | We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`. Takahashi, who hates the string `ST`, will perform the following operation 10^{10000} times: * Among the occurrences of `ST` in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing. Find the eventual length of X. | ["s = input()\ncnt = 0\ncnt_set = 0\nfor x in S:\n if x == 'S':\n cnt += 1\n else:\n if cnt > 0:\n cnt_set += 1\n cnt -= 1\nprint(len(s)-2*cnt_set)", "s = input()\ncnt = 0\ncnt_set = 0\nfor x in s:\n if x == 'S':\n cnt += 1\n else:\n if cnt > 0:\n cnt_set += 1\n cnt -= 1\nprint(len(s)-2*cnt_set)"] | ['Runtime Error', 'Accepted'] | ['s833247009', 's821773091'] | [3500.0, 3500.0] | [17.0, 51.0] | [177, 177] |