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 |
|---|---|---|---|---|---|---|---|---|---|---|
p02756 | u666961261 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['a = input()\nif \'A\' in a and \'B\' in a:\n print("Yes")\nelse:\n print("No")\n--------------------------------\nn, a, b = map(int, input().split())\nperiod = a+b\ntimes = n//period\nk = n%period\nn = a if k >a else k\nprint(times*a + n)\n---------------------------\na, b = [int(x) for x in input().split()]\n \nif (b < a):\n temp = b\n b = a\n a = temp\n \n \nx = 1\nwhile True:\n if (int(x*0.08) == a and int(x*0.1) == b):\n print(x)\n break\n else:\n if (x > 1500):\n print(-1)\n break\n else:\n x += 1\n\n1, 2 and 3\n------------------------\ns = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft= right = ""\nfor operation in qs:\n if operation[0] == \'1\':\n n = not n\n if operation[0] == \'2\':\n t , f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left=c+left\n elif f == 2:\n right+=c\ns = left+s+right\nprint(s[::-1] if n else s)', 's = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft= right = ""\nfor operation in qs:\n if operation[0] == \'1\':\n n = not n\n if operation[0] == \'2\':\n t , f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left=c+left\n elif f == 2:\n right+=c\ns = left+s+right\nprint(s[::-1] if n else s)'] | ['Runtime Error', 'Accepted'] | ['s920098253', 's163798923'] | [3064.0, 41460.0] | [17.0, 1378.0] | [1010, 417] |
p02756 | u667024514 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=list(str(input()))\nq=int(input())\nnow = 0\nfor _ in range(q):\n lis = list(map(str,input().split()))\n if int(lis[0]) == 1:\n now = (now+1)%2\n else:\n if (int(lis[1])+now)%2 == 1:\n s.insert(0,lis[2])\n else:\n s.append(lis[2])\nif now ==0:\n for i in range(len(s)):\n print(s[i],end="")\nelse:\n for i in range(len(s)):\n print(s[-i-1],end="")\n \n \n', 's=str(input())\nq=int(input())\nnow = 0\nmae,usiro="",""\nfor _ in range(q):\n lis = list(map(str,input().split()))\n if int(lis[0]) == 1:\n now = (now+1)%2\n else:\n if (int(lis[1])+now)%2 == 1:\n mae = lis[2]+mae\n else:\n usiro= usiro +lis[2]\ns = mae+s+usiro\nif now ==0:\n for i in range(len(s)):\n print(s[i],end="")\nelse:\n for i in range(len(s)):\n print(s[-i-1],end="")\n \n \n', 's=str(input())\nq=int(input())\nnow = 0\nmae,usiro="",""\nfor _ in range(q):\n lis = list(map(str,input().split()))\n if int(lis[0]) == 1:\n now = (now+1)%2\n else:\n if (int(lis[1])+now)%2 == 1:\n mae = lis[2]+mae\n else:\n usiro= usiro +lis[2]\ns = mae+s+usiro\nif now ==0:\n print(s)\nelse:\n print(s[::-1])\n \n \n'] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s911022836', 's974716875', 's463438311'] | [4340.0, 5456.0, 4608.0] | [2104.0, 2104.0, 1979.0] | [371, 399, 326] |
p02756 | u673338219 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = str(input())\nq = int(input())\nstate = True\nfront = ""\nend = ""\nfor _ in range(q):\n qi = str(input())\n if qi[0] == "2":\n fi,ci = map(str,qi[2:].split())\n if state == True:\n if fi == "1":\n front += ci\n else:\n end += ci\n else:\n if fi == "1":\n end += ci\n else:\n front += ci\n else:\n state = not state\nif state:\n first = front[::-1]\n last = end\nelse:\n first = end[::-1]\n last = front\n s = s[::-1]\nfor f in first:\n print(f,end="")\nfor si in s:\n print(s,end="")\nfor l in last:\n print(l,end="")\n\n\n\n', 's = str(input())\nq = int(input())\nstate = True\nfront = ""\nend = ""\nfor _ in range(q):\n qi = str(input())\n if qi[0] == "2":\n fi,ci = map(str,qi[2:].split())\n if state == True:\n if fi == "1":\n front += ci\n else:\n end += ci\n else:\n if fi == "1":\n end += ci\n else:\n front += ci\n else:\n state = not state\nif state:\n first = front[::-1]\n last = end\nelse:\n first = end[::-1]\n last = front\n s = s[::-1]\nfor f in first:\n print(f,end="")\nfor si in s:\n print(s,end="")\nfor l in last:\n print(l,end="")', 's = str(input())\nq = int(input())\nstate = True\nfront = ""\nending = ""\nfor _ in range(q):\n qi = str(input())\n if qi[0] == "2":\n fi,ci = map(str,qi[2:].split())\n if state == True:\n if fi == "1":\n front += ci\n else:\n ending += ci\n else:\n if fi == "1":\n ending += ci\n else:\n front += ci\n else:\n state = not state\nif state:\n first = front[::-1]\n lastt = ending\nelse:\n first = ending[::-1]\n lastt = front\n s = s[::-1]\nfor f in first:\n print(f,end="")\nfor si in s:\n print(s,end="")\nfor l in lastt:\n print(l,end="")', 's = str(input())\nq = int(input())\nstate = True\nfront = ""\nending = ""\nfor _ in range(q):\n qi = str(input())\n if qi[0] == "2":\n fi,ci = map(str,qi[2:].split())\n if state == True:\n if fi == "1":\n front += ci\n else:\n ending += ci\n else:\n if fi == "1":\n ending += ci\n else:\n front += ci\n else:\n state = not state\nif state:\n first = front[::-1]\n lastt = ending\nelse:\n first = ending[::-1]\n lastt = front\n s = s[::-1]\nprint(first+s+lastt)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s176855516', 's226321326', 's620508999', 's009914157'] | [136176.0, 136048.0, 136176.0, 4468.0] | [950.0, 960.0, 918.0, 672.0] | [564, 560, 578, 500] |
p02756 | u674588203 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["# ABC158\n# D - String Formation\n\ndef ChangeState(Is_normal):\n if Is_normal==True:\n return False\n else:\n return True\n\n\n\nS=input()\nQ=int(input())\nprint('-'*10)\nIs_normal=True\n\nfor _ in range(Q):\n q = list(map(str,input().split()))\n if len(q)== 1 :\n Is_normal = ChangeState(Is_normal)\n else:\n if q[1]=='1':\n if Is_normal==True:\n S=q[2]+S\n else :\n S=S+q[2]\n else :\n if Is_normal==True:\n S=S+q[2]\n else:\n S=q[2]+S\n # print(Is_normal, S)\nif Is_normal==False:\n S=S[::-1]\nprint(S)\n", "# ABC158\n# D - String Formation\n\nfrom collections import deque\n\ndef ChangeState(Is_normal):\n if Is_normal==True:\n return False\n else:\n return True\n\nS=deque(input().split())\nQ=int(input())\nIs_normal=True\n\nfor _ in range(Q):\n q = input()\n if len(q)== 1 :\n Is_normal = ChangeState(Is_normal)\n else:\n if q[2]=='1':\n if Is_normal==True:\n # S=q[4]+S\n S.appendleft(q[4])\n else :\n # S=S+q[4]\n S.append(q[4])\n\n else :\n if Is_normal==True:\n # S=S+q[4]\n S.append(q[4])\n\n else:\n # S=q[4]+S\n S.appendleft(q[4])\n\n # print(Is_normal, S)\nS=''.join(S)\nif Is_normal==False:\n S=S[::-1]\nprint(S)\n"] | ['Wrong Answer', 'Accepted'] | ['s294158185', 's073470856'] | [9844.0, 12748.0] | [2206.0, 288.0] | [633, 796] |
p02756 | u680851063 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = list(input())\nn=int(input())\nl = [input().split(" ") for _ in range(n)]\n\nfor i in range(n):\n if l[i][0]==\'1\':\n s=s[::-1]\n elif l[i][0]==\'2\':\n if l[i][1]==1:\n s = s+[l[i][2]]\n else:\n s.append(l[i][2])\nprint(\'\'.join(s))\n', "from collections import deque\n\ns = deque(input())\nn = int(input())\n\nmemo = 0\nfor i in range(n):\n q = list(input().split())\n if q[0] == '1':\n if memo == 0: memo = 1\n else: memo = 0\n else:\n if memo == 0:\n if q[1] == '1': s.appendleft(q[2])\n else: s.append(q[2])\n else:\n if q[1] == '1': s.append(q[2])\n else: s.appendleft(q[2])\n\nif memo == 0: print(''.join(s))\nelse: print(''.join(list(s)[::-1]))"] | ['Wrong Answer', 'Accepted'] | ['s920653741', 's655569232'] | [43296.0, 15776.0] | [2106.0, 320.0] | [271, 475] |
p02756 | u686230543 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\nappendix = [[], []]\nreverse = False\nfor _ in range(q):\n query = input().split()\n if query[0] == '1':\n reverse ^= True\n else:\n f = bool(int(query[1]) - 1)\n appendix[int(f ^ reverse)].append(query[2])\nprint(''.join(appendix[int(reverse)][::-1]) + s + ''.join(appendix[int(not reverse)])", "s = input()\nq = int(input())\nappendix = [[], []]\nreverse = False\nfor _ in range(q):\n query = input().split()\n if query[0] == '1':\n reverse ^= True\n else:\n f = bool(int(query[1]) - 1)\n appendix[int(f ^ reverse)].append(query[2])\nif reverse:\n print(''.join(appendix[1][::-1]) + s[::-1] + ''.join(appendix[0]))\nelse:\n print(''.join(appendix[0][::-1]) + s + ''.join(appendix[1]))"] | ['Runtime Error', 'Accepted'] | ['s325339229', 's945139878'] | [3064.0, 6272.0] | [18.0, 585.0] | [325, 389] |
p02756 | u687044304 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['# -*- coding:utf-8 -*-\nfrom collections import deque\n\ndef solve():\n d = deque(input())\n Q = int(input())\n\n is_reverse = False \n\n for _ in range(Q):\n query = input()\n if query == "1":\n is_reverse = not is_reverse\n else:\n _, f, c = query.split()\n\n if f == "1":\n if is_reverse:\n \n d.append(c)\n else:\n \n d.appendleft(c)\n else:\n if is_reverse:\n \n d.appendleft(c)\n else:\n \n d.append(c)\n\n if is_reverse:\n print("".join(reversed(list(d))))\n else:\n print("".join(d))\n\n\ndef solve2():\n S = list(input())\n Q = int(input())\n M = 2*10**5+10\n data = [None]*M\n data.extend(S)\n data.extend([None]*M)\n left, right = M-1, M+len(S)\n\n is_reverse = False\n\n for _ in range(Q):\n query = input()\n if query == "1":\n is_reverse = not is_reverse\n else:\n t, f, c = query.split()\n if f == "1":\n if is_reverse:\n \n data[right] = c\n right += 1\n else:\n \n data[left] = c\n left -= 1\n else:\n if is_reverse:\n \n data[left] = c\n left -= 1\n else:\n \n data[right] = c\n right += 1\n\n \n if is_reverse:\n print("".join(data[right-1:left:-1])\n \n # print(data[i], end="")\n else:\n \n # print(data[i], end="")\n print("".join(data[left+1:right]))\n # print()\n\n\nif __name__ == "__main__":\n solve()\n', '# -*- coding:utf-8 -*-\nfrom collections import deque\n\ndef solve():\n d = deque(input())\n Q = int(input())\n\n is_reverse = False \n\n for _ in range(Q):\n query = input()\n if query == "1":\n is_reverse = not is_reverse\n else:\n _, f, c = query.split()\n\n if f == "1":\n if is_reverse:\n \n d.append(c)\n else:\n \n d.appendleft(c)\n else:\n if is_reverse:\n \n d.appendleft(c)\n else:\n \n d.append(c)\n\n if is_reverse:\n print("".join(reversed(list(d))))\n else:\n print("".join(d))\n\n\ndef solve2():\n S = list(input())\n Q = int(input())\n M = 2*10**5+10\n data = [None]*M\n data.extend(S)\n data.extend([None]*M)\n left, right = M-1, M+len(S)\n\n is_reverse = False\n\n for _ in range(Q):\n query = input()\n if query == "1":\n is_reverse = not is_reverse\n else:\n t, f, c = query.split()\n if f == "1":\n if is_reverse:\n \n data[right] = c\n right += 1\n else:\n \n data[left] = c\n left -= 1\n else:\n if is_reverse:\n \n data[left] = c\n left -= 1\n else:\n \n data[right] = c\n right += 1\n\n \n if is_reverse:\n print("".join(data[right-1:left:-1]))\n \n # print(data[i], end="")\n else:\n \n # print(data[i], end="")\n print("".join(data[left+1:right]))\n # print()\n\n\nif __name__ == "__main__":\n solve2()\n'] | ['Runtime Error', 'Accepted'] | ['s884083431', 's936851202'] | [3064.0, 10584.0] | [17.0, 384.0] | [2141, 2143] |
p02756 | u687574784 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\ns = input()\nq = int(input())\nque = deque([s])\nflg=False\nfor _ in range(q):\n a = list(input().split())\n if a[0]=='1':\n flg=not(flg)\n# s=s[::-1]\n else:\n if flg ^ a[1]!='1':\n que.append(a[2])\n else:\n que.appendleft(a[2])\n\nans = ''.join(que)\n\nif flg:\n ans = ans[::-1]\nprint(ans)", "from collections import deque\ns = input()\nq = int(input())\nque = deque([s])\nflg=False\nfor _ in range(q):\n a = list(input().split())\n if a[0]=='1':\n flg=not(flg)\n# s=s[::-1]\n else:\n if flg ^ a[1]!='1':\n que.append(a[2])\n else:\n que.appendleft(a[2])\n\nans = ''.join(que)\n\nif flg:\n ans = ans[::-1]\nprint(ans)", "from collections import deque\ns = input()\nq = int(input())\nque = deque([s])\nflg=False\nfor _ in range(q):\n a = list(input().split())\n if a[0]=='1':\n flg=not(flg)\n# s=s[::-1]\n else:\n if flg ^ (a[1]!='1'):\n que.append(a[2])\n else:\n que.appendleft(a[2])\n\nans = ''.join(que)\n\nif flg:\n ans = ans[::-1]\nprint(ans)\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s482882349', 's492160350', 's071133133'] | [3572.0, 3572.0, 6900.0] | [21.0, 24.0, 483.0] | [366, 366, 369] |
p02756 | u690781906 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\ninput = sys.stdin.readline\n\nS = input().rstrip()\nQ = int(input())\nhead = ''\ntail = ''\nrev = False\n\nfor _ in range(Q):\n query = list(input().split())\n for i in range(10**5):\n if query[0] == '1':\n if flag:\n rev = False\n else:\n rev = True\n continue\n elif query[0] == '2':\n f = query[1]\n c = query[2].rstrip()\n if f == '1':\n if rev:\n tail = tail + c\n else:\n head = c + head\n elif:\n if rev:\n head = c + head\n else:\n tail = tail + c\nif flag:\n print(head + S + tail)\nelse:\n tmp = head + S + tail\n print(tmp[::-1])\n", "import sys\ninput = sys.stdin.readline\n\nS = input().rstrip()\nQ = int(input())\nhead = ''\ntail = ''\nrev = False\n\nfor _ in range(Q):\n query = list(input().split())\n if query[0] == '1':\n if rev:\n rev = False\n else:\n rev = True\n elif query[0] == '2':\n f = query[1]\n c = query[2].rstrip()\n if f == '1':\n if rev:\n tail = tail + c\n else:\n head = c + head\n else:\n if rev:\n head = c + head\n else:\n tail = tail + c\nif rev:\n tmp = head + S + tail\n print(tmp[::-1])\nelse:\n print(head + S + tail)\n"] | ['Runtime Error', 'Accepted'] | ['s226947504', 's200339274'] | [3064.0, 4564.0] | [27.0, 1268.0] | [790, 668] |
p02756 | u692746605 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ninput=sys.stdin.readline\nfrom collections import deque\n\nr=False\nd=deque(list(input()))\nfor i in range(int(input())):\n Q=input().split()\n if Q[0]==\'1\':\n r=not r\n else:\n if (Q[1]==\'1\' and not r) or (Q[1]==\'2\' and r):\n d.appendleft(Q[2])\n else:\n d.append(Q[2])\n\nif r:\n d.reverse()\n\nprint("".join(list(d)))\n', 'import sys\ninput=lambda:sys.stdin.readline().rstrip()\nfrom collections import deque\n\nr=False\nd=deque(list(input()))\nfor i in range(int(input())):\n Q=input().split()\n if Q[0]==\'1\':\n r=not r\n else:\n if (Q[1]==\'1\' and not r) or (Q[1]==\'2\' and r):\n d.appendleft(Q[2])\n else:\n d.append(Q[2])\n\nif r:\n d.reverse()\n\nprint("".join(list(d)))\n'] | ['Wrong Answer', 'Accepted'] | ['s830969523', 's297882136'] | [8420.0, 8676.0] | [180.0, 225.0] | [337, 355] |
p02756 | u694991843 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import collections\n\nx = collections.deque(input())\nn = int(input())\n\nfor i in range(n):\n y = input()\n if len(y) == 1:\n x.reverse()\n else:\n if int(y[1]) == 2:\n x.append(y[2])\n else:\n x.appendleft(y[2])\n\nprint("".join(x))', 'import collections\n\nx = collections.deque(input())\nn = int(input())\nrev = False\n\nfor i in range(n):\n y = input().split()\n if len(y) == 1:\n rev = not rev\n elif rev:\n if int(y[1]) == 2:\n x.appendleft(y[2])\n else:\n x.append(y[2])\n else:\n if int(y[1]) == 2:\n x.append(y[2])\n else:\n x.appendleft(y[2])\n\nif rev:\n x.reverse()\n\nprint("".join(x))'] | ['Runtime Error', 'Accepted'] | ['s657386838', 's913862775'] | [4212.0, 8820.0] | [23.0, 487.0] | [261, 411] |
p02756 | u699296734 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ninput = sys.stdin.readline.rstrip()\ndef main():\n moji=input()\n cycle=int(input())\n flont_or_back=0\n flont=""\n back=""\n for i in range(cycle):\n line=input()\n if line[0]=="1":\n flont_or_back+=1\n else:\n fi=line[2]\n ci=line[4]\n if flont_or_back%2==0:\n if fi=="1":\n flont=ci+flont\n else:\n back+=ci\n else:\n if fi=="1":\n back+=ci\n else:\n flont=ci+flont\n moji=flont+moji+back\n if flont_or_back%2==0:\n print(moji)\n else:\n print(moji[::-1])\n \n\nif __name__ == \'__main__\':\n main() \n ', 'import sys\ninput = sys.stdin.readline\ndef main():\n moji=input()\n cycle=int(input())\n flont_or_back=0\n flont=""\n back=""\n for i in range(cycle):\n line=input()\n if line[0]=="1":\n flont_or_back+=1\n else:\n fi=line[2]\n ci=line[4]\n if flont_or_back%2==0:\n if fi=="1":\n flont=ci+flont\n else:\n back+=ci\n else:\n if fi=="1":\n back+=ci\n else:\n flont=ci+flont\n moji=flont+moji+back\n if flont_or_back%2==0:\n print(moji)\n else:\n print(moji[::-1])\n \n\nif __name__ == \'__main__\':\n main() \n ', 'from collections import deque\nimport sys\ninput = lambda: sys.stdin.readline().rstrip() \ndef main():\n moji=input()\n d=deque(moji)\n cycle=int(input())\n flont_or_back=0\n flont=""\n back=""\n for i in range(cycle):\n line=input()\n if line[0]=="1":\n flont_or_back+=1\n else:\n fi=line[2]\n ci=line[4]\n if flont_or_back%2==0:\n if fi=="1":\n d.appendleft(ci)\n else:\n d.append(ci)\n else:\n if fi=="1":\n d.append(ci)\n else:\n d.appendleft(ci)\n if flont_or_back%2==0:\n print("".join(d))\n else:\n d.reverse()\n print("".join(d))\n\nif __name__ == \'__main__\':\n main() \n \n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s019677368', 's296828063', 's529527482'] | [3064.0, 4732.0, 8564.0] | [17.0, 1077.0, 164.0] | [742, 733, 812] |
p02756 | u699944218 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom collections import deque\n\nS = deque(readline().rstrip().decode())\nQ = int(readline())\nquery = int(readlines())\nrev = False\nfor q in query:\n if q[0] == ord('1'):\n rev = not rev\n else:\n _, f, c = q.decode().split()\n f = int(f)\n if rev ^ (f == 1):\n S.appendleft(c)\n else:\n S.append(c)\n \nT = ''.join(S)\nif rev:\n T = T[::-1]\nprint(T)", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nfrom collections import deque\n \nS = deque(readline().rstrip().decode())\nQ = int(readline())\nquery = readlines()\n \nrev = False\nfor q in query:\n if q[0] == ord('1'):\n rev = not rev\n else:\n _, f, c = q.decode().split()\n f = int(f)\n if rev ^ (f == 1):\n S.appendleft(c)\n else:\n S.append(c)\n \nT = ''.join(S)\nif rev:\n T = T[::-1]\nprint(T)"] | ['Runtime Error', 'Accepted'] | ['s953518113', 's099880832'] | [2940.0, 18148.0] | [17.0, 261.0] | [514, 513] |
p02756 | u701426727 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = []\ns.append(input())\nnum = int(input())\nchange_flag = 1\nfor i in range(num):\n a = input().split(" ")\n if(a[0] == "1"):\n change_flag *= -1\n else:\n if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):\n s.insert(0, a[2])\n else:\n s.append(a[2])\n\nif(change_flag == -1):\n s = s[::-1]\nfor i in s:\n print(i, end="")\n\n', 's = input()\nb = ""\nf = ""\nchange_flag = 1\nfor i in range(int(input())):\n a = input().split(" ")\n if(a[0] == "1"):\n change_flag *= -1\n else:\n if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):\n b = a[2] + b\n else:\n f = f + a[2]\n\nif(change_flag == -1):\n print(f[::-1]+s[::-1]+b[::-1])\nelse:\n print(b+s+f)\n'] | ['Wrong Answer', 'Accepted'] | ['s255478855', 's334412277'] | [4088.0, 4516.0] | [2104.0, 1496.0] | [397, 389] |
p02756 | u705007443 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=[input()]\nq=int(input())\nturn=True\nfor i in range(q):\n qq=input().split()\n if qq[0]==\'1\':\n turn=not turn\n else:\n if turn and int(qq[1])-2:\n s.insert(0,qq[2])\n else:\n s.append(qq[2])\ntext="".join(s)\nprint(text if turn else text[::-1])', "ad=[[],[]]\nadd=[[],[]]\ncount=0\ns=input()\nq=int(input())\nfor i in range(q):\n t=input().split()\n if t[0]=='1':\n count+=1\n ad[0].reverse()\n ad[1].reverse()\n add=[add[0]+ad[1],add[1]+ad[0]]\n ad=[[],[]]\n elif t[1]=='1':\n ad[0].insert(0,t[2])\n else:\n ad[1].append(t[2])\n\n\nif count%2==0:\n print(''.join(add[0]+ad[0])+s+''.join(add[1]+ad[1]))\nelse:\n print(''.join(add[0]+ad[0])+s[::-1]+''.join(add[1]+ad[1]))", "ad=[[],[]]\nadd=[[],[]]\ncount=0\ns=input()\nq=int(input())\nfor i in range(q):\n t=input().split()\n if t[0]=='1':\n count+=1\n ad[0].reverse()\n ad[1].reverse()\n add=[add[0]+=ad[1],add[1]+=ad[0]]\n ad=[[],[]]\n elif t[1]=='1':\n ad[0].insert(0,t[2])\n else:\n ad[1].append(t[2])\n\n\nif count%2==0:\n print(''.join(add[0]+ad[0])+s+''.join(add[1]+ad[1]))\nelse:\n print(''.join(add[0]+ad[0])+s[::-1]+''.join(add[1]+ad[1]))", 's=[input()]\nq=int(input())\nturn=True\nl=""\nfor i in range(q):\n qq=input().split()\n if qq[0]==\'1\':\n turn=not turn\n else:\n if turn and int(qq[1])-2:\n l+=qq[2]\n else:\n s.append(qq[2])\n\ntext=l+"".join(s)\nprint(text if turn else text[::-1])', "ad=[[],[]]\ncount=0\ns=input()\nq=int(input())\nfor i in range(q):\n t=input().split()\n if t[0]=='1':\n count+=1\n ad[1].reverse()\n ad[0].reverse()\n ad=[ad[1],ad[0]]\n elif t[1]=='1':\n ad[0].insert(0,t[2])\n else:\n ad[1].append(t[2])\n\nif count%2==0:\n print(''.join(ad[0],s,ad[1]))\nelse:\n print(''.join(ad[0]),end='')\n for i in range(len(s)):\n print(s[-(i+1)],end='')\n print(''.join(ad[1]))", 's=[input()]\nq=int(input())\nturn=True\n\nfor i in range(q):\n qq=input().split()\n if qq[0]==\'1\':\n turn=not turn\n else:\n if turn==bool(int(qq[1])-2):\n s.appendleft(qq[2])\n else:\n s.append(qq[2])\n\ntext="".join(s)\nprint(text if turn else text[::-1])', 's=[input()]\nq=int(input())\nturn=True\nfor i in ragne(q):\n qq=input().split()\n if qq[0]==\'1\':\n turn=not turn\n else:\n if turn==not (int(qq[1])-1]):\n s.insert(0,qq[2])\n else:\n s.append(qq[2])\ntext="".join(s)\nprint(text if turn else text[::-1])', 's=[input()]\nq=int(input())\nturn=True\nl=""\nfor i in range(q):\n qq=input().split()\n if qq[0]==\'1\':\n turn=not turn\n else:\n if turn and int(qq[1])-2:\n l+=qq[2]\n else:\n s.append(qq[2])\n\ntext=l[::-1]+"".join(s)\nprint(text if turn else text[::-1])', 'from collections import deque\ns=deque(input())\nq=int(input())\nturn=True\n \nfor i in range(q):\n qq=input().split()\n if qq[0]==\'1\':\n turn=not turn\n else:\n if turn==bool(int(qq[1])-2):\n s.appendleft(qq[2])\n else:\n s.append(qq[2])\n \n\ntext="".join(s)\nprint(text if turn else text[::-1])'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s162262996', 's201764115', 's507838669', 's598484782', 's814975804', 's847135298', 's889009771', 's933123244', 's433025722'] | [4340.0, 5468.0, 3064.0, 5348.0, 4276.0, 3188.0, 2940.0, 5432.0, 8428.0] | [2104.0, 2104.0, 18.0, 485.0, 2104.0, 17.0, 18.0, 519.0, 542.0] | [287, 467, 469, 286, 453, 294, 291, 292, 332] |
p02756 | u706330549 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\n\nx = []\ny = []\ncnt = 0\n\nfor i in range(q):\n a = list(input().split())\n if a[0] == "1":\n x, y = y, x\n cnt += 1\n else:\n if a[1] == "1":\n x.append(a[2])\n else:\n y.append(a[2])\n\nif cnt % 2 == 1:\n s = s[::-1]\n\nprint(\'\'.join(x[::-1]) + s + \'\'.join(y))\n\nprint(s)\n', "s = input()\nq = int(input())\nx = 1\nf, b = '', ''\n\nfor i in range(q):\n a = input().split()\n if a[0] == '1':\n x = -x\n elif (1.5 - int(a[1])) * x > 0:\n f = a[2] + f\n else:\n b = b + a[2]\n s = f + s + b\n if x == -1:\n s = s[::-1]\n\nprint(s)\n", 's = input()\nq = int(input())\n\nx = []\ny = []\ncnt = 0\n\nfor i in range(q):\n a = list(input().split())\n if a[0] == "1":\n x, y = y, x\n cnt += 1\n else:\n if a[1] == "1":\n x.append(a[2])\n else:\n y.append(a[2])\n\nif cnt % 2 == 1:\n s = s[::-1]\n\ns = \'\'.join(x[::-1]) + s + \'\'.join(y)\n\nprint(s)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s408177897', 's468887854', 's886487198'] | [6208.0, 28744.0, 6268.0] | [470.0, 2104.0, 465.0] | [347, 284, 344] |
p02756 | u706433263 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s=input()\nq=int(input())\nc=0\nfor _ in range(q):\n L=list(input().split())\n if L[0]=='1':\n c+=1\n else:\n if L[1]=='2':\n s+=L[2]\n else:\n t=L[2]+s\n s=t\n\nif c//2==0:\n print(s)\nelse:\n s=s[::-1]\n print(s)", 'def main():\n from collections import deque\n s=input()\n q=int(input())\n turn = 2\n d=deque(s)\n\n for _ in [0]*q:\n query = input()\n if query[0] == "1":\n t = int(query)\n turn = 3 - turn\n else:\n t,f,c = map(str,query.split())\n if (int(f) + turn)% 2 == 0:\n d.append(c)\n else:\n d.appendleft(c)\n if turn == 2:\n print("".join(d))\n else:\n print("".join(list(d)[::-1]))\nmain()\n'] | ['Wrong Answer', 'Accepted'] | ['s122323611', 's329363620'] | [3864.0, 10328.0] | [2104.0, 626.0] | [226, 470] |
p02756 | u709304134 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\nd = deque()\ns = input()\nd.append(s)\nrev = 0\n\nQ = int(input())\n\nfor q in range(Q):\n ls = input().split()\n print (ls)\n if ls[0] == '1':\n rev = (rev + 1) % 2\n else:\n if (int(ls[1]) + rev) % 2 == 0:\n d.append(ls[2])\n else:\n d.appendleft(ls[2])\n\nans = ''.join(list(d))\nif rev == 1:\n ans = ans[::-1]\nprint (ans)\n", "from collections import deque\nd = deque()\ns = input()\nd.append(s)\nrev = 0\n\nQ = int(input())\n\nfor q in range(Q):\n ls = input().split()\n #print (ls)\n if ls[0] == '1':\n rev = (rev + 1) % 2\n else:\n if (int(ls[1]) + rev) % 2 == 0:\n d.append(ls[2])\n else:\n d.appendleft(ls[2])\n\nans = ''.join(list(d))\nif rev == 1:\n ans = ans[::-1]\nprint (ans)\n"] | ['Wrong Answer', 'Accepted'] | ['s553225677', 's373711675'] | [10100.0, 6900.0] | [1708.0, 531.0] | [394, 395] |
p02756 | u717671569 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\ninput = sys.stdin.readline\n\ns = list(input())\nq = int(input())\n\n\nfor i in range(q):\n query = list(input().split())\n if (int(query[0]) == 1):\n s.reverse()\n else:\n if (int(query[1]) == 1):\n s.insert(0, query[2])\n else:\n s.append(query[2])\n \nprint(''.join(s))\n", "from collections import deque\n\nd = deque()\ns = input()\nd.append(s)\nrev = 0\nq = int(input())\n\nfor i in range(q):\n query = list(input().split())\n if (int(query[0]) == 1):\n rev = (rev + 1) % 2\n else:\n if ((int(query[1]) + rev) % 2 == 0):\n d.append(query[2])\n else:\n d.appendleft(query[2])\n\nans = ''.join(list(d))\nif rev == 1:\n ans = ans[::-1]\n\nprint(ans)\n\n\n"] | ['Wrong Answer', 'Accepted'] | ['s411521464', 's089298052'] | [4260.0, 6900.0] | [2104.0, 616.0] | [291, 377] |
p02756 | u723345499 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\nflg = False\n\nfor i in range(q):\n x = input()\n if int(len(x)) == 1:\n a = int(x)\n if flg == False:\n flg = True\n else:\n flg = False\n print("G:",s)\n else:\n a, b, c = map(str, x.split()) \n if flg == False and int(b) == 1:\n s = c + s\n elif flg == False and int(b) == 2:\n s = s + c\n elif flg == True and int(b) == 1:\n s = s + c\n else:\n s = c + s\n\nif flg == True:\n s = s[::-1]\nprint(s)', 'from collections import deque\n\ns = input()\nq = int(input())\n\nt = deque(s)\nflg = False\nfor _ in range(q):\n query = input()\n if query[0] == "1":\n flg = not flg\n elif query[0] == "2":\n _, f, c = query.split()\n if f == "1":\n if flg:\n t.append(c)\n else:\n t.appendleft(c)\n elif f == "2":\n if flg:\n t.appendleft(c)\n else:\n t.append(c)\nresult = "".join(t)\nif flg:\n result = result[::-1]\nprint(result)'] | ['Runtime Error', 'Accepted'] | ['s620612362', 's093525303'] | [134608.0, 8564.0] | [2104.0, 412.0] | [547, 536] |
p02756 | u723583932 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=input()\nq=int(input())\nfor i in range(q):\n line=list(input().split())\n if line[0]==1:\n s=s[::-1]\n else:\n t=line[2]\n if line[1]==1:\n s=t+s \n else:\n s=s+t\nprint(s)', '#abc 158 d\nfrom collections import deque\nx=deque()\nflag=True \ns=input()\nx.append(s)\nq=int(input())\ncnt=0\nfor i in range(q):\n line=list(input().split())\n if len(line)==1:\n cnt+=1\n if cnt%2==1:\n flag=False\n else:\n flag=True\n else:\n t=line[2]\n if line[1]=="1":\n if flag==True:\n x.appendleft(t)\n else:\n x.append(t)\n else:\n if flag==True:\n x.append(t)\n else:\n x.appendleft(t)\nans="".join(x)\nif flag==False:\n ans=ans[::-1]\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s607734391', 's392824702'] | [3992.0, 6900.0] | [496.0, 502.0] | [222, 640] |
p02756 | u726285999 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\n\njun = True\n\nfor _ in range(Q):\n T = input().split()\n if T[0] == "1":\n jun = not jun\n \n else:\n\n if (T[1] == "1" and jun) or (T[1] == "2" and not jun):\n S = T[2] + S\n continue\n\n else:\n (T[1] == "2" and jun) or (T[1] == "1" and not jun):\n S = S + T[2]\n\nif jun:\n print(S)\nelse:\n print(S[::-1])', 'S = input()\nQ = int(input())\n\njun = True\nhead = ""\n\nfor _ in range(Q):\n T = input().split()\n if T[0] == "1":\n jun = not jun\n \n else:\n\n if (T[1] == "1" and jun) or (T[1] == "2" and not jun):\n head += T[2]\n continue\n\n else:\n S += T[2]\n\nif jun:\n print(head[::-1] + S)\nelse:\n print(S[::-1] + head)'] | ['Runtime Error', 'Accepted'] | ['s020546865', 's365249376'] | [2940.0, 4468.0] | [17.0, 443.0] | [402, 365] |
p02756 | u728473456 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\ns = input()\nq = int(input())\nquery = [input() for _ in range(q)]\n\n\n\ninv = 0\nfor q in query :\n if q[0] == '1':\n inv += 1\n else:\n _,f,c = q.split()\n if f == '1':\n if inv % 2 == 0:\n s.append(c)\n else:\n s.appendleft(c)\ns = ''.join(s)\nprint(s if inv % 2 == 0 else s[::-1])\n", "from collections import deque\n\ns = input()\nq = int(input())\nquery = [input() for _ in range(q)]\n\n\n\ninv = 0\nfor q in query :\n if q[0] == '1':\n inv += 1\n else:\n _,f,c = q.split()\n if f == '1':\n if inv % 2 == 0:\n s.appendleft(c)\n else:\n s.append(c)\n else:\n if inv % 2 ==0:\n s.append(c)\n else:\n s.appendleft(c)\ns = ''.join(s)\nprint(s if inv % 2 == 0 else s[::-1])\n", "from collections import deque\n\ns = input()\nq = int(input())\nquery = [input() for _ in range(q)]\n\ns = deque(s)\n\ninv = 0\nfor q in query :\n if q[0] == '1':\n inv += 1\n else:\n _,f,c = q.split()\n if f == '1':\n if inv % 2 == 0:\n s.appendleft(c)\n else:\n s.append(c)\n else:\n if inv % 2 ==0:\n s.append(c)\n else:\n s.appendleft(c)\ns = ''.join(s)\nprint(s if inv % 2 == 0 else s[::-1])\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s560134005', 's661585039', 's799542260'] | [16220.0, 16220.0, 21084.0] | [260.0, 266.0, 373.0] | [391, 511, 510] |
p02756 | u729133443 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s,_,*q=open(0)\na=['',s[:-1]]\np=1\nfor q in q:\n if q>'1':\n f=1if q<'2 2'else 0\n a[f^p]+=q[-2]\n else:p^=1\nprint(a[p^1][::-1]+a[p])", 'S = str(input())\nQ = int(input())\n\nhead = ""\ntail = ""\nmain = S\n\nstatus = 0\n\nwhile Q:\n Q -= 1\n l = list(map(str,input().split()))\n if l[0] == "1":\n status = (status+1)%2\n else:\n letter = l[2]\n if l[1] == "1":\n if status == 0:\n head += letter\n else:\n tail += letter\n else:\n if status == 0:\n tail += letter\n else:\n head += letter\n\nif status == 0:\n print(head[::-1]+main+tail)\nelse:\n print(tail[::-1]+main[::-1]+head)\n'] | ['Wrong Answer', 'Accepted'] | ['s287845697', 's246354903'] | [18336.0, 4412.0] | [1924.0, 716.0] | [135, 481] |
p02756 | u729938879 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\ns = deque(input())\nn = int(input())\ninitial = "left"\nfor i in range(n):\n order = list(input().split())\n if len(order) == 3:\n if initial == "left":\n if int(order[1]) == 1:\n s.appendleft(order[2])\n else:\n s.append(order[2])\n else:\n if int(order[1]) == 1:\n s.append(order[2])\n else:\n s.appendleft(order[2])\n else:\n initial = "right"\n \nif initial == "left":\n print(\'\'.join(s))\nelse:\n print(\'\'.join(s)[::-1])', 'from collections import deque\ns = deque()\nn = int(input())\ninitial = "left"\nfor i in range(n):\n order = list(input().split())\n if len(order) == 3:\n if initial == "left":\n if int(order[1]) == 1:\n s.appendleft(order[2])\n else:\n s.append(order[2])\n else:\n if int(order[1]) == 1:\n s.append(order[2])\n else:\n s.appendleft(order[2])\n else:\n initial = "right"\n \nif initial == "left":\n print(s)\nelse:\n print(s[::-1])', 's = input()\nn = int(input())\ninitial = "right"\nfor i in range(n):\n order = list(input().split())\n if len(order) == 3:\n if initial == "right":\n if int(order[1]) == 1:\n s = order[2] + s\n else:\n s += order[2]\n else:\n if int(order[1]) == 1:\n s += order[2]\n else:\n s = order[2] + s\n else:\n initial = "left"\n \nif initial == "right":\n print(s)\nelse:\n print(s[::-1])', 's = deque()\nn = int(input())\ninitial = "left"\nfor i in range(n):\n order = list(input().split())\n if len(order) == 3:\n if initial == "left":\n if int(order[1]) == 1:\n s.appendleft(order[2])\n else:\n s.append(order[2])\n else:\n if int(order[1]) == 1:\n s.append(order[2])\n else:\n s.appendleft(order[2])\n else:\n initial = "right"\n \nif initial == "left":\n print(s)\nelse:\n print(s[::-1])', "from collections import deque\ns = deque(input())\nn = int(input())\ninitial = True\nfor i in range(n):\n order = list(input().split())\n if len(order) == 3:\n if initial:\n if int(order[1]) == 1:\n s.appendleft(order[2])\n else:\n s.append(order[2])\n else:\n if int(order[1]) == 1:\n s.append(order[2])\n else:\n s.appendleft(order[2])\n else:\n initial = not initial\n \nif initial:\n print(''.join(s))\nelse:\n print(''.join(s)[::-1])"] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s007564991', 's277797322', 's562568656', 's963971289', 's009205954'] | [8564.0, 3444.0, 4092.0, 3064.0, 8692.0] | [571.0, 21.0, 2104.0, 18.0, 531.0] | [576, 551, 501, 521, 558] |
p02756 | u730107446 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s=input()\na=int(input())\n\nfor i in range(a):\n c=input()\n if c[0]=='1':\n s=''.join(list(reversed(s)))\n else:\n if c[2]=='1':\n s=c[4]+s\n else:\n s=s+c[4]\n \n print(s)\n \nprint(s)", "s=input()\nn=int(input())\nrev=1\npre=''\nsuf=''\n\nfor i in range(n):\n q=input().split()\n if q[0]=='1':\n rev+=1\n elif (rev+int(q[1]))%2==0:\n pre=q[2]+pre\n else:\n suf=suf+q[2]\n \nans=pre+s+suf\n \nif rev%2==0:\n print(ans[::-1])\nelse:\n print(ans)"] | ['Runtime Error', 'Accepted'] | ['s071004477', 's065444092'] | [135376.0, 4612.0] | [409.0, 1666.0] | [241, 255] |
p02756 | u731322489 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\ncount = 0\ntop = ""\nend = ""\nans = s\nfor i in range(q):\n tmp = input()\n count += 1\n else:\n _, f, c = map(str, tmp.split())\n if (count % 2 == 0 and f == "1") or (count % 2 == 1 and f == "2"):\n top = c + top\n else:\n end = end + c\n\nans = top + ans + end\nans = ans[::-1] if count % 2 == 1 else ans\nprint(ans)\n', 's = input()\nq = int(input())\ncount = 0\ntop = ""\nend = ""\nans = s\nfor i in range(q):\n tmp = input()\n if tmp[0] == "1":\n count += 1\n else:\n _, f, c = map(str, tmp.split())\n if (count % 2 == 0 and f == "1") or (count % 2 == 1 and f == "2"):\n top = c + top\n else:\n end = end + c\n\nans = top + ans + end\nans = ans[::-1] if count % 2 == 1 else ans\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s251861921', 's991115349'] | [2940.0, 4384.0] | [17.0, 1780.0] | [389, 411] |
p02756 | u731603651 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=input()\nq=int(input())\ntrans=0\naft=""\nbef=""\nfor i in range(q):\n que=input()\n if que[0]=="1":\n trans=1-trans\n else:\n que=que.split()\n if (que[1]=="1" and trans==0) or (que[1]=="2" and trans==1):\n bef=bef+que[2]\n else:\n aft=aft+que[2]\nif trans==0:\n l=len(bef)\n for i in range(l):\n print(bef[l-1-i],end="")\n print(s,end="")\n for i in range(len(aft)):\n print(aft[i],end="")\nelse:\n l=len(aft)\n for i in range(l):\n print(aft[l-1-i],end="")\n print(s,end="")\n for i in range(len(bef)):\n print(bef[i],end="")', 's=input()\nq=int(input())\ntrans=0\naft=""\nbef=""\nfor i in range(q):\n que=input()\n if que[0]=="1":\n trans=1-trans\n else:\n if (que[2]=="1" and trans==0) or (que[2]=="2" and trans==1):\n bef=bef+que[4]\n else:\n aft=aft+que[4]\nif trans==0:\n print("".join(bef[::-1])+s+"".join(aft))\nelse:\n print("".join(aft[::-1])+s[::-1]+"".join(bef))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s957815571', 's976116044'] | [5228.0, 5108.0] | [681.0, 388.0] | [547, 353] |
p02756 | u736470924 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from queue import deque\n\ns = deque([i for i in input()])\nQ = int(input())\nstate = 0\nfor _ in range(Q):\n q = input()\n if q[0] == '1':\n if state == 0:\n state = 1\n else:\n state = 0\n else:\n if q[2] == '1':\n if state == 0:\n s.appendleft(q[-1])\n else:\n s.append(q[-1])\n else:\n if state == 0:\n s.append(q[-1])\n else:\n s.appendleft(q[-1])\n\nif state == 1:\n print(s[::-1])\nelse:\n print(s)\n", "from queue import deque\n\ns = deque([i for i in input()])\nQ = int(input())\nstate = 0\nfor _ in range(Q):\n q = input()\n if q[0] == '1':\n if state == 0:\n state = 1\n else:\n state = 0\n else:\n if int(q[2]) == 1:\n if state == 0:\n s.appendleft(q[-1])\n else:\n s.append(q[-1])\n elif int(q[2]) == 2:\n if state == 0:\n s.append(q[-1])\n else:\n s.appendleft(q[-1])\n\nif state == 1:\n s.reverse()\nprint(''.join(s))\n"] | ['Runtime Error', 'Accepted'] | ['s719272160', 's581864197'] | [11748.0, 9056.0] | [379.0, 432.0] | [548, 562] |
p02756 | u736848749 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = str(input())\nQ = int(input())\nQy = list([input().split() for _ in range(Q)])\nans = [S]\n\nrev = False \n\nfor i in Qy:\n if i[0] == '1':\n rev = not rev\n\telif i[0] == '2':\n if rev == False:\n if i[1] == '1':\n ans.insert(0,i[2])\n else:\n ans.append(i[2])\n else:\n if i[1] == '1':\n ans.append(i[2])\n else:\n ans.insert(0,i[2])\n\nif rev == False:\n print(''.join(ans))\nelse:\n ans.reverse()\n print(''.join(ans))", "S = str(input())\nQ = int(input())\nQy = list([input().split() for _ in range(Q)])\nans = [S]\nfor i in Qy:\n if i[0] == '1':\n ans.reverse()\n elif i[0] == '2':\n if i[1] == '1':\n ans.insert(0,i[2])\n else:\n ans.append(i[2])\n print(ans)\nprint(''.join(ans))", "from collections import deque\nS = str(input())\nQ = int(input())\nQy = list([input().split() for _ in range(Q)])\nrev = False \nans = deque([S])\nfor t in Qy:\n if t[0] == '1':\n rev = not rev\n else:\n if (t[1]=='1' and rev == False) or (t[1]=='2' and rev == True):\n ans.appendleft(t[2])\n else:\n ans.append(t[2])\nif rev == False:\n print(''.join(ans))\nelse:\n print(''.join(ans)[::-1])"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s096240308', 's300992035', 's063827234'] | [2940.0, 170712.0, 43096.0] | [18.0, 944.0, 441.0] | [555, 300, 449] |
p02756 | u744920373 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["for i in range(Q):\n r = sys.stdin.readline().strip('\\n')\n if r == '1':\n S = S[::-1]\n else:\n ni, f, c = r.split()\n if f=='1':\n S = c + S\n else:\n S+=c\n\nprint(S)", "import sys\n\nS = input()\n\nQ = int(input())\nflag=0\nmae = ''\nmatsu = ''\nfor i in range(Q):\n r = sys.stdin.readline().strip('\\n')\n if r == '1':\n flag = 1- flag\n else:\n ni, f, c = r.split()\n if f=='1':\n if flag == 0:\n mae += c\n else:\n matsu += c\n else:\n if flag == 0:\n matsu += c\n else:\n mae += c\n if flag ==0:\n print(mae[::-1]+S+matsu)\n else:\n print(matsu[::-1]+S+mae)", "import sys\n\nS = input()\n\nQ = int(input())\nflag=0\nmae = ''\nmatsu = ''\n\nfor i in range(Q):\n r = sys.stdin.readline().rstrip('\\n')\n if r == '1':\n flag = 1 - flag\n else:\n ni, f, c = r.split()\n if f=='1':\n if flag == 0:\n mae += c\n else:\n matsu += c\n else:\n if flag == 0:\n matsu += c\n else:\n mae += c\n\n\nif flag ==0:\n print(mae[::-1]+S+matsu)\nelse:\n print(matsu[::-1]+S[::-1]+mae)"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s950465286', 's955166604', 's671293333'] | [2940.0, 134540.0, 4468.0] | [17.0, 215.0, 221.0] | [217, 525, 520] |
p02756 | u745687363 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ninput = sys.stdin.readline\n\ns = input()\nq = int(input())\npar = 0\npre = ""\npos = ""\n\nfor i in range(q):\n t = input().split()\n if t[0] == "1":\n par += 1\n elif (par + int(t[1]))%2 == 1:\n pre = t[2] + pre\n else:\n pos = pos + t[2]\n \nans = pre + s + pos\n\nif par%2 == 0:\n print(ans)\nelse:\n print(ans[::-1])', 'import sys\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\nA = [(input().split("")) for _ in range(Q)]\n\nfor i in range(Q):\n if A[i] == ["1"]:\n S = \'\'.join(list(reversed(S)))\n else:\n if A[i][1] == "1":\n S = S + A[i][2]\n else:\n S = A[i][2] + S\n \nprint(S)\n \n', 'import sys\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\nA = [(input().split()) for _ in range(Q)]\n\nfor i in range(Q):\n if A[i] == ["1"]:\n S = \'\'.join(list(reversed(S)))\n else:\n if A[i][1] == "1":\n S = S + A[i][2]\n else:\n S = A[i][2] + S\n \nprint(S)\n \n', 'import sys\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\nA = [(input().split("")) for _ in range(Q)]\n\nfor i in range(Q):\n if A[i] == ("1"):\n S = \'\'.join(list(reversed(S)))\n else:\n if A[i][1] == "1":\n S = A[i][2] + "S"\n else:\n S = "S" + A[i][2] \n \nprint(S)', 'import sys\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\nA = [(input().split("")) for _ in range(Q)]\n\nfor i in range(Q):\n if A[i] == ["1"]:\n S = \'\'.join(list(reversed(S)))\n else:\n if A[i][1] == "1":\n S = A[i][2] + S\n else:\n S = S + A[i][2] \n \nprint(S)\n \n', 'import sys\ninput = sys.stdin.readline\n\nS = str(input())\nQ = int(input())\nA = [[input().split("")] for _ in range(Q)]\n\nfor i in range(Q):\n if A[i] == ["1"]:\n S = \'\'.join(list(reversed(S)))\n else:\n if A[i][1] == "1":\n S = A[i][2] + str(S)\n else:\n S = str(S) + A[i][2] \n \nprint(S)\n \n', 'import sys\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\nA = [[input().split()] for _ in range(Q)]\n\nfor i in range(Q):\n if A[i] == ["1"]:\n S = \'\'.join(list(reversed(S)))\n else:\n if A[i][1] == "1":\n S = S + A[i][2]\n else:\n S = A[i][2] + S\n \nprint(S)\n \n', 'import sys\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\nA = [(input().split()) for _ in range(Q)]\n\nfor i in range(Q):\n if A[i] == ["1"]:\n S = \'\'.join(list(reversed(S)))\n else:\n if A[i][1] ==1:\n S = S + A[i][2]\n else:\n S = A[i][2] + S\n \nprint(S)\n ', 's = input()\nq = int(input())\npar = 0\npre = ""\npos = ""\n\nfor i in range(q):\n t = input().split()\n if t[0] == "1":\n par += 1\n elif (par + int(t[1]))%2 == 1:\n pre = t[2] + pre\n else:\n pos = pos + t[2]\n \nans = pre + s + pos\n\nif par%2 == 0:\n print(ans)\nelse:\n print(ans[::-1])\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s012583120', 's479719786', 's539328789', 's637855727', 's737243239', 's794328998', 's856090693', 's931733531', 's800743039'] | [4660.0, 3188.0, 42508.0, 3188.0, 3188.0, 3188.0, 58100.0, 43216.0, 4672.0] | [1349.0, 17.0, 2106.0, 19.0, 17.0, 18.0, 262.0, 2110.0, 1700.0] | [328, 293, 291, 292, 294, 309, 291, 287, 290] |
p02756 | u745802292 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['#!/usr/bin/env python3 ## -*- python -*-\n\ndef main():\n s = list(input())\n q = int(input())\n for i in range(q):\n d = input()\n if d[0] == "1":\n s.reverse()\n else: # 2\n dd = d.split()\n f = int(dd[1])\n c = dd[2]\n if f == 1:\n s.insert(1, c)\n else: # f == 2\n s.append(c)\n\n print(\'\'.join(s))\n\nmain()', '#!/usr/bin/env python3 ## -*- python -*-\nfrom collections import deque\n\ndef main():\n s = deque()\n s.extend(input())\n q = int(input())\n head = "l"\n for i in range(q):\n d = input()\n if d[0] == "1":\n if head == "l":\n head = "r"\n else:\n head = "l"\n else: # 2\n dd = d.split()\n f = int(dd[1])\n c = dd[2]\n if f == 1:\n if head == "l":\n s.appendleft(c)\n else:\n s.append(c)\n else: # f == 2\n if head == "l":\n s.append(c)\n else:\n s.appendleft(c)\n\n if head == "r":\n s.reverse()\n ans = \'\'.join(s)\n print(ans)\nmain()'] | ['Wrong Answer', 'Accepted'] | ['s195780251', 's635786228'] | [4260.0, 8436.0] | [2104.0, 493.0] | [421, 796] |
p02756 | u745812846 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\ns = input()\nq = int(input())\nflip = 0\nd = deque([s])\nfor i in range(q):\n query = input().split()\n if query[0] == '1':\n flip ^= 1\n else:\n f = int(query[1]) - 1\n c = query[2]\n if f ^ flip == 0:\n d.append(c)\n else:\n d.appendleft(c)\nif flip:\n d.reverse()\nprint(''.join(d))", "from collections import deque\ns = input()\nq = int(input())\nflip = 0\nd = deque(list(s))\nfor i in range(q):\n query = input().split()\n if query[0] == '1':\n flip ^= 1\n else:\n f = int(query[1]) - 1\n c = query[2]\n if f ^ flip == 1:\n d.append(c)\n else:\n d.appendleft(c)\nif flip:\n d.reverse()\nprint(''.join(d))"] | ['Wrong Answer', 'Accepted'] | ['s582443619', 's112471548'] | [6900.0, 8548.0] | [544.0, 564.0] | [367, 371] |
p02756 | u748241164 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = str(input())\nQ = int(input())\nst = [0] * Q\nn = [0] * Q\np = 0\nfor i in range(Q):\n q = str(input())\n if int(q[0]) == 1:#Ti = 1\n s_h += 1\n else:\n if int(q[2]) == 1:\n st[p] = q[4]\n n[p] = s_h\n p += 1\n else:\n st[p] = q[4]\n n[p] = s_h + 1\n p += 1\n\nprint(S)', 'S = str(input())\nQ = int(input())\nst = [0] * Q\nn = [0] * Q\np = 0\ns_h = 0\nfor i in range(Q):\n q = str(input())\n if int(q[0]) == 1:#Ti = 1\n s_h += 1\n else:\n if int(q[2]) == 1:\n st[p] = q[4]\n n[p] = s_h\n p += 1\n else:\n st[p] = q[4]\n n[p] = s_h + 1\n p += 1\n\nodd = ["".join(st[a]) for a in range(Q) if ((n[a] + s_h) % 2 == 1) and (str(st[a]) != "0")]\nodd = "".join(odd)\neven = ["".join(st[a]) for a in range(Q) if ((n[a] + s_h) % 2 == 0) and (str(st[a]) != "0")]\neven = "".join(even)[::-1]\nif s_h % 2 == 1:\n S = S[::-1]\n\nb = [even, S, odd]\n#print(S,odd,even)\nprint("".join(b))'] | ['Runtime Error', 'Accepted'] | ['s251756137', 's203373848'] | [6388.0, 10772.0] | [22.0, 679.0] | [303, 622] |
p02756 | u750838232 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\n\nquery = [input() for _ in range(q)]\ncount = 0\n\n#memo = [[]for _ in range(10**5)]\nright = ""\nleft = ""\nfor qu in query:\n if len(qu.split()) == 1:\n count += 1\n right, left = left, right\n continue\n num, f, c = qu.split()\n num = int(num)\n\n if f == 1:\n left += c\n \n else:\n right += c\n\nprint(left[::-1] + s + right)\n', 's = input()\nq = int(input())\n\nquery = [input() for _ in range(q)]\ncount = 0\nright = ""\nleft = ""\nfor qu in query:\n if len(qu.split()) == 1:\n count += 1\n right, left = left, right\n continue\n num, f, c = qu.split()\n f = int(f)\n\n if f == 1:\n left += c\n \n else:\n right += c\nif count % 2 == 1:\n s = s[::-1]\n\nprint(left[::-1] + s + right)\n'] | ['Wrong Answer', 'Accepted'] | ['s295469058', 's458039838'] | [16888.0, 16888.0] | [455.0, 452.0] | [397, 391] |
p02756 | u752907966 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['def main():\n from collections import deque\n import sys\n input = sys.stdin.readline\n s=input()\n q=int(input())\n turn = 2\n d=deque(s)\n\n for _ in [0]*q:\n query = input()\n if query[0] == "1":\n t = int(query)\n turn = 3 - turn\n else:\n t,f,c = map(str,query.split())\n if (int(f) + turn)% 2 == 0:\n d.append(c)\n else:\n d.appendleft(c)\n if turn == 2:\n print("".join(d))\n else:\n print("".join(list(d)[::-1]))\nmain()\n', 's=input()\nq=int(input())\nfor _ in range(q):\n query = input()\n try:\n t = int(query)\n s = s[::-1]\n except ValueError:\n t,f,c = map(str,query.split())\n if f == 1:\n s = c + s\n if f == 2:\n s = s + c\nprint(s)', '\n\n#E \nn,p=map(int,input().split())\ns=input()\n\n\n\n#D\ndef main():\n s=input()\n q=int(input())\n turn = 2\n\n for _ in [0]*q:\n query = input()\n try:\n t = int(query)\n turn = 3 - turn\n except ValueError:\n t,f,c = map(str,query.split())\n if (int(f) + turn)% 2 == 0:\n s = s + c\n else:\n s = c + s\n if turn == 2:\n print(s)\n else:\n print(s[::-1])\nmain()', 'def main():\n from collections import deque\n import sys\n input = sys.stdin.readline\n s=input().rstrip()\n q=int(input().rstrip())\n turn = 2\n d=deque(s)\n\n for _ in [0]*q:\n query = input().rstrip()\n if query[0] == "1":\n t = int(query)\n turn = 3 - turn\n else:\n t,f,c = map(str,query.split())\n if (int(f) + turn)% 2 == 0:\n d.append(c)\n else:\n d.appendleft(c)\n if turn == 2:\n print("".join(d))\n else:\n print("".join(list(d)[::-1]))\nmain()\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s536352530', 's746721590', 's913473512', 's602782055'] | [10200.0, 3336.0, 3188.0, 10328.0] | [304.0, 2103.0, 19.0, 345.0] | [512, 268, 441, 539] |
p02756 | u760256928 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\nquery_list = []\nfor i in range(Q):\n query_list.append(input())\n\n\nM = 10 ** 6\nstart_position = int(M / 2)\nleft_position = start_position\nright_position = start_position + len(S)\nresult = ["-"] * M\nfor i in range(len(S)):\n # print(i + left_position)\n result[i + left_position] = S[i]\n\n# result = "".join(result[left_position:right_position])\n# print(result)\n# exit(0)\nreverse_flag = False\n\nfor i in range(Q):\n # print(i + 1)\n # print(result[left_position:right_position])\n q = query_list[i]\n # print(q)\n t = int(q[0])\n if t == 1:\n reverse_flag = not reverse_flag\n else:\n t, f, c = q.split()\n f = int(f)\n c = c\n if f == 1:\n if reverse_flag:\n result[right_position] = c\n right_position += 1\n else:\n result[left_position - 1] = c\n left_position -= 1\n else:\n if reverse_flag:\n result[left_position - 1] = c\n left_position -= 1\n else:\n result[right_position] = c\n right_position += 1\n # print(t, f, c, result)\n # print("--------")\n print(result[left_position:right_position])\n# result = str(result)\n# result = "".join(result)\n# print(result)\n# print(result[left_position:right_position])\n\nresult = "".join(result[left_position:right_position])\nif reverse_flag:\n result = result[::-1]\nprint(result)', 'S = input()\nQ = int(input())\nquery_list = []\nfor i in range(Q):\n query_list.append(input())\n\n\nM = 10 ** 6\nstart_position = int(M / 2)\nleft_position = start_position\nright_position = start_position + len(S)\nresult = ["-"] * M\nfor i in range(len(S)):\n # print(i + left_position)\n result[i + left_position] = S[i]\n\n# result = "".join(result[left_position:right_position])\n# print(result)\n# exit(0)\nreverse_flag = False\n\nfor i in range(Q):\n # print(i + 1)\n # print(result[left_position:right_position])\n q = query_list[i]\n # print(q)\n t = int(q[0])\n if t == 1:\n reverse_flag = not reverse_flag\n else:\n t, f, c = q.split()\n f = int(f)\n c = c\n if f == 1:\n if reverse_flag:\n result[right_position] = c\n right_position += 1\n else:\n result[left_position - 1] = c\n left_position -= 1\n else:\n if reverse_flag:\n result[left_position - 1] = c\n left_position -= 1\n else:\n result[right_position] = c\n right_position += 1\n # print(t, f, c, result)\n # print("--------")\n #print(result[left_position:right_position])\n# result = str(result)\n# result = "".join(result)\n# print(result)\n# print(result[left_position:right_position])\n\nresult = "".join(result[left_position:right_position])\nif reverse_flag:\n result = result[::-1]\nprint(result)'] | ['Runtime Error', 'Accepted'] | ['s780680204', 's815200856'] | [156920.0, 26384.0] | [2077.0, 521.0] | [1492, 1493] |
p02756 | u760771686 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\nP = [input().split() for i in range(Q)]\n\ncount = 0\nleft = ""\nright = ""\nfor query in P:\n if query[0]=="1":\n count+=1\n else:\n if query[1]=="1":\n if count%2==0:\n left+=query[2]\n else:\n right+=query[2]\n else:\n if count%2==0:\n right+=query[2]\n else:\n left+=query[2]\nif count%2==1:\n S=left[::-1]+S[::-1]+right\n \nprint(S)\n', 'S = input()\nQ = int(input())\nP = [input().split() for i in range(Q)]\n\ncount = 0\nleft = ""\nright = ""\nfor query in P:\n if query[0]=="1":\n count+=1\n else:\n if query[1]=="1":\n if count%2==0:\n left+=query[2]\n else:\n right+=query[2]\n else:\n if count%2==0:\n right+=query[2]\n else:\n left+=query[2]\n \nS = left[::-1]+S+right\nif count%2==1:\n S=S[::-1]\n \nprint(S)'] | ['Wrong Answer', 'Accepted'] | ['s632419590', 's287553106'] | [40436.0, 40436.0] | [433.0, 445.0] | [482, 504] |
p02756 | u762420987 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ninput = sys.stdin.readline\n\n\nfrom collections import deque\nreverse = -1\nS = deque(input())\nQ = int(input())\nfor _ in range(Q):\n Query = input().split()\n if Query[0] == "1":\n reverse *= -1\n else:\n if Query[1] == "1":\n if reverse == 1:\n S.append(Query[2])\n else:\n S.appendleft(Query[2])\n else:\n if reverse == 1:\n S.appendleft(Query[2])\n else:\n S.append(Query[2])\n\nans = "".join(S)\nif reverse == 1:\n ans = ans[::-1]\nprint(ans)', 'from collections import deque\nS = input()\nd = deque(S)\nQ = int(input())\nrev = False\nfor _ in range(Q):\n Q, *sub = input().split()\n if Q == "1":\n rev = not rev\n else:\n F, C = sub\n if F == "1":\n if rev:\n d.append(C)\n else:\n d.appendleft(C)\n else:\n if rev:\n d.appendleft(C)\n else:\n d.append(C)\nif rev:\n d.reverse()\nprint("".join(list(d)))\n'] | ['Wrong Answer', 'Accepted'] | ['s755628981', 's490300181'] | [8564.0, 8564.0] | [166.0, 495.0] | [571, 480] |
p02756 | u768896740 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\n\ns = list(s)\n\n\ndef query_1():\n global s\n s = s[-1::-1]\n\n\ndef query_2(s, a, b):\n if a == 2:\n s.append(b)\n elif a == 1:\n s.insert(0, b)\n\n\nfor i in range(q):\n array = list(input().split())\n if len(array) == 1:\n query_1()\n else:\n query_2(s, int(array[1]), array[2])\n\nfor i in s:\n print(i, end='')\n\n\n", "from collections import deque\n\ns = deque(input())\nq = int(input())\n\nflg_reverse = False\n\n\ndef query_1():\n global flg_reverse\n if flg_reverse is True:\n flg_reverse = False\n else:\n flg_reverse = True\n\n\n\ndef query_2(s, a, b):\n global flg_reverse\n if flg_reverse is False:\n if a == 2:\n s.append(b)\n elif a == 1:\n s.appendleft(b)\n else:\n if a == 1:\n s.append(b)\n elif a == 2:\n s.appendleft(b)\n\n\nfor i in range(q):\n array = list(input().split())\n if len(array) == 1:\n query_1()\n else:\n query_2(s, int(array[1]), array[2])\n\nif flg_reverse is False:\n for i in s:\n print(i, end='')\nelse:\n for i in range(len(s)-1, -1, -1):\n print(s[i], end='')\n\n", "from collections import deque\n\ns = deque(input())\nq = int(input())\n\nflg_reverse = False\n\n\ndef query_2(s, a, b):\n global flg_reverse\n if flg_reverse is False:\n if a == 2:\n s.append(b)\n elif a == 1:\n s.appendleft(b)\n else:\n if a == 1:\n s.append(b)\n elif a == 2:\n s.appendleft(b)\n\n\nfor i in range(q):\n array = list(input().split())\n if len(array) == 1:\n flg_reverse = not flg_reverse\n else:\n query_2(s, int(array[1]), array[2])\n\nif flg_reverse is False:\n for i in s:\n print(i, end='')\nelse:\n for i in range(len(s)-1, -1, -1):\n print(s[i], end='')\n\n", "s = input()\nq = int(input())\n\ns = list(s)\n\nflg_reverse = False\n\n\ndef query_1():\n global flg_reverse\n if flg_reverse is True:\n flg_reverse = False\n else:\n flg_reverse = True\n\n\n\ndef query_2(s, a, b):\n global flg_reverse\n if flg_reverse is False:\n if a == 2:\n s.append(b)\n elif a == 1:\n s.insert(0, b)\n else:\n if a == 1:\n s.append(b)\n elif a == 2:\n s.insert(0, b)\n\n\nfor i in range(q):\n array = list(input().split())\n if len(array) == 1:\n query_1()\n else:\n query_2(s, int(array[1]), array[2])\n\nif flg_reverse is False:\n for i in s:\n print(i, end='')\nelse:\n for i in range(len(s)-1, -1, -1):\n print(s[i], end='')\n\n\n\n", "from collections import deque\n\ns = deque(list(input()))\nq = int(input())\nflg = 1\nfor i in range(q):\n array = input().split(' ')\n if array[0] == '1':\n flg *= -1\n elif array[0] == '2':\n if array[1] == '1' and flg == 1 or array[1] == '2' and flg == -1:\n s.appendleft(array[2])\n else:\n s.append(array[2])\n\ns = list(s)\nif flg == -1:\n s = s[::-1]\n\ns = ''.join(s)\nprint(s)"] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s051711900', 's265968511', 's737169788', 's953396443', 's862040692'] | [6140.0, 9328.0, 7536.0, 4260.0, 10084.0] | [2104.0, 2104.0, 2104.0, 2104.0, 450.0] | [376, 783, 669, 758, 420] |
p02756 | u771007149 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['#D\nimport sys\ninput = sys.stdin.readline\ns = input()\nq = int(input())\nquery = []\nfor _ in range(q):\n t = list(map(str,input().split()))\n if t[0] == \'1\':\n s = s[::-1]\n else:\n if t[1] == "1":\n s = t[2] + s\n else:\n s = s + t[2]\n \nprint(s)', '#D\n#import sys\n#input = sys.stdin.readline\nfrom collections import deque\ns = deque(input())\nq = int(input())\n\nflg = False\n\nfor _ in range(q):\n t = tuple(map(str,input().split()))\n if t[0] == \'1\':\n if flg:\n flg = False\n else:\n flg = True\n else:\n if t[1] == "1" and flg == False:\n s.appendleft(t[2])\n elif t[1] == "1" and flg == True:\n s.append(t[2])\n elif t[1] == "2" and flg == False:\n s.append(t[2])\n else:\n s.appendleft(t[2])\n \n \nif flg:\n s.reverse()\nprint("".join(s))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s842744321', 's650904878'] | [3972.0, 8684.0] | [2104.0, 674.0] | [298, 649] |
p02756 | u775681539 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom collections import deque \ndef main():\n s = deque(readline().rstrip().decode())\n q = int(readline())\n\n \n dir = 1\n for _ in range(q):\n txt = readline().rstrip().decode()\n if txt[0] == '1':\n dir ^= 1\n elif txt[0] == '2':\n f = txt[2]\n c = txt[4]\n if ((dir==1) and (f==1)) or ((dir==0) and (f==2)):\n s.appendleft(c)\n else:\n s.append(c)\n if dir!=1:\n print(''.join(reversed(s)))\n else:\n print(''.join(s))\nif __name__ == '__main__':\n main()\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom collections import deque \ndef main():\n s = deque(readline().rstrip().decode())\n q = int(readline())\n dir = 1\n for _ in range(q):\n txt = readline().rstrip().decode()\n if txt[0] == '1':\n dir += 1\n dir%=2\n elif txt[0] == '2':\n f = txt[2]\n c = txt[4]\n if ((dir==1) and (f=='1')) or ((dir==0) and (f=='2')):\n s.appendleft(c)\n else:\n s.append(c)\n if dir==0:\n print(''.join(reversed(s)))\n else:\n print(''.join(s))\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s746868743', 's558447425'] | [8368.0, 8372.0] | [150.0, 155.0] | [724, 716] |
p02756 | u779170803 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["\nINT = lambda: int(input())\nINTM = lambda: map(int,input().split())\nSTRM = lambda: map(str,input().split())\nSTR = lambda: str(input())\nLIST = lambda: list(map(int,input().split()))\nLISTS = lambda: list(map(str,input().split()))\n\ndef query2(s,f,c,ct):\n if ct%2==1:\n s.reverse()\n \n if f=='1':\n s=c+s\n else:\n s=s+c\n \n \n #print(s)\n return s\n \ndef do():\n S=STR()\n q=INT()\n ct=0\n for i in range(q):\n qt=LISTS()\n if qt[0]=='1':\n ct+=1\n else:\n S=query2(S,qt[1],qt[2],ct)\n ct=0\n \n if ct%2==1:\n S.reverse()\n \n print(S)\n \nif __name__ == '__main__':\n do()", 'INT = lambda: int(input())\nINTM = lambda: map(int,input().split())\nSTRM = lambda: map(str,input().split())\nSTR = lambda: str(input())\nLIST = lambda: list(map(int,input().split()))\nLISTS = lambda: list(map(str,input().split()))\ndef do():\n s=STR()\n q=INT()\n l=\'\'\n r=\'\'\n ct=0\n for i in range(q):\n fc=LISTS()\n if fc[0]=="1":\n ct+=1\n else:\n if fc[1]=="1":\n if ct%2==0:\n l=fc[2]+l\n else:\n r=r+fc[2]\n else:\n if ct%2==1:\n l=fc[2]+l\n else:\n r=r+fc[2]\n \n sums=l+s+r\n if ct%2==1:\n ans=""\n for i in range(len(sums)-1,-1,-1):\n ans=ans+sums[i]\n else:\n ans=sums\n \n print(ans)\n \nif __name__ == \'__main__\':\n do()'] | ['Runtime Error', 'Accepted'] | ['s510510493', 's800641438'] | [3716.0, 10412.0] | [2104.0, 969.0] | [682, 871] |
p02756 | u785573018 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\ns = deque(input())\nq = int(input())\na = 0\nc = ""\nfor i in range(q):\n b = list(input().split())\n if b[0] == "1":\n if a == 0:\n a = 1\n else:\n a = 0\n else:\n if (a, b[1]) == (0, "1") or (a, b[1]) == (1, "2"):\n s.appendleft(0, b[2])\n else:\n s.append(b[2])\nif a == 0:\n for i in range(len(s)):\n c += s[i]\nelse:\n for i in range(len(s)):\n c += s[-i-1]\nprint(c)', 's = input()\nq = int(input())\na = 0\nc = ""\nd = ""\nfor i in range(q):\n b = list(input().split())\n if b[0] == "1":\n if a == 0:\n a = 1\n else:\n a = 0\n else:\n if (a, b[1]) == (0, "1") or (a, b[1]) == (1, "2"):\n c = b[2]+c\n else:\n d += b[2]\ns = c+s+d\nif a == 0:\n print(s)\nelse:\n print(s[::-1])'] | ['Runtime Error', 'Accepted'] | ['s683087728', 's473710200'] | [4212.0, 4696.0] | [23.0, 1646.0] | [481, 373] |
p02756 | u785578220 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["\ns = input()\nn = int(input())\ntmp =['','']\nc = 1\nfor i in range(n):\n t = list(map(str,input().split()))\n if t[0] == '1':\n c+=1\n else:\n C = (c%2==0)\n \n if t[1] == '1':\n C+=1\n C%=2\n tmp[C] = tmp[C] +t[2]\n else:\n tmp[C] = tmp[C] + t[2]\n # print(tmp)\nprint(tmp[0][::-1]+s+tmp[1])", "\ns = input()\nn = int(input())\ntmp =['',s]\nc = 1\nfor i in range(n):\n t = list(map(str,input().split()))\n if t[0] == '1':\n c+=1\n else:\n C = (c%2==0)\n \n if t[1] == '1':\n C+=1\n C%=2\n tmp[C] = tmp[C] +t[2]\n else:\n tmp[C] = tmp[C] + t[2]\n # print(tmp)\nprint(tmp[0][::-1]+tmp[1])", 's = input()\nT = ""\nn = int(input())\nfor i in range(n):\n # print(s,T)\n t = list(map(str,input().split()))\n if t[0] == "1":\n s,T = T,s\n else:\n if t[1] == "1":\n T += t[2]\n else:\n s += t[2]\n\nprint(T[::-1]+s)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s675519862', 's975196770', 's277637290'] | [4412.0, 4276.0, 4436.0] | [2104.0, 2104.0, 678.0] | [367, 364, 258] |
p02756 | u793666115 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\n\nli = [input() for i in range(q)]\n\nk= 0\n\nfor i in range(q):\n if li[0] == 1:\n k += 1\n else:\n li3 = li[i].split()\n if (int(li3[1])+k) % 2 == 0:\n s = s + li3[2]\n else:\n s = li3[2] + s\n\nif k % 2 == 0:\n print(s)\nelse:\n print(s[::-1])', 'from collections import deque\ns = input()\nq = int(input())\n\nli = [input() for i in range(q)]\nk = 0\nans = [s]\nans = deque(ans)\n\nfor i in li:\n if i == "1":\n k += 1\n else:\n if (int(i[2]) + k) % 2 == 0:\n ans.append(i[4])\n else:\n ans.appendleft(i[4])\n\nans = list(ans)\ns = "".join(ans)\nif k % 2 == 0:\n print(s)\nelse:\n print(s[::-1])'] | ['Runtime Error', 'Accepted'] | ['s008285917', 's494328724'] | [16484.0, 19548.0] | [2104.0, 376.0] | [319, 381] |
p02756 | u800058906 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s=input()\nq=int(input())\na=[list(map(str,input().split())) for i in range(q)]\n\nans=[]\nans.append(s)\n\nfor i in range(q):\n if len(a[i])==1:\n ans.insert(0,ans[-1])\n ans.append(ans[1])\n print(ans)\n ans.pop(1)\n ans.pop(-2)\n\n else:\n if a[i][1]=='1':\n ans.insert(0,a[i][2])\n else:\n ans.append(a[i][2])\n\nprint(''.join(ans))", "from collections import deque\n\ns=deque(input())\nq=int(input())\nqq=[list(input().split()) for i in range(q)]\n\nrl=1\nfleft=deque()\nfright=deque()\n\nfor i in qq:\n if i[0]=='1':\n rl*=-1\n else:\n if i[1]=='1':\n if rl==1:\n fleft.appendleft(i[2])\n else:\n fright.append(i[2])\n else:\n if rl==1:\n fright.append(i[2])\n else:\n fleft.appendleft(i[2])\n\nfleft.reverse()\n\ns.extendleft(fleft)\ns.extend(fright)\n\nif rl==-1:\n s.reverse()\n\nprint(''.join(s))"] | ['Runtime Error', 'Accepted'] | ['s947724924', 's202751666'] | [162188.0, 36424.0] | [2206.0, 360.0] | [348, 493] |
p02756 | u807028974 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = collections.deque(list(input()))\nq = int(input())\nrev = 0\nfor i in range(q):\n tfc = list(input().split())\n if tfc[0]=='1':\n rev = abs(rev-1)\n else:\n t,f,c = tfc\n if rev:\n if f=='1':\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if f=='1':\n s.appendleft(c)\n else:\n s.append(c)\nif rev:\n t = []\n for i in range(len(s)):\n t.append(s.pop())\n print(''.join(t))\nelse:\n print(''.join(s))", "import collections\n\ns = collections.deque(list(input()))\nq = int(input())\nrev = 0\nfor i in range(q):\n tfc = list(input().split())\n if tfc[0]=='1':\n rev = abs(rev-1)\n else:\n t,f,c = tfc\n if rev:\n if f=='1':\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if f=='1':\n s.appendleft(c)\n else:\n s.append(c)\nif rev:\n t = []\n for i in range(len(s)):\n t.append(s.pop())\n print(''.join(t))\nelse:\n print(''.join(s))"] | ['Runtime Error', 'Accepted'] | ['s029265658', 's746874840'] | [3064.0, 9180.0] | [17.0, 531.0] | [542, 562] |
p02756 | u809816772 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = str(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nA_S = ''\nS_A = ''\nfor i in range(Q):\n if querry[i][0] == '1':\n S = S[::-1]\n A_S = A_S[::-1]\n S_A = S_A[::-1]\n elif querry[i][0] == '2':\n if querry[i][1] == '1':\n A_S += querry[i][2] \n elif querry[i][1] == '2':\n S_A += querry[i][2]\n\nprint(A_S + S + S_A)", 'from collections import deque\nS = deque(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nreverse = False\nfor i in range(Q):\n if querry[i][0] == \'1\':\n reverse = not reverse\n elif querry[i][0] == \'2\':\n if querry[i][1] == \'1\':\n S.appendleft(querry[i][2])\n elif querry[i][1] == \'2\':\n S.append(querry[i][2])\n\nans=list(S)\n\nif reverse:\n print("".join(ans))\nelse:\n print("".join(reversed(ans)))', "S = str(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nfor i in range(Q):\n if querry[i][0] == '1':\n S = S[::-1]\n A_S = A_S[::-1]\n S_A = S_A[::-1]\n elif querry[i][0] == '2':\n if querry[i][1] == '1':\n A_S += querry[i][2] \n elif querry[i][1] == '2':\n S_A += querry[i][2]\n\nprint(A_S + S + S_A)", "S = str(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nA_S = ''\nS_A = ''\nfor i in range(Q):\n if querry[i][0] == '1':\n S = S[::-1]\n elif querry[i][0] == '2':\n if querry[i][1] == '1':\n A_S += querry[i][2] \n elif querry[i][1] == '2':\n S_A += querry[i][2]\n\nprint(A_S + S + S_A)", 'from collections import deque\nS = deque(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nfor i in range(Q):\n if querry[i][0] == \'1\':\n S.reverse\n elif querry[i][0] == \'2\':\n if querry[i][1] == \'1\':\n S.appendleft(querry[i][2])\n elif querry[i][1] == \'2\':\n S.append(querry[i][2])\n\nans=list(S)\n\nprint("".join(ans))', "S = str(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nfor i in range(Q):\n if querry[i][0] == '1':\n S = S[::-1]\n elif querry[i][0] == '2':\n if querry[i][1] == '1':\n A_S += querry[i][2] \n elif querry[i][1] == '2':\n S_A += querry[i][2]\n\nprint(A_S + S + S_A)", "S = str(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nfor i in range(Q):\n if querry[i][0] == '1':\n S = S[::-1]\n elif querry[i][0] == '2':\n if querry[i][1] == '1':\n A_S += querry[i][2] \n elif querry[i][1] == '2':\n S_A += querry[i][2]\n\nprint(A_S + S + S_A)", 'from collections import deque\nS = deque(input())\nQ = int(input())\nquerry = [list(map(str, input().split())) for i in range(Q)]\nreverse = False\nfor i in range(Q):\n if querry[i][0] == \'1\':\n reverse = not reverse\n elif querry[i][0] == \'2\':\n if querry[i][1] == \'1\':\n if reverse:\n S.append(querry[i][2])\n else:\n S.appendleft(querry[i][2])\n elif querry[i][1] == \'2\':\n if reverse:\n S.appendleft(querry[i][2])\n else:\n S.append(querry[i][2])\n\nans=list(S)\n\nif reverse:\n print("".join(reversed(ans)))\nelse:\n print("".join(ans))\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s314437613', 's314470872', 's476619691', 's496017630', 's547595746', 's782477231', 's976083877', 's918492520'] | [41556.0, 46836.0, 39156.0, 41472.0, 45172.0, 39156.0, 39284.0, 46316.0] | [2106.0, 677.0, 595.0, 2106.0, 672.0, 594.0, 600.0, 685.0] | [410, 479, 392, 362, 395, 344, 344, 654] |
p02756 | u811817592 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['# -*- coding: utf-8 -*-\nS = str(input())\nQ = int(input())\n\nrev_flag = 1\nhead_str = ""\ntail_str = ""\nfor _ in range(Q):\n query = str(input())\n if query[0] == "1":\n rev_flag *= -1\n else:\n h_or_t_flag = 1 if query[1] == "1" else -1\n h_or_t_flag *= rev_flag\n \n if h_or_t_flag == 1:\n head_str += query[2]\n else:\n tail_str += query[2]\n\nans = head_str[::-1] + S + tail_str\nprint(ans if rev_flag == 1 else ans[::-1])', 'resolve()\ndef resolve():\n S = str(input())\n Q = int(input())\n\n rev_flag = 1\n head_str = ""\n tail_str = ""\n for _ in range(Q):\n query = input() # contains spaces\n if query[0] == "1":\n rev_flag *= -1\n else:\n h_or_t_flag = 1 if query[2] == "1" else -1\n h_or_t_flag *= rev_flag\n\n if h_or_t_flag == 1:\n head_str += query[4]\n else:\n tail_str += query[4]\n\n ans = head_str[::-1] + S + tail_str\n print(ans if rev_flag == 1 else ans[::-1])\n', 'def resolve():\n S = str(input())\n Q = int(input())\n\n rev_flag = 1\n head_str = ""\n tail_str = ""\n for _ in range(Q):\n query = input() # contains spaces\n if query[0] == "1":\n rev_flag *= -1\n else:\n h_or_t_flag = 1 if query[2] == "1" else -1\n h_or_t_flag *= rev_flag\n\n if h_or_t_flag == 1:\n head_str += query[4]\n else:\n tail_str += query[4]\n\n ans = head_str[::-1] + S + tail_str\n print(ans if rev_flag == 1 else ans[::-1])\nresolve()\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s179082398', 's348673057', 's457127450'] | [4540.0, 3064.0, 4540.0] | [455.0, 17.0, 351.0] | [481, 560, 560] |
p02756 | u812867074 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\nq1 = [list(map(str,input().split())) for i in range(q)]\n\nap = ["", ""]\nrevCount = 0\n\nfor j in q1:\n if j[0] == "1":\n revCount = (revCount+1) % 2\n\n else:\n if revCount == 0:\n ap[j[1] - 1] = ap[j[1] - 1] + j[2]\n else:\n ap[j[1] - 2] = ap[j[1] - 2] + j[2]\n \n\nif revCount == 0:\n ap[0] = ap[0][::-1]\n print(ap[0] + s + ap[1])\n\nelse:\n aps = (s+ap[1])[::-1]\n print(aps + ap[0])\n', 's = input()\nq = int(input())\nq1 = [list(map(str,input().split())) for i in range(q)]\n\nap = ["", ""]\nrevCount = 0\n\nfor j in q1:\n if j[0] == "1":\n revCount = (revCount+1) % 2\n\n else:\n if revCount == 0:\n ap[int(j[1]) - 1] = ap[int(j[1]) - 1] + j[2]\n else:\n ap[int(j[1]) - 2] = ap[int(j[1]) - 2] + j[2]\n \n\nif revCount == 0:\n ap[0] = ap[0][::-1]\n print(ap[0] + s + ap[1])\n\nelse:\n aps = (s+ap[1])[::-1]\n print(aps + ap[0])'] | ['Runtime Error', 'Accepted'] | ['s784895310', 's162119588'] | [39284.0, 40552.0] | [589.0, 1835.0] | [429, 448] |
p02756 | u814271993 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\nans = 0\n \nfor i in range(q):\n c = list(map(str, input().split()))\n if c[0] == '1':\n ans +=1\n ans = ans&2\n if c[0] == '2':\n if (int(c[1])+ans)%2== 1 :\n s = c[2] + s\n if (int(c[1])+ans)%2== 0 :\n s = s + c[2]\n \nif ans == 1:\n s = s[::-1]\n \nprint(s)", "s = input()\nq = int(input())\nl = [s]\n\nfor i in range(q):\n c = list(map(str, input().split()))\n if c[0] == '1':\n s = s[::-1]\n if c[0] == '2':\n if c[1] == '1':\n l.insert(0,c[2])\n s =''.join(l)\n if c[1] == '2':\n l.append(c[2])\n s =''.join(l)\n\nprint(s)", 's=input()\nq=int(input())\nf=""\nb=""\nr=0\nfor i in range(q):\n query=input().split()\n if int(query[0])==1:\n r=1-r\n else:\n if (r^(int(query[1])-1))==0:\n f+=query[2]\n else:\n b+=query[2]\nret=f[::-1]+s+b\nif r:\n ret=ret[::-1]\nprint(ret)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s407395035', 's845033547', 's486741570'] | [9888.0, 9624.0, 9824.0] | [2206.0, 2205.0, 366.0] | [329, 322, 250] |
p02756 | u814885356 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input()\nQ = int(input())\nfor i in range(Q):\n Query_i = list(map(str, input().split()))\n if Query_i[0]=='1':\n S = S[::-1]\n elif Query_i[1] = '1':\n S = Query_i[2] + S\n else:\n S = S + Query_i[2]\nprint(S)", "S = input()\nQ = int(input())\nhead = True # True: left side is head\nfor i in range(Q):\n Query_i = list(map(str, input().split()))\n if Query_i[0]=='1':\n head = not head\n elif Query_i[1] == '1' and head:\n S = Query_i[2] + S\n elif Query_i[1] == '1' and not head:\n S = S + Query_i[2]\n elif Query_i[1] == '2' and head:\n S = S + Query_i[2]\n else Query_i[1] == '2' and not head:\n S = Query_i[2] + S\n if not head:\n S = S[::-1]\nprint(S)", "S = input()\nQ = int(input())\nfor i in range(Q):\n Query_i = list(map(str, input().split()))\n if Query_i[0]=='1':\n S = S[::-1]\n elif Query_i[1] = '1':\n S = Query_i[2] + S\n else:\n S = S + Query_i[2]", "S = input()\nQ = int(input())\nhead = True # True: left side is head\nfor i in range(Q):\n Query_i = list(map(str, input().split()))\n if Query_i[0]=='1':\n head = not head\n elif Query_i[1] == '1' and head:\n S = Query_i[2] + S\n elif Query_i[1] == '1' and not head:\n S = S + Query_i[2]\n elif Query_i[1] == '2' and head:\n S = S + Query_i[2]\n else: # Query_i[1] == '2' and not head:\n S = Query_i[2] + S\n if not head:\n S = S[::-1]\nprint(S)", "from collections import deque\n\nS = deque(input())\nQ = int(input())\nflip = False # False: left side is the head\nfor i in range(Q):\n Query_i = list(map(str, input().split()))\n if Query_i[0]=='1':\n flip = not flip\n elif Query_i[1] == '1' and not flip:\n S.appendleft(Query_i[2])\n elif Query_i[1] == '1' and flip:\n S.append(Query_i[2])\n elif Query_i[1] == '2' and not flip:\n S.append(Query_i[2])\n elif Query_i[1] == '2' and flip:\n S.appendleft(Query_i[2])\nif flip:\n S.reverse()\nprint(''.join(S))"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s153336080', 's473436730', 's738945811', 's837048846', 's772333273'] | [3064.0, 2940.0, 2940.0, 3872.0, 8692.0] | [17.0, 17.0, 17.0, 2104.0, 678.0] | [217, 451, 208, 454, 512] |
p02756 | u815304751 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\n\nt = ''\nfor i in range(q):\n query = input().split()\n if query[0] == '1':\n s,t = t,s\n else:\n if query[1] == '1':\n t = t + query[2]\n else:\n s += query[2]\n\nprint(t + s)\n", "s = input()\nq = int(input())\n\nt = ''\nfor i in range(q):\n query = input().split()\n if query[0] == '1':\n s,t = t,s\n else:\n if query[1] == '1':\n t += query[2] \n else:\n s += query[2]\n\nprint(t[::-1] + s)\n"] | ['Wrong Answer', 'Accepted'] | ['s202158008', 's682479590'] | [4468.0, 4480.0] | [429.0, 416.0] | [247, 251] |
p02756 | u815763296 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\nfrom collections import deque\n\n\ndef LS():\n return list(input().split())\n\n\nS = deque(input())\nQ = int(input())\nrev = 0\nfor i in range(Q):\n A = LS()\n if A[0] == "1":\n rev += 1\n rev %= 2\n else:\n if A[1] == "1":\n if rev == 0:\n S.appendleft(A[2])\n else:\n S.append(A[2])\n else:\n if rev == 0:\n S.append(A[2])\n else:\n S.appendleft(A[2])\nif rev == 0:\n for i in range(len(S)):\n print(S[i], end="")\nelse:\n for i in range(len(S)-1, -1, -1):\n print(S[i], end="")\n', 'import sys\nfrom collections import deque\n\n\ndef LS():\n return list(input().split())\n\n\nS = deque(input())\nQ = int(input())\nrev = 0\nfor i in range(Q):\n A = LS()\n if A[0] == "1":\n rev += 1\n rev %= 2\n else:\n if A[1] == "1":\n if rev == 0:\n S.appendleft(A[2])\n else:\n S.append(A[2])\n else:\n if rev == 0:\n S.append(A[2])\n else:\n S.appendleft(A[2])\nif rev == 0:\n print(\'\'.join(S))\nelse:\n S.reverse()\n print(\'\'.join(S))\n'] | ['Time Limit Exceeded', 'Accepted'] | ['s924186712', 's096324530'] | [12036.0, 14188.0] | [2051.0, 336.0] | [625, 563] |
p02756 | u821775079 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S=input()\nQ=int(input())\nquery=[]\nfor _ in range(Q):\n query.append(input().split())\n\nfor i in query:\n if i[0]=="1":\n S=S[::-1]\n else:\n if i[1]==1:\n S=i[2]+S\n else:\n S=S+i[2]\nprint(S)', 'S=input()\nQ=int(input())\nquery=[]\nfor _ in range(Q):\n query.append(input().split())\n\nflag = True\n\nfor i in query:\n if i[0]=="1":\n flag = not flag\n# S=S[::-1]\n else:\n if flag:\n if i[1]=="1":\n S=i[2]+S\n else:\n S=S+i[2]\n else:\n if i[1]=="1":\n S=S+i[2][::-1]\n else:\n S=i[2][::-1]+S\nif flag:\n print(S)\nelse:\n print(S[::-1]', 'S=input()\nQ=int(input())\nquery=[]\nfor _ in range(Q):\n query.append(input().split())\n\nflag = True\nt=""\nu=""\n\nfor i in query:\n if i[0]=="1":\n u,t=t,u\n flag = not flag\n# S=S[::-1]\n else:\n if i[1]=="1":\n t+=i[2]\n else:\n u+=i[2]\nif flag:\n print(t[::-1]+S+u)\nelse:\n print(t[::-1]+S[::-1]+u)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s236899639', 's610356553', 's723653266'] | [41700.0, 3064.0, 40436.0] | [2107.0, 17.0, 441.0] | [234, 464, 356] |
p02756 | u822961851 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\ndef resolve():\n s = deque(input().split())\n q = int(input())\n for i in range(q):\n list = input().split()\n t = list[0]\n if t == "1" :\n if len(s) > 1:\n l, r = s.popleft(), s. pop()\n s.appendleft(r)\n s.append(l)\n else:\n f, c = list[1], list[2]\n if f == "1":\n s.appendleft(c)\n else:\n s.append(c)\n print("".join(s))', 'from collections import deque\n\n\ndef resolve():\n s = input()\n s = deque(s)\n q = int(input())\n for i in range(q):\n list = input().split()\n t = list[0]\n if t == "1":\n if len(s) > 1:\n l, r = s.popleft(), s.pop()\n s.appendleft(r)\n s.append(l)\n elif list[1] == "1":\n s.appendleft(list[2])\n else:\n s.append(list[2])\n s = \'\'.join(s)\n print(s)', 'from collections import deque\n\ndef resolve():\n s = input()\n s = deque(s)\n q = int(input())\n flag = False\n for i in range(q):\n list = input().split()\n t = list[0]\n if t == "1":\n if len(s) > 1:\n flag = not flag\n elif (list[1] == "1") ^ flag:\n s.appendleft(list[2])\n else:\n s.append(list[2])\n s = \'\'.join(s)\n if flag:\n s = \'\'.join(reversed(s))\n print(s)\n\nif __name__ == \'__main__\':\n resolve()'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s281437306', 's500485647', 's591757775'] | [3316.0, 3316.0, 8436.0] | [21.0, 20.0, 392.0] | [499, 465, 506] |
p02756 | u826929627 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n \nS = input()\nQ = int(input())\nS = deque(S)\n \nflg_reverse = False\n \nfor q in range(Q):\n _ = input()\n if _[0] == '1':\n flg_reverse = flg_reverse ^ True\n else:\n _T, _F, _C = _.split()\n \n if _F == '1':\n if cnt_reverse % 2 == 0:\n S.appendleft(_C)\n else:\n S.append(_C)\n else:\n if cnt_reverse % 2 == 0:\n S.append(_C)\n else:\n S.appendleft(_C)\n \nS = list(S)\n\nif flg_reverse:\n S.reverse()\n \nprint(''.join(S))", "from collections import deque\n \nS = input()\nQ = int(input())\nS = deque(S)\n\n\nflg_reverse = False\nfor q in range(Q):\n _ = input()\n if _[0] == '1':\n flg_reverse = flg_reverse ^ True\n else:\n _T, _F, _C = _.split()\n if (_F == '1') ^ flg_reverse:\n S.appendleft(_C)\n else:\n S.append(_C) \n\nS = list(S)\n\nif flg_reverse:\n S.reverse()\n\nprint(''.join(S))"] | ['Runtime Error', 'Accepted'] | ['s149611689', 's850708480'] | [4212.0, 8556.0] | [24.0, 428.0] | [589, 402] |
p02756 | u829859091 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input()\nQ = int(input())\n\nnum_turn = 0\n\nfront = []\nend = []\n\nfor i in range(Q):\n query = input()\n if query == '1':\n num_turn += 1\n else:\n _, f, c = query.split()\n f = int(f)\n if f == 1:\n if num_turn%2==0:\n front.append(c)\n else:\n end.append(c)\n else:\n if num_turn%2==0:\n end.append(c)\n else:\n front.append(c)\n\nS = list(S)\nif num_turn%2==1:\n ans = end[::-1] + S[::-1] + front\nelse:\n ans = front + S + end[::-1]\nprint(''.join(ans))", "S = input()\nQ = int(input())\n\nnum_turn = 0\n\nfront = []\nend = []\n\nfor i in range(Q):\n query = input()\n if query == '1':\n num_turn += 1\n else:\n _, f, c = query.split()\n f = int(f)\n if f == 1:\n if num_turn%2==0:\n front.append(c)\n else:\n end.append(c)\n else:\n if num_turn%2==0:\n end.append(c)\n else:\n front.append(c)\n\nS = list(S)\nif num_turn%2==1:\n ans = end[::-1] + S[::-1] + front\nelse:\n ans = front[::-1] + S + end\nprint(''.join(ans))"] | ['Wrong Answer', 'Accepted'] | ['s919383022', 's482274765'] | [10324.0, 10044.0] | [498.0, 503.0] | [587, 587] |
p02756 | u830592648 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S=(input())\nQ=int(input())\ncnt_re=0\ns=''\nfor i in range(Q):\n q=list(input().split())\n if q[0]=='1':\n cnt_re+=1\n else:\n if (int(q[1])+cnt_re)%2==1:\n s=s+q[2]\n else:\n S=S+q[2]\nprint(S,s)\nif cnt_re%2==1:\n print(S[::-1]+s)\nelse:\n print(s[::-1]+S)", "S=(input())\nQ=int(input())\ncnt_re=0\ns=''\nfor i in range(Q):\n q=list(input().split())\n if q[0]=='1':\n cnt_re+=1\n else:\n if (int(q[1])+cnt_re)%2==1:\n s=s+q[2]\n else:\n S=S+q[2]\nif cnt_re%2==1:\n print(S[::-1]+s)\nelse:\n print(s[::-1]+S)"] | ['Wrong Answer', 'Accepted'] | ['s093787409', 's038227177'] | [4828.0, 4480.0] | [634.0, 620.0] | [300, 289] |
p02756 | u840974625 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nsc = s[::-1]\nn = int(input())\nl = [list(input().split()) for i in range(n)]\n\n#last = 1\n\nfor i in range(n):\n if l[i][0] == '1':\n save = s\n s = sc\n sc = save\n \nif last > 0:\n print(s)\nelse:\n print(sc)", "s = input()\n#sc = s[::-1]\nn = int(input())\nl = [list(input().split()) for i in range(n)]\n\nfor i in range(n):\n if l[i][0] == '1':\n save = s\n #s = sc\n #sc = save\n elif l[i][1] == '1':\n s = l[i][2] + s\n #sc += l[i][2]\n else:\n s += l[i][2]\n #sc = l[i][2] + sc\n\nprint(s)", "s = input()\nsc = s[::-1]\nn = int(input())\nl = [list(input().split()) for i in range(n)]\n\nlast = 1\n\nfor i in range(n):\n if l[i][0] == '1':\n last = last * -1\n \nif last > 0:\n print(s)\nelse:\n print(sc)", "import copy\nfrom collections import deque\ns = deque(input())\nsc = copy.deepcopy(s) \nsc.reverse()\nn = int(input())\nl = [list(input().split()) for i in range(n)]\n\nfor i in range(n):\n if l[i][0] == '1':\n save = s\n s = sc\n sc = save\n elif l[i][1] == '1':\n s.appendleft(l[i][2])\n sc.append(l[i][2])\n #s = l[i][2] + s\n #sc += l[i][2]\n else:\n s.append(l[i][2])\n sc.appendleft(l[i][2])\n #s += l[i][2]\n #sc = l[i][2] + sc\n\nprint(''.join(s))\n"] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s254588590', 's516501593', 's674444208', 's525642388'] | [29940.0, 30752.0, 30068.0, 38008.0] | [470.0, 2106.0, 449.0, 601.0] | [242, 323, 220, 518] |
p02756 | u841531687 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\nimport sys\ninput = sys.stdin.readline\n\ns = deque(list(input()))\nq = int(input())\nrev = -1\n\nfor i in range(q):\n a = list(input().split())\n if a[0] == '1': #T1\n rev *= -1 \n \n else: #T2\n if a[1] == '1': #Fi = 1\n if rev == -1:\n s.appendleft(a[2])\n else:\n s.append(a[2])\n \n else: #Fi = 2\n if rev == -1:\n s.append(a[2])\n else:\n s.appendleft(a[2])\n \nif rev == -1:\n print(''.join(s))\nelse:\n s = list(s)\n print(''.join(s[::-1]))", "from collections import deque\n#import sys\n#input = sys.stdin.readline\n\ns = deque(list(input()))\nq = int(input())\nrev = -1\n\nfor i in range(q):\n a = list(input().split())\n if a[0] == '1': #T1\n rev *= -1 \n \n else: #T2\n if a[1] == '1': #Fi = 1\n if rev == -1:\n s.appendleft(a[2])\n else:\n s.append(a[2])\n \n else: #Fi = 2\n if rev == -1:\n s.append(a[2])\n else:\n s.appendleft(a[2])\n \nif rev == -1:\n print(''.join(s))\nelse:\n s = list(s)\n print(''.join(s[::-1]))"] | ['Wrong Answer', 'Accepted'] | ['s786494073', 's992287917'] | [10212.0, 10212.0] | [230.0, 481.0] | [625, 627] |
p02756 | u846226907 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import numpy as np\nimport sys\n\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\n\nleft = []\nright = []\nrev = False\nfor i in range(Q):\n l = input().split()\n if l[0] == '1':\n rev = not rev\n else:\n if ( l[1] == '1' and not rev) or (l[1] == '2' and rev):\n left.append(l[2])\n else:\n right.append(l[2])\n\nS = ''.join(left[::-1]) + S + ''.join(right)\n\nif rev:\n print(S[::-1])\nelse:\n print(S)", 'import sys\ninput = sys.stdin.readline\ns = input()\n\nn = int(input())\n\n#y = []\n\n# x = input()\n# y.append(x)\n#\n#print(y)\n#print(y[0].split())\nfor i in range(n):\n x = input()\n if int(x[0]) == 1:\n s = s[::-1]\n else:\n x = x.split()\n if int(x[1]) == 1:\n s = x[2] + s\n\n else:\n s = s + x[2]\n\n\nprint(s)', "import numpy as np\nimport sys\n\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\n\nleft = []\nright = []\nrev = False\n\nfor i in range(Q):\n l = input().split()\n if l[0] == '1':\n rev = not rev\n else:\n if (l[1] == '1' and not rev) or (l[1] == '2' and rev):\n left.append(l[2])\n else:\n right.append(l[2])\n\nS = ''.join(left[::-1]) + S + ''.join(right)\n\nif rev:\n print(S[::-1].replace('\\n',''))\nelse:\n print(S.replace('\\n',''))\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s063740381', 's111336674', 's232419818'] | [15712.0, 3912.0, 15664.0] | [310.0, 2104.0, 293.0] | [448, 376, 483] |
p02756 | u850779832 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\nhead = []\ntail = []\nrev=False\nfor _ in range(q):\n tmp = list(input.split())\n if tmp[0] == '1'\n \tif rev == False:\n rev == True\n else:\n rev == False\n if tmp[0] == '2':\n if tmp[1] == '1':\n if rev == False:\n head.append(tmp[2])\n if rev == True:\n tail.append(tmp[2])\n if tmp[1] == '2':\n if rev == False:\n tail.append(tmp[2])\n if rev == True:\n head.append(tmp[2])\nhead = ''.join(map(str,head))\ntail = ''.join(map(str,tail))\n\nans=head[::-1]+s+tail \nif rev==True:\n ans=ans[::-1]\nprint(ans)", "s = input()\nq = int(input())\nhead = []\ntail = []\nrev=False\nfor _ in range(q):\n tmp = list(input().split())\n if tmp[0] == '1':\n if rev == False:\n rev = True\n else:\n rev = False\n if tmp[0] == '2':\n if tmp[1] == '1':\n if rev == False:\n head.append(tmp[2])\n if rev == True:\n tail.append(tmp[2])\n if tmp[1] == '2':\n if rev == False:\n tail.append(tmp[2])\n if rev == True:\n head.append(tmp[2])\nhead = ''.join(map(str,head))\ntail = ''.join(map(str,tail))\n\nans = head[::-1]+s+tail\nif rev == True:\n ans = ans[::-1]\nprint(ans)"] | ['Runtime Error', 'Accepted'] | ['s064645518', 's856131380'] | [2940.0, 6272.0] | [17.0, 530.0] | [581, 589] |
p02756 | u851319680 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["N = input()\nQ = int(input())\nQs = []\nfor _ in range(Q):\n Qs.append(list(map(str, input().split())) ) \nk=0\nfor q in Qs:\n if q[0] == '1':\n k+=1\n else:\n if (k%2 ==0\u3000& q[1] == '1') or (k%2==1 & q[1] == '2'):\n N = q[2] + N\n else:\n N = N + q[2]\n\nif k%2==1:\n ans = ''.join(list(reversed(N)))\n print(ans)\nelse:\n print(N)\n", "from collections import deque\n\nN = deque(input())\nQ = int(input())\nQs = []\nfor _ in range(Q):\n Qs.append(list(map(str, input().split())) ) \nk=0\nfor q in Qs:\n if q[0] == '1':\n k+=1\n else:\n if k%2 ==0:\n if q[1]=='1':\n N.appendleft(q[2])\n else:\n N.append(q[2])\n else:\n if q[1]=='2':\n N.appendleft(q[2])\n else:\n N.append(q[2])\nif k%2==1:\n ans=''\n for x in reversed(N):\n ans += x\nelse:\n ans=''\n for x in N:\n ans += x\n\nprint(ans)\n"] | ['Runtime Error', 'Accepted'] | ['s975854516', 's990096053'] | [2940.0, 42964.0] | [18.0, 749.0] | [376, 584] |
p02756 | u853547292 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft= right = ""\nfor operation in qs:\n if operation[0] == \'1\':\n n = not n\n if operation[0] == \'2\':\n t , f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left=c+left\n elif f == 2:\n right+=c\ns = left+s+right\nprint(s[::-1] if n else s', '\n\n\n\ns = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft= right = ""\nfor operation in qs:\n if operation[0] == \'1\':\n n = not n\n if operation[0] == \'2\':\n t , f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left=c+left\n elif f == 2:\n right+=c\ns = left+s+right\nprint(s[::-1] if n else s)'] | ['Runtime Error', 'Accepted'] | ['s902679183', 's161380634'] | [3064.0, 41524.0] | [18.0, 1407.0] | [416, 421] |
p02756 | u856282038 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nnumQ = int(input())\nlead = 1\n\nfor i in range(numQ):\n Q = input()\n if Q[0] == "1":\n lead *= -1\n else:\n if Q[1] == 1:\n if lead == 1:\n S = Q[2] + S\n else:\n S = S + Q[2]\n else:\n if lead == 1:\n S = S + Q[2]\n else:\n S = Q[2] + S\nif lead == -1:\n S = S[::-1]\n\nprint(S)\n \n ', 'S = input()\nnumQ = int(input())\nlead = 1\n\nfor i in range(numQ):\n Q = input()\n if Q[0] == "1":\n lead *= -1\n else:\n if Q[2] == 1:\n if lead == 1:\n S = Q[4] + S\n else:\n S = S + Q[4]\n else:\n if lead == 1:\n S = S + Q[4]\n else:\n S = Q[4] + S\nif lead == -1:\n S = S[::-1]\n\nprint(S)\n \n ', 'S = input()\nnumQ = int(input())\nlead = 1\nfront = ""\nrear = ""\nfor i in range(numQ):\n Q = input()\n if Q[0] == "1":\n lead *= -1\n else:\n if Q[2] == "1":\n if lead == 1:\n front = Q[4] + front\n else:\n rear = rear + Q[4]\n else:\n if lead == 1:\n rear = rear + Q[4]\n else:\n front = Q[4] + front\nS = front + S + rear\nif lead == -1:\n S = S[::-1]\n\nprint(S)\n \n '] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s958274016', 's963937690', 's350021036'] | [3992.0, 3992.0, 4436.0] | [2104.0, 2104.0, 1362.0] | [347, 347, 418] |
p02756 | u863442865 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["def main():\n from sys import stdin\n #input = sys.stdin.readline\n sys.setrecursionlimit(10000000)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations\n #from itertools import accumulate, product\n from bisect import bisect_left,bisect_right\n from math import floor, ceil\n #from operator import itemgetter\n\n #mod = 1000000007\n\n S = input()\n Q = int(input())\n mae = ''\n usiro = ''\n s = True\n for _ in range(Q):\n q = stdin.readline()\n if q[0]=='1':\n s = not s\n else:\n if q[2]=='1' and s:\n mae = q[4] + mae\n elif q[2]=='2' and s:\n usiro = usiro + q[4] \n elif q[2]=='2' and not s:\n mae = q[4] + mae\n else:\n usiro = usiro + q[4]\n if s:\n print(mae+S+usiro)\n else:\n print(usiro[::-1]+S[::-1]+mae[::-1])\n\n\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n from sys import stdin\n #input = sys.stdin.readline\n sys.setrecursionlimit(10000000)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations\n #from itertools import accumulate, product\n from bisect import bisect_left,bisect_right\n from math import floor, ceil\n #from operator import itemgetter\n\n #mod = 1000000007\n\n S = input()\n Q = int(input())\n mae = ''\n usiro = ''\n s = True\n for _ in range(Q):\n q = stdin.readline()\n if q[0]=='1':\n s = not s\n else:\n if q[1]=='1' and s:\n mae = q[2] + mae\n elif q[1]=='2' and s:\n usiro = usiro + q[2] \n elif q[1]=='2' and not s:\n mae = q[2] + mae\n else:\n usiro = usiro + q[2]\n if s:\n print(mae+S+usiro)\n else:\n print(usiro[::-1]+S[::-1]+mae[::-1])\n\n\n\n\nif __name__ == '__main__':\n main()\n", "\n\n#A:\n#B:\n#C:\n#D:\n#DP\n\n\n\nimport sys\n#input = sys.stdin.readline\nsys.setrecursionlimit(10000000)\nfrom collections import Counter, deque\n#from collections import defaultdict\nfrom itertools import combinations, permutations\n#from itertools import accumulate, product\nfrom bisect import bisect_left,bisect_right\nfrom math import floor, ceil\n#from operator import itemgetter\n\n#mod = 1000000007\n\ndef main():\n from sys import stdin\n #input = sys.stdin.readline\n sys.setrecursionlimit(10000000)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations\n #from itertools import accumulate, product\n from bisect import bisect_left,bisect_right\n from math import floor, ceil\n #from operator import itemgetter\n\n #mod = 1000000007\n\n S = list(stdin.readline().rstrip())\n Q = int(input())\n mae = []\n usiro =[]\n s = True\n for _ in range(Q):\n q = stdin.readline()\n if q[0]=='1':\n s = not s\n else:\n if q[2]=='1' and s:\n mae.append(q[4])\n elif q[2]=='2' and s:\n usiro.append(q[4])\n elif q[2]=='2' and not s:\n mae.append(q[4])\n else:\n usiro.append(q[4])\n if s:\n print(''.join(mae[::-1]+S+usiro))\n else:\n print(''.join(usiro[::-1]+S[::-1]+mae))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s189684401', 's810247298', 's692814456'] | [3064.0, 3064.0, 10248.0] | [18.0, 18.0, 116.0] | [1017, 1017, 1555] |
p02756 | u864197622 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ninput = sys.stdin.readline\n\nS = input()\nL = []\nR = []\nrev = 0\nfor _ in range(int(input())):\n A = input().split()\n if A[0] == "1":\n rev ^= 1\n else:\n if (int(A[1]) ^ rev) & 1:\n L.append(A[2])\n else:\n R.append(A[2])\n\nif rev:\n print("".join(R[::-1]) + S[::-1] + "".join(L))\nelse:\n print("".join(L[::-1]) + S + "".join(R))\n', 'import sys\nS = sys.stdin.readline().rstrip()\nL = []\nR = []\nrev = 0\nfor _ in range(int(sys.stdin.readline().rstrip())):\n A = sys.stdin.readline().rstrip().split()\n if A[0] == "1":\n rev ^= 1\n else:\n if (int(A[1]) ^ rev) & 1:\n L.append(A[2])\n else:\n R.append(A[2])\n\nif rev:\n print("".join(R[::-1]) + S[::-1] + "".join(L))\nelse:\n print("".join(L[::-1]) + S + "".join(R))'] | ['Wrong Answer', 'Accepted'] | ['s430902060', 's718874760'] | [6364.0, 6252.0] | [205.0, 252.0] | [387, 424] |
p02756 | u866374539 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=input()\nq=int(input())\n\nrev=1\n\nfor _ in range(0,q):\n n=input()\n# print(n[0:1])\n if n[0:1]=="1":\n# print("!")\n rev*=-1\n else:\n m=n.split()\n x=[]\n if (m[1]=="1" and rev==1) or (m[1]=="2" and rev==-1):\n x.append(m[2])\n x.append(s)\n s=\'\'.join(x)\n# s=m[2]+s\n else:\n x.append(s)\n x.append(m[2])\n s=\'\'.join(x)\n# s=s+m[2]\nif rev==1:\n print(s)\nelse:\n print(s[::-1])\n', 's=input()\nq=int(input())\n\nrev=1\n\nsf=[]\nsb=[]\n\nfor _ in range(0,q):\n n=input().split()\n if n[0]=="1":\n rev*=-1\n else:\n if (n[1]=="1" and rev==1) or (n[1]=="2" and rev==-1):\n sf.append(n[2])\n else:\n sb.append(n[2])\n\ns=\'\'.join(sf)+s+\'\'.join(sb)\n\nif rev==1:\n print(s)\nelse:\n print(s[::-1])\n', 'sf=""\nsb=input()\nq=int(input())\n\nrev=1\n\nfor _ in range(0,q):\n n=input().split()\n if n[0]=="1":\n rev*=-1\n else:\n a,b=n[1],n[2]\n if (a=="1" and rev==1) or (a=="2" and rev==-1):\n sf+=b\n else:\n sb+=b\n\ns=sf[::-1]+sb\n\nif rev==1:\n print(s)\nelse:\n print(s[::-1])\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s130846821', 's935851585', 's628043263'] | [2940.0, 5712.0, 4480.0] | [17.0, 377.0, 457.0] | [415, 310, 282] |
p02756 | u867848444 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\ninput=sys.stdin.readline\ns = input()\nq = int(input())\n\nrev = 0\nfor i in range(q):\n inp = list(input().split())\n if inp[0] == '1':rev = rev ^ 1\n if inp[0] == '2':\n if (inp[1] == '1' and rev == 0) or (inp[1] == '2' and rev == 1):\n s = inp[2] + s\n else:\n s = s + inp[2]\n\nprint(s if rev == 0 else s[::-1])", "from collections import deque\ns=input()\nq=int(input())\nans_str=deque([s])\ncnt=0\nfor _ in range(q):\n Q=list(input().split())\n if Q[0]=='1':\n cnt=1 if cnt==0 else 0\n\n else:\n if Q[1]=='1':\n if cnt==0:\n ans_str.appendleft(Q[-1])\n else:\n ans_str.append(Q[-1][::-1])\n\n else:\n if cnt==0:\n ans_str.append(Q[-1])\n else:\n ans_str.appendleft(Q[-1][::-1])\n print(ans_str,cnt,Q)\n\nans=list(ans_str) if cnt==0 else list(ans_str)[::-1]\nprint(*ans,sep='')", "from collections import deque\ns = input()\ns = deque(s)\nq = int(input())\n\nrev = 0\nfor i in range(q):\n inp = list(input().split())\n if inp[0] == '1':rev = rev^1\n else:\n if (inp[1] == '1' and rev == 0) or (inp[1] == '2' and rev == 1):\n s.appendleft(inp[2])\n else:\n s.append(inp[2])\n\ns = list(s)\nif rev == 1:s = s[::-1]\nprint(*s, sep = '')"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s595922724', 's893845573', 's124240009'] | [3976.0, 134884.0, 12400.0] | [2104.0, 923.0, 570.0] | [357, 575, 380] |
p02756 | u871934301 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ninput = sys.stdin.readline\nS=input()\nQ=int(input())\nfor i in range(Q):\n L=list(input().split())\n if L[0]=="1":\n S=S[::-1]\n else:\n if L[1]=="1":\n S=L[2]+S\n else:\n S=S+L[2]\nprint(S)\n \n\n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n \n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n', 'from collections import deque\nS=input()\nd=deque()\nfor i in S:\n d.append(i)\nQ=int(input())\nFlag=True\nfor i in range(Q):\n L=input().split()\n if L[0]=="1":\n Flag=not Flag\n else:\n if L[1]=="1" and Flag or L[1]=="2" and not Flag:\n d.appendleft(L[2])\n else:\n d.append(L[2])\nans=""\nfor i in d:\n ans+=i\nif not Flag:\n ans=ans[::-1]\nprint(ans)\n \n\n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n \n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s959005391', 's618576104'] | [9828.0, 12576.0] | [2205.0, 340.0] | [510, 662] |
p02756 | u875541136 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nn = int(input())\nprint(n)\nfor i in range(n):\n li = input().split()\n if(li[0] == '1'):\n s = s[::-1]\n else:\n if(li[1] == '1'):\n s = li[2] + s\n else:\n s = s + li[2]\nprint(s)", "s = input()\ntop = ''\nn = int(input())\nisReverse = False\nfor i in range(n):\n Q = input().split()\n if(Q[0] == '1'):\n isReverse = not isReverse\n else:\n if Q[1] == '1':\n if isReverse: s += Q[2]\n else: top += Q[2]\n else:\n if isReverse: top += Q[2]\n else: s += Q[2]\nif isReverse: s = s[::-1] + top\nelse: s = top[::-1] + s\nprint(s)"] | ['Wrong Answer', 'Accepted'] | ['s756081318', 's505909460'] | [3744.0, 4192.0] | [2104.0, 423.0] | [234, 398] |
p02756 | u878129968 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = list(input().split())\nq = int(input())\nd = deque(S)\nrev_cnt = 0\nfor ind in range(q):\n cur_list = list(input().split())\n #print(cur_list)\n if int(cur_list[0]) == 1:\n rev_cnt += 1\n else:\n f = int(cur_list[1])\n c = cur_list[2]\n if (rev_cnt + f) % 2 == 0:\n d.append(c)\n else:\n d.appendleft(c) \nS = list(d)\nif rev_cnt %2 == 1:\n S.reverse()\nprint("".join(S))', 'S = input()\nq = int(input())\nhead = ""\ntail = ""\nrev_cnt = 1\nfor ind in range(q):\n cur_list = list(input().split())\n #print(cur_list)\n if int(cur_list[0]) == 1:\n rev_cnt *= -1\n else:\n f = int(cur_list[1])\n c = cur_list[2]\n if f == 1:\n if rev_cnt == 1:\n head += c\n else:\n tail += c\n elif f == 2:\n if rev_cnt == 1:\n tail += c\n else:\n head += c\n \nS = head[::-1] + S + tail \nif rev_cnt == -1:\n S = S[::-1]\n \nprint("".join(S))'] | ['Runtime Error', 'Accepted'] | ['s984746128', 's039571665'] | [3188.0, 6368.0] | [18.0, 654.0] | [436, 591] |
p02756 | u878545651 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['a = input()\nif \'A\' in a and \'B\' in a:\n print("Yes")\nelse:\n print("No")\n--------------------------------\nn, a, b = map(int, input().split())\nperiod = a+b\ntimes = n//period\nk = n%period\nn = a if k >a else k\nprint(times*a + n)\n---------------------------\na, b = [int(x) for x in input().split()]\n \nif (b < a):\n temp = b\n b = a\n a = temp\n \n \nx = 1\nwhile True:\n if (int(x*0.08) == a and int(x*0.1) == b):\n print(x)\n break\n else:\n if (x > 1500):\n print(-1)\n break\n else:\n x += 1\n\n1, 2 and 3\n------------------------\ns = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft= right = ""\nfor operation in qs:\n if operation[0] == \'1\':\n n = not n\n if operation[0] == \'2\':\n t , f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left=c+left\n elif f == 2:\n right+=c\ns = left+s+right\nprint(s[::-1] if n else s)', 's = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft= right = ""\nfor operation in qs:\n if operation[0] == \'1\':\n n = not n\n if operation[0] == \'2\':\n t , f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left=c+left\n elif f == 2:\n right+=c\ns = left+s+right\nprint(s[::-1] if n else s)'] | ['Runtime Error', 'Accepted'] | ['s029951496', 's048727123'] | [2940.0, 40668.0] | [17.0, 1416.0] | [1010, 417] |
p02756 | u884323674 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import numpy as np\n\nS = input()\nQ = int(input())\nq = np.array([[i for i in input().split()] for j in range(Q)])\n\nfor i in range(Q):\n if q[i,0] == "1":\n S = S[::-1]\n elif q[i,0] == "2":\n if q[i,1] == "1":\n S = q[i,2] + S\n else:\n S = S + q[i,2]\n \nprint(S)', 'S = input()\nQ = int(input())\nq = [[i for i in input().split()] for j in range(Q)]\n\nf = ""\nl = ""\ncount = 0\nfor i in range(Q):\n if q[i][0] == "1":\n count += 1\n elif q[i][0] == "2":\n if count % 2 == 0:\n if q[i][1] == "1":\n f = q[i][2] + f\n else:\n l = l + q[i][2]\n else:\n if q[i][1] == "1":\n l = l + q[i][2]\n else:\n f = q[i][2] + f\n \nif count % 2 == 0:\n print(f+S+l)\nelse:\n print((f+S+l)[::-1])'] | ['Runtime Error', 'Accepted'] | ['s877365956', 's905468080'] | [38012.0, 28040.0] | [2109.0, 1459.0] | [313, 535] |
p02756 | u886655280 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from sys import stdin\n\nS = input()\nQ = int(input())\n\nT_list = []\nfor q in range(Q):\n T = stdin.readline()\n T_list.append(T)\n\nfor t in T_list:\n if t == '1':\n S = S[::-1]\n\n else:\n T, f, c = t.split()\n\n if f == '1':\n S = c + S\n else:\n S = S + c\n\nprint(S) \n", "from sys import stdin\n\nS = input()\nQ = int(input())\n\nreverse_flg = False\n\nformer_list = []\nlatter_list = []\n\nfor q in range(Q):\n T = stdin.readline()[:-1]\n\n if T == '1':\n if reverse_flg:\n reverse_flg = False\n else:\n reverse_flg = True\n \n else:\n t, f, c = T.split()\n if (f == '1' and reverse_flg == False) or (f == '2' and reverse_flg == True):\n former_list.append(c)\n else:\n latter_list.append(c)\n\n\nif reverse_flg:\n latter_list = ''.join(reversed(latter_list))\n former_list = ''.join(former_list)\n S = ''.join(list(reversed(S)))\n S = ''.join([latter_list, S, former_list])\n\nelse:\n former_list = ''.join(reversed(former_list))\n latter_list = ''.join(latter_list)\n S = ''.join([former_list, S, latter_list])\n\nprint(S) \n"] | ['Runtime Error', 'Accepted'] | ['s431822985', 's978616773'] | [16520.0, 6288.0] | [2104.0, 196.0] | [315, 829] |
p02756 | u887207211 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\n\nstdin = sys.stdin\n\nns = lambda : stdin.readline().rstrip()\nni = lambda : int(ns())\nna = lambda : list(map(int, stdin.readline().split()))\nsys.setrecursionlimit(10 ** 7)\n\ndef main():\n s = ns()\n Q = ni()\n\n T1 = 0\n FrontS = ""\n BackS = ""\n for _ in range(Q):\n T = stdin.readline().split()\n if T[0] == "1":\n T1 += 1\n else:\n if T1 % 2 == 0:\n \n if T[1] == "1":\n FrontS = T[2] + FrontS\n else:\n BackS += T[2]\n else:\n \n if T[1] == "1":\n BackS = T[2] + BackS\n else:\n FrontS += T[2]\n \n if T1 % 2 == 0:\n print(FrontS + s + BackS)\n else:\n print(BackS + s[::-1] + FrontS)\n\nif __name__ == \'__main__\':\n main()', 'import sys\n\nstdin = sys.stdin\n\nns = lambda : stdin.readline().rstrip()\nni = lambda : int(ns())\nna = lambda : list(map(int, stdin.readline().split()))\nsys.setrecursionlimit(10 ** 7)\n\ndef main():\n s = ns()\n Q = ni()\n\n T1 = 0\n FrontS = ""\n BackS = ""\n for _ in range(Q):\n T = stdin.readline().split()\n if T[0] == "1":\n FrontS, BackS = BackS, FrontS\n T1 += 1\n else:\n if T[1] == "1":\n FrontS += T[2]\n else:\n BackS += T[2]\n \n FrontS = FrontS[::-1]\n\n if T1 % 2 == 0:\n print(FrontS + s + BackS)\n else:\n print(FrontS + s[::-1] + BackS)\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s185053385', 's273166003'] | [4472.0, 4408.0] | [1083.0, 148.0] | [909, 717] |
p02756 | u888092736 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\nfrom functools import reduce\nfrom operator import add\nimport sys\n\ninput = sys.stdin.readline\n\ns = deque(list(input()))\nq = int(input())\n\nrev_cnt = 0\nfor i in range(q):\n query = input().split()\n if query[0] == '2':\n if (query[1] == '1' and rev_cnt % 2 == 0) or ((query[1] == '2' and rev_cnt % 2 == 1)):\n s.appendleft(query[2])\n else:\n s.append(query[2])\n else:\n rev_cnt += 1\n\nres = reduce(add, s)\nif rev_cnt % 2 == 1:\n res = res[::-1]\n\nprint(res)\n", 'from collections import deque\nimport sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nq = deque(input())\nQ = int(input())\nflipped = False\nfor _ in range(Q):\n q_t, *q_b = input().split()\n if q_t == "1":\n flipped = not flipped\n else:\n F, C = q_b\n if (F == "2" and not flipped) or (F == "1" and flipped):\n q.append(C)\n else:\n q.appendleft(C)\nq = list(q)\nif flipped:\n print("".join(q[::-1]))\nelse:\n print("".join(q))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s083727744', 's185555721'] | [6864.0, 13836.0] | [2104.0, 175.0] | [531, 491] |
p02756 | u890601274 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import math\nS = input()\nQ = int(input())\n\nlr = 'left'\n\ndef reverse_list(lr):\n if lr == 'right'\n return 'left'\n else return 'right'\n\ndef moji_tuika(S, f, c, lr):\n if f == 1 and lr == 'left':\n return c + S\n elif f == 1 and lr == 'right':\n return S + c\n elif f == 2 and lr == 'left':\n return S + c\n else:\n return c + S\nq = []\nfor i in range(Q):\n temp = input().split()\n if len(temp) == 1:\n q.append(1)\n else:\n q.append(temp)\n\nfor i in q:\n if type(i) == int:\n lr = reverse_list(lr)\n elif int(i[0]) == 2:\n S = moji_tuika(S,int(i[1]),i[2],lr)\n\nif lr == 'right':\n S = list(S)\n S.reverse()\n S = ''.join(S)\n\n\nprint(S)\n", "from collections import deque\n\nS = input()\nQ = int(input())\n\nlr = 'left'\n\ndef reverse_list(lr):\n if lr == 'right':\n return 'left'\n else:\n return 'right'\n\ndef moji_tuika(S, f, c, lr):\n if f == 1 and lr == 'left':\n S.appendleft(c)\n elif f == 1 and lr == 'right':\n S.append(c)\n elif f == 2 and lr == 'left':\n S.append(c)\n else:\n S.appendleft(c)\n return S\n\nq = []\nfor i in range(Q):\n temp = input().split()\n if len(temp) == 1:\n q.append(1)\n else:\n q.append(temp)\n\nS = deque(list(S))\nfor i in q:\n\n if type(i) == int:\n lr = reverse_list(lr)\n elif int(i[0]) == 2:\n S = moji_tuika(S,int(i[1]),i[2],lr)\nif lr == 'right':\n S.reverse()\n\nS = ''.join(S)\nprint(S)\n"] | ['Runtime Error', 'Accepted'] | ['s339018436', 's457346488'] | [2940.0, 44516.0] | [18.0, 639.0] | [714, 759] |
p02756 | u891884439 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nSlist = [S[i] for i in range(len(S))]\nQ = int(input())\nQuery = [list(input().split()) for i in range(Q)]\nQlen = len(Query)\ncnt = 0\nlast = []\nhead = []\nfor i in range(Qlen):\n if int(Query[i][0]) == 1:\n cnt +=1\n else:\n if int(Query[i][1]) == 1: \n if cnt % 2 != 0: \n last = last + [Query[i][2]]\n else:\n head = [Query[i][2]] + head\n else: \n if cnt % 2 != 0:\n head = [Query[i][2]] + head\n else:\n last = last + [Query[i][2]]\nif cnt % 2 == 0:\n print(head + "".join(Slist) + last)\nelse:\n Slist = Slist[::-1]\n head = head[::-1]\n last = last[::-1]\n print("".join(last + Slist + head))\n \n', 'S = input()\nSlist = [S[i] for i in range(len(S))]\nQ = int(input())\nQuery = [list(input().split()) for i in range(Q)]\nQlen = len(Query)\ncnt = 0\nlast = []\nhead = []\nfor i in range(Qlen):\n if int(Query[i][0]) == 1:\n cnt +=1\n else:\n if int(Query[i][1]) == 1: \n if cnt % 2 != 0: \n last = last + [Query[i][2]]\n else:\n head = [Query[i][2]] + head\n else: \n if cnt % 2 != 0:\n head = [Query[i][2]] + head\n else:\n last = last + [Query[i][2]]\nif cnt % 2 == 0:\n print(head + "".join(Slist) + last)\nelse:\n Slist = Slist[::-1]\n head = head[::-1]\n last = last[::-1]\n print("".join(last + Slist + head))\n \n', 'S = input()\nSlist = [S[i] for i in range(len(S))]\nQ = int(input())\nQuery = [list(input().split()) for i in range(Q)]\nQlen = len(Query)\nreverse = False\nback = []\nhead = []\n\nfor idx, value in enumerate(Query):\n if value[0] == "1":\n reverse ^= True\n head, back = back, head\n else:\n if value[1] == "1":\n back = back + [value[2]]\n else:\n head = head + [value[2]]\nif reverse == False:\n print( "".join(head.reverse()) + "".join(Slist) + "".join(back) )\n\nelse:\n print( \'\'.join(reversed(head)) + "".join(Slist[::-1]) + "".join(back))', 'S = input()\nSlist = [S[i] for i in range(len(S))]\nQ = int(input())\nQuery = [list(input().split()) for i in range(Q)]\nQlen = len(Query)\ncnt = 0\nlast = []\nhead = []\nfor i in range(Qlen):\n if int(Query[i][0]) == 1:\n cnt +=1\n else:\n if int(Query[i][1]) == 1: \n if cnt % 2 != 0: \n last = last + [Query[i][2]]\n else:\n head = [Query[i][2]] + head\n else: \n if cnt % 2 != 0:\n head = [Query[i][2]] + head\n else:\n last = last + [Query[i][2]]\nif cnt % 2 == 0:\n print(head + "".join(Slist) + last)\nelse:\n Slist = Slist[::-1]\n head = head[::-1]\n last = last[::-1]\n print("".join(last + Slist + head))\n \n', 'S = input()\nSlist = [S[i] for i in range(len(S))]\nQ = int(input())\nQuery = [list(input().split()) for i in range(Q)]\nQlen = len(Query)\nreverse = False\nback = []\nhead = []\n\nfor idx, value in enumerate(Query):\n if value[0] == "1":\n reverse ^= True\n head, back = back, head\n else:\n if value[1] == "1":\n back = back + [value[2]]\n else:\n head = head + [value[2]]\n\nif reverse == False:\n head.reverse()\n print("".join(head + Slist + back))\nelse:\n head.reverse()\n print("".join(head + Slist[::-1] + back))', 'S = input()\nSlist = [S[i] for i in range(len(S))]\nQ = int(input())\nQuery = [list(input().split()) for i in range(Q)]\nQlen = len(Query)\nreverse = False\nback = []\nhead = []\n\nfor idx, value in enumerate(Query):\n if value[0] == "1":\n reverse ^= True\n head, back = back, head\n else:\n if value[1] == "1":\n head += [value[2]]\n else:\n back += [value[2]]\n\nif reverse == False:\n head.reverse()\n print("".join(head + Slist + back))\nelse:\n head.reverse()\n print("".join(head + Slist[::-1] + back))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s022266197', 's284623891', 's382902266', 's647655725', 's983384739', 's331846103'] | [32804.0, 32500.0, 32888.0, 32680.0, 33104.0, 36772.0] | [2105.0, 2106.0, 2109.0, 2105.0, 2109.0, 510.0] | [799, 799, 586, 799, 565, 553] |
p02756 | u891945807 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = list(input().rstrip())\nQ = int(input().rstrip())\n\n\nq = []\nfor n in range(Q):\n q.append(list(input().rstrip().split()))\n\n#print(q)\ndef rev(olist):\n nlist = olist[::-1]\n return nlist\n\ndef addhead(olist,ele):\n nlist = olist.insert(0,ele)\n return nlist\n \ndef addtail(olist,ele):\n nlist = olist.append(ele)\n return nlist\n\ndef rev2(flg):\n if flg == 0:\n flg = 1\n else:\n flg = 0\n return flg\n\ndef add(olist,ele,j,flg,head,tail):\n if j == '1' and flg == 0:\n head.insert(0,ele)\n elif j == '1' and flg == 1:\n tail.append(ele)\n elif j == '2' and flg == 0:\n tail.append(ele)\n elif j == '2' and flg == 1:\n head.insert(0,ele)\n\nflg = 0\nhead = []\ntail = []\n\nfor n in range(Q):\n \n if q[n][0] == '1':\n flg = rev2(flg)\n \n else:\n print(q[n][2])\n add(S,q[n][2],q[n][1],flg,head,tail)\n\nans = head + S + tail\n\nif flg == 1:\n ans = rev(ans)\n \nprint(''.join(ans))\n\n", "S = list(input().rstrip())\nQ = int(input().rstrip())\n\n\nq = []\nfor n in range(Q):\n q.append(list(input().rstrip().split()))\n\n#print(q)\ndef rev(olist):\n nlist = olist[::-1]\n return nlist\n\ndef addhead(olist,ele):\n nlist = olist.insert(0,ele)\n return nlist\n \ndef addtail(olist,ele):\n nlist = olist.append(ele)\n return nlist\nv = []\nfor n in range(Q):\n if q[n][0] == '1':\n S = rev(S)\n else:\n if q[n][1] == '1':\n S.append(q[n][2])\n else:\n S.insert(0,q[n][2])\n\nprint(''.join(S))\n\n", "S = input().rstrip()\nQ = int(input().rstrip())\n\n\nq = []\nfor n in range(Q):\n q.append(list(input().rstrip().split()))\n\n#print(q)\ndef rev(olist):\n nlist = olist[::-1]\n return nlist\n\ndef addhead(olist,ele):\n nlist = olist.insert(0,ele)\n return nlist\n \ndef addtail(olist,ele):\n nlist = olist.append(ele)\n return nlist\n\ndef rev2(flg):\n if flg == 0:\n flg = 1\n else:\n flg = 0\n return flg\n\ndef add(olist,ele,j,flg,head,tail):\n if j == '1' and flg == 0:\n head.insert(0,ele)\n elif j == '1' and flg == 1:\n tail.append(ele)\n elif j == '2' and flg == 0:\n tail.append(ele)\n elif j == '2' and flg == 1:\n head.insert(0,ele)\n \ndef add2(olist,ele,j,flg,head,tail):\n if j == '1' and flg == 0:\n head = ele + head\n elif j == '1' and flg == 1:\n tail = tail + ele\n elif j == '2' and flg == 0:\n tail = tail + ele\n elif j == '2' and flg == 1:\n head = ele + head\n return head,tail\nflg = 0\n#head = []\n#tail = []\nhead=''\ntail = ''\nfor n in range(Q):\n \n if q[n][0] == '1':\n flg = rev2(flg)\n \n else:\n head,tail = add2(S,q[n][2],q[n][1],flg,head,tail)\n\n\nans = head + S + tail\n\nif flg == 1:\n ans1 = rev(list(ans))\n print(''.join(ans1))\nelse:\n print(ans)\n\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s449682439', 's515837496', 's730000343'] | [34924.0, 32740.0, 34580.0] | [2106.0, 2105.0, 1746.0] | [890, 502, 1188] |
p02756 | u895592784 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input('')\nQ = int(input(''))\nrev_flag = 1\nfor i in range(Q):\n str = input('')\n if(str.count(' ') == 0 and str == '1'):\n rev_flag = -rev_flags\n elif(str[0] == '2' and ((str[2] == '1' and rev_flag == 1) or (str[2] == '2' and rev_flag == -1))):\n S = str[4] + S\n elif(str[0] == '2' and ((str[2] == '2' and rev_flag == 1) or (str[2] == '1' and rev_flag == -1))):\n S = S + str[4]\nif rev_flag == 1:\n print(S)\nelif rev_flag == -1:\n print(S[::-1])\n", "S = input('')\nQ = int(input(''))\nhead, tail, rev_flag = '', '', 1\nfor i in range(Q):\n char = input()\n if char == '1':\n rev_flag *= -1\n else:\n t, f, c = char.split()\n if (f == '1' and rev_flag == 1) or (f == '2' and rev_flag == -1):\n head = c + head\n elif (f == '2' and rev_flag == 1) or (f == '1' and rev_flag == -1):\n tail = tail + c\nif rev_flag == 1:\n print(head, S, tail, sep='')\nelse:\n print(tail[::-1], S[::-1], head[::-1], sep='')\n"] | ['Runtime Error', 'Accepted'] | ['s653036104', 's222336036'] | [3740.0, 4064.0] | [2104.0, 1475.0] | [482, 502] |
p02756 | u898999125 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\ninput=sys.stdin.readline\n\ns=input()\nq=int(input())\nfor i in range(q):\n t=input()\n if t=='1':\n s=s[::-1]\n else:\n t, f, c = map(str, t.split())\n if f =='1':\n s=c+s\n else:\n s=s+c\nprint(s)", "s=input()\nq=int(input())\nhead=''\nfoot=''\n\na=0\nfor i in range(q):\n t=input()\n if t=='1':\n a=a^1\n else:\n t, f, c = map(str, t.split())\n f=int(f)\n if (f^a)&1==0:\n foot+=c\n else:\n head+=c\ns=head[::-1]+s+foot\nif a==1:\n s=s[::-1]\nprint(s)"] | ['Runtime Error', 'Accepted'] | ['s923349050', 's365397687'] | [3760.0, 4468.0] | [2104.0, 742.0] | [220, 261] |
p02756 | u900848911 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\ns = deque(input())\nq = int(input())\nrev = 0 \n\nfor _ in range(q):\n t = input().split()\n\n if len(t) == 1:\n rev ^= 1\n else:\n if rev == 1:\n if t[1] == '1':\n s.append(t[2])\n else:\n s.appendleft(t[2])\n else:\n if t[1] == '1':\n s.appendleft(t[2])\n else:\n s.append(t[2])\n\nif rev == 1:\n s.reverse()\n\nfor i in range(len(word)):\n print(s[i],end='')\n\nprint()\n", "from collections import deque\n\ns = deque(input())\nq = int(input())\nrev = 0 \n\nfor _ in range(q):\n t = input().split()\n\n if len(t) == 1:\n rev ^= 1\n else:\n if rev == 1:\n if t[1] == '1':\n s.append(t[2])\n else:\n s.appendleft(t[2])\n else:\n if t[1] == '1':\n s.appendleft(t[2])\n else:\n s.append(t[2])\n\nif rev == 1:\n s.reverse()\n\nprint(''.join(s))\n"] | ['Runtime Error', 'Accepted'] | ['s302345460', 's472059399'] | [5876.0, 8436.0] | [403.0, 412.0] | [560, 519] |
p02756 | u903699277 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['def main():\n S = list(str(input()))\n Q = int(input())\n SS = [list(input(_).split()) for _ in range(Q)] # [[abc],[def],[ghi]]\n for s in SS:\n if len(s) == 1 and int(s[0]) == 1:\n S.reverse()\n elif int(s[1]) == 1:\n S = list(s[2]) + S\n elif int(s[1]) == 2:\n S.append(s[2])\n\n ans = ""\n for i in S:\n ans += i\n print(ans)\n\nmain()', 'def main():\n S = list(str(input()))\n Q = int(input())\n SS = [list(input(_).split()) for _ in range(Q)] # [[abc],[def],[ghi]]\n J = True\n for s in SS:\n if len(s) == 1 and int(s[0]) == 1:\n J = not J\n elif int(s[1]) == 1:\n if J: S = list(s[2]) + S\n elif not J: S = S + list(s[2])\n elif int(s[1]) == 2:\n if not J: S = list(s[2]) + S\n elif J: S = S + list(s[2])\n\n ans = ""\n if J:\n for i in S:\n ans += i\n else:\n for i in S[::-1]:\n ans +=i\n print(ans)\n\nmain()', 'def main():\n S = input()\n Q = int(input())\n H = True\n A = "" #\n B = ""\n for _ in range(Q): \n q = list(input().split())\n if q[0] == "1": H = not H\n elif q[1] == "1" and H: A = q[2] + A\n elif q[1] == "1" and not H: B = B + q[2]\n elif q[1] == "2" and H: B = B + q[2]\n elif q[1] == "2" and not H: A = q[2] + A\n\n ans = A + S + B\n if H: print(ans)\n else: print(ans[::-1])\n\nmain()'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s261376672', 's270816672', 's467085863'] | [33328.0, 34892.0, 4588.0] | [2110.0, 2106.0, 1552.0] | [404, 589, 487] |
p02756 | u909375661 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\ndef input(): return sys.stdin.buffer.readline().rstrip()\nS = input()\nQ = int(input())\nqs = list(input() for _ in range(Q))\nrev = False\nfor q in qs:\n q = q.split()\n if q[0] == '1':\n rev = not(rev)\n else:\n if (q[1]=='1' and rev is False) or (q[1]=='2' and rev is True):\n S = q[2] + S\n else:\n S = S + q[2]\nprint(S if rev == 0 else S[::-1])", "from collections import deque\nS=input()\nd=deque(S)\nrev=False\nQ=int(input())\nfor i in range(Q):\n Que=input()\n if(Que=='1'):\n rev=True if not rev else False\n else:\n T,F,C=map(str,Que.split())\n if(F=='1'):\n if(not rev):\n d.appendleft(C)\n else:\n d.append(C)\n elif(F=='2'):\n if(not rev):\n d.append(C)\n else:\n d.appendleft(C)\nif(not rev):\n for i in range(len(d)):\n print(d[i],end='')\nelse:\n for i in reversed(range(len(d))):\n print(d[i],end='')\n", 'import sys\nfrom collections import deque\ndef input(): return sys.stdin.readline().rstrip()\nS = deque(input())\nQ = int(input())\nrev = False\n\nfor _ in range(Q):\n q = input().split()\n if q[0] == \'1\':\n rev = not(rev)\n else:\n if (q[1]==\'1\' and rev is False) or (q[1]==\'2\' and rev is True):\n S.appendleft(q[2])\n else:\n S.append(q[2])\n\nfor i in (range(len(S)) if rev is False: else reversed(range(len(S)))):\n print(S[i], end="")\nelse:\n print("")', "import sys\nfrom collections import deque\ndef input(): return sys.stdin.readline().rstrip()\nS = deque(input())\nrev = False\napdlft = S.appendleft\napd = S.append\n\nfor _ in range(int(input())):\n q = input().split()\n if q[0] == '1':\n rev = not(rev)\n else:\n if (q[1]=='1' and rev is False) or (q[1]=='2' and rev is True):\n apdlft(q[2])\n else:\n apd(q[2])\n\nif rev:\n print((''.join(S))[::-1])\nelse:\n print(''.join(S))"] | ['Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Accepted'] | ['s316424752', 's583958513', 's778750722', 's148087296'] | [13188.0, 9576.0, 3060.0, 8436.0] | [2104.0, 2104.0, 17.0, 217.0] | [399, 600, 496, 466] |
p02756 | u909991537 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\nS = input()\nQ = int(input())\n\nq = deque()\nrev = 0\n\nfor s in S:\n q.append(s)\n\nfor _ in range(Q):\n TFC = input()\n if len(TFC) == 1: # T == 1\n rev ^= 1\n else:\n T, F, C = (i for i in TFC.split()) \n if F == '1' and rev:\n q.append(C)\n else:\n q.appendleft(C)\n \nans = ''.join(q)\n\nif reverse:\n print(ans[::-1])\nelse:\n print(ans)", "from collections import deque\n\nS = input()\nQ = int(input())\n\nq = deque()\nrev = 1\n\nfor s in S:\n q.append(s)\n\nfor _ in range(Q):\n TFC = input()\n if len(TFC) == 1: # T == 1\n rev ^= 1\n else:\n T, F, C = (i for i in TFC.split()) \n if F == '2' and rev:\n q.append(C)\n else:\n q.appendleft(C)\n \nans = ''.join(q)\n\nif rev:\n print(ans[::-1])\nelse:\n print(ans)", "from collections import deque\n\nS = input()\nQ = int(input())\n\nq = deque()\nrev = 0\n\nfor s in S:\n q.append(s)\n\nfor _ in range(Q):\n TFC = input()\n if len(TFC) == 1: # T == 1\n rev ^= 1\n else:\n T, F, C = (i for i in TFC.split()) \n if (F == '2' and not rev) or (F == '1' and rev):\n q.append(C)\n else:\n q.appendleft(C)\n \nans = ''.join(q)\n\nif rev:\n print(ans[::-1])\nelse:\n print(ans)"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s031238040', 's834211713', 's939879296'] | [8564.0, 8564.0, 8564.0] | [582.0, 586.0, 641.0] | [384, 380, 408] |
p02756 | u919235786 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S=input()\nq=int(input())\ns=[]\nfor i in S:\n s.append(i)\nt=1\nfor i in range(q):\n qv=list(input().split())\n if qv[0]=='1':\n t^=1\n else:\n if int(qv[1])^t==0:\n s.insert(0,qv[2])\n else:\n s.append(qv[2])\n \nif t==0:\n for j in range(len(s)):\n ss.append(s[-1-j])\nans=''.join(s)\nprint(ans)", "S=input()\nq=int(input())\ns=[]\nfor i in S:\n s.append(i)\nt=1\nfor i in range(q):\n qv=list(input().split())\n if qv[0]=='1':\n t^=1\n else:\n if int(qv[1])^t==0:\n s.insert(0,qv[2])\n else:\n s.append(qv[2])\n \nif t==0:\n ss=s.copy()\n s=[]\n for j in range(len(s)):\n s.append(ss[-1-j])\nans=''.join(s)\nprint(ans)", "s=input()\nq=int(input())\ns=[]\nr=[]\nfor i in S:\n s.append(i)\nt=1\nfor i in range(q):\n qv=list(input().split())\n if qv[0]=='1':\n t^=1\n else:\n if int(qv[1])^t==0 or int(qv[1])^t==2:\n r.append(qv[2])\n else:\n s.append(qv[2])\n \nif t==0:\n ss=s.copy()\n s=[]\n for j in range(len(ss)):\n s.append(ss[-1-j])\n ans=s\n ans.extend(r)\nelse:\n rr=r.copy()\n r=[]\n for j in range(len(rr)):\n r.append(rr[-1-j])\n ans=r\n ans.extend(s)\nanswer=''.join(ans)\nprint(answer)", "S=input()\nq=int(input())\ns=[]\nfor i in S:\n s.append(i)\nt=1\nfor i in range(q):\n qv=list(input().split())\n if qv[0]=='1':\n t^=1\n else:\n if int(qv[1])^t==0 or nt(qv[1])^t==2:\n s.insert(0,qv[2])\n else:\n s.append(qv[2])\n \nif t==0:\n ss=s.copy()\n s=[]\n for j in range(len(ss)):\n s.append(ss[-1-j])\nans=''.join(s)\nprint(ans)", "S=input()\nq=int(input())\ns=[]\nr=[]\nfor i in S:\n s.append(i)\nt=1\nfor i in range(q):\n qv=list(input().split())\n if qv[0]=='1':\n t^=1\n else:\n if int(qv[1])^t==0 or int(qv[1])^t==2:\n r.append(qv[2])\n else:\n s.append(qv[2])\n \nif t==0:\n ss=s.copy()\n s=[]\n for j in range(len(ss)):\n s.append(ss[-1-j])\n ans=s\n ans.extend(r)\nelse:\n rr=r.copy()\n r=[]\n for j in range(len(rr)):\n r.append(rr[-1-j])\n ans=r\n ans.extend(s)\nanswer=''.join(ans)\nprint(answer)"] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s376766693', 's384176504', 's402681900', 's783774788', 's103736824'] | [11088.0, 10916.0, 9352.0, 9888.0, 14992.0] | [2206.0, 2206.0, 25.0, 33.0, 401.0] | [354, 379, 553, 398, 553] |
p02756 | u922487073 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input()\nQ = int(input())\n\nr_flg = False\nfor i in range(Q):\n q = input()\n if q == '1':\n r_flg = True\n continue\n t,f,c = q.split()\n if f == '1':\n S = c + S if not r_flg else S + c\n else:\n S = S + c if not r_flg else c + S\nif r_flg:\n print(S[::-1])\nelse:\n print(S)", "S = input()\nQ = int(input())\n\n\n\nfront = ''\nback = ''\n\nr_flg = False\nfor i in range(Q):\n q = input()\n if q == '1':\n r_flg = False if r_flg else True\n continue\n \n t,f,c = q.split()\n if not r_flg:\n if f == '1':\n front += c\n else:\n back += c\n else:\n if f == '1':\n back += c\n else:\n front += c\n \nif not r_flg:\n print(front[::-1]+S+back)\nelse:\n print(back[::-1] + S[::-1] + front)"] | ['Wrong Answer', 'Accepted'] | ['s116324336', 's213354863'] | [4132.0, 4340.0] | [2104.0, 430.0] | [314, 491] |
p02756 | u924273546 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["# -*- coding: utf-8 -*-\ns = str(input())\nq = int(input())\nl = []\nfor i in range(q):\n qy = input().split()\n l.append(qy)\n \nst = s\ncount = 0\nfor i in range(q):\n k = l[i][0]\n if(k == '1'):\n count += 1\n elif(k == '2'):\n c = count\n d = int(l[i][1])\n e = i[i][2]\n if((c + d) % 2 == 1):\n st = e + st\n elif((c + d) % 2 == 0):\n st = st + e\n\nif(count % 2 == 1):\n st = st[::-1]\n \nprint(st)", '# -*- coding: utf-8 -*-\ns = str(input())\nq = int(input()) \nst = s\nsth = s\nsth2 = ""\nstm = ""\nstm2 = ""\ncount = 0\nfor i in range(q):\n k = input().split()\n if(k[0] == \'1\'):\n count = (count + 1) % 2\n else:\n c = count - 2\n d = int(k[1]) \n e = k[2]\n if(c + d != 0):\n sth = e + sth\n if(len(sth) > 500):\n sth2 = sth\n sth = ""\n else:\n stm = stm + e\n if(len(stm) > 500):\n stm2 = stm\n stm = ""\n \n\nst = sth + sth2 + stm2 + stm\nif(count == 1):\n st = st[::-1]\n \nprint(st', '# -*- coding: utf-8 -*-\ns = str(input())\nq = int(input()) \nst = s\nsth = s\nsth2 = ""\nstm = ""\nstm2 = ""\ncount = 0\nflagh = 0\nflagm = 0\nfor i in range(q):\n k = input().split()\n if(k[0] == \'1\'):\n count = (count + 1) % 2\n else:\n c = count - 2\n d = int(k[1]) \n e = k[2]\n if(c + d != 0):\n sth = e + sth\n if(len(sth) > 5000 and flagh == 0):\n flagh = 1\n sth2 = sth\n sth = ""\n else:\n stm = stm + e\n if(len(stm) > 5000 and flagm == 0):\n flagm = 1\n stm2 = stm\n stm = ""\n \n\nst = sth + sth2 + stm2 + stm\nif(count == 1):\n st = st[::-1]\n \nprint(st)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s388351887', 's544286552', 's735145873'] | [39156.0, 3064.0, 4620.0] | [408.0, 17.0, 1771.0] | [418, 534, 623] |
p02756 | u930705402 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\nS=input()\nd=deque(S)\nrev=False\nQ=int(input())\nfor i in range(Q):\n Que=input().split()\n if(Que[0]=='1'):\n rev=not rev\n else:\n if(Que[1]=='1'):\n if(not rev):\n d.appendleft(Que[2])\n else:\n d.append(Que[2])\n else:\n if(not rev):\n d.append(Que[2])\n else:\n d.appendleft(Que[2])\nif(not rev):\n for i in range(len(d)):\n print(d[i],end='')\nelse:\n for i in reversed(range(len(d))):\n print(d[i],end='')", "from collections import deque\nS=input()\nd=deque(S)\nrev=False\nQ=int(input())\nfor i in range(Q):\n Que=input()\n if(Que=='1'):\n rev=True if not rev else False\n else:\n T,F,C=map(str,Que.split())\n if(F=='1'):\n if(not rev):\n d.appendleft(C)\n else:\n d.append(C)\n elif(F=='2'):\n if(not rev):\n d.append(C)\n else:\n d.appendleft(C)\nif(not rev):\n for i in range(len(d)):\n print(d[i],end='')\nelse:\n for i in reversed(range(len(d))):\n print(d[i],end='')", "from collections import deque\nS=input()\nd=deque(S)\nrev=False\nQ=int(input())\nfor i in range(Q):\n Que=input().split()\n if(Que[0]=='1'):\n rev=not rev\n else:\n if(Que[1]=='1'):\n if(not rev):\n d.appendleft(Que[2])\n else:\n d.append(Que[2])\n else:\n if(not rev):\n d.append(Que[2])\n else:\n d.appendleft(Que[2])\nd=d if not rev else reversed(d)\nprint(*d,sep='')\n"] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s324006884', 's649842643', 's849427727'] | [7528.0, 7532.0, 12272.0] | [2104.0, 2104.0, 494.0] | [573, 599, 484] |
p02756 | u936050991 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = list(input())\nq = int(input())\nfor i in range(q):\n query = list(input().split())\n # print(query)\n \n if query[0]=='1':\n s.reverse()\n elif query[0]=='2' and query[1]=='1':\n s.insert(0,query[2])\n elif query[0]=='2' and query[1]=='2':\n s.append(query[2])\n[print(a, end='') for a in s]", "import sys\nfrom collections import deque\n\ns = input()\nq = int(input())\nans = deque()\nans.append(s)\nreverseFlg = False\n\nfor i in range(q):\n query = list(input().split())\n # print(query)\n\n if query[0]=='1':\n reverseFlg = not reverseFlg\n else:\n if reverseFlg:\n if query[1]=='1':\n ans.append(query[2])\n else:\n ans.appendleft(query[2])\n else:\n if query[1]=='1':\n ans.appendleft(query[2])\n else:\n ans.append(query[2])\n \n\nout = ''.join(ans)\n\nif reverseFlg:\n print(out[::-1])\nelse:\n print(out)"] | ['Time Limit Exceeded', 'Accepted'] | ['s142702704', 's289043427'] | [4260.0, 6900.0] | [2104.0, 471.0] | [323, 631] |
p02756 | u941438707 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=input()\nq=int(input())\ni=0\nfor _ in range(q):\n a=list(input().split())\n if a[0]=="1":\n i+=1\n else:\n if a[1]=="1" and i%2==1:\n z=z+a[3]\n elif a[1]=="1" and i%2==0: \n x=a[2]+x\n elif a[1]=="2" and i%2==1: \n x=x+a[3]\n else:\n z=z+a[3]\nprint(z[::-1]+s[::-1]+x[::-1] if i%2 else x+s+z)', 's=input()\nq=int(input())\ni=0\nx=z=""\nfor _ in range(q):\n a=list(input().split())\n if a[0]=="1":\n i+=1\n else:\n if a[1]=="1" and i%2==1:\n z=z+a[2]\n elif a[1]=="1" and i%2==0: \n x=a[2]+x\n elif a[1]=="2" and i%2==1: \n x=a[2]+x\n else:\n z=z+a[2]\nprint(z[::-1]+s[::-1]+x[::-1] if i%2 else x+s+z)'] | ['Runtime Error', 'Accepted'] | ['s417827236', 's741659615'] | [3188.0, 4444.0] | [18.0, 1744.0] | [373, 380] |
p02756 | u946517952 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nn = int(input())\nquery = []\nfor i in range(n):\n query.append(input().split())\ncond = 1\ns = deque(s)\nfor i in range(n):\n if query[i] == ['1']:\n cond *= -1\n else:\n if cond == 1:\n if query[i][1] == '1':\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n else:\n if query[i][1] == '2':\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n\nresult = ''.join(s)\nif cond == -1:\n result = result[::-1]\nprint(result)\n", "s = input()\nn = int(input())\nquery = []\nfor i in range(n):\n query.append(input().split())\ncond = 1\ndeque(s)\nfor i in range(n):\n if query[i] == ['1']:\n cond *= -1\n else:\n if cond == 1:\n if query[i][1] == '1':\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n else:\n if query[i][1] == '2':\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n\nresult = ''.join(s)\nif cond == -1:\n result = result[::-1]\nprint(result)\n", "from collections import deque\ns = input()\nn = int(input())\nquery = []\nfor i in range(n):\n query.append(input().split())\ncond = 1\nword = deque(s)\nfor i in range(n):\n if query[i] == ['1']:\n cond *= -1\n else:\n if cond == 1:\n if query[i][1] == '1':\n word.appendleft(query[i][2])\n else:\n word.append(query[i][2])\n else:\n if query[i][1] == '2':\n word.appendleft(query[i][2])\n else:\n word.append(query[i][2])\n\nresult = ''.join(word)\nif cond == -1:\n result = result[::-1]\nprint(result)\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s526391734', 's958950122', 's462669449'] | [39156.0, 39156.0, 44652.0] | [394.0, 415.0, 488.0] | [567, 563, 615] |
p02756 | u947327691 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=str(input())\nq=int(input())\n\nright=[]\nleft=[]\nflag=0\n\nfor i in range(q):\n a = input()\n if int(a[0]) == 1:\n if flag == 0:\n flag=1\n else:\n flag=0\n else:\n if int(a[2]) == 1:\n if flag == 0:\n left.append(0,a[4])\n else:\n right.append(a[4])\n elif int(a[2]) ==2:\n if flag ==0:\n right.append(a[4])\n else:\n left.append(0,a[4])\n\nright_result="".join(right)\nleft_result="".join(left)\n\nif flag==0:\n print(str(left_result[::-1]+s+right_result))\nelse:\n print(str(right_result[::-1]+s[::-1]+left_result))\n', 's=str(input())\nq=int(input())\n\nright=[]\nleft=[]\nflag=0\n\nfor i in range(q):\n a = input()\n if int(a[0]) == 1:\n if flag == 0:\n flag=1\n else:\n flag=0\n else:\n if int(a[2]) == 1:\n if flag == 0:\n left.insert(0,a[4])\n else:\n right.append(a[4])\n elif int(a[2]) ==2:\n if flag ==0:\n right.append(a[4])\n else:\n left.insert(0,a[4])\n\nright_result="".join(right)\nleft_result="".join(left)\n\nprint("結果"+str(flag))\nif flag==0:\n print(str(left_result+s+right_result))\nelse:\n print(str(right_result[::-1]+s[::-1]+left_result[::-1]))', 's=str(input())\nq=int(input())\n\nright=[]\nleft=[]\nflag=0\n\nfor i in range(q):\n a = input()\n if int(a[0]) == 1:\n if flag == 0:\n flag=1\n else:\n flag=0\n else:\n if int(a[2]) == 1:\n if flag == 0:\n left.append(a[4])\n else:\n right.append(a[4])\n elif int(a[2]) ==2:\n if flag ==0:\n right.append(a[4])\n else:\n left.append(a[4])\n\nright_result="".join(right)\nleft_result="".join(left)\n\nif flag==0:\n print(str(left_result[::-1]+s+right_result))\nelse:\n print(str(right_result[::-1]+s[::-1]+left_result))\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s031529784', 's902819279', 's141551457'] | [3188.0, 5052.0, 5872.0] | [19.0, 2104.0, 445.0] | [660, 685, 656] |
p02756 | u950825280 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from sys import stdin\ninput = stdin.readline\n\n\ns = input()\nq = int(input())\n\nfor i in range(q):\n query = list(input().split())\n if len(query) == 1:\n s = ''.join(list(reversed(s)))\n elif query[1] == '1':\n s = query[2] + s\n elif query[1] == '2':\n s = s + query[2]\n \nprint(s)\n \n", "from sys import stdin\ninput = stdin.readline\n\ns = input().rstrip()\nq = int(input())\n\nisRev = False\n\nhead = ''\n\nfor i in range(q):\n query = list(input().split())\n if len(query) == 1:\n isRev = not isRev\n else:\n if isRev and query[1] == '1':\n s = s + query[2]\n elif query[1] == '1':\n head = head + query[2]\n elif isRev and query[1] == '2':\n head = head + query[2]\n elif query[1] == '2':\n s = s + query[2]\n \nif isRev:\n s = s[::-1] + head\nelse:\n s = head[::-1] + s\n \nprint(s)\n \n"] | ['Wrong Answer', 'Accepted'] | ['s592202658', 's111013417'] | [6220.0, 4212.0] | [2104.0, 227.0] | [322, 592] |
p02756 | u952656646 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\nreverse = 0\nleft = ""\nright = ""\nfor _ in range(Q):\n q = input().split()\n if q[0]=="1":\n reverse += 1\n left, right = right, left\n if q[0]=="2":\n if q[1]=="1":\n left = q[2]+left\n if q[1]=="2":\n right = right+q[2]\nif reverse%2==1:\n left = left[::-1]\n right = right[::-1]\n S = S[::-1]\nprint(left+S+right)', 'S = input()\nQ = int(input())\nreverse = 0\nleft = ""\nright = ""\nfor _ in range(Q):\n q = input().split()\n if q[0]=="1":\n reverse += 1\n left, right = right, left\n if q[0]=="2" and q[1]=="1":\n if reverse%2==0: left = q[2]+left\n else: left = left+q[2]\n if q[0]=="2" and q[1]=="2":\n if reverse%2==0: right = right+q[2]\n else: right = q[2]+right\nif reverse%2==1:\n left = left[::-1]\n right = right[::-1]\n S = S[::-1]\nprint(left+S+right)'] | ['Wrong Answer', 'Accepted'] | ['s337153531', 's074193946'] | [10588.0, 9916.0] | [918.0, 887.0] | [358, 490] |
p02756 | u955125992 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["L = []\nS = str(input())\nQ = int(input())\nQl = [[] for _ in range(Q)] \n\nfor i in range(len(S)):\n L.append(S[i])\n\nfor i in range(Q):\n A = input().split()\n Ql[i] = A\n\nfor i in range(Q):\n print(L)\n if Ql[i][0] == '1':\n L.reverse()\n \n elif Ql[i][0] == '2':\n if Ql[i][1] == '1':\n L.insert(0, Ql[i][2])\n else:\n L.append(Ql[i][2])\n\nprint(''.join(L))", "from collections import deque\n\nL = deque([])\nS = str(input())\nq = int(input())\nQ = [[] for _ in range(q)] \n\nfor i in range(len(S)):\n L.append(S[i])\n\nfor i in range(q):\n A = input().split()\n Q[i] = A\n\nnum = 0\n\nfor i in range(q):\n if Q[i][0] == '1':\n num ^= 1\n if Q[i][0] == '2':\n if num == 0:\n if Q[i][1] == '1':\n L.appendleft(Q[i][2])\n else:\n L.append(Q[i][2])\n else:\n if Q[i][1] == '2':\n L.appendleft(Q[i][2])\n else:\n L.append(Q[i][2])\n\nif num:\n L.reverse()\n\nprint(''.join(L))"] | ['Runtime Error', 'Accepted'] | ['s517274280', 's715350102'] | [172560.0, 44660.0] | [1999.0, 501.0] | [413, 620] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.