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
u399973890
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())\nquery = [input().split() for i in range(Q)]\nprint(query)\nfor i in query:\n if i[0] == '1':\n S = list(reversed(S))\n elif i[0]=='2' and i[1]=='1':\n S.insert(0, i[2])\n elif i[0]=='2' and i[1]=='2':\n S.append(i[2])\nprint(''.join(S))\n", "S = list(input())\nQ = int(input())\nquery = [input().split() for i in range(Q)]\nprint(query)\nfor i in query:\n # print(i)\n if i[0] == '1':\n \n S = list(reversed(S))\n print(S)\n elif i[0]=='2' and i[1]=='1':\n S.insert(0, i[2])\n print(S)\n elif i[0]=='2' and i[1]=='2':\n S.append(i[2])\n print(S)\nprint(''.join(S))\n", "from collections import deque\n\nS = list(input())\nS = deque(S)\nQ = int(input())\nreverse = 1\nquery = [input().split() for i in range(Q)]\nfor i in query:\n if len(i) == 1:\n reverse *= -1\n elif (i[1]=='1' and reverse == 1) or (i[1]=='2' and reverse==-1):\n S.appendleft(i[2])\n else:\n S.append(i[2])\nif reverse == -1:\n S.reverse() \nprint(''.join(list(S)))"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s090347910', 's984282010', 's577024058']
[49904.0, 172920.0, 44516.0]
[2106.0, 2106.0, 435.0]
[293, 368, 380]
p02756
u401487574
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())\ninv = 1\nsfb = [0,"",""]\nfor i in range(q):\n ls = list(input().split())\n if ls[0] == "1":\n inv *=-1\n else:\n f,c = ls[1:]\n if f == "1":\n sfb[inv] +=c\n else:\n sfb[-inv] +=c\n\nans = sfb[1][::-1] + s + sfb[-1]\nprint(ans[::inv])\n', 'def main():\n s = input()\n q = int(input())\n inv = 1\n sfb = [0,"",""]\n for i in range(q):\n ls = list(input().split())\n if ls[0] == "1":\n inv *=-1\n else:\n f,c = ls[1:]\n if f == "1":\n sfb[inv] +=c\n else:\n sfb[-inv] +=c\n\n ans = sfb[1][::-1] + s + sfb[-1]\n print(ans[::inv])\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s677352983', 's008299629']
[4584.0, 4636.0]
[1397.0, 1894.0]
[350, 426]
p02756
u403331159
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()\nN=int(input())\nQ=[input() for i in range(N)]\nT=deque(S)\nfor i in range(N):\n if Q[i][0]=="2":\n if Q[i][2]=="1":\n T.appendleft(Q[i][4])\n S=list(T)\n if Q[i][2]=="2":\n T.append(Q[i][4])\n S=list(T)\n if Q[i][0]=="1":\n S=list(T)\n S=S[::-1]\n T=deque(S)\nprint(str(S))', 'from collections import deque\nS=input()\nN=int(input())\nQ=[input() for i in range(N)]\nT=deque(S)\ncnt=0\nfor i in range(N):\n if Q[i][0]=="1":\n cnt+=1\n if cnt%2==0:\n if Q[i][0]=="2":\n if Q[i][2]=="1":\n T.appendleft(Q[i][4])\n if Q[i][2]=="2":\n T.append(Q[i][4])\n if cnt%2==1:\n if Q[i][0]=="2":\n if Q[i][2]=="1":\n T.append(Q[i][4])\n if Q[i][2]=="2":\n T.appendleft(Q[i][4])\nif cnt%2==1:\n T.reverse()\nprint(\'\'.join(T))']
['Wrong Answer', 'Accepted']
['s584484202', 's007438730']
[21632.0, 21212.0]
[2105.0, 386.0]
[383, 547]
p02756
u408148811
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\ncnt = [0]*(q+5)\narr=[]\nl=0\nr=0\n\nfor i in range(q):\n t=input().split()\n if t[0]==\'1\':\n r+=1\n cnt[0]+=1 \n cnt[l]-=1 \n else:\n arr.append([t[2],int(t[1])])\n l+=1 \nif r%2==1:\n s=s[::-1]\nsm=0\nfor i in range(len(arr)):\n sm+=cnt[i]\n if sm%2==1:\n if arr[i][1]==1:arr[i][1]=2\n elif arr[i][1]==2:arr[i][1]=1 \nans1=""\nans2=""\nfor i in range(len(arr)):\n if arr[i][1]==1:\n ans1+=arr[i][0]\n\n else:ans2+=arr[i][0]\nprint("%s%s%s"%(ans1,s,ans2)) \n \n \n \n \n ', 's=input()\nq=int(input()) \n\ncnt = [0]*(q+5)\narr=[]\nl=0\nr=0\n\nfor i in range(q):\n t=input().split()\n if t[0]==\'1\':\n r+=1\n cnt[0]+=1 \n cnt[l]-=1 \n else:\n arr.append([t[2],int(t[1])])\n l+=1 \nif r%2==1:\n s=s[::-1]\nsm=0\nfor i in range(len(arr)):\n sm+=cnt[i]\n if sm%2==1:\n if arr[i][1]==1:arr[i][1]=2\n elif arr[i][1]==2:arr[i][1]=1 \nans1=""\nans2=""\nfor i in range(len(arr)):\n if arr[i][1]==1:\n ans1+=arr[i][0]\n\n else:ans2+=arr[i][0]\nprint("%s%s%s"%(ans1[::-1],s,ans2)) \n \n \n \n \n ']
['Wrong Answer', 'Accepted']
['s422666330', 's090421905']
[26480.0, 26316.0]
[684.0, 694.0]
[571, 577]
p02756
u408677243
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\ndef main():\n readline = stdin.readline\n S=readline()\n Q=int(readline())\n Queries=[readline().split() for i in range(Q)]\n\n for i in Queries:\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]\n print(S)\nmain()", "S=input()\nQ=int(input())\nQ=[input().split() for i in range(Q)]\nForward=[]\nBackward=[]\ncount=0\nfor i in Q:\n if i[0]=='1':\n count+=1\n else:\n if (int(i[1])+count)%2==1:\n Forward.append(i[2])\n else:\n Backward.append(i[2]) \nif count%2==0:\n ans = (''.join(Forward))[::-1]+S+(''.join(Backward))\nelse:\n ans = (''.join(Backward)[::-1]+S[::-1]+(''.join(Forward)))\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s046429192', 's250872737']
[42992.0, 44700.0]
[2207.0, 364.0]
[348, 420]
p02756
u411858517
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())\nQ = [list(map(str, input().split())) for i in range(q)]\n\nans = ['' for in range(10 ** 5 * 3 + 2)]\n\nfor i in range(len(s)):\n ans[10 ** 5 + i + 1] = s[i]\n\nreverse_num = 0\ntmp1 = 0\ntmp2 = 0\nfor i in range(q):\n if int(Q[i][0]) == 1:\n reverse_num += 1\n else:\n if int(Q[i][1]) == 1:\n if reverse_num % 2 == 0:\n ans[10 ** 5 - tmp1] = Q[i][2]\n tmp1 += 1\n else:\n ans[10 ** 5 + len(s) + tmp2] = Q[i][2]\n tmp2 += 1\n else:\n if reverse_num % 2 != 0:\n ans[10 ** 5 - tmp1] = Q[i][2]\n tmp1 += 1\n else:\n ans[10 ** 5 + len(s) + tmp2] = Q[i][2]\n tmp2 += 1\n \nres = ''\nfor i in range(len(ans)):\n if ans[i] != '':\n res += ans[i]\n \nprint(ans)\n", "s = input()\nq = int(input())\nQ = [list(map(str, input().split())) for i in range(q)]\n\nans = ['' for i in range(10 ** 5 * 3 + 2)]\n\nfor i in range(len(s)):\n ans[10 ** 5 + i + 1] = s[i]\n\nreverse_num = 0\ntmp1 = 0\ntmp2 = 0\nfor i in range(q):\n if int(Q[i][0]) == 1:\n reverse_num += 1\n else:\n if int(Q[i][1]) == 1:\n if reverse_num % 2 == 0:\n ans[10 ** 5 - tmp1] = Q[i][2]\n tmp1 += 1\n else:\n ans[10 ** 5 + len(s) + tmp2] = Q[i][2]\n tmp2 += 1\n else:\n if reverse_num % 2 != 0:\n ans[10 ** 5 - tmp1] = Q[i][2]\n tmp1 += 1\n else:\n ans[10 ** 5 + len(s) + tmp2] = Q[i][2]\n tmp2 += 1\n \nres = ''\nfor i in range(len(ans)):\n if ans[i] != '':\n res += ans[i]\n \nprint(ans)\n", "from collections import deque\n\ns = input()\nq = int(input())\nQ = [list(map(str, input().split())) for i in range(q)]\n\nans = deque(s)\n\nreverse_num = 0\nfor i in range(q):\n if int(Q[i][0]) == 1:\n reverse_num += 1\n else:\n if int(Q[i][1]) == 1:\n if reverse_num % 2 == 0:\n ans.appendleft(Q[i][2])\n else:\n ans.append(Q[i][2])\n else:\n if reverse_num % 2 != 0:\n ans.appendleft(Q[i][2])\n else:\n ans.append(Q[i][2])\n\nres = ''\nif reverse_num % 2 == 0: \n for i in range(len(ans)):\n res += ans.popleft()\n print(res)\nelse:\n for i in range(len(ans)):\n res += ans.pop()\n print(res)\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s635790984', 's668416300', 's671544676']
[3064.0, 46356.0, 42380.0]
[17.0, 890.0, 784.0]
[748, 750, 633]
p02756
u415888833
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.
["mport sys\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\nfrom collections import deque\ndef resolve():\n S = deque(list(sr().split()), maxlen=1000000)\n Q = ir()\n rev = 1\n for i in range(Q):\n T = list(sr().split())\n if int(T[0]) == 1:\n rev *= -1\n else:\n x, F, C = T\n if int(F) == 1:\n if rev == 1:\n S.appendleft(C)\n else:\n S.append(C)\n else:\n if rev == 1:\n S.append(C)\n else:\n S.appendleft(C)\n if rev == -1:\n S.reverse()\n print(*S, sep='')\nresolve()", "import sys\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\nfrom collections import deque\ndef resolve():\n S = deque(sr())\n Q = ir()\n rev = 1\n for i in range(Q):\n T = list(sr().split())\n if int(T[0]) == 1:\n rev *= -1\n else:\n x, F, C = T\n if int(F) == 1:\n if rev == 1:\n S.appendleft(C)\n else:\n S.append(C)\n else:\n if rev == 1:\n S.append(C)\n else:\n S.appendleft(C)\n if rev == -1:\n S.reverse()\n print(*S, sep='')\nresolve()"]
['Runtime Error', 'Accepted']
['s046730086', 's820785298']
[3064.0, 12264.0]
[17.0, 377.0]
[732, 703]
p02756
u419963262
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\nguuki=0\nANS=S\nANS_front=""\nANS_back=""\nfor i in range(Q):\n A=list(input().split())\n if A[0]=="1":\n guuki+=1\n elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):\n ANS_back+=A[2]\n else:\n ANS_front=A[2]+ANS_front\nif guuki%2==1:\n ANS=ANS[::-1]\n ANS_back,ANS_front=ANS_front,ANS_back\nprint(ANS_front[::-1]+ANS+ANS_back)', 'S=input()\nQ=int(input())\n\nguuki=0\nANS=S\nANS_back=""\nANS_front=""\nfor i in range(Q):\n A=list(input().split())\n if A[0]=="1":\n guuki+=1\n elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):\n ANS_back+=A[2]\n else:\n ANS_front+=A[2]\nif guuki%2==1:\n ANS=ANS[::-1]\n ANS_back,ANS_front=ANS_front,ANS_back\nprint(ANS_front[::-1]+ANS+ANS_back)']
['Wrong Answer', 'Accepted']
['s477154864', 's014920199']
[4448.0, 4412.0]
[1811.0, 649.0]
[384, 375]
p02756
u424467986
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 StrConv(S, T, F, C):\n ans = ''\n if T == '1':\n pass\n \n else:\n if F == '1':\n ans = C + S\n else:\n ans = S + C\n return ans\n \n\nS = input()\nQ = int(input())\ndumy = '|' \ncnt = 0 \n\n\nfor i in range(Q):\n tmp = str(input())\n \n if tmp[0] == '1':\n T = tmp[0]\n F = '-'\n C = '-'\n cnt += 1\n else:\n T, F, C = tmp.split(' ')\n \n dumy = StrConv(dumy, T, F, C)\n\n\nif (cnt % 2) == 0:\n ans = dumy[0:dumy.find('|')] + S + dumy[dumy.find('|')+1:]\nelse:\n ans = dumy[0:dumy.find('|')] + S[::-1] + dumy[dumy.find('|')+1:]\nprint(ans)\n", "\nS = input()\nQ = int(input())\ncnt = 0 \nhead = ''\ntail = ''\n\n\nfor i in range(Q):\n tmp = str(input())\n \n if tmp[0] == '1':\n cnt += 1\n else:\n T, F, C = tmp.split(' ')\n if cnt % 2 == 1:\n if F == '1':\n tail = tail + C\n else:\n head = C + head\n else:\n if F == '1':\n head = C + head\n else:\n tail = tail + C\n #cnt = 0\n #print('head=',head)\n #print('tail=',tail)\n\nprint('cnt=',cnt)\nif cnt % 2 == 0:\n ans = head + S + tail\nelse:\n ans = tail[::-1] + S[::-1] + head[::-1]\nprint(ans)\n", "def StrConv(S, T, F, C):\n ans = ''\n if T == '1':\n \n else:\n if F == '1':\n ans = C + S\n else:\n ans = S + C\n return ans\n \n\nS = input()\nQ = int(input())\ndumy = '|' \ncnt = 0 \n\n\nfor i in range(Q):\n tmp = str(input())\n \n if tmp[0] == '1':\n T = tmp[0]\n F = '-'\n C = '-'\n cnt += 1\n else:\n T, F, C = tmp.split(' ')\n \n dumy = StrConv(dumy, T, F, C)\n\n\nif (cnt % 2) == 0:\n ans = dumy[0:dumy.find('|')] + S + dumy[dumy.find('|')+1:]\nelse:\n ans = dumy[0:dumy.find('|')] + S[::-1] + dumy[dumy.find('|')+1:]\nprint(ans)\n", "\nS = input()\nQ = int(input())\ncnt = 0 \nhead = ''\ntail = ''\n\n\nfor i in range(Q):\n tmp = str(input())\n \n if tmp[0] == '1':\n cnt += 1\n else:\n T, F, C = tmp.split(' ')\n if cnt % 2 == 1:\n if F == '1':\n tail = tail + C\n else:\n head = C + head\n else:\n if F == '1':\n head = C + head\n else:\n tail = tail + C\n #cnt = 0\n #print('head=',head)\n #print('tail=',tail)\n\n#print('cnt=',cnt)\nif cnt % 2 == 0:\n ans = head + S + tail\nelse:\n ans = tail[::-1] + S[::-1] + head[::-1]\nprint(ans)\n"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s169103912', 's742563948', 's998871510', 's046299326']
[3756.0, 4452.0, 2940.0, 4396.0]
[2104.0, 1662.0, 18.0, 1614.0]
[766, 660, 757, 661]
p02756
u437215432
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(2, q):\n txt3 = input().split()\n if txt3[0] == '1':\n s = s[::-1]\n else:\n if txt3[1] == '1':\n s = txt3[2] + s\n else:\n s = s + txt3[2]\nprint(s)\n", 'def ABC158D(txt):\n txt2 = txt.split("\\n")\n s = txt2[0]\n q = int(txt2[1])\n for i in range(2, len(txt2)):\n txt3 = txt2[i].split()\n if txt3[0] == \'1\':\n s = s[::-1]\n else:\n if txt3[1] == \'1\':\n s = txt3[2] + s\n else:\n s = s + txt3[2]\n print(s)\n \nABC158D(txt)\n', 'def ABC158D():\n s = input()\n q = int(input())\n for i in range(2, q):\n txt3 = input().split()\n print(f"txt3 = {txt3}")\n if txt3[0] == \'1\':\n s = s[::-1]\n else:\n if txt3[1] == \'1\':\n s = txt3[2] + s\n else:\n s = s + txt3[2]\n print(s)\n\nABC158D()\n', "\ns = input()\nq = int(input())\nht = 1\ncount = 0\nfor i in range(2, q):\n txt3 = input().split()\n if txt3[0] == '1':\n ht = 3 - ht\n count += 1\n else:\n if int(txt3[1]) == ht:\n s = txt3[2] + s\n else:\n s = s + txt3[2]\nif count % 2 == 1:\n s = s[::-1]\nprint(s)\n", 'print(1)', 'def ABC158D():\n txt2 = txt.split("\\n")\n s = txt2[0]\n q = int(txt2[1])\n for i in range(2, len(txt2)):\n txt3 = txt2[i].split()\n if txt3[0] == \'1\':\n s = s[::-1]\n else:\n if txt3[1] == \'1\':\n s = txt3[2] + s\n else:\n s = s + txt3[2]\n print(s)\n \nABC158D()\n', 'def ABC158D():\n txt2 = txt.split("\\n")\n s = txt2[0]\n q = int(txt2[1])\n for i in range(2, len(txt2)):\n txt3 = txt2[i].split()\n if txt3[0] == \'1\':\n s = s[::-1]\n else:\n if txt3[1] == \'1\':\n s = txt3[2] + s\n else:\n s = s + txt3[2]\n print(s)\n\nf = open("foot/bar.dat")\ntxt = f.read()\nf.close()\nABC158D(txt)\n', "# ABC158D\n\ns = input()\nq = int(input())\nht = 1\nhead = ''\ntail = ''\ncount = 0\nfor i in range(q):\n txt3 = input().split()\n if txt3[0] == '1':\n ht = 3 - ht\n count += 1\n else:\n if int(txt3[1]) == ht:\n head = txt3[2] + head\n else:\n tail = tail + txt3[2]\ns = head + s + tail\nif count % 2 == 1:\n s = s[::-1]\nprint(s)\n"]
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s356198294', 's414942209', 's449190614', 's495016909', 's536186832', 's593564438', 's809696258', 's768998811']
[3732.0, 2940.0, 3064.0, 3824.0, 2940.0, 3056.0, 3060.0, 10036.0]
[2104.0, 17.0, 19.0, 2107.0, 17.0, 17.0, 17.0, 851.0]
[237, 368, 343, 313, 8, 362, 399, 372]
p02756
u437351386
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())\nrev=0\nfor i in range(q):\n t=list(input().split())\n if t[0]=="1":\n rev=rev+1\n else:\n if t[1]=="1":\n if rev%2==0:\n s.appendleft(t[2])\n else:\n s.append(t[2])\n else:\n if rev%2==0:\n s.append(t[2])\n else:\n s.appendleft(t[2])\nif rev%2==0:\n print("".join(s))\nelse:\n s.reverse()\n print("".join(s))\n\n', 'from collections import deque\ns=deque(list(input()))\nq=int(input())\nrev=0\nfor i in range(q):\n t=list(input().split(" "))\n if t[0]=="1":\n rev=rev+1\n else:\n if t[1]=="1":\n if rev%2==0:\n s.appendleft(t[2])\n else:\n s.append(t[2])\n else:\n if rev%2==0:\n s.append(t[2])\n else:\n s.appendleft(t[2])\nif rev%2==0:\n print("".join(s))\nelse:\n s.reverse()\n print("".join(s))']
['Runtime Error', 'Accepted']
['s165273673', 's180371066']
[3956.0, 8676.0]
[19.0, 505.0]
[464, 422]
p02756
u440161695
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())\nfor i in range(Q):\n N=list(input().split())\n if N[0]=="1":\n S.reverse()\n elif N[1]="1":\n S.appendleft(N[2])\n else:\n S.append(N[2])\nprint(S)', '\nrL=list(input())\nlL=[]\nQ=int(input())\nfor i in range(Q):\n N=list(input().split())\n if N[0]=="1":\n lL,rL=rL,lL\n elif N[1]=="1":\n lL.append(N[2])\n else:\n rL.append(N[2])\nlL.reverse()\nprint("".join(lL)+"".join(rL))']
['Runtime Error', 'Accepted']
['s346668626', 's510174567']
[2940.0, 6292.0]
[17.0, 460.0]
[226, 453]
p02756
u441254033
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\nfrom collections import deque\n\nss = deque(s)\nflg = True\n\nfor i in range(q):\n t = input().split()\n if t[0] == \'1\':\n flg = !flg\n else:\n if t[1] == \'2\':\n ss.append(t[2]) if flg else ss.appendleft(t[2])\n else:\n ss.append(t[2]) if flg != True else ss.appendleft(t[2])\n\n\n\nprint("".join(ss)) if flg else print("".join(ss[::-1]))\n\n', 's = input()\nq = int(input())\nss = []\n\nfor i in range(q):\n t = input().split()\n if t[0] == \'1\':\n ss = ss[::-1]\n else:\n if t[1] == \'2\':\n ss.append(t[2])\n else:\n ss.insert(0,t[2]\n\nprint("".join(ss))\n\n', 's = input()\nq = int(input())\n\nfrom collections import deque\n\nss = deque(s)\nflg = True\n\nfor i in range(q):\n t = input().split()\n if t[0] == \'1\':\n flg = not flg\n else:\n if t[1] == \'2\':\n ss.append(t[2]) if flg else ss.appendleft(t[2])\n else:\n ss.append(t[2]) if not flg else ss.appendleft(t[2])\n\nss = list(ss)\n\nprint("".join(ss)) if flg else print("".join(ss[::-1]))\n\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s511503739', 's705306983', 's138247352']
[2940.0, 2940.0, 10100.0]
[17.0, 17.0, 408.0]
[379, 219, 391]
p02756
u441599836
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())\nhanten = 0\n\nfor i in range(q):\n x = input().split()\n if len(x) == 1:\n t = x[0]\n if t == "1" and hanten == 0:\n hanten = 1\n elif t == "1" and hanten == 1:\n hanten = 0\n\n else:\n f = int(x[1])\n c = str(x[2])\n if f == 1 and hanten == 0:\n s.insert(0, c)\n\n elif f == 1 and hanten == 1:\n s.append(c)\n\n elif f == 2 and hanten == 0:\n s.append(c)\n\n elif f == 2 and hanten == 1:\n s.insert(0, c)\n\nelse:\n d = len(s)\n if hanten == 1:\n for i in range(d):\n print(s[d-1-i], end="")\n else:\n for i in range(d):\n print(s[i], end="")\n', 'from collections import deque\n\ns = deque(str(input()))\nq = int(input())\nhanten = 0\n\nfor i in range(q):\n x = input().split()\n if len(x) == 1:\n t = x[0]\n if t == "1" and hanten == 0:\n hanten = 1\n elif t == "1" and hanten == 1:\n hanten = 0\n\n else:\n f = int(x[1])\n c = str(x[2])\n if f == 1 and hanten == 0:\n s.appendleft(c)\n\n elif f == 1 and hanten == 1:\n s.append(c)\n\n elif f == 2 and hanten == 0:\n s.append(c)\n\n elif f == 2 and hanten == 1:\n s.appendleft(c)\n\nelse:\n if hanten == 1:\n s.reverse()\n\nprint("".join(s))\n']
['Time Limit Exceeded', 'Accepted']
['s597684459', 's565346235']
[4260.0, 8436.0]
[2104.0, 526.0]
[734, 660]
p02756
u442855260
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\nflip=0\nfr=''\nba=''\nfor i in range(Q):\n Qq=input()\n \n if(Qq.count(' ')>0):\n ti,fi,ci=Qq.split()\n if( flip%2==0 ):\n if(fi=='1'):\n fr=str(ci)+fr\n else:\n ba=ba+str(ci)\n else:\n if(fi=='1'):\n #fr=fr+str(ci)\n ba=ba+str(ci)\n else:\n #ba=str(ci)+ba\n fr=str(ci)+fr\n else:\n flip+=1\n #S=S[::-1]\nif(flip&2==0):\n print(fr+S+ba)\nelse:\n print(ba[::-1]+S[::-1]+fr[::-1])\n", "S=input()\nQ=int(input())\n\nflip=0\nfr=''\nba=''\nfor i in range(Q):\n Qq=input()\n \n if(Qq.count(' ')>0):\n ti,fi,ci=Qq.split()\n if( flip%2==0 ):\n if(fi=='1'):\n fr=str(ci)+fr\n else:\n ba=ba+str(ci)\n else:\n if(fi=='1'):\n ba=ba+str(ci)\n else:\n fr=str(ci)+fr\n else:\n flip+=1\nif(flip%2==0):\n print(fr+S+ba)\nelse:\n print(ba[::-1]+S[::-1]+fr[::-1])"]
['Wrong Answer', 'Accepted']
['s735036402', 's924997566']
[4372.0, 4420.0]
[1695.0, 1684.0]
[568, 486]
p02756
u442877951
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 = list(map(str,input().split()))\nQ = int(input())\nQuery = [list(map(str,input().split())) for _ in range(Q)]\nd = deque(S)\nfor i in range(Q):\n if Query[i][0] == "1":\n d = d.rotate()\n elif Query[i][0] == "2":\n if Query[i][1] == "1":\n d.append(Query[i][2])\n elif Query[i][1] == "2":\n d.appendleft(Query[i][2])\nans = \'\'.join(d)\nprint(ans)', 'from collections import deque\nS = list(map(str,input().split()))\nQ = int(input())\nQuery = [list(map(str,input().split())) for _ in range(Q)]\nd = deque(S)\nfor i in range(Q):\n if Query[i][0] == "1":\n d = \'\'.join(list(reversed(d)))\n elif Query[i][0] == "2":\n if Query[i][1] == "1":\n d.append(Query[i][2])\n elif Query[i][1] == "2":\n d.appendleft(Query[i][2])\nans = \'\'.join(d)\nprint(ans)', "from collections import deque\nS = str(input())\nQ = int(input())\nd = deque()\nreverse = 1\nfor i in S:\n d.append(i)\nfor j in range(Q):\n Query = input().split()\n if len(Query) == 1:\n reverse *= -1\n else:\n F = int(Query[1])\n C = str(Query[2])\n if reverse == 1:\n if F == 1:\n d.appendleft(C)\n elif F == 2:\n d.append(C)\n elif reverse == -1:\n if F == 1:\n d.append(C)\n elif F == 2:\n d.appendleft(C)\nif reverse == -1:\n d.reverse()\nans = ''.join(d)\nprint(ans)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s128735525', 's806212969', 's976077404']
[42996.0, 43124.0, 8820.0]
[671.0, 708.0, 535.0]
[387, 403, 519]
p02756
u447679353
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 copy\n\nS=input()\nQ=int(input())\nQuery=[]\ntemp=[]\n\nrevflag=0\nsbef=[]\nsaft=[]\n\nfor i in range(Q):\n temp=input().split()\n if len(temp) ==1:\n revflag += 1\n else:\n if (revflag + int(temp[1])-1 )%2 == 0:\n sbef.append(temp[2])\n else:\n saft.append(temp[2])\n\nans=""\n\nfor i in range(len(sbef)):\n ans+=sbef[len(sbef)-i-1]\n\nans += S\nfor i in range(len(saft)):\n ans+=saft[i]\nprint(ans)\n\ntmp=""\ntmp2 = copy.copy(ans)\n\n\nif revflag%2 ==1:\n for i in range(len(ans)):\n tmp+=tmp2[len(ans)-i-1]\n ans=tmp\n\n\nprint(ans)\n', 'import copy\n\nS=input()\nQ=int(input())\nQuery=[]\ntemp=[]\n\nrevflag=0\nsbef=[]\nsaft=[]\n\nfor i in range(Q):\n temp=input().split()\n if len(temp) ==1:\n revflag += 1\n else:\n if (revflag + int(temp[1])-1 )%2 == 0:\n sbef.append(temp[2])\n else:\n saft.append(temp[2])\n\nans=""\n\nfor i in range(len(sbef)):\n ans+=sbef[len(sbef)-i-1]\n\nans += S\nfor i in range(len(saft)):\n ans+=saft[i]\n\ntmp=""\ntmp2 = copy.copy(ans)\n\n\nif revflag%2 ==1:\n for i in range(len(ans)):\n tmp+=tmp2[len(ans)-i-1]\n ans=tmp\n\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s183172029', 's336176421']
[6652.0, 6224.0]
[647.0, 657.0]
[574, 563]
p02756
u449473917
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())\nisreverse=False\ntop=\'\'\n\nfor i in range(n):\n ss=input().split()\n if len(ss)==1:\n isreverse=not isreverse\n else:\n if ss[1]=="1":\n if isreverse: s+=ss[2]\n else: top+ss[2]\n else:\n if isreverse: top+=ss[2]\n else: s+=ss[2]\nif isreverse:\n s=s[::-1]+top\nelse:\n s=top[::-1]+s\n\n\nprint(s)', 's=input()\nn=int(input())\nisreverse=False\ntop=\'\'\n\nfor i in range(n):\n ss=input().split()\n if len(ss)==1:\n isreverse=not isreverse\n else:\n if ss[1]=="1":\n if isreverse: s+=ss[2]\n else: top+=ss[2]\n else:\n if isreverse: top+=ss[2]\n else: s+=ss[2]\nif isreverse:\n s=s[::-1]+top\nelse:\n s=top[::-1]+s\n\n\nprint(s)']
['Wrong Answer', 'Accepted']
['s900886217', 's979230331']
[3848.0, 4192.0]
[477.0, 449.0]
[382, 383]
p02756
u454472984
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.
['string=list(input())\nQ=int(input())\ndef func1(s):\n s.reverse()\n \ndef func2(s,F,C):\n if F=="1":\n s.insert(0,C)\n #return s\n if F=="2":\n s.append(C)\n #return s\n\n \nfor i in range(Q):\n Input=list(map(str,input().split()))\n if Input[0]==\'1\':\n func1(string)\n \n elif Input[0]==\'2\':\n func2(string,Input[1],Input[2])\nfor i in string:\n print(i,end="")', 'string=list(input())\nQ=int(input())\nreverse=0\ndef func1(s):\n s.reverse()\n \ndef func2(s,F,C):\n if F=="1":\n s.insert(0,C)\n #return s\n if F=="2":\n s.append(C)\n #return s\n\n \nfor i in range(Q):\n Input=list(map(str,input().split()))\n if Input[0]==\'1\':\n func1(string)\n \n elif Input[0]==\'2\':\n func2(string,Input[1],Input[2])\nfor i in string:\n print(i,end="")', 'string=list(input())\nQ=int(input())\ndef func1(s):\n s.reverse()\n return s\ndef func2(s,F,C):\n if F=="1":\n s.insert(0,C)\n #return s\n if F=="2":\n s.append(C)\n #return s\n\n \nfor i in range(Q):\n Input=list(map(str,input().split()))\n if Input[0]==\'1\':\n func1(string)\n \n elif Input[0]==\'2\':\n func2(string,Input[1],Input[2])\nfor i in string:\n print(i,end="")', 'S = str(input())\nQ = int(input())\n \nhanten = 0\nfront = ""\nend = ""\n \nfor i in range(Q):\n query=list(map(str,input().split()))\n if query[0]=="1":\n hanten+=1\n hanten=hanten%2\n else:\n if query[1]=="1":\n if hanten==0:\n front=query[2]+front\n else:\n end=end+query[2]\n else:\n if hanten==0:\n end=end+query[2]\n else:\n front=query[2]+front\nans=front+S+end\nif hanten==1:\n ans=ans[::-1]\nprint(ans)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s551901988', 's804045963', 's806515251', 's011114545']
[4340.0, 4340.0, 4468.0, 4420.0]
[2107.0, 2104.0, 2108.0, 1836.0]
[424, 434, 432, 529]
p02756
u464205401
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=list(input())\nq=int(input())\nd = deque(s)\nreverse=False\n\nfor i in range(q):\n qs=list(input().split())\n if qs[0]==\'1\':\n reverse=not reverse\n else:\n if qs[1]==\'1\':\n d.appendleft(qs[2]) if reverse else d.append(qs[2])\n else:\n d.append(qs[2]) if reverse else d.appendleft(qs[2])\n# print(d)\nprint("".join(d))\n', 'from collections import deque\n\ns=list(input())\nq=int(input())\nd = deque(s)\nreverse=False\n\nfor i in range(q):\n qs=list(input().split())\n if qs[0]==\'1\':\n reverse=not reverse\n else:\n if qs[1]==\'1\':\n d.appendleft(qs[2]) if not reverse else d.append(qs[2])\n else:\n d.append(qs[2]) if not reverse else d.appendleft(qs[2])\n# print(d)\nif reverse:\n d.reverse()\nprint("".join(d))\n']
['Wrong Answer', 'Accepted']
['s507830230', 's150220530']
[9460.0, 9332.0]
[474.0, 496.0]
[360, 394]
p02756
u474925961
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\ns=input()\n\nss=[]\nfor i in range(len(s)):\n ss.append(s[i])\narr=np.array(ss)\n\nq=int(input())\nfor i in range(q):\n l=list(map(str,input().split()))\n if l[0]=="1":\n arr=arr[::-1]\n \n else:\n if l[1]=="1":\n arr=arr[::-1]\n arr=np.hstack((arr,l[2]))\n arr=arr[::-1]\n if l[1]=="2":\n arr=np.hstack((arr,[l[2]]))\n \n\na=arr.tolist()\nfor i in a:\n print(i,end="")', 'import numpy as np\ns=input()\n\nss=[]\nfor i in range(len(s)):\n ss.append(s[i])\narr=np.array(ss)\n\nq=int(input())\nfor i in range(q):\n l=list(map(str,input().split()))\n if l[0]=="1":\n arr=arr[::-1]\n \n else:\n if l[1]=="1":\n arr=np.hstack((l[2],arr))\n if l[1]=="2":\n arr=np.hstack((arr,[l[2]]))\n \n\na=arr.tolist()\nfor i in a:\n print(i,end="")', 'import numpy as np\ns=input()\nss=[]\nfor i in range(len(s)):\n ss.append(s[i])\n\n \narr=np.array(ss)\n\nq=int(input())\nfor i in range(q):\n l=list(map(str,input().split()))\n if l[0]=="1":\n arr=arr[::-1]\n \n else:\n if l[1]=="1":\n arr=arr[::-1]\n arr=np.append(arr,l[2])\n arr=arr[::-1]\n if l[1]=="2":\n arr=np.append(arr,[l[2]])\n \n\na=arr.tolist()\nfor i in a:\n print(i,end="")', '\ns=input()\nq=int(input())\np=0\na=""\nb=""\nfor i in range(q):\n l=list(map(str,input().split()))\n if l[0]=="1":\n p=(p+1)%2\n else:\n if p==0:\n if l[1]=="1":\n a+=l[2]\n else:\n b+=l[2]\n else:\n if l[1]=="1":\n b+=l[2]\n else:\n a+=l[2]\nif p==1:\n print(b[::-1]+s[::-1]+a)\nelse:\n print(a[::-1]+s+b)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s346482279', 's560816557', 's909311138', 's660744148']
[16364.0, 16828.0, 22084.0, 4468.0]
[2109.0, 2108.0, 2108.0, 689.0]
[458, 406, 459, 424]
p02756
u477320129
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(input())\nflag = 0\nfor T_F_C in (input().split() for _ in range(int(input()))):\n if T_F_C[0] == \'1\':\n flag ^= 1\n continue\n _, f, c = T_F_C\n if (flag+int(f)) % 2:\n\td.appendleft(c)\n else:\n d.append(c)\nif flag:\n d = reversed(d)\nprint("".join(d))', 'from collections import deque\nd = deque(input())\nflag = 0\nfor T_F_C in (input().split() for _ in range(int(input()))):\n print("".join(d) if flag else "".join(reversed(d)))\n if T_F_C[0] == \'1\':\n flag ^= 1\n continue\n _, f, c = T_F_C\n if (flag+int(f)) % 2:\n d.append(c)\n else:\n d.appendleft(c)\nif flag:\n print("".join(d))\nelse:\n print("".join(reversed(d)))', "#!/usr/bin/env python3\n\ndef main():\n from itertools import chain\n S = input()\n Q = int(input())\n Queries = [input().split() for _ in range(Q)]\n H_T = H, T = [], []\n flag = 0\n for query in Queries:\n if len(query) == 1:\n flag ^= 1\n continue\n _, f, c = query\n H_T[(int(f) + flag - 1) % 2].append(c)\n t = ''.join(chain(reversed(H), S, T))\n if flag:\n t = reversed(t)\n print(''.join(t))\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s503704187', 's706942205', 's760482457']
[2940.0, 136164.0, 43768.0]
[17.0, 2070.0, 444.0]
[317, 402, 501]
p02756
u478719560
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\ns = str(stdin.readline().rstrip())\nq = int(stdin.readline().rstrip())\nfor i in range(q):\n query = list(map(int, stdin.readline().rstrip().split()))\n if int(query[0])==1:\n s = s[::-1]\n else:\n if int(query[1])==2:\n s += query[2]\n else:\n s = query[2] + s\n\nprint(s)\n', 'from sys import stdin\ns = str(stdin.readline().rstrip())\n#A, B, C = map(int, stdin.readline().rstrip().split())\n\nq= int(stdin.readline().rstrip())\nhanten = 0\nt=""\nu=""\n\nfor i in range(q):\n l = list(map(str, stdin.readline().rstrip().split()))\n if int(l[0]) == 1:\n t,u = u,t\n hanten ^= 1\n else:\n if int(l[1])==1:\n t+=l[2]\n else:\n u+=l[2]\n\n\nif hanten==0:\n print(t[::-1]+s+u)\nelse:\n print(t[::-1]+s[::-1]+u)\n']
['Runtime Error', 'Accepted']
['s505560141', 's654034271']
[3188.0, 4340.0]
[18.0, 440.0]
[336, 570]
p02756
u482157295
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.
['temp = input()\ns = ["tikan"]\nflag = "off"\nq = int(input())\ndummy = ""\nfor i in range(q):\n q_list = input().split()\n if q_list[0] == "1":\n if flag == "on":\n flag = "off"\n else:\n flag = "on"\n else:\n if q_list[1] == "1":\n if flag == "off":\n s.insert(0,q_list[2])\n else:\n s.append(q_list[2])\n else:\n if flag == "off":\n s.append(q_list[2])\n else:\n s.insert(0,q_list[2])\n# print(s)\nans = ""\nfor i in s:\n if i == "tikan":\n i = temp\n if flag == "on":\n i = list(i)\n i.reverse()\n i = "".join(i)\n ans += i\nif flag == "on":\n ans = list(ans)\n ans.reverse()\n ans = "".join(ans)\nprint(ans)v', 's = input()\nq = int(input())\nturn = 1\nstart = []\nend = []\nfor i in range(q):\n q_list = list(input().split())\n if q_list[0] == "1":\n turn *= -1\n else:\n if q_list[1] == "1":\n if turn == 1:\n start.append(q_list[2])\n else:\n end.append(q_list[2])\n else:\n if turn == -1:\n start.append(q_list[2])\n else:\n end.append(q_list[2])\n\ndum1 = "".join(start)\ndum2 = "".join(end)\nif turn == 1:\n print(dum1[::-1]+s+dum2)\nelse:\n print(dum2[::-1] + s[::-1] + dum1)']
['Runtime Error', 'Accepted']
['s568866870', 's793139347']
[3064.0, 5876.0]
[17.0, 472.0]
[675, 584]
p02756
u489155878
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\n\nS=input()\nQ=int(input())\n#Query=[]\n\n# Query.append(list(input().split()))\n \n \n\nt=0\nb=""\na=""\nfor j in range(Q):\n i=list(input().split())\n if i[0]=="1":\n t+=1\n elif i[0]=="2":\n if t%2==0:\n if i[1]=="1":\n b=i[2]+b\n elif i[1]=="2":\n a=a+i[2]\n elif t%2==1:\n if i[1]=="1":\n a=i[2]+a\n elif i[1]=="2":\n b=b+i[2]\nif t%2==0:\n print(b+S+a)\n \nelse:\n print(a+S[::-1]+b)', '#D\n\nS=input()\nQ=int(input())\n#Query=[]\n\n# Query.append(list(input().split()))\n \n \n\nt=0\nb=""\na=""\nfor j in range(Q):\n i=list(input().split())\n if i[0]=="1":\n t+=1\n elif i[0]=="2":\n if t%2==0:\n if i[1]=="1":\n b=i[2]+b\n elif i[1]=="2":\n a=a+i[2]\n elif t%2==1:\n if i[1]=="1":\n a=a+i[2]\n elif i[1]=="2":\n b=i[2]+b\nif t%2==0:\n print(b+S+a)\n \nelse:\n print(a[::-1]+S[::-1]+b[::-1])']
['Wrong Answer', 'Accepted']
['s715844325', 's700176774']
[4424.0, 4468.0]
[1645.0, 1672.0]
[546, 558]
p02756
u490489966
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\ns=input()\nq=int(input())\nl=[]\nans=[s]\nfor i in range(q):\n l.append(list(input().split()))\nfor i in range(q):\n if int(l[i][0])==1:\n ans.reverse()\n elif int(l[i][1])==1:#2 1\n ans.reverse()\n ans.append(l[i][2])\n ans.reverse()\n else:#2 2\n ans.append(l[i][2])\nfor i in ans:\n print(i,end="")', '#D\ns=input()\nq=int(input())\nl=[]\nleft=[]\nright=[]\nans=[s]\nfor i in range(q):\n l.append(list(input().split()))\n if int(l[i][0])==1:\n left,right=right,left\n elif int(l[i][1])==1:#2 1\n left.append(l[i][2])\n else:#2 2\n right.append(l[i][2])\nans.extend(right)\nans.reverse()\nans.extend(left)\nans.reverse()\nfor i in ans:\n print(i,end="")', '#D\nfrom collections import deque\ns=input()\nq=int(input())\nl=[]\nturn=0\nans=deque()\nans.append(s)\nfor i in range(q):\n query=input().split()\n if query[0]=="1":\n turn+=1\n if query[0]=="2":\n if query[1]=="1":\n if turn%2==0:\n ans.appendleft(query[2])\n else:\n ans.append(query[2])\n elif query[1]=="2":\n if turn%2==0:\n ans.append(query[2])\n else:\n ans.appendleft(query[2])\nans="".join(ans)\nif turn%2==1:\n ans=ans[::-1]\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s399887833', 's999471854', 's075430805']
[31532.0, 34672.0, 7020.0]
[2105.0, 821.0, 426.0]
[338, 366, 594]
p02756
u490642448
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\nqs = [list(input().split()) for _ in range(q)]\n\nleft = ''\nright = ''\n\n\nfront = False\nfor i in qs:\n if(i[0] == '1'):\n front = not front\n continue\n\n f = int(i[1])\n c = i[2]\n if(front + f == 2):\n right = right + c\n else:\n left = left + c\n\nif(not front):\n ans = left[::-1] + s + right\nelse:\n ans = right[::-1] + s[::-1] + left\n\nprint(ans)", "import sys\ninput = sys.stdin.readline\n\nqs = [list(input().split()) for _ in range(q)]\n\nleft = ''\nright = ''\n\n\nfront = False\nfor i in qs:\n if(i[0] == '1'):\n front = not front\n continue\n\n f = int(i[1])\n c = i[2]\n if(front + f == 2):\n right = right + c\n else:\n left = left + c\n\nif(not front):\n ans = left[::-1] + s + right\nelse:\n ans = right[::-1] + s[::-1] + left\n\nprint(ans)", "s = input()\nq = int(input())\n\nimport sys\ninput = sys.stdin.readline\n\nqs = [list(input().split()) for _ in range(q)]\n\nleft = ''\nright = ''\n\n\nfront = False\nfor i in qs:\n if(i[0] == '1'):\n front = not front\n continue\n\n f = int(i[1])\n c = i[2]\n if(front + f == 2):\n right = right + c\n else:\n left = left + c\n\nif(not front):\n ans = left[::-1] + s + right\nelse:\n ans = right[::-1] + s[::-1] + left\n\nprint(ans)\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s807286448', 's952002650', 's013131088']
[3064.0, 3064.0, 31092.0]
[18.0, 18.0, 306.0]
[422, 422, 453]
p02756
u497952650
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 a = list(input().split())\n if len(a) == 1:##T_i=1\n S.reverse()\n else:#T_i == 2\n if a[1] == "1":\n S.insert(0,a[2])\n else:\n S.append(a[2])\n\nfor i in range(len(S)):\n print(S[i],end="")\n', 'S = input()\nQ = int(input())\nAtama = []\nOsiri = []\nrev = [0]*Q\nfor i in range(Q):\n a = list(input().split())\n if len(a) == 1:##T_i=1\n rev[i] = 1\n else:#T_i == 2\n if a[1] == "1":\n Atama.append([i,a[2],1])\n else:\n Osiri.append([i,a[2],-1])\n\n\nRev = []\ntmp = 0\nr = sum(rev)\nfor i in range(len(rev)):\n r -= rev[i]\n Rev.append(r)\n##print(Rev)\nfor i in range(len(Atama)):\n Atama[i][2] *= (-1)**Rev[Atama[i][0]]\nfor i in range(len(Osiri)):\n Osiri[i][2] *= (-1)**Rev[Osiri[i][0]]\n\nAns = Atama+Osiri\nAns.sort()\n##print(Ans)\nfw = ""\naw = ""\nN = len(Ans)\nfor i in range(N):\n if Ans[i][2] == 1:\n fw += Ans[i][1]\n else:\n aw += Ans[i][1]\n\nif sum(rev)%2 == 1:\n S = S[::-1]\nfw = fw[::-1]\n\nprint(fw+S+aw)']
['Time Limit Exceeded', 'Accepted']
['s153338063', 's321458470']
[4260.0, 39200.0]
[2104.0, 765.0]
[292, 790]
p02756
u498620941
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().split()\nN = int(input())\nQ = [[] for _ in range(N)]\nfor i in range(N):\n line = input().split()\n Q[i] = line\nreverse = 0\nr_b = []\nr_f = []\nfor i in range(N):\n if Q[i][0] == '1' :\n reverse = (reverse + 1) % 2\n else :\n if reverse == 0 :\n if Q[i][1] == '1' :\n r_f = [Q[i][2]] + r_f\n else :\n r_b.append(Q[i][2])\n else:\n if Q[i][1] == '1':\n r_b.append(Q[i][2])\n else:\n r_f = [Q[i][2]] + r_f\n\nprint(1)", 'S = input().split()\nN = int(input())\nreverse = 0\nr_b = []\nr_f = []\nfor i in range(N):\n line = input().split()\n if line[i][0] == \'1\' :\n reverse = (reverse + 1) % 2\n else :\n if reverse == 0 :\n if line[i][1] == \'1\' :\n r_f = [line[i][2]] + r_f\n else :\n r_b.append(line[i][2])\n else:\n if line[i][1] == \'1\':\n r_b.append(line[i][2])\n else:\n r_f = [line[i][2]] + r_f\n\nif reverse == 0 :\n S = r_f + S + r_b\n print("".join(S))\nelse:\n S.reverse()\n r_b.reverse()\n r_f.reverse()\n S = r_b + S + r_f\n print("".join(S))', 'S = input()\nN = int(input())\nQ = [[] for _ in range(N)]\nfor i in range(N):\n line = input().split()\n Q[i] = line\nreverse = 0\nr_b = ""\nr_f = ""\nfor i in range(N):\n if Q[i][0] == \'1\' :\n reverse = (reverse + 1) % 2\n else :\n if reverse == 0 :\n if Q[i][1] == \'1\' :\n r_f = Q[i][2] + r_f\n else :\n r_b = r_b +Q[i][2]\n else:\n if Q[i][1] == \'1\':\n r_b = r_b +Q[i][2]\n else:\n r_f = Q[i][2] + r_f\nif reverse == 0 :\n print(r_f + S + r_b)\nelse:\n r_f = r_f[::-1]\n r_b = r_b[::-1]\n S = S[::-1]\n print(r_b + S + r_f)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s143591336', 's786335963', 's782574982']
[41240.0, 3188.0, 40700.0]
[2106.0, 18.0, 1368.0]
[543, 657, 649]
p02756
u500297289
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 = list(input())\nQ = int(input())\nd = deque(S)\nflag = -1\nfor _ in range(Q):\n q = list(input().split())\n if q[0] == '1':\n flag *= -1\n else:\n f = int(q[1])\n c = q[2]\n if flag == 1 and f == 1 or flag == -1 and f == 2:\n d.appendleft(c)\n else:\n d.append(c)\n\nif flag == -1:\n d = d[::-1]\n\nprint(''.join(d))\n", "from collections import deque\n\nS = list(input())\nQ = int(input())\nd = deque(S)\nflag = -1\nfor _ in range(Q):\n q = list(input().split())\n if q[0] == '1':\n flag *= -1\n else:\n f = int(q[1])\n c = q[2]\n if flag == 1 and f == 1 or flag == -1 and f == 2:\n d.appendleft(c)\n else:\n d.append(c)\nd = list(d)\nif flag == 1:\n d = d[::-1]\n\nprint(''.join(d))\n", "from collections import deque\n\nS = list(input())\nQ = int(input())\nd = deque(S)\nflag = -1\nfor _ in range(Q):\n q = list(input().split())\n if q[0] == '1':\n flag *= -1\n else:\n f = int(q[1])\n c = q[2]\n if flag == -1 and f == 1 or flag == 1 and f == 2:\n d.appendleft(c)\n else:\n d.append(c)\nd = list(d)\nif flag == 1:\n d = d[::-1]\n\nprint(''.join(d))\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s591459243', 's837086610', 's194112014']
[8948.0, 10996.0, 10996.0]
[615.0, 589.0, 593.0]
[401, 411, 411]
p02756
u502508885
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 = str(input())\nQ = int(input())\n\ntmp = deque(S)\nhoukou = 1 \n\nfor i in range(Q):\n inp = input().split()\n if inp[0] == '1':\n if houkou == 1:\n houkou = 2\n else:\n houkou = 1\n else:\n if houkou == 1 and inp[1] == '1':\n tmp.appendleft(inp[2])\n elif houkou == 1 and inp[1] == '2':\n tmp.append(inp[2])\n elif houkou == 2 and inp[1] == '1':\n tmp.append(inp[2])\n else:\n tmp.appendleft(inp[2])\n \n print(houkou, tmp)\n\noutput = ''.join(list(tmp))\nif houkou == 2:\n output = output[::-1]\n\nprint(output)\n", "from collections import deque\n\nS = str(input())\nQ = int(input())\n\ntmp = deque(S)\nhoukou = 1 \n\nfor i in range(Q):\n inp = input().split()\n if inp[0] == '1':\n if houkou == 1:\n houkou = 2\n else:\n houkou = 1\n else:\n if houkou == 1 and inp[1] == '1':\n tmp.appendleft(inp[2])\n elif houkou == 1 and inp[1] == '2':\n tmp.append(inp[2])\n elif houkou == 2 and inp[1] == '1':\n tmp.append(inp[2])\n else:\n tmp.appendleft(inp[2])\n \n# print(houkou, tmp)\n\noutput = ''.join(list(tmp))\nif houkou == 2:\n output = output[::-1]\n\nprint(output)\n"]
['Runtime Error', 'Accepted']
['s868699846', 's175357898']
[137212.0, 8820.0]
[1884.0, 416.0]
[664, 665]
p02756
u502731482
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())\n\nfor i in range(n):\n Q = input()\n if int(Q[0]) == 2:\n F = int(Q[2])\n C = Q[4]\n print(F, C)\n if F == 1:\n s = C + s\n else:\n s = s + C\n else:\n s = s[::-1]\n \nprint(s)\n', '\nS = input()\nn = int(input())\n\nflag = 0\ns = []\ns.append(S)\nfor i in range(n):\n Q = input()\n if Q[0] == "2":\n print(Q[0], Q[2], Q[4])\n if Q[2] == "1":\n if flag == 1:\n s.append(Q[4])\n else:\n s.insert(0, Q[4])\n else:\n if flag == 0:\n s.append(Q[4])\n else:\n s.insert(0, Q[4])\n else:\n flag ^= 1\n \nprint("".join(s) if flag == 0 else "".join(s[::-1]))\n', '\ns = list(input())\nn = int(input())\n\nflag = 0\ns1 = []\ns2 = s\nfor i in range(n):\n Q = input()\n if Q[0] == "2":\n if Q[2] == "1":\n if flag == 1:\n s2.append(Q[4])\n else:\n s1.append(Q[4])\n else:\n if flag == 0:\n s2.append(Q[4])\n else:\n s1.append(Q[4])\n else:\n flag ^= 1\ns2 = s1[::-1] + s2\nprint("".join(s2) if flag == 0 else "".join(s2[::-1]))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s406675078', 's755532861', 's468852172']
[3956.0, 10484.0, 15652.0]
[2104.0, 2206.0, 276.0]
[269, 488, 472]
p02756
u506858457
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()\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 rev==False: \n \n if tmp[1]=='1':\n head.append(tmp[2])\n if tmp[1]=='2':\n tail.append(tmp[2])\n if rev==True: \n \n if tmp[1]=='1':\n tail.append(tmp[2])\n if tmp[1]=='2':\n head.append(tmp[2])\nhead=''.join(map(str,head))\ntail=''.join(map(str,tail))\nans=head[::-1]+s+tail \nif rev==True: \n ans=ans[::-1]\nprint(ans)", "\ns=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 rev==False: \n \n if tmp[1]=='1':\n head.append(tmp[2])\n if tmp[1]=='2':\n tail.append(tmp[2])\n if rev==True:\n if tmp[1]=='1':\n tail.append(tmp[2])\n if tmp[1]=='2':\n head.append(tmp[2])\nhead=''.join(map(str,head))\ntail=''.join(map(str,tail))\nans=head[::-1]+s+tail \nif rev==True: \n ans=ans[::-1]\nprint(ans)", "\nS=input()\nQ=int(input())\nhead=[]\ntail=[]\nrev=False\nfor i 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 rev==False:\n if tmp[1]=='1':\n head.append(tmp[2])\n else:\n tail.append(tmp[2])\n if rev==True:\n if tmp[1]=='1':\n tail.append(tmp[2])\n else:\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', 'Runtime Error', 'Accepted']
['s049004057', 's189808259', 's973912338']
[2940.0, 6396.0, 6344.0]
[17.0, 494.0, 497.0]
[1440, 1428, 1272]
p02756
u509739538
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\nimport queue\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tif n<r:\n\t\treturn 0\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\ndef printQueue(q):\n\tr=q\n\tans=[0]*r.qsize()\n\tfor i in range(r.qsize()-1,-1,-1):\n\t\tans[i] = r.get()\n\tprint(ans)\n\ns = readChar()\nq = readInt()\nqa = []\nbooh = 0\nfor i in range(q):\n\tx = input()\n\tif x=="1":\n\t\tqa.append([1,0,0])\n\telse:\n\t\tx = x.split()\n\t\tqa.append([int(x[0]),int(x[1]),x[2]])\n\ndef t1(s):\n\treturn s[::-1]\n\ndef t2(f,c,s):\n\tif f==1:\n\t\treturn c+s\n\telse:\n\t\treturn s+c\n\nfi=""\nla=""\nfor a in qa:\n\tif a[0]==1:\n\t\tbooh = (booh+1)%2\n\telse:\n\t\tif (a[1]+booh)%2==1:\n\t\t\tfi+=a[2]\n\t\telse:\n\t\t\tla+=a[2]\n\ns = fi+s+la\nif booh==1:\n\ts = t1(s)\n\nprint(s)', 'import math\nimport queue\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tif n<r:\n\t\treturn 0\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\ndef printQueue(q):\n\tr=q\n\tans=[0]*r.qsize()\n\tfor i in range(r.qsize()-1,-1,-1):\n\t\tans[i] = r.get()\n\tprint(ans)\n\ns = readChar()\nq = readInt()\nqa = []\nbooh = 0\nfor i in range(q):\n\tx = input()\n\tif x=="1":\n\t\tqa.append([1,0,0])\n\telse:\n\t\tx = x.split()\n\t\tqa.append([int(x[0]),int(x[1]),x[2]])\n\ndef t1(s):\n\treturn s[::-1]\n\ndef t2(f,c,s):\n\tif f==1:\n\t\treturn c+s\n\telse:\n\t\treturn s+c\n\nfi=""\nla=""\nq = queue.deque()\nfor a in qa:\n\tif a[0]==1:\n\t\tbooh = (booh+1)%2\n\telse:\n\t\tif (a[1]+booh)%2==1:\n\t\t\tfi=a[2]+fi\n\t\t\tq.appendleft(a[2])\n\t\telse:\n\t\t\tla+=a[2]\n\ns = "".join(list(q))+s+la\nif booh==1:\n\ts = t1(s)\n\nprint(s)']
['Wrong Answer', 'Accepted']
['s342519298', 's844429369']
[25708.0, 27744.0]
[659.0, 1603.0]
[1362, 1418]
p02756
u512099209
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 _ in range(Q):\n query = input().split()\n if query[0] == '1':\n S = S[::-1]\n else: \n F, C = query[1:]\n if F == '1':\n S = [C] + S\n else: # F == '2'\n S += [C]\nprint(S)\nprint(''.join(S))", "from collections import deque\n\nS = input()\npre, post = deque(), deque()\nQ = int(input())\nreversed = False\nfor _ in range(Q):\n query = input().split()\n if query[0] == '1':\n reversed = not reversed\n pre, post = post, pre\n else: \n F, C = query[1:]\n if F == '1':\n if reversed:\n pre.append(C)\n else:\n pre.appendleft(C)\n else: # F == '2'\n if reversed:\n post.appendleft(C)\n else:\n \tpost.append(C)\nif reversed:\n print(''.join(pre)[::-1] + S[::-1] + ''.join(post)[::-1])\nelse:\n print(''.join(pre) + S + ''.join(post))"]
['Wrong Answer', 'Accepted']
['s632348546', 's785098541']
[7636.0, 6508.0]
[2104.0, 441.0]
[262, 591]
p02756
u514118270
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\na = list(input())\nQ = int(input())\nd = deque(a)\nans = 0\nfor i in range(Q):\n b = list(input().split())\n if len(b) == 1:\n ans += 1\n elif b[1] == "1" and ans % 2 == 1:\n d.appendleft(b[2])\n elif b[1] == "1" and ans % 2 == 0:\n d.append(b[2])\n elif b[1] == "2" and ans % 2 == 1:\n d.append(b[2])\n elif b[1] == "2" and ans % 2 == 0:\n d.appendleft(b[2])\nprint("".join(d))', "from collections import deque\nS = deque(list(input()))\nQ = int(input())\nflag = 1\nfor i in range(Q):\n a = list(input().split())\n if a[0] == '1':\n if flag == 0:\n flag = 1\n else:\n flag = 0\n else:\n if a[1] == '1':\n if flag == 1:\n S.appendleft(a[2])\n else:\n S.append(a[2])\n else:\n if flag == 1:\n S.append(a[2])\n else:\n S.appendleft(a[2])\nif flag == 1:\n print(''.join(S))\nelse:\n S.reverse()\n print(''.join(S)) "]
['Wrong Answer', 'Accepted']
['s735562545', 's667071648']
[9332.0, 8420.0]
[523.0, 464.0]
[413, 577]
p02756
u515740713
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\nS = readline().decode().rstrip()\nQ = int(readline())\ncnt = 0\nstart = ''\nend = ''\nfor i in range(Q):\n A = list(map(str,readline().decode().split()))\n if A[0] == '1':\n cnt +=1\n else:\n if (cnt + int(A[1])) % 2:\n start += A[2]\n else:\n end += A[2]\nans = start + S + end\nif cnt % 2:\n print(ans[::-1])\nelse:\n print(ans)", "import sys \nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nS = readline().decode().rstrip()\nQ = int(readline())\ncnt = 0\nstart = ''\nend = ''\nfor i in range(Q):\n A = list(map(str,readline().decode().split()))\n if A[0] == '1':\n cnt +=1\n else:\n if (cnt + int(A[1])) % 2:\n start += A[2]\n else:\n end += A[2]\nans = start + S + end\nif cnt % 2 == 1:\n print(end[::-1] + S[::-1] + start)\nelse:\n print(start[::-1] + S + end)"]
['Wrong Answer', 'Accepted']
['s438515553', 's545209345']
[10088.0, 10308.0]
[255.0, 261.0]
[487, 528]
p02756
u516554284
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())\nh=0\nm=''\nu=''\nfor _ in range(q):\n d=input()\n if '2' in d:\n a,b,c=map(str,d.split())\n if b=='1':\n if h%2==0:\n u+=c\n else:\n m+=c\n \n else:\n if h%2==0:\n m+=c\n else:\n u+=c\n \n else:\n h+=1\n \nM=list(m)\nG=list(reversed(M))\ns=G+s+u\nif h%2==0:\n print(s)\nelse:\n f=list(s)\n g=list(reversed(f))\n print(''.join(g))", "s=input()\nq=int(input())\nh=0\nm=''\nu=''\nfor _ in range(q):\n d=input()\n if '2' in d:\n a,b,c=map(str,d.split())\n if b=='1':\n if h%2==0:\n m+=c\n else:\n u+=c\n \n else:\n if h%2==0:\n u+=c\n else:\n m+=c\n \n else:\n h+=1\n \nM=list(m)\nG=list(reversed(M))\nGG=''.join(G)\ns=GG+s+u\nif h%2==0:\n print(s)\nelse:\n f=list(s)\n g=list(reversed(f))\n print(''.join(g))"]
['Runtime Error', 'Accepted']
['s894465573', 's996624254']
[10764.0, 16076.0]
[399.0, 406.0]
[409, 424]
p02756
u517152997
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.
['#\nimport sys\nimport math\nimport numpy as np\nimport itertools\n\n\ns = list(input())\n\nq = int(input())\n\nt=0\na=[]\nb=[]\n\nfor i in range(q):\n query = input().split()\n print(query)\n if query[0]==\'1\':\n t = (t+1)%2\n else:\n if (t+int(query[1]))%2==0:\n b.append(query[2])\n else:\n a.append(query[2])\np=[]\nprint(a,s,b)\nif t == 0:\n a.reverse()\n p.extend(a)\n p.extend(s)\n p.extend(b)\nelse:\n b.reverse()\n s.reverse()\n p.extend(b)\n p.extend(s)\n p.extend(a)\n\nfor i in p:\n print(i,end="")\nprint("")\n\n', '#\nimport sys\nimport math\nimport numpy as np\nimport itertools\n\n\ns = list(input())\n\nq = int(input())\n\nt=0\na=[]\nb=[]\n\nfor i in range(q):\n query = input().split()\n# print(query)\n if query[0]==\'1\':\n t = (t+1)%2\n else:\n if (t+int(query[1]))%2==0:\n b.append(query[2])\n else:\n a.append(query[2])\np=[]\n#print(a,s,b)\nif t == 0:\n a.reverse()\n p.extend(a)\n p.extend(s)\n p.extend(b)\nelse:\n b.reverse()\n s.reverse()\n p.extend(b)\n p.extend(s)\n p.extend(a)\n\nfor i in p:\n print(i,end="")\nprint("")\n\n']
['Wrong Answer', 'Accepted']
['s837370853', 's037324619']
[23496.0, 18876.0]
[2109.0, 894.0]
[599, 601]
p02756
u517797706
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\nif __name__ == \'__main__\':\n\n s = input()\n n = int(input())\n\n rvflg = False\n\n d_st = deque()\n d_ed = deque()\n\n for _ in range(n):\n q = input()\n if len(q) == 1:\n if rvflg:\n rvflg = False\n else:\n rvflg = True\n else:\n i,f,c = map(str,q.split())\n if f == "1":\n if rvflg:\n \n d_ed.append(c)\n else:\n \n d_st.append(c)\n else:\n if rvflg:\n \n d_st.append(c)\n else:\n \n d_ed.append(c)\n\n ans = "".join(d_st) + s + "".join(d_ed)\n \n if rvflg:\n ans = ans[::-1]\n print(ans)\n\n', 'from collections import deque\nif __name__ == \'__main__\':\n\n s = input()\n n = int(input())\n\n rvflg = False\n\n d_st = deque()\n d_ed = deque()\n\n for _ in range(n):\n q = input()\n if len(q) == 1:\n if rvflg:\n rvflg = False\n else:\n rvflg = True\n else:\n i,f,c = map(str,q.split())\n if f == "1":\n if rvflg:\n \n d_ed.append(c)\n else:\n \n d_st.appendleft(c)\n else:\n if rvflg:\n \n d_st.appendleft(c)\n else:\n \n d_ed.append(c)\n\n ans = "".join(d_st) + s + "".join(d_ed)\n \n if rvflg:\n ans = ans[::-1]\n print(ans)\n\n']
['Wrong Answer', 'Accepted']
['s002429919', 's323716912']
[12468.0, 12348.0]
[394.0, 405.0]
[970, 978]
p02756
u517910772
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 switch(S):\n tmp = S[0]\n S[0] = S[-1]\n S[-1] = tmp\n return S\n\n\ndef d():\n S = list(str(input()))\n Q = int(input())\n\n for i in range(Q):\n print(S)\n q = list(input().split())\n # print(str(q))\n\n if q[0] == '1':\n S = switch(S)\n elif q[0] == '2':\n if q[1] == '1':\n S.insert(0, q[2])\n elif q[1] == '2':\n S.append(q[2])\n else:\n raise ValueError(\n 'F({}) is {}, which is invalid!'.format(i, q[1]))\n else:\n raise ValueError('T({}) is {}, which is invalid!'.format(i, q[0]))\n\n print(''.join(S))\n", "def switch(S):\n tmp = S[0]\n S[0] = S[-1]\n S[-1] = tmp\n return S\n\n\ndef d():\n S = list(str(input()))\n Q = int(input())\n\n for i in range(Q):\n # print(S)\n q = list(input().split())\n\n if q[0] == '1':\n S = switch(S)\n elif q[0] == '2':\n if q[1] == '1':\n S.insert(0, q[2])\n elif q[1] == '2':\n S.append(q[2])\n else:\n raise ValueError(\n 'F({}) is {}, which is invalid!'.format(i, q[1]))\n else:\n raise ValueError('T({}) is {}, which is invalid!'.format(i, q[0]))\n\n print(''.join(S))\n", "def switch(S):\n tmp = S[0]\n S[0] = S[-1]\n S[-1] = tmp\n return S\n\n\ndef d2():\n S = str(input())\n Q = int(input())\n\n for i in range(Q):\n # print(S)\n q = list(input().split())\n\n if q[0] == '1':\n S = switch(S)\n elif q[0] == '2':\n if q[1] == '1':\n S = q[2] + S\n elif q[1] == '2':\n S = S + q[2]\n else:\n raise ValueError(\n 'F({}) is {}, which is invalid!'.format(i, q[1]))\n else:\n raise ValueError('T({}) is {}, which is invalid!'.format(i, q[0]))\n\n print(''.join(S))\n\n\n##########\nd2()\n", 'def d():\n from collections import deque\n S = deque(str(input()))\n Q = int(input())\n rvs = False\n\n for i in range(Q):\n q = list(input().split())\n\n if q[0] == \'1\':\n rvs = not rvs\n elif q[0] == \'2\':\n if q[1] == \'1\':\n if rvs:\n S.append(q[2])\n else:\n S.appendleft(q[2])\n elif q[1] == \'2\':\n if rvs:\n S.appendleft(q[2])\n else:\n S.append(q[2])\n else:\n raise ValueError(\n \'F({}) is {}, which is invalid!\'.format(i, q[1]))\n else:\n raise ValueError(\'T({}) is {}, which is invalid!\'.format(i, q[0]))\n\n if rvs:\n ans = list(S)[::-1]\n else:\n ans = list(S)\n print(\'\'.join(ans))\n\n\n##########\nif __name__ == "__main__":\n d()\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s161498845', 's586918828', 's873176729', 's378556456']
[3064.0, 3064.0, 3760.0, 10100.0]
[17.0, 17.0, 2104.0, 437.0]
[672, 650, 656, 901]
p02756
u518064858
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.
['q=int(input())\ncnt1=0\nfor i in range(q):\n query=list(input().split())\n if int(query[0])==1:\n cnt1+=1\n else:\n if (int(query[1])+cnt1)%2==0:\n s.join(query[2])\n else:\n query[2].join(s)\nif cnt1%2==0:\n print(s)\nelse:\n s2=""\n for i in range(len(s)):\n s2.join(s[-1-i])\n print(s2)\n', 's=input()\nq=int(input())\ncnt1=0\ns_mae=[]\ns_ushiro=[]\nfor i in range(q):\n query=list(input().split())\n if int(query[0])==1:\n cnt1+=1\n else:\n if (int(query[1])+cnt1)%2==0:\n s_ushiro.append(query[2]])\n else:\n s_mae=[query[2]]+s_mae\nans="".join(s_mae)+s+"".join(s_ushiro)\nif cnt1%2==0:\n print(ans)\nelse:\n ans2=""\n for i in range(len(ans)):\n ans2=ans2+ans[-1-i]\n print(ans2)', 's=input()\nq=int(input())\ncnt1=0\ns_mae=[]\ns_ushiro=[]\nfor i in range(q):\n query=list(input().split())\n if int(query[0])==1:\n cnt1+=1\n else:\n if (int(query[1])+cnt1)%2==0:\n s_ushiro.append(query[2])\n else:\n s_mae.append(query[2])\ns1=""\nfor i in range(len(s_mae)):\n s1=s1+s_mae[-1-i]\ns2="".join(s_ushiro)\nans=s1+s+s2\nif cnt1%2==0:\n print(ans)\nelse:\n ans2=""\n for i in range(len(ans)):\n ans2=ans2+ans[-1-i]\n print(ans2)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s464321394', 's739180882', 's707348795']
[3188.0, 2940.0, 5968.0]
[18.0, 17.0, 665.0]
[344, 444, 490]
p02756
u524489226
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())\nn = int(input())\n\nfor _ in range(n):\n q = input()\n\n \n if q[0] == "1":\n s = s[::-1]\n continue\n\n q = q.split()\n\n print(q)\n\n if q[1] == "1":\n s = q[2] + s\n\n if q[1] == "2":\n s = s + q[2]\n\nprint(s)\n', 's = str(input())\nn = int(input())\n\nstat = 0\nfront = ""\nback = ""\n\nfor _ in range(n):\n q = input()\n\n \n if q[0] == "1":\n stat = (stat + 1) % 2\n continue\n\n judge = int(q[2])\n if stat == 1:\n if judge == 1:\n judge = 2\n elif judge == 2:\n judge = 1\n\n if judge == 1:\n front = q[4] + front \n\n if judge == 2:\n back = back + q[4]\n\ns = front + s + back\nif stat == 1:\n s = s[::-1]\n\nprint(s)\n']
['Wrong Answer', 'Accepted']
['s324943481', 's123742385']
[4952.0, 4416.0]
[2104.0, 1531.0]
[277, 483]
p02756
u527993431
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\nfor i in range(Q):\n\tK=input().split()\n\tif K[0]=="1":\n\t\tif i==Q-1:\n\t\t\tS=S[::-1]\n\t\telse:\n\t\t\tcount+=1\n\tif K[0]=="2":\n\t\tif K[1]=="1":\n\t\t\tif count%2==0:\n\t\t\t\tS=K[2]+S\n\t\t\telse:\n\t\t\t\tS=S+K[2]\n\t\telif K[1]=="2":\n\t\t\tif count%2==0:\n\t\t\t\tS=S+K[2]\n\t\t\telse:\n\t\t\t\tS=K[2]+S\nprint(S)\n', 'from collections import deque\nD=deque(input().rstrip())\nQ=int(input())\ncount=0\nfor _ in range(Q):\n\tY=list(input().split())\n\tif Y[0]=="1":\n\t\tcount=(count+1)%2\n\telse:\n\t\tif Y[1]=="1":\n\t\t\tif count==0:\n\t\t\t\tD.appendleft(Y[2])\n\t\t\telse:\n\t\t\t\tD.append(Y[2])\n\t\telse:\n\t\t\tif count==0:\n\t\t\t\tD.append(Y[2])\n\t\t\telse:\n\t\t\t\tD.appendleft(Y[2])\nD=list(D)\nif count==0:\n\tprint("".join(D))\nelse:\n\tD.reverse()\n\tprint("".join(D))']
['Wrong Answer', 'Accepted']
['s140881013', 's085389365']
[3840.0, 8436.0]
[2104.0, 483.0]
[296, 402]
p02756
u530786533
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.
["rom collections import deque\n\ns = input()\nq = int(input())\n\nt = deque(s)\n\nreverse = False\nfor _ in range(q):\n query = input()\n if query[0] == '1':\n reverse = not reverse\n elif query[0] == '2':\n _, f, c = query.split()\n if f == '1':\n if reverse:\n t.append(c)\n else:\n t.appendleft(c)\n elif f == '2':\n if reverse:\n t.appendleft(c)\n else:\n t.append(c)\n\nresult = ''.join(t)\nif reverse:\n result = result[::-1]\nprint(result)\n", "from collections import deque\n\ns = input()\nq = int(input())\n\nt = deque(s)\n\nreverse = False\nfor _ in range(q):\n query = input()\n if query[0] == '1':\n reverse = not reverse\n elif query[0] == '2':\n _, f, c = query.split()\n if f == '1':\n if reverse:\n t.append(c)\n else:\n t.appendleft(c)\n elif f == '2':\n if reverse:\n t.appendleft(c)\n else:\n t.append(c)\n\nresult = ''.join(t)\nif reverse:\n result = result[::-1]\nprint(result)\n"]
['Runtime Error', 'Accepted']
['s356262136', 's798203745']
[2940.0, 8820.0]
[17.0, 425.0]
[522, 523]
p02756
u530823931
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("S"))\nQ = int(input("Q"))\nquery = []\nfor i in range(Q) :\n query.append(input())\n if query[i] == "1" : #Ti = 1 reverse\n S[0], S[len(S)-1] = S[len(S)-1], S[0]\n else : #Ti = 2 str +\n T, F, C = query[i].split()\n if F == "1" :#Fi = 1 str + top\n S.insert(0, C)\n else :#Fi = 2 str + end\n S.append(C)\nprint(\'\'.join(S))', 'from collections import deque\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n S = list(input().strip())\n Q = int(input())\n\n d = deque(S)\n mode = True\n\n for _ in range(Q):\n query = input().split()\n\n if query[0] == "1":\n mode = not mode\n elif query[0] == "2":\n F, C = query[1], query[2]\n if F == "1":\n if mode:\n d.appendleft(C)\n else:\n d.append(C)\n elif F == "2":\n if mode:\n d.append(C)\n else:\n d.appendleft(C)\n\n s = list(d)\n if not mode:\n s = s[::-1]\n\n print(\'\'.join(s))\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s244762994', 's470584344']
[10612.0, 10868.0]
[2104.0, 140.0]
[391, 744]
p02756
u533328562
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\nl = r = ""\nfor op in qs:\n if op[0] == \'1\':\n n = not n\n if op[0] == \'2\':\n t , f, c = op\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f != 1:\n l=c+l\n elif f == 2:\n r+=c\ns = l+s+r\nprint(s[::-1] if n else s)', 's = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nl = r = ""\nfor op in qs:\n if op[0] == \'1\':\n n = not n\n if op[0] == \'2\':\n t , f, c = op\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f = 1:\n l=c+l\n elif f == 2:\n r+=c\ns = l+s+r\nprint(s[::-1] if n else s)', 's = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nl = r = ""\nfor op in qs:\n if op[0] == \'1\':\n n = not n\n if op[0] == \'2\':\n t , f, c = op\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n l=c+l\n elif f == 2:\n r+=c\ns = l+s+r\nprint(s[::-1] if n else s)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s540652184', 's881991771', 's746137290']
[40196.0, 2940.0, 41332.0]
[720.0, 18.0, 1445.0]
[366, 365, 366]
p02756
u535803878
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\n\n# for ss in lines:\n# yield ss.rstrip()\n# input = _input().__next__\n\ns = input()\nq = int(input())\nturn = 0\n\nbefore = "" \nafter = ""\nfor _ in range(q):\n tmp = input()\n if tmp=="1":\n turn += 1\n else:\n _,f,c = tmp.split()\n f = int(f)\n if (turn + f) % 2 == 1:\n before += c\n else:\n after += c\nif turn%2==0:\n out = before[::-1] + s + after\nelse:\n out = after[::-1] + s[::-1] + before\nprint(out)', '\ns = input()\nq = int(input())\nturn = 0\n\nbefore = "" \nafter = ""\nfor _ in range(q):\n tmp = input()\n if tmp=="1":\n turn += 1\n else:\n _,f,c = tmp.split()\n f = int(f)\n if (turn + f) % 2 == 1:\n before += c\n else:\n after += c\nif turn%2==0:\n out = before[::-1] + s + after\nelse:\n out = after[::-1] + s[::-1] + before\nprint(out)\n']
['Runtime Error', 'Accepted']
['s861801571', 's182038018']
[4212.0, 4340.0]
[256.0, 565.0]
[602, 432]
p02756
u540698208
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 = stdin.readline().rstrip().split()\nq = int(stdin.readline().rstrip())\n\nleft = 1\nfor i in range(q):\n line = stdin.readline().rstrip().split()\n if len(line) == 1:\n left *= -1\n else:\n if ((line[1] == '1') and (left == 1)) or ((line[1] == '2') and (left == -1)):\n s.append(line[2])\n else:\n s.insert(0, line[2])", "from sys import stdin\nfrom collections import deque\n\ns = deque(x for x in stdin.readline().rstrip())\nq = int(stdin.readline().rstrip())\n\ndirection = 1\n\nfor i in range(q):\n query = stdin.readline().rstrip().split()\n if len(query) == 1:\n direction *= -1\n else:\n if ((query[1] == '1') and (direction == 1)) or ((query[1] == '2') and (direction == -1)):\n s.appendleft(query[2])\n else:\n s.append(query[2])\n\nsl = list(s)\nif direction == 1:\n print(''.join(sl))\nelse:\n print(''.join(sl[::-1]))"]
['Wrong Answer', 'Accepted']
['s077337496', 's504221551']
[4724.0, 10356.0]
[2104.0, 209.0]
[384, 543]
p02756
u546338822
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.
['12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11^CTraceback (most recent call last):\n File "/Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py", line 48, in <module>\n main(ptvsdArgs)\n File "/Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main\n run()\n File "/Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file\n runpy.run_path(target, run_name=\'__main__\')\n File "/Users/kenmurata/anaconda3/lib/python3.7/runpy.py", line 263, in run_path\n pkg_name=pkg_name, script_name=fname)\n File "/Users/kenmurata/anaconda3/lib/python3.7/runpy.py", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File "/Users/kenmurata/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code\n exec(code, run_globals)\n File "/Users/kenmurata/practice/AtCoder/test.py", line 10, in <module>\n print(j)\nKeyboardInterrupt\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 63018 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \n^CTraceback (most recent call last):\n File "/Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py", line 48, in <module>\n main(ptvsdArgs)\n File "/Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main\n run()\n File "/Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file\n runpy.run_path(target, run_name=\'__main__\')\n File "/Users/kenmurata/anaconda3/lib/python3.7/runpy.py", line 263, in run_path\n pkg_name=pkg_name, script_name=fname)\n File "/Users/kenmurata/anaconda3/lib/python3.7/runpy.py", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File "/Users/kenmurata/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code\n exec(code, run_globals)\n File "/Users/kenmurata/practice/AtCoder/test.py", line 10, in <module>\n if int(s[j:j+nagasa]) == tansaku:\nKeyboardInterrupt\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 63781 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncpa\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 51171 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncpa\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 51236 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncbaa\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 51386 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncbaa\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 51967 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncbaa\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 52232 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \n0\n0\n0\n1\n1\n0\ncbaa\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 52636 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \n0\n0\n0\n1\n1\n0\naabc\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 52680 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \naabc\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 52735 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \nxy\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 55393 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \nxy\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 55498 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \naacb\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 55580 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \npca\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 56916 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncap\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 57679 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncap\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 58073 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \nc p\ncap\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 58448 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \n cp\nacp\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 59236 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \n cp\nacp\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 59555 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \n c\nac\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 62327 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncp \na\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 62438 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \ncpa\ncpa\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 62627 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \naabc\n(base) bash-3.2$ cd /Users/kenmurata/practice ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kenmurata/anaconda3/bin/python /Users/kenmurata/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 62684 /Users/kenmurata/practice/AtCoder/test.py < /Users/kenmurata/practice/AtCoder/input.txt \nxy\n(base) bash-3.2$ ', 'def main():\n s = input()\n q = int(input())\n l,r = \'\',\'\'\n rev = 0\n for i in range(q):\n Q = input().split()\n if Q[0]=="1":\n rev = (rev+1)%2\n else:\n if Q[1]==\'1\':\n if rev==0:\n l = Q[2]+l\n else:\n r = r+Q[2]\n else:\n if rev==0:\n r = r+Q[2]\n else:\n l = Q[2]+l\n s = l+s+r\n if rev==0:\n print(s)\n else:\n print(s[::-1])\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s290948758', 's289396091']
[3704.0, 4712.0]
[18.0, 1443.0]
[12472, 575]
p02756
u548303713
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\nss=deque()\ns=list(input())\nl=len(s)\nfor i in range(l):\n ss.append(s[i])\nq=int(input())\ninfo=[]\nfor i in range(q):\n info.append(list(input().split()))\nmoji=l\nfor i in range(q):\n if info[i][0]=="1":\n ss.rotate(moji-1)\n else:\n if info[i][1]=="2":\n ss.append(info[i][2])\n else:\n ss.appendleft(info[i][2])\n moji+=1\n #print(s)\nprint("".join(ss))', 'from collections import deque\n\ns=input()\nq=int(input())\ncount=0 \nss=deque(s)\nflag=True \nfor i in range(q):\n info=input()\n if info[0]=="1":\n count+=1\n if flag:\n flag=False\n else:\n flag=True\n else:\n _,f,c=info.split()\n if flag:\n if f=="1":\n ss.appendleft(c)\n else:\n ss.append(c)\n else: \n if f=="1":\n ss.append(c)\n else:\n ss.appendleft(c)\nans="".join(ss)\nprint(ans if count%2==0 else ans[::-1])']
['Wrong Answer', 'Accepted']
['s176081702', 's781409681']
[35956.0, 8564.0]
[556.0, 419.0]
[434, 619]
p02756
u548545174
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())\nQueries = [input().split() for _ in range(Q)]\n\nneed_reverse = False\n\nfor q in Queries:\n if q[0] == "1":\n need_reverse = not need_reverse\n else:\n if q[1] == "1":\n if not need_reverse:\n S.appendleft(q[2])\n else:\n S.append(q[2])\n else:\n if not need_reverse:\n S.append(q[2])\n else:\n S.appendleft(q[2])\n\nprint(S if not need_reverse else S[::-1])\n', 'from collections import deque\n\nS = deque(input())\nQ = int(input())\n\nreverse = False\ncnt = 0\nfor i in range(Q):\n inp = input().split()\n if inp[0] == "1":\n cnt += 1\n reverse = (cnt % 2 != 0)\n #S = S[::-1]\n else:\n f, c = inp[1:]\n if int(f) == 1:\n if reverse:\n S.append(c)\n else:\n S.leftappend(c)\n else:\n if reverse:\n S.leftappend(c)\n else:\n S.append(c)\nS = "".join(S)\nprint(S[::-1] if reverse else S)', 'S = input()\nQ = int(input())\n#inp = [input().split() for _ in range(Q)]\n\n\n\ncnt = 0\nfor i in range(Q):\n inp = input().split()\n if len(inp) == 1:\n cnt += 1\n #S = S[::-1]\n else:\n if cnt % 2 != 0:\n S = S[::-1]\n cnt = 0\n f, c = inp[1:]\n if int(f) == 1:\n S = c + S\n else:\n S = S + c\nprint(S)', 'from collections import deque\n\nS = deque(input())\nQ = int(input())\nQueries = [input().split() for _ in range(Q)]\n\nneed_reverse = False\n\nfor q in Queries:\n if q[0] == "1":\n need_reverse = not need_reverse\n else:\n if q[1] == "1":\n if not need_reverse:\n S.appendleft(q[2])\n else:\n S.append(q[2])\n else:\n if not need_reverse:\n S.append(q[2])\n else:\n S.appendleft(q[2])\n\nS = "".join(S)\nprint(S if not need_reverse else S[::-1])\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s284455911', 's781163999', 's866170842', 's517723135']
[47472.0, 4212.0, 3804.0, 44532.0]
[474.0, 23.0, 2104.0, 437.0]
[539, 552, 406, 554]
p02756
u549383771
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 rev_f(string , i):\n if i[2] == '2':\n string = string + i[4]\n\n if i[2] == '1':\n string = i[4] + string\n return string\n\n\n\ndef rev_s(string , i):\n if i[2] == '1':\n string = string + i[4]\n\n if i[2] == '2':\n string = i[4] + string\n return string\n\n\n\nfront = ''\nback = ''\nstring = input()\nnum = int(input())\nq_list = []\nreverse_num = 0\nreverse = True\nreverese_s = False\nfor a in range(num):\n i = input()\n if i == '1':\n reverse_num +=1 \n if reverese_s:\n reverese_s = False\n else:\n reverese_s = True\n else:\n if reverese_s == False:\n if i[2] == '2':\n back += i[4]\n else:\n front += i[4]\n \n else :\n if i[2] == '2':\n front += i[4]\n else:\n back += i[4]\n \nif reverse_num %2 == 0:\n reverse = False\n \nif reverse == True:\n string = back + string[::-1] + front\n \nelse:\n string = front + string + back\nprint(string)\n", "def rev_f(string , i):\n if i[2] == '2':\n string = string + i[4]\n\n if i[2] == '1':\n string = i[4] + string\n return string\n\n\n\ndef rev_s(string , i):\n if i[2] == '1':\n string = string + i[4]\n\n if i[2] == '2':\n string = i[4] + string\n return string\n\n\n\nfront = ''\nback = ''\nstring = input()\nnum = int(input())\nq_list = []\nreverse_num = 0\nreverse = True\nreverese_s = False\nfor a in range(num):\n i = input()\n if i == '1':\n reverse_num +=1 \n if reverese_s:\n reverese_s = False\n else:\n reverese_s = True\n else:\n if reverese_s == False:\n if i[2] == '2':\n back += i[4]\n else:\n front = i[4] + front\n \n else :\n if i[2] == '2':\n front = i[4] + front\n else:\n back += i[4]\n \nif reverse_num %2 == 0:\n reverse = False\n \nstring = front + string + back\nif reverse == True:\n string = string[::-1]\n \nprint(string)\n"]
['Wrong Answer', 'Accepted']
['s833670605', 's721320007']
[4384.0, 4412.0]
[377.0, 1365.0]
[1050, 1039]
p02756
u556589653
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()\nk = []\nQ = int(input())\nnow = 0\nans = ""\nfor i in range(Q):\n K = input().split()\n if K[0] == "1":\n if mode == 1:\n mode = 0\n else:\n mode = 1\n else:\n if K[1] == "1":\n if mode == 0:\n #k[left] = K[2]\n S = K[2]+ S\n else:\n S = S+K[2]\n else:\n if mode == 0:\n S = S+K[2]\n else:\n S = K[2]+S\nif mode == 1:\n for i in range(1,len(S)+1):\n ans += S[-i]\n print(ans)\nelse:\n print(S)', 'S = input()\nQ = int(input())\nmode = 0\nans_1 = ""\nans_2 = ""\nfor i in range(Q):\n K = input().split()\n if K[0] == "1":\n if mode == 0:\n mode = 1\n else:\n mode = 0\n else:\n if K[1] == "1":\n if mode == 0:\n ans_1 += K[2]\n else:\n ans_2 += K[2]\n else:\n if mode == 0:\n ans_2 += K[2]\n else:\n ans_1 += K[2]\nans_1 = ans_1[::-1]\nK = ans_1+S+ans_2\nif mode == 1:\n print(K[::-1])\nelse:\n print(K)']
['Runtime Error', 'Accepted']
['s538196763', 's233544813']
[3188.0, 4468.0]
[18.0, 443.0]
[571, 546]
p02756
u556610039
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())\nisReverce = False\nans = q\nfor x in range(q):\n query = list(map(str, input().split()))\n if query[0] == "1": isReverce = not isReverce\n else:\n if (query[1] == "1" and isReverce == False) or (query[1] == "2" and isReverce == True):\n s = query[2] + s\n else: s += query[2]\nif isReverce == False: print(s[::-1])\nelse: print(s[::-1])\n', 's = input()\nq = int(input())\nansList = [""] * (2 * 10 ** 5 * 2 + 1)\nlast = 2 * 10 ** 5\nfirst = 2 * 10 ** 5 - 1\nfor x in range(len(s)):\n ansList[last] = s[x]\n last += 1\nisReverce = False\nfor x in range(q):\n query = list(map(str, input().split()))\n if query[0] == "1": isReverce = not isReverce\n else:\n if (query[1] == "1" and isReverce == False) or (query[1] == "2" and isReverce == True):\n ansList[first] = query[2]\n first -= 1\n else:\n ansList[last] = query[2]\n last += 1\nans = "".join(ansList)\nif isReverce == False: print(ans)\nelse: print(ans[::-1])\n']
['Wrong Answer', 'Accepted']
['s887570895', 's232844856']
[3968.0, 7412.0]
[2104.0, 698.0]
[390, 625]
p02756
u557565572
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(list(input()))\nq = int(input())\n\nfor i in range(q):\n que = input().split()\n if que[0] == 1:\n S.reverse()\n \n else:\n if que[1]==1:\n S.appendleft(que[-1])\n else: S.append(que[-1])\n \nans = "".join(S)\nprint(ans)\n', "\n# import heapq\n# from copy import deepcopy\nfrom collections import deque\n# from collections import Counter\n# from itertools import accumulate\n# from itertools import permutations\n# import numpy as np\n# import math\n\n\n# a = list(map(int, input().split()))\ns = deque(input())\nq = int(input())\nrev = False\nfor i in range(q):\n que = input()\n if que[0] == '1':\n rev = not rev\n else:\n que = list(que.split())\n if (int(que[1])==1 and not rev) or (int(que[1])==2 and rev):\n s.appendleft(que[2])\n else:\n s.append(que[2])\n\nif rev: ans = s[::-1]\nelse: ans = s\nprint(ans)\n", 'from collections import deque\n\ns = deque(input())\nq = int(input())\n\nfor i in range(q):\n que = input().split()\n if que[0] == 1:\n S.reverse()\n \n else:\n if que[1]==1:\n S.appendleft(que[-1])\n else: S.append(que[-1])\n \nS = "".join(S)\nprint(S)', "\n# import heapq\n# from copy import deepcopy\nfrom collections import deque\n# from collections import Counter\n# from itertools import accumulate\n# from itertools import permutations\n# import numpy as np\n# import math\n\n\n# a = list(map(int, input().split()))\ns = deque(input())\nq = int(input())\nrev = False\nfor i in range(q):\n que = input()\n if que[0] == '1':\n rev = not rev\n else:\n que = list(que.split())\n if (int(que[1])==1 and not rev) or (int(que[1])==2 and rev):\n s.appendleft(que[2])\n else:\n s.append(que[2])\n\nif rev: ans = ''.join(reversed(s))\nelse: ans = ''.join(s)\nprint(ans)\n"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s154229144', 's589225302', 's875506984', 's651883382']
[4852.0, 11120.0, 4212.0, 8564.0]
[23.0, 609.0, 23.0, 592.0]
[303, 668, 292, 690]
p02756
u557792847
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\nimport numpy as np\n\ninput = sys.stdin.readline\n\ns = list(input())\n\nn = int(input())\n\nfor ii in range(n):\n q = input()\n# print("".join(s))\n if q[0] == "1":\n s = s[::-1]\n else:\n t, f, c = q.split()\n if f == "1":\n s.insert(0, c)\n else:\n s.append(c)\nprint("".join(s))', '# TLE\nimport sys\nimport numpy as np\nfrom collections import deque\n\n# input = sys.stdin.readline\n\ns = list(input())\n\nn = int(input())\n\nd = deque(s)\n\nreverse = False\nfor ii in range(n):\n q = input()\n# print("".join(s))\n if q[0] == "1":\n reverse += 1\n reverse %= 2\n\n else:\n t, f, c = q.split()\n if f == "1":\n if reverse:\n d.append(c)\n else:\n d.appendleft(c)\n else:\n if reverse:\n d.appendleft(c)\n else:\n d.append(c)\n \nif reverse:\n d.reverse()\nprint("".join(d))']
['Wrong Answer', 'Accepted']
['s452705074', 's480214327']
[21404.0, 18264.0]
[2108.0, 548.0]
[337, 647]
p02756
u558182684
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 c = 0\n s = input()\n f = ''\n b = ''\n for _ in range(int(input())):\n q = input().split()\n if q[0] == '1':\n c += 1\n else:\n if (q[1] == '1' and c%2 == 0) or (q[1]=='2' and c%2==1):\n f = q[2] + f\n else:\n b += q[2]\n if c % 2:\n print(f+s+b)\n else:\n print(b[::-1]+s[::-1]+f[::-1])\n\nif __name__ == '__main__':\n main()\n", "def main():\n c = 0\n s = input()\n for _ in range(int(input())):\n q = input().split()\n if q[0] == '1':\n c += 1\n else:\n if q[1] == '1':\n s = q[2] + s\n else:\n s += q[2]\n if c%2 == 0:\n\t print(s)\n else:\n print(s[::-1])\n\nif __name__ == '__main__':\n main()\n", "def main():\n c = 0\n s = input()\n f = ''\n b = ''\n for _ in range(int(input())):\n q = input().split()\n if q[0] == '1':\n c += 1\n else:\n if (q[1] == '1' and c%2 == 0) or (q[1]=='2' and c%2==1):\n f = q[2] + f\n else:\n b += q[2]\n if c % 2 == 0:\n print(f+s+b)\n else:\n print(b[::-1]+s[::-1]+f[::-1])\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s172765772', 's983094666', 's168746103']
[4464.0, 3940.0, 4464.0]
[1446.0, 2104.0, 1483.0]
[444, 361, 448]
p02756
u562550538
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()\ns=deque(s)\nq=int(input())\nans=''\nflg=False\nfor _ in range(q):\n\tflg=False\n\tquery=list(map(str,input().split()))\n\tif query[0]=='1':\n\t\tflg=True\n\telse:\n\t\tif flg:\n\t\t\ts.reverse()\n\t\tif query[1]=='1':\n\t\t\ts.appendleft(query[2])\n\t\telse:\n\t\t\ts.append(query[2])\nans=''.join(s)\nif flg:\n\tans=ans[::-1]\n\nprint(ans)", "from collections import deque\n\ns=input()\ns=deque(s)\nq=int(input())\nans=''\nflg=False\nfor _ in range(q):\n\tflg=False\n\tquery=list(map(str,input().split()))\n\tif query[0]=='1':\n\t\tflg=True\n\telse:\n\t\tif flg:\n\t\t\ts.reverse()\n\t\tif query[1]=='1':\n\t\t\ts.appendleft(query[2])\n\t\telse:\n\t\t\ts.append(query[2])\nif flg:\n\ts.reverse()\n\nprint(''.join(s))", "\n#n,m=map(int,input().split())\n#a=[int(x) for _ in input().split()]\n\ns=input()\nq=int(input())\nans=''\nflg=False\nfor i in range(q):\n t=map(str,input().split())\n if t[0]=='1':\n \tflg=True\n else:\n\t\tif flg:\n\t\t\ts.reverse()\n if t[1]=='1':\n\t\t\ts=t[2]+s\n else:\n s=s+t[2]\n ans=s\nprint(s)", "from collections import deque\n\ns=input()\ns=deque(s)\nq=int(input())\nans=''\nflg=False\nfor _ in range(q):\n\tflg=False\n\tquery=list(map(str,input().split()))\n\tif query[0]=='1':\n\t\tflg=True\n\telse:\n\t\tif flg:\n\t\t\ts.reverse()\n\t\tif query[1]=='1':\n\t\t\ts.appendleft(query[2])\n\t\telse:\n\t\t\ts.append(query[2])\nif flg:\n\ts=s[::-1]\n\nprint(''.join(s))", "\n#n,m=map(int,input().split())\n#a=[int(x) for _ in input().split()]\n\ns=input()\nq=int(input())\nans=''\nflg=False\nfor i in range(q):\n t=map(str,input().split())\n if t[0]=='1':\n \tflg=True\n else:\n\t\tif flg:\n\t\t\ts.reverse()\n if t[1]=='1':\n\t\t\ts=t[2]+s\n else:\n s=s+t[2]\n ans=s\nprint(s)", "from collections import deque\n\ns=input()\ns=deque(s)\nq=int(input())\nans=''\nflg=False\nfor _ in range(q):\n\tflg=False\n\tquery=list(map(str,input().split()))\n\tif query[0]=='1':\n\t\tflg=True\n\telse:\n\t\tif flg:\n\t\t\ts.reverse()\n\t\tif query[1]=='1':\n\t\t\ts.appendleft(query[2])\n\t\telse:\n\t\t\ts.append(query[2])\nif flg:\n\ts.reverse()\n\nprint(''.join(s))", "from collections import deque\n\ns=input()\ns=deque(s)\nq=int(input())\nans=''\nflg=0\nfor _ in range(q):\n\tquery=list(map(str,input().split()))\n\tif query[0]=='1':\n\t\tflg=1-flg\n\telse:\n\t\tif flg:\n\t\t\tif query[1]=='1':\n\t\t\t\ts.append(query[2])\n\t\t\telse:\n\t\t\t\ts.appendleft(query[2])\n\t\telse:\n\t\t\tif query[1]=='1':\n\t\t\t\ts.appendleft(query[2])\n\t\t\telse:\n\t\t\t\ts.append(query[2])\nif flg:\n\tt=[]\n\tfor i in range(len(s)):\n\t\tt.append(s.pop())\n\tprint(''.join(t))\nelse:\n print(''.join(s))"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s002231689', 's012854094', 's207555632', 's436254992', 's655747621', 's794535725', 's399293846']
[8820.0, 8692.0, 2940.0, 8692.0, 3188.0, 8820.0, 8692.0]
[666.0, 686.0, 17.0, 657.0, 18.0, 659.0, 710.0]
[339, 329, 315, 327, 315, 329, 458]
p02756
u563838154
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 = []\n# for j in range(q):\n# a.extend([list(map(str,input().split()))])\n# # print(a)\n\nfor j in range(q):\n i = map(str,input().split())\n if i ==["1"]:\n s = s[::-1]\n elif i[0]=="2" and i[1]=="1":\n s = i[2]+s\n elif i[0]=="2" and i[1]=="2":\n s = s +i[2]\nprint(s)', 's = input()\nq = int(input())\na = []\n# for j in range(q):\n# a.extend([list(map(str,input().split()))])\n# # print(a)\n\npre = ""\nnex = ""\nc = 1\nTFC = [input().split() for _ in range(q)]\nfor i in TFC:\n# for j in range(q):\n\n if i ==["1"]:\n c *= -1\n \n elif i[0]=="2" and i[1]=="1":\n \n if c == 1:\n pre=pre+i[2]\n else:\n nex = nex + i[2]\n elif i[0]=="2" and i[1]=="2":\n \n if c ==1:\n nex = nex +i[2]\n else:\n pre = pre+i[2]\nif c==-1:\n print(nex[::-1]+s[::-1]+pre)\nelse:\n print(pre[::-1]+s+nex)']
['Runtime Error', 'Accepted']
['s466931733', 's120993417']
[3188.0, 40436.0]
[17.0, 455.0]
[338, 691]
p02756
u566552503
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\ns = str(sys.stdin.readline())\nQ = int(sys.stdin.readline())\n\nfor _ in range(Q):\n\tqu = input()\n\tif qu == '1':\n\t\ts = s[::-1]\n\telse:\n\t\t_, fi, ci = qu.split()\n\t\tif fi == '1':\n\t\t\ts = ci + s\n\t\tif fi == '2':\n\t\t\ts += ci\nprint(s)", 'from collections import deque\nimport sys\n\ndef main():\n s = sys.stdin.readline().strip()\n qn = int(sys.stdin.readline().strip())\n qs = [input().split() for _ in range(qn)]\n\n cn = 0\n s = deque(s)\n\n for q in qs:\n if len(q) == 1:\n cn+=1\n else:\n if q[1] == \'1\':\n s.appendleft(q[2])\n else:\n s.append(q[2])\n\n if cn%2 == 1:\n s.reverse()\n print(\'%s\' % \'\'.join(s))\n\nif __name__ == "__main__":\n\n main()', "import sys\n\ndef main():\n\n try:\n Ti = n = 0\n S = []\n S = list(map(str, input()))\n Q = map(int, input())\n while n < 6:\n Query = input().split()\n if len(Query) == 1:\n S[0], S[-1] = S[-1], S[0]\n\n if len(Query) == 3:\n Ti, Fi, Ci = Query\n if Ti == '2':\n if Fi == '1':\n S.insert(0, Ci)\n if Fi == '2':\n S.append(Ci)\n n+=1\n print(''.join(S))\n\n except KeyboardInterrupt:\n sys.exit(0)\n\nif __name__ == '__main__':\n main()", "n = 0\nS = str(input())\nQ = int(input())\n\nwhile n < Q:\n Query = input().split()\n if len(Query) == 1:\n s = S[:S.find('_')]\n e = S[S.rfind('_')+1:]\n c = S[S.find('_')+1:S.rfind('_')]\n ecs = e + '_' +c + '_' +s\n S = ecs\n if len(Query) == 3:\n Ti, Fi, Ci = Query\n if Ti == '2':\n if Fi == '1':\n S = Ci + '_' + S\n if Fi == '2':\n S+='_'+Ci\n n+=1", "import sys\ninput = sys.stdin.readline\n\ns = str(input())\nQ = int(input())\n\nfor _ in range(Q):\n\tqu = input()\n\tif qu == '1':\n\t\ts = s[::-1]\n\telse:\n\t\t_, fi, ci = qu.split()\n\t\tif fi == '1':\n\t\t\ts = ci + s\n\t\tif fi == '2':\n\t\t\ts += ci\nprint(s)", 'from collections import deque\nimport sys\n\ndef main():\n s = sys.stdin.readline().strip()\n qn = int(sys.stdin.readline().strip())\n qs = [input().split() for _ in range(qn)]\n\n s = deque(s)\n r = 1\n for q in qs:\n if len(q) == 1:\n r = r * -1\n\n else:\n if q[1] == \'1\':\n if r == 1:\n s.appendleft(q[2])\n else:\n s.append(q[2])\n else:\n if r == 1:\n s.append(q[2])\n else:\n s.appendleft(q[2])\n\n if r == 1:\n print(\'\'.join(s))\n else:\n s.reverse()\n print(\'\'.join(s))\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s280953693', 's373555865', 's643054881', 's792961941', 's870134689', 's471829546']
[3804.0, 161464.0, 4132.0, 5580.0, 3956.0, 44532.0]
[2104.0, 2106.0, 28.0, 2104.0, 2104.0, 408.0]
[231, 518, 640, 449, 233, 715]
p02756
u574211979
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())\nrlist, llist = [], []\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n pass\n else:\n if lists[1] == "2":\n rlist.append(lists[2])\n else:\n llist.append(lists[2])\nprint(S)', 'S = input() \nQ = int(input())\nrlist, llist = [], []\nflag, cnt = 0, 0\n\ndef trans(f):\n if f == 1:\n f = 0\n elif f == 0:\n f = 1\n return f\n\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n flag = trans(flag)\n else:\n if lists[1] == "2":\n rlist.append(lists[2])\n else:\n llist.append(lists[2])\nprint(S)', 'S = input() \nQ = int(input())\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n pass\n else:\n pass\nprint(S)', 'S = input() \nQ = int(input())\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n S = S[::-1]\n else:\n S = S + lists[2]\nprint(S)', 'S = input() \nQ = int(input())\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n pass\n else:\n S = S + lists[2]\nprint(S)', 'S = input() \nQ = int(input())\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n pass\n else:\n if lists[1] == "2":\n S = S + lists[2]\n else:\n S = lists[2] + S\nprint(S)', 'S = input() \nQ = int(input())\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n pass\n else:\n if lists[1] == "2":\n S = S + lists[2]\n else:\n pass\nprint(S)', 'S = input() \nQ = int(input())\nrlist, llist = [], []\nflag, cnt = 0, 0\n\ndef trans(f):\n if f == 1:\n f = 0\n elif f == 0:\n f = 1\n return f\n\ndef pros(f, r, add):\n if f == 0:\n if r == "1":\n llist.append(lists[2])\n elif r == "2":\n rlist.append(lists[2])\n elif f == 1:\n if r == "2":\n llist.append(lists[2])\n elif r == "1":\n rlist.append(lists[2])\n\nfor i in range(Q):\n lists = input().split()\n if lists[0] == "1":\n flag = trans(flag)\n cnt += 1\n else:\n pros(flag, lists[1], lists[2])\n \nllist.reverse()\n \nS = "".join(llist) + S + "".join(rlist)\n\nif cnt % 2 == 1:\n S = S[::-1]\nprint(S)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s267332788', 's378462064', 's499385562', 's517227842', 's766520103', 's924507179', 's937766176', 's202598799']
[4928.0, 4916.0, 3316.0, 3992.0, 3992.0, 3932.0, 3700.0, 5704.0]
[394.0, 385.0, 340.0, 2104.0, 395.0, 2104.0, 384.0, 440.0]
[266, 386, 145, 164, 157, 232, 220, 720]
p02756
u580697892
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 = input()\nQ = int(input())\nfront = ""\nrear = ""\ncnt = 0\nfor i in range(Q):\n q = input().split()\n if q[0] == "1":\n S = S[::-1]\n front, rear = rear, front\n else:\n if q[1] == "1":\n front += q[2]\n else:\n rear += q[2]\nprint(front + S + rear)', '# coding: utf-8\nfrom collections import deque\nS = deque(input())\nQ = int(input())\ncnt = 0\nfor i in range(Q):\n q = input().split()\n if q[0] == "1":\n cnt += 1\n else:\n if (int(q[1]) + cnt) % 2 == 1:\n S.appendleft(q[2])\n else:\n S.append(q[2])\nans = "".join(S)\nprint(ans if cnt % 2 == 0 else ans[::-1])']
['Wrong Answer', 'Accepted']
['s165234335', 's302873264']
[4468.0, 8692.0]
[2104.0, 530.0]
[313, 349]
p02756
u586639900
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\nQueries = []\nfor i in range(Q):\n Queries.append(list(input().split()))\n\nrev_count = 0\nhead = ""\ntail = ""\n\nfor query in Queries:\n if query[0] == \'1\':\n tmp = head[::-1]\n head = tail[::-1]\n tail = tmp\n rev_count += 1\n\n if query[0] == \'2\':\n if query[1] == \'1\':\n head += query[2]\n if query[1] == \'2\':\n tail += query[2]\n\n\nif rev_count % 2 == 1:\n S = S[::-1]\nS = head[::-1] + S + tail\nprint(S)', 'S = input()\nQ = int(input())\n\nQueries = []\nfor i in range(Q):\n Queries.append(list(input().split()))\n\nrev = False\nhead = ""\ntail = ""\n\n\n\nfor query in Queries:\n if query[0] == \'1\':\n tmp = head\n head = tail\n tail = tmp\n rev = 1 - rev \n\n if query[0] == \'2\':\n if query[1] == \'1\':\n head += query[2]\n if query[1] == \'2\':\n tail += query[2]\n\nif rev:\n S = S[::-1]\nS = head[::-1] + S + tail\nprint(S)']
['Wrong Answer', 'Accepted']
['s172896728', 's433077820']
[31880.0, 30964.0]
[2105.0, 643.0]
[493, 579]
p02756
u591143370
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())\nList = [list(map(str, input().split())) for i in range(Q)]\n\n#print(List)\n\n#S='a'\n#Q=4\n#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]\nhan=0\nb=''\nfor a in List:\n if a[0]=='1':\n han+=1\n if a[0]=='2':\n if (a[1]=='1' and han%2==0) or (a[1]=='2' and han%2==1):\n b=+a[2]\n if (a[1]=='2' and han%2==0) or (a[1]=='1' and han%2==1):\n S=S+a[2]\n \nif han%2==0:\n print(b[::-1]+S)\nelse:\n print(S[::-1]+b)\n ", "S = str(input())\nQ = int(input())\nList = [list(map(str, input().split())) for i in range(Q)]\n\n#print(List)\n\n#S='a'\n#Q=4\n#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]\nhan=0\nb=''\nfor a in List:\n if a[0]=='1':\n han+=1\n if a[0]=='2':\n if (a[1]=='1' and han%2==0) or (a[1]=='2' and han%2==1):\n b+=a[2]\n if (a[1]=='2' and han%2==0) or (a[1]=='1' and han%2==1):\n S=S+a[2]\n#print(S)\n#print(b)\nif han%2==0:\n print(b[::-1]+S)\nelse:\n print(S[::-1]+b)"]
['Runtime Error', 'Accepted']
['s370280298', 's435890011']
[39156.0, 40436.0]
[585.0, 722.0]
[505, 503]
p02756
u592035627
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)\ns = []\nn = int(input())\nfor i in range(n):\n array = list(map(str,input().split()))\n s.append(array)\n\nfor i in range(N):\n if s[i][0] == "1":\n d.reverse()\n else:\n if s[i][1] == "1":\n d.extendleft(s[i][2])\n else:\n d.extend(s[i][2])\n\nprint("".join(list(d)))', 'x = input()\ns = []\nn = int(input())\nfor i in range(n):\n array = list(map(str,input().split()))\n s.append(array)\n \na = ""\nb = ""\nc = 0\nfor i in range(n):\n if s[i][0] == "1":\n c += 1\n c = c%2\n else:\n if c == 0:\n if s[i][1] == "1":\n a = s[i][2] + a\n else:\n b = b + s[i][2]\n else:\n if s[i][1] == "1":\n b = s[i][2] + b\n else:\n a = a + s[i][2]\nif c == 0:\n print(a + x + b)\nelse:\n print(b + x + a)', 'import sys\ninput = sys.stdin.readline\nS = list(input())\nn = int(input())\ns = []\nfor i in range(n):\n array = list(map(str,input().split()))\n s.append(array)\nfor i in range(n):\n if s[i][0] == "1":\n S.reverse()\n else:\n if s[i][1] == "1":\n S.insert(0,s[i][2])\n else:\n S.append(s[i][2])\n \nprint("".join(S))', 'x = input()\ns = []\nn = int(input())\nfor i in range(n):\n array = list(map(str,input().split()))\n s.append(array)\n \na = ""\nb = ""\nc = 0\nfor i in range(n):\n if s[i][0] == "1":\n c += 1\n c = c%2\n else:\n if c == 0:\n if s[i][1] == "1":\n a = s[i][2] + a\n else:\n b = b + s[i][2]\n else:\n if s[i][1] == "1":\n b = b + s[i][2]\n else:\n a = s[i][2] + a\nif c == 0:\n print(a + x + b)\nelse:\n print(\'\'.join(list(reversed(b))) + \'\'.join(list(reversed(x))) + \'\'.join(list(reversed(a))))']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s104449864', 's727732544', 's825913939', 's253065401']
[39668.0, 40576.0, 42100.0, 41596.0]
[648.0, 1597.0, 2106.0, 1592.0]
[374, 543, 356, 618]
p02756
u595375942
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.
['\nfrom collections import deque\n\ndef bfs(N):\n S = "abcdefghij"\n result = []\n deq = deque(["a"])\n\n while deq:\n s = deq.popleft()\n if len(s) == N:\n result.append(s)\n continue\n else:\n for i in S[:len(set(s))+1]:\n deq.append(s + i)\n return result\n\nN = int(input())\nans = bfs(N)\nprint(\'\\n\'.join(ans))', 'import collections\n\ndef bfs(N):\n S = "abcdefghij"\n result = []\n deq = collections.deque(["a"])\n\n while deq:\n s = deq.popleft()\n if len(s) == N:\n result.append(s)\n continue\n else:\n for i in S[:len(set(s))+1]:\n deq.append(s + i)\n return result\n\nN = int(input())\nans = bfs(N)\nfor a in ans:\n print(a)\nexit()', '\nfrom collections import deque\n\ndef bfs(N):\n S = "abcdefghij"\n result = []\n deq = deque(["a"])\n\n while deq:\n s = deq.popleft()\n if len(s) == N:\n result.append(s)\n continue\n else:\n for i in S[:len(set(s))+1]:\n deq.append(s + i)\n return result\n\nN = int(input())\nans = bfs(N)\nfor a in ans:\n print(a)', '\nfrom collections import deque\n\ndef bfs(N):\n S = "abcdefghij"\n result = []\n deq = deque(["a"])\n\n while deq:\n s = deq.popleft()\n if len(s) == N:\n result.append(s + "\\n")\n continue\n else:\n for i in S[:len(set(s))+1]:\n deq.append(s + i)\n return result\n\nN = int(input())\nans = bfs(N)\nprint(\'\'.join(ans))', "from collections import deque\nS = deque(list(input()))\nQ = int(input())\nFlag = True\nfor _ in range(Q):\n q = input().split()\n if len(q) == 1:\n Flag = False if Flag else True\n else:\n if Flag:\n if q[1] == '1':\n S.appendleft(q[2])\n else:\n S.append(q[2])\n else:\n if q[1] == '1':\n S.append(q[2])\n else:\n S.appendleft(q[2])\n\nif Flag:\n print(''.join(S))\nelse:\n print(''.join(reversed(S)))"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s037930732', 's845071653', 's919113877', 's945725828', 's153876784']
[3572.0, 3444.0, 3572.0, 3572.0, 8420.0]
[21.0, 21.0, 21.0, 23.0, 396.0]
[412, 390, 417, 417, 520]
p02756
u595905528
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())\nreverseflag = 0\nfor _ in range(Q):\n newS = input()\n if int(newS[0]) == 1:\n reverseflag += 1\n reverseflag %= 2\n else:\n if (newS[2] == '1' and reverseflag==0) or (newS[2] != '1' and reverseflag!=0):\n S = newS[4].join(S[:])\n else:\n S = S[:].join(newS[4])\nif reverseflag == 1:\n S = S[::-1]\nprint(S)", 'from collections import deque\ns = input()\ns = deque(s)\nq = int(input())\nreverse = False\nfor i in range(q):\n query = input()\n if len(query) == 1:\n reverse = not reverse\n else:\n if not reverse:\n if query[2] == \'1\':\n s.appendleft(query[4])\n else:\n s.append(query[4])\n else:\n if query[2] == \'2\':\n s.appendleft(query[4])\n else:\n s.append(query[4])\ns ="".join(list(s))\nif reverse:\n s = s[::-1]\nprint(s)']
['Wrong Answer', 'Accepted']
['s044418338', 's481236690']
[303372.0, 8436.0]
[1746.0, 349.0]
[381, 533]
p02756
u597455618
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\ns = deque([sys.stdin.readline().rstrip()])\nq = int(input())\ncnt = 0\nfor i in range(q):\n query = sys.stdin.readline().split()\n if query[0] == \'1\':\n cnt = (cnt + 1)%2\n else:\n if (int(query[1]) + cnt)%2 == 1:\n s.appendleft(query[2])\n else:\n s.append(query[2])\n\nif cnt:\n s = "".join(s)\nprint(s[::-1])', 'import sys\nfrom collections import deque\n\ns = deque([sys.stdin.readline().rstrip()])\nq = int(input())\ncnt = 0\nfor i in range(q):\n query = sys.stdin.readline().split()\n if query[0] == \'1\':\n cnt = (cnt + 1)%2\n else:\n if (int(query[1]) + cnt)%2 == 1:\n s.appendleft(query[2])\n else:\n s.append(query[2])\n\nif cnt:\n s = "".join(s)\nprint(s.reverse())', 'import sys\nfrom collections import deque\n\ns = deque([sys.stdin.readline().rstrip()])\nq = int(input())\ncnt = 0\nfor i in range(q):\n query = sys.stdin.readline().split()\n if query[0] == \'1\':\n cnt = (cnt + 1)%2\n else:\n if (int(query[1]) + cnt)%2 == 1:\n s.appendleft(query[2])\n else:\n s.append(query[2])\n\nif cnt:\n s = "".join(s)[::-1]\nprint(s)', 'import sys\nfrom collections import deque\n\ns = deque([sys.stdin.readline().rstrip()])\nq = int(input())\ncnt = 0\nfor i in range(q):\n query = sys.stdin.readline().split()\n if query[0] == \'1\':\n cnt = (cnt + 1)%2\n else:\n if (int(query[1]) + cnt)%2 == 1:\n s.appendleft(query[2])\n else:\n s.append(query[2])\ns = "".join(s)\nif cnt:\n s = s[::-1]\nprint(s)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s161855379', 's753358302', 's982296299', 's677585637']
[6644.0, 6644.0, 8944.0, 6900.0]
[226.0, 238.0, 246.0, 221.0]
[393, 397, 393, 398]
p02756
u601575292
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\nfor _ in range(Q):\n q = input()\n if len(q) == 1:\n S.reverse()\n else:\n T, F, C = q.split()\n if int(F) == 1:\n S = C + S\n else:\n S = S + C\n\nprint(S)\n', 'from collections import deque\n\nS = list(input())\nQ = int(input())\n\nd = deque(S)\nhead = "l"\n\nfor _ in range(Q):\n q = input()\n if len(q) == 1:\n if head == "l":\n head = "r"\n else:\n head = "l"\n else:\n T, F, C = q.split()\n if int(F) == 1:\n if head == "l":\n d.appendleft(C)\n else:\n d.append(C)\n else:\n if head == "l":\n d.append(C)\n else:\n d.appendleft(C)\nif head == "l":\n print("".join(list(d)))\nelse:\n print("".join(list(d)[::-1]))\n']
['Runtime Error', 'Accepted']
['s925864345', 's600164578']
[3848.0, 10860.0]
[2104.0, 489.0]
[235, 603]
p02756
u602740328
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\ndef main():\n S = input()\n Q = int(input())\n r = False\n ans = deque(S)\n for l in sys.stdin:\n TFC = l.split()\n if TFC[0]=="1": r = not r\n elif TFC[1]=="1":\n if r: ans.append(TFC[2])\n else: ans.appendleft(TFC[2])\n elif TFC[1]=="2":\n if r: ans.appendleft(TFC[2])\n else: ans.append(TFC[2])\n print("".join(reversed(ans) if r else ))\n\nif __name__ == "__main__":\n main()', 'import sys\nfrom collections import deque\ndef main():\n S = input()\n Q = int(input())\n r = False\n ans = deque(S)\n for l in sys.stdin:\n TFC = l.split()\n if TFC[0]=="1": r = not r\n elif TFC[1]=="1":\n if r: ans.append(TFC[2])\n else: ans.appendleft(TFC[2])\n elif TFC[1]=="2":\n if r: ans.appendleft(TFC[2])\n else: ans.append(TFC[2])\n print("".join(reversed(ans) if r else ))\n\nif __name__ == "__main__":\n main()', 'import sys\nfrom collections import deque\ndef main():\n S = input()\n Q = int(input())\n r = False\n ans = deque(S)\n for l in sys.stdin:\n TFC = l.split()\n if TFC[0]=="1": r = not r\n elif TFC[1]=="1":\n if r: ans.append(TFC[2])\n else: ans.appendleft(TFC[2])\n elif TFC[1]=="2":\n if r: ans.appendleft(TFC[2])\n else: ans.append(TFC[2])\n print("".join(S[::-1] if r else S))\n\nif __name__ == "__main__":\n main()', 'import sys; input = sys.stdin.readline\ndef main():\n S = input()\n Q = int(input())\n for i in range(Q):\n TFC = input().split()\n S = S[::-1] if TFC[0]=="1" else (TFC[2]+S if TFC[1]=="1" else S+TFC[2])\n print(S)\n\nif __name__=="__main__":\n main()\n', 'import sys\nfrom collections import deque\ndef main():\n S = input()\n Q = int(input())\n r = False\n ans = deque(S)\n for l in sys.stdin:\n TFC = l.split()\n if TFC[0]=="1": r = not r\n elif TFC[1]=="1":\n if r: ans.append(TFC[2])\n else: ans.appendleft(TFC[2])\n elif TFC[1]=="2":\n if r: ans.appendleft(TFC[2])\n else: ans.append(TFC[2])\n print("".join(reversed(ans) if r else ans))\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s101263036', 's149109779', 's205071862', 's513726228', 's743250593']
[3064.0, 3064.0, 6772.0, 4012.0, 8820.0]
[17.0, 17.0, 121.0, 2104.0, 117.0]
[442, 442, 437, 253, 445]
p02756
u606523772
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())\nl_list = []\nr_list = []\nfor i in range(Q):\n A = list(map(str, input().split()))\n if len(A)==1:\n flag = not flag\n else:\n if flag:\n if A[1]=="1":\n l_list.insert(0, A[2])\n else:\n r_list.append(A[2])\n else:\n if A[1]=="1":\n r_list.insert(0, A[2])\n else:\n l_list.append(A[2])\nif flag:\n print("".join(l_list)+"".join(S)+"".join(r_list))\nelse:\n print("".join(r_list[::-1])+"".join(S[::-1])+"".join(l_list[::-1]))', 'S = list(input())\nQ = int(input())\nl_list = []\nr_list = []\nfor i in range(Q):\n A = list(map(str, input().split()))\n if len(A)==1:\n flag = not flag\n else:\n if flag:\n if A[1]=="1":\n l_list.insert(0, A[2])\n else:\n r_list.append(A[2])\n else:\n if A[1]=="1":\n r_list.insert(0, A[2])\n else:\n l_list.append(A[2])\nif flag:\n print("".join(l_list)+"".join(S)+"".join(r_list))\nelse:\n print("".join(r_list[::-1])+"".join(S[::-1])+"".join(l_list[::-1]))', 'S = list(input())\nQ = int(input())\nl_list = []\nr_list = []\nflag = True\nfor i in range(Q):\n A = list(map(str, input().split()))\n if len(A)==1:\n flag = not flag\n else:\n if flag:\n if A[1]=="1":\n l_list.appendleft(A[2])\n else:\n r_list.append(A[2])\n else:\n if A[1]=="1":\n r_list.append(A[2])\n else:\n l_list.appendleft(A[2])\nif flag:\n print("".join(l_list)+"".join(S)+"".join(r_list))\nelse:\n print("".join(r_list[::-1])+"".join(S[::-1])+"".join(l_list[::-1]))', 'S = list(input())\nQ = int(input())\nl_list = []\nr_list = []\nflag = True\nfor i in range(Q):\n A = list(map(str, input().split()))\n if len(A)==1:\n flag = not flag\n else:\n if flag1:\n if A[1]=="1":\n l_list.appendleft(A[2])\n else:\n r_list.append(A[2])\n else:\n if A[1]=="1":\n r_list.append(A[2])\n else:\n l_list.appendleft(A[2])\nif flag:\n print("".join(l_list)+"".join(S)+"".join(r_list))\nelse:\n print("".join(r_list[::-1])+"".join(S[::-1])+"".join(l_list[::-1]))', 'from collections import deque\nS = deque(input())\nQ = int(input())\nflag = True\nfor i in range(Q):\n A = list(map(str, input().split()))\n if len(A)==1:\n flag = not flag\n else:\n if flag:\n if A[1]=="1":\n S.appendleft(A[2])\n else:\n S.append(A[2])\n else:\n if A[1]=="1":\n S.append(A[2])\n else:\n S.appendleft(A[2])\nS = "".join(S)\nif flag:\n print(S)\nelse:\n print(S[::-1])']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s085312166', 's567441122', 's718194401', 's939311924', 's284068450']
[4084.0, 4084.0, 4084.0, 4084.0, 8948.0]
[19.0, 19.0, 19.0, 19.0, 667.0]
[579, 579, 593, 594, 501]
p02756
u607074939
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())\nfor i in range (q):\n t = list(str(input()))\n if t[0] == '2':\n if t[2] == '2':\n s.reverse()\n s.append(t[4])\n s.reverse() \n else:\n s.append(t[4])\n else:\n s.reverse()\nprint(''.join(s))", "s = list(str(input()))\nq = int(input())\nf = []\nb = []\ncnt = 0\nfor i in range (q):\n t = list(str(input()))\n if t[0] == '2':\n if t[2] == '1':\n f.append(t[4])\n else:\n b.append(t[4])\n else:\n x = f\n y = b\n f = y\n b = x\n cnt += 1\nf.reverse()\nif cnt%2 != 0:\n s.reverse()\n \nprint(''.join(f) + ''.join(s) + ''.join(b))"]
['Wrong Answer', 'Accepted']
['s890175960', 's564646954']
[4512.0, 6428.0]
[2104.0, 506.0]
[300, 395]
p02756
u607155447
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\nS = input()\nQ = int(input())\nkey = 1\n\nfor i in sys.stdin:\n if i[0] == '0':\n break\n\n if i[0] == '1':\n key = -key\n \n if key == 1:\n if i[2] == '1':\n S = i[4] + S\n else:\n S = S + i[4]\n\n else:\n if i[2] == '2':\n S = i[4] + S\n else:\n S = S + i[4]\n\n\nprint(S[::key])\n", "import sys\nS = input()\nA = ''\ninput()\nkey = 1\n\nfor i in sys.stdin:\n if i[0] == '0':\n break\n\n if i[0] == '1':\n key = -key\n \n elif key == 1:\n if i[2] == '1':\n A = A + i[4]\n else:\n S = S + i[4]\n\n else:\n if i[2] == '2':\n A = A + i[4]\n else:\n S = S + i[4]\n\nans = A[::-1] + S\nprint(ans[::key])\n"]
['Runtime Error', 'Accepted']
['s601417985', 's471368632']
[9572.0, 9852.0]
[2002.0, 101.0]
[370, 389]
p02756
u607563136
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\nt1 = 1\nt2 = 2\n\nst = ""\nse = ""\n\nfor _ in range(q):\n q = input().split()\n if int(q[0]) == 1:\n t1 = t2\n t2 = t1\n elif int(q[0]) == 2:\n if int(q[1]) == t1:\n st += q[2]\n elif int(q[1]) == t2:\n se += q[2]\n\nst = list(st) \nst.reverse()\nst = "".join(st)\nans = st + s + se\nif t1 == 2:\n ans = list(ans)\n ans.reverse()\n ans = "".join(ans)\nprint(ans)', 's = input()\nq = int(input())\n\nf1 = 1\nf2 = 2\ncnt = 0\nst = ""\nse = ""\n\nfor _ in range(q):\n q = input().split()\n if int(q[0]) == 1:\n cnt += 1\n elif int(q[0]) == 2:\n if cnt % 2 == 0:\n if int(q[1]) == 1:\n st = q[2] + st\n elif int(q[1]) == 2:\n se += q[2]\n else:\n if int(q[1]) == 1:\n se = q[2] + se\n elif int(q[1]) == 2:\n st += q[2]\n\n\nans = st + s + se\nif cnt % 2 == 0:\n print(ans)\nelse:\n ans = list(ans)\n ans.reverse()\n ans = "".join(ans)\n print(ans)', 's = input()\nq = int(input())\n\nf1 = 1\nf2 = 2\n\nst = ""\nse = ""\n\nfor _ in range(q):\n q = input().split()\n if int(q[0]) == 1:\n f1 = f2\n f2 = f1\n elif int(q[0]) == 2:\n if int(q[1]) == f1:\n st = q[2] + st\n elif int(q[1]) == f2:\n se += q[2]\n\n\nans = st + s + se\nif f1 == 2:\n ans = list(ans)\n ans.reverse()\n ans = "".join(ans)\nprint(ans)', 'from collections import deque\n\ns = input()\nq = int(input())\n\ndt = deque()\nde = deque()\n\nf1 = 1\nf2 = 2\n\nfor _ in range(q):\n q = input().split()\n if int(q[0]) == 1:\n f1,f2 = f2,f1\n elif int(q[0]) == 2:\n if int(q[1]) == f1:\n dt.appendleft(q[2])\n elif int(q[1]) == f2:\n de.append(q[2])\n \nst = "".join(dt)\nse = "".join(de)\nans = st + s + se\n\nif f1 == 1:\n print(ans)\nelse:\n ans = list(ans)\n ans.reverse()\n ans = "".join(ans)\n print(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s019664349', 's724667060', 's734834757', 's709866134']
[10768.0, 12644.0, 10820.0, 13892.0]
[391.0, 967.0, 956.0, 390.0]
[447, 593, 396, 528]
p02756
u607729897
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\n\ndef main():\n S = readline().strip().decode('utf-8')\n Q = int(readline())\n Query = [tuple(readline().decode('utf-8').split()) for _ in range(Q)]\n rev_flg = 0\n for q in Query:\n if q[0] == '1':\n rev_flg += 1\n else:\n if int(q[1])-(rev_flg%2) == 1:\n S = q[2] + S\n else:\n S += q[2]\n print(rev_flg)\n if rev_flg%2 == 1:\n S = S[::-1]\n print(S)\n\n return\nif __name__ == '__main__':\n main()\n\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\ndef main():\n S = readline().strip().decode('utf-8')\n Q = int(readline())\n Query = [tuple(readline().decode('utf-8').split()) for _ in range(Q)]\n rev_flg = False\n for q in Query:\n if q[0] == '1':\n rev_flg += 1\n else:\n if int(q[1])+rev_flg == '1':\n S = q[2] + S\n else:\n S += q[2]\n if rev_flg == True:\n S = S[::-1]\n print(S)\n\n return\nif __name__ == '__main__':\n main()\n\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\ndef main():\n S = readline().strip().decode('utf-8')\n Q = int(readline())\n Query = [tuple(readline().decode('utf-8').split()) for _ in range(Q)]\n rev_flg = 0\n for q in Query:\n if q[0] == '1':\n rev_flg += 1\n else:\n if int(q[1])+(rev_flg%2) == '1':\n S = q[2] + S\n else:\n S += q[2]\n if rev_flg%2 == 1:\n S = S[::-1]\n print(S)\n\n return\nif __name__ == '__main__':\n main()\n\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\ndef main():\n from collections import deque\n S = deque(readline().strip().decode())\n Q = int(readline())\n Query = readlines()\n rev_flg = False\n for q in Query:\n if q[0] == ord('1'):\n rev_flg = not rev_flg\n else:\n _, f, c = q.decode().split()\n if int(f)-(rev_flg) == 1:\n S.appendleft(c)\n else:\n S.append(c)\n S = ''.join(S)\n if rev_flg is True:\n S = S[::-1]\n print(S)\n\n return\nif __name__ == '__main__':\n main()\n\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s815034292', 's945694591', 's953390496', 's074639092']
[19644.0, 19800.0, 19796.0, 17888.0]
[2105.0, 248.0, 261.0, 185.0]
[572, 556, 555, 655]
p02756
u614314290
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, Counter as cnt\nfrom collections import defaultdict as dd\nfrom operator import itemgetter as ig\nfrom bisect import bisect_right as bsr\nfrom math import factorial, ceil, floor\nimport sys\nsys.setrecursionlimit(1000000)\n\n\nargs = None\nINF = float("inf")\nMOD = int(1e9 + 7)\n\n\ndef input(*ps):\n if type(ps[0]) is list:\n return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]\n elif len(ps) == 1:\n return ps[0](next(args))\n else:\n return [p(next(args)) for p in ps]\n\n\ndef nlist(n, v):\n if not n:\n return [] if type(v) is list else v\n return [nlist(n[1:], v) for _ in range(n[0])]\n\n\ndef yesno(v):\n print(["Yes", "No"][not v])\n\n\n\ndef main():\n S, Q = input(str, int)\n front, end, state = "", "", 0\n for _ in range(Q):\n t = int(next(args))\n if t == 1:\n state = (state + 1) % 2\n continue\n F, C = int(next(args)), str(next(args))\n if state == 0:\n if F == 1:\n front = C + front\n else:\n end = end + C\n else:\n if F == 1:\n end = end + C\n else:\n front = C + front\n print(front, end, state)\n ans = front + S + end\n if state == 1:\n ans = end[::-1] + S[::-1] + front[::-1]\n print(ans)\n\n\nif __name__ == \'__main__\':\n args = iter(sys.stdin.read().split())\n main()\n', 'from collections import deque, Counter as cnt\nfrom collections import defaultdict as dd\nfrom operator import itemgetter as ig\nfrom bisect import bisect_right as bsr\nfrom math import factorial, ceil, floor\nimport sys\nsys.setrecursionlimit(1000000)\n\n\nargs = None\nINF = float("inf")\nMOD = int(1e9 + 7)\n\n\ndef input(*ps):\n if type(ps[0]) is list:\n return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]\n elif len(ps) == 1:\n return ps[0](next(args))\n else:\n return [p(next(args)) for p in ps]\n\n\ndef nlist(n, v):\n if not n:\n return [] if type(v) is list else v\n return [nlist(n[1:], v) for _ in range(n[0])]\n\n\ndef yesno(v):\n print(["Yes", "No"][not v])\n\n\n\ndef main():\n S, Q = input(str, int)\n front, end, state = "", "", 0\n for _ in range(Q):\n t = int(next(args))\n if t == 1:\n state = (state + 1) % 2\n continue\n F, C = int(next(args)), str(next(args))\n if state == 0:\n if F == 1:\n front = C + front\n else:\n end = end + C\n else:\n if F == 1:\n end = end + C\n else:\n front = C + front\n ans = front + S + end\n if state == 1:\n ans = end[::-1] + S[::-1] + front[::-1]\n print(ans)\n\n\nif __name__ == \'__main__\':\n args = iter(sys.stdin.read().split())\n main()\n']
['Runtime Error', 'Accepted']
['s986543567', 's634214365']
[141436.0, 12508.0]
[265.0, 978.0]
[1452, 1419]
p02756
u616169109
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\nhead = []\ntail = []\nfor i in range(Q):\n s = input().split()\n if int(s[0]) == 1:\n reverse = (reverse + 1) % 2\n else:\n if int(s[1]) == 1:\n if reverse == 1:\n tail.append(s[2])\n else:\n head.append(s[2])\n else:\n if reverse == 1:\n head.append(s[2])\n else:\n tail.append(s[2])\nhead = ''.join(head)\ntail = ''.join(tail)\nS = head + S + tail\nif reverse == 1:\n print(S[::-1])\nelse:\n print(S)", "def main():\n from sys import stdin\n from collections import deque\n S = input()\n Q = int(input())\n reverse = 0\n head = []\n tail = []\n head_deque = deque(head)\n tail_deque = deque(tail)\n \n for _ in [0] * Q:\n readline = stdin.readline\n s = readline().split()\n if int(s[0]) == 1:\n if reverse == 1:\n reverse = 0\n else:\n reverse = 1\n else:\n if int(s[1]) == 1:\n if reverse == 1:\n tail.append(s[2])\n else:\n head_deque.appendleft(s[2])\n else:\n if reverse == 1:\n head_deque.appendleft(s[2])\n else:\n tail.append(s[2])\n head = list(head_deque)\n head = ''.join(head)\n tail = ''.join(tail)\n if reverse == 1:\n print(tail[::-1]+S[::-1]+head[::-1])\n else:\n print(head+S+tail)\n \nmain()"]
['Wrong Answer', 'Accepted']
['s584776444', 's501224909']
[4972.0, 6636.0]
[482.0, 202.0]
[560, 974]
p02756
u616382321
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(input().split()) for _ in range(Q)]\nprint(query)\nforward = 1\nfor i in range(Q):\n if query[i][0] == '1':\n forward *= -1\n else:\n if query[i][1] == '1':\n if forward == 1:\n S = query[i][2] + S\n else:\n S = S + query[i][2] \n else:\n if forward == 1:\n S = S + query[i][2] \n else:\n S = query[i][2] + S\n\nif forward == -1:\n ans = ''\n for i in range(len(S)):\n ans += S[-i-1]\nelse:\n ans = S\nprint(ans)\n", "S = input()\nQ = int(input())\nquery = [list(input().split()) for _ in range(Q)]\nforward = 1\nf = ''\nb = ''\nfor i in range(Q):\n if query[i][0] == '1':\n forward *= -1\n else:\n if query[i][1] == '1':\n if forward == 1:\n f += query[i][2]\n else:\n b += query[i][2] \n else:\n if forward == 1:\n b += query[i][2] \n else:\n f += query[i][2]\nS = ''.join(list(reversed(f))) + S + b\n\nif forward == -1:\n ans = ''.join(list(reversed(S)))\nelse:\n ans = S\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s561601914', 's589621338']
[36180.0, 32160.0]
[1221.0, 375.0]
[579, 580]
p02756
u619197965
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())\nmuki=True\na=[[_ for _ in input().split()] for i in range(q)]\nfront=""\nback=""\nfor i in a:\n if i[0]=="1":\n muki=not muki\n continue\n if (i[1]=="1" and muki) or (i[1]=="2" and not muki):\n front+=i[2]\n else:\n back+=i[2]\nif muki:\n print(front+s+back)\nelse:\n print((front+s+back)[::-1])', 's=input()\nq=int(input())\nmuki=True\na=[[_ for _ in input().split()] for i in range(q)]\nfront=""\nback=""\nfor i in a:\n if i[0]=="1":\n muki=not muki\n continue\n if (i[1]=="1" and muki) or (i[1]=="2" and not muki):\n front=i[2]+front\n else:\n back+=i[2]\nif muki:\n print(front+s+back)\nelse:\n print((front+s+back)[::-1])']
['Wrong Answer', 'Accepted']
['s587414899', 's712545731']
[27928.0, 28100.0]
[550.0, 1409.0]
[348, 353]
p02756
u620238824
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()) \nX = [0] * Q\nR = 1\nfor i in range(Q):\n X[i] = list(input().split() ) 、複数行複数列\n if X[i][0] == "1":\n R *= - 1\n else:\n if X[i][1] == "1":\n if R == 1:\n S = X[i][2] + S\n else:\n S = S + X[i][2] \n else:\n if R == 1:\n S = S + X[i][2] \n else:\n S = X[i][2] + S\n\nprint(S[::R])', 'S = input() \nQ = int(input()) \nX = [0] * Q\nR = 1\nfor i in range(Q):\n X[i] = list(input().split() ) 、複数行複数列\n if X[i][0] == "1":\n R *= - 1\n else:\n T = int(X[i][1])\n if T * R == 1 or T * R == -2:\n S = X[i][2] + S\n else:\n S = S + X[i][2] \n\nprint(S[::R])', 'S = input() \nQ = int(input()) \nX = list(input().split() for i in range(Q)) 、複数行複数列\n\n#print(X)\n\nfor i in range(Q):\n if X[i][0] == "1":\n S = S[::-1]\n else:\n if X[i][1] == "1":\n S = X[i][2] + S\n else:\n S = S + X[i][2]\nprint(S)', 'S = input() \nQ = int(input()) \nX = [0] * Q\nfor i in range(Q):\n X[i] = list(input().split() ) 、複数行複数列\n if X[i][0] == "1": \n S = S[::-1]\n else:\n if X[i][1] == "1":\n S = X[i][2] + S\n else:\n S = S + X[i][2]\nprint(S)', 's = input()\nq = int(input())\ncou = 1\nfrt = ""\nbck = ""\nfor i in range(q):\n t = list(input().split())\n \n if t[0] == "1":\n cou *= -1\n else:\n if (t[1] == "1" and cou == 1)or(t[1] == "2" and cou == -1):\n frt = t[2] + frt\n else:\n bck = bck + t[2]\n\n\ns = frt + s + bck\n\nif cou == 1:\n print(\'\'.join(s))\nelse:\n print(\'\'.join(s[::-1]))']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s133719011', 's247303782', 's329764020', 's941048602', 's918633038']
[29556.0, 29564.0, 41852.0, 20700.0, 12512.0]
[2105.0, 2105.0, 2107.0, 2105.0, 924.0]
[494, 360, 309, 307, 469]
p02756
u620480037
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=list(input())\n\nD={}\nMIN=0\nMAX=len(S)-1\nfor i in range(len(S)):\n D[i]=S[i]\n\nQ=int(input())\nfor i in range(Q):\n q=list(input().split())\n if q[0]=="1":\n D[MIN],D[MAX]=D[MAX],D[MIN]\n else:\n if q[1]=="1":\n D[MIN-1]=q[2]\n MIN-=1\n else:\n D[MAX+1]=q[2]\n MAX+=1\nans=""\nfor i in range(MIN,MAX+1):\n ans+=D[i]\nprint(ans)', 'S=list(input())\n\nD={}\nMIN=0\nMAX=len(S)-1\nfor i in range(len(S)):\n D[i]=S[i]\nF=1\nQ=int(input())\nfor i in range(Q):\n q=list(input().split())\n if F==1:\n if q[0]=="1":\n F*=-1\n else:\n if q[1]=="1":\n D[MIN-1]=q[2]\n MIN-=1\n else:\n D[MAX+1]=q[2]\n MAX+=1\n else:\n if q[0]=="1":\n F*=-1\n else:\n if q[1]=="2":\n D[MIN-1]=q[2]\n MIN-=1\n else:\n D[MAX+1]=q[2]\n MAX+=1\nans=""\n\nfor i in range(MIN,MAX+1):\n ans+=D[i]\nif F==1:\n print(ans)\nelse:\n print(ans[::-1])\n']
['Wrong Answer', 'Accepted']
['s445115420', 's020751825']
[28076.0, 27936.0]
[330.0, 585.0]
[426, 676]
p02756
u624696727
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\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\nprintV = lambda x: print(*x, sep="\\n")\nprintH = lambda x: print(" ".join(map(str,x)))\ndef IS(): return sys.stdin.readline()[:-1]\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LI1(): return list(map(int1, sys.stdin.readline().split()))\ndef LII(rows_number): return [II() for _ in range(rows_number)]\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef LLI1(rows_number): return [LI1() for _ in range(rows_number)]\n\ndef main():\n\tS = IS()\n\tQ = II()\n\tc = 0\n\thead=[]\n\ttail=[]\n\tfor _ in range(Q):\n\t\tquery = IS()\n\t\tif(len(query)==1):\n\t\t\tc = (c + 1)%2\n\t\telse:\n\t\t\tprint(query)\n\t\t\tT,F,C = query.split()\n\t\t\tT = int(T)\n\t\t\tF = int(F)\n\t\t\tif F==1:\n\t\t\t\tif(c==0):\n\t\t\t\t\thead.append(C)\n\t\t\t\telse:\n\t\t\t\t\ttail.append(C)\n\t\t\telse:\n\t\t\t\tif(c==1):\n\t\t\t\t\thead.append(C)\n\t\t\t\telse:\n\t\t\t\t\ttail.append(C)\n\tif c == 0:\n\t\thead = \'\'.join(head[::-1])\n\t\ttail = \'\'.join(tail)\n\t\tans = head+S+tail\n\telse:\n\t\thead = \'\'.join(head)\n\t\ttail = "".join(tail[::-1])\n\t\tns = S[::-1]\n\t\tans = tail+ns+head\n\tprint(ans)\n\n\n\n\nif __name__ == \'__main__\':\n\tmain()', 'import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\nprintV = lambda x: print(*x, sep="\\n")\nprintH = lambda x: print(" ".join(map(str,x)))\ndef IS(): return sys.stdin.readline()[:-1]\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LI1(): return list(map(int1, sys.stdin.readline().split()))\ndef LII(rows_number): return [II() for _ in range(rows_number)]\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef LLI1(rows_number): return [LI1() for _ in range(rows_number)]\n\ndef main():\n\tS = IS()\n\tQ = II()\n\tc = 0\n\thead=[]\n\ttail=[]\n\tfor _ in range(Q):\n\t\tquery = IS()\n\t\tif(len(query)==1):\n\t\t\tc = (c + 1)%2\n\t\telse:\n\t\t\tT,F,C = query.split()\n\t\t\tT = int(T)\n\t\t\tF = int(F)\n\t\t\tif F==1:\n\t\t\t\tif(c==0):\n\t\t\t\t\thead.append(C)\n\t\t\t\telse:\n\t\t\t\t\ttail.append(C)\n\t\t\telse:\n\t\t\t\tif(c==1):\n\t\t\t\t\thead.append(C)\n\t\t\t\telse:\n\t\t\t\t\ttail.append(C)\n\tif c == 0:\n\t\thead = \'\'.join(head[::-1])\n\t\ttail = \'\'.join(tail)\n\t\tans = head+S+tail\n\telse:\n\t\thead = \'\'.join(head)\n\t\ttail = "".join(tail[::-1])\n\t\tns = S[::-1]\n\t\tans = tail+ns+head\n\tprint(ans)\n\n\n\n\nif __name__ == \'__main__\':\n\tmain()']
['Wrong Answer', 'Accepted']
['s281652926', 's356688422']
[8476.0, 6372.0]
[388.0, 259.0]
[1206, 1190]
p02756
u625963200
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())\nquery=[list(map(str,input().split())) for _ in range(Q)]\n\nans=deque(S)\nreverse=False\nfor i,q in enumerate(query):\n if len(q)==1:\n reverse=not reverse\n else:\n _,f,c=q\n if (f=='1') ^ reverse:\n ans.append(c)\n else:\n ans.appendleft(c)\nprint(*ans,sep='')", "from collections import deque\nS=input()\nQ=int(input())\nquery=[list(map(str,input().split())) for _ in range(Q)]\n\nd=deque(S)\nreverse=False\nfor q in query:\n if len(q)==1:\n reverse=not reverse\n else:\n _,f,c=q\n if f=='1':\n d.append(c) if reverse else d.appendleft(c)\n else:\n d.appendleft(c) if reverse else d.append(c)\nprint(*reversed(d),sep='') if reverse else print(*d,sep='')"]
['Wrong Answer', 'Accepted']
['s011413847', 's614173611']
[48368.0, 48368.0]
[790.0, 735.0]
[328, 398]
p02756
u629350026
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())\ns=list(s)\nq=int(input())\nsb=[0]*q\nsa=[0]*q\nsbi=0\nsai=0\nta=0\nfor i in range(q):\n temp=str(input())\n temp=list(temp)\n if temp[0]=="1":\n ta=ta+1\n else:\n if (temp[2]=="1" and ta%2==0) or (temp[2]=="2" and ta%2!=0):\n sb[sbi]=temp[4]\n sbi=sbi+1\n else:\n sa[sai]=temp[4]\n sai=sai+1\nlsb=sb.index(0)\nlsa=sa.index(0)\nsa.reverse()\nans=sb[0:lsb]+s+sa[len(sa)-lsa:len(sa)]\nif ta%2!=0:\n ans.reverse()\nprint("".join(ans))', 's=str(input())\ns=list(s)\nq=int(input())\nsb=[0]*(q+1)\nsa=[0]*(q+1)\nsbi=0\nsai=0\nta=0\nfor i in range(q):\n temp=str(input())\n temp=list(temp)\n if temp[0]=="1":\n ta=ta+1\n else:\n if (temp[2]=="1" and ta%2==0) or (temp[2]=="2" and ta%2!=0):\n sb[sbi]=temp[4]\n sbi=sbi+1\n else:\n sa[sai]=temp[4]\n sai=sai+1\nlsb=sb.index(0)\nlsa=sa.index(0)\nsa.reverse()\nans=sb[0:lsb]+s+sa[len(sa)-lsa:len(sa)]\nif ta%2!=0:\n ans.reverse()\nprint("".join(ans))', 's=str(input())\ns=list(s)\nq=int(input())\nsb=[0]*(q+1)\nsa=[0]*(q+1)\nsbi=0\nsai=0\nta=0\nfor i in range(q):\n temp=str(input())\n temp=list(temp)\n if temp[0]=="1":\n ta=ta+1\n else:\n if (temp[2]=="1" and ta%2==0) or (temp[2]=="2" and ta%2!=0):\n sb[sbi]=temp[4]\n sbi=sbi+1\n else:\n sa[sai]=temp[4]\n sai=sai+1\nlsb=sb.index(0)\nlsa=sa.index(0)\nsb.reverse()\nans=sb[len(sb)-lsb:len(sb)]+s+sa[0:lsa]\nif ta%2!=0:\n ans.reverse()\nprint("".join(ans))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s579477961', 's912078389', 's358959518']
[17480.0, 17640.0, 17512.0]
[372.0, 372.0, 375.0]
[454, 462, 462]
p02756
u631019293
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\ntop = ""\ntail = ""\n\nrev = 1\n\n\nfor i in range(q):\n query = input()\n if query == "1":\n rev *= -1\n elif query[2] == "1":\n if rev == 1:\n top += query[4]\n else:\n tail += query[4]\n else:\n if rev != 1:\n top += query[4]\n else:\n tail += query[4]\n\nif rev == 1:\n reversed(top)\n print(top + s + tail)\nelse:\n reversed(tail)\n print(tail + s + top)\n\n\n', 's = input()\nq = int(input())\n\ntop = ""\ntail = ""\n\nrev = 1\n\n\nfor i in range(q):\n query = input()\n if query == "1":\n rev *= -1\n elif query[2] == "1":\n if rev == 1:\n top += query[4]\n else:\n tail += query[4]\n else:\n if rev != 1:\n top += query[4]\n else:\n tail += query[4]\n\nif rev == 1:\n reversed(top)\n print(top + s + tail)\nelse:\n reversed(tail)\n reversed(s)\n print(tail + s + top)\n\n\n', 's = input()\nq = int(input())\n\ntop = ""\ntail = ""\n\nrev = 1\n\n\nfor i in range(q):\n query = input()\n if query == "1":\n rev *= -1\n elif query[2] == "1":\n if rev == 1:\n top += query[4]\n else:\n tail += query[4]\n else:\n if rev != 1:\n top += query[4]\n else:\n tail += query[4]\n\nif rev == 1:\n print(top[::-1] + s + tail)\nelse:\n print(tail[::-1] + s[::-1] + top)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s148039824', 's848512563', 's038172579']
[4212.0, 4468.0, 4468.0]
[363.0, 371.0, 359.0]
[488, 504, 467]
p02756
u631755487
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())\nstring = []\nis_normal = 1\nsaq = ""\nsol = ""\nfor i in range(q):\n emir = input()\n if emir[0] == \'1\':\n is_normal *= -1\n elif emir[0] == \'2\':\n if is_normal == 1:\n if emir[2] == \'1\':\n saq += emir[4]\n elif emir[2] == \'2\':\n sol += emir[4]\n else:\n if emir[2] == \'1\':\n sol += emir[4]\n elif emir[2] == \'2\':\n saq += emir[4]\ns = sol + s + saq\nif is_normal == -1:\n s = s[::-1]\n\nprint(s)', 's = input()\nq = int(input())\nstring = []\nis_normal = 1\nsaq = ""\nsol = ""\nfor i in range(q):\n emir = input()\n if emir[0] == \'1\':\n is_normal *= -1\n elif emir[0] == \'2\':\n if is_normal == 1:\n if emir[2] == \'1\':\n sol += emir[4]\n elif emir[2] == \'2\':\n saq += emir[4]\n else:\n if emir[2] == \'1\':\n saq += emir[4]\n elif emir[2] == \'2\':\n sol += emir[4]\ns = sol[::-1] + s + saq\nif is_normal == -1:\n s = s[::-1]\n\nprint(s)']
['Wrong Answer', 'Accepted']
['s535332033', 's640178928']
[4212.0, 4320.0]
[384.0, 370.0]
[539, 545]
p02756
u634282234
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 \na = []\nb = []\nrev = 0\n \nfor _ in range(Q):\n q = input().split()\n if q[0] == '1':\n a, b = b, a\n rev += 1\n else:\n if q[1] == '1':\n a.append(q[2])\n else:\n b.append(q[2])\n \nprint(a)\nprint(b)\nif rev % 2 == 1:\n S = S[::-1]\nans = ''.join(a[::-1]) + S + ''.join(b)\nprint(ans)", "S = input()\nQ = int(input())\n \na = []\nb = []\nrev = 0\n \nfor _ in range(Q):\n q = input().split()\n if q[0] == '1':\n a, b = b, a\n rev += 1\n else:\n if q[1] == '1':\n a.append(q[2])\n else:\n b.append(q[2])\nif rev % 2 == 1:\n S = S[::-1]\nans = ''.join(a[::-1]) + S + ''.join(b)\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s866106644', 's544282717']
[7432.0, 6268.0]
[394.0, 378.0]
[360, 340]
p02756
u638033979
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\nd = deque()\nS = input()\nd.append(S)\nQ = int(input())\nFlag = True\n \nfor i in range(Q):\n Query = input()\n if Query[0] == "1":\n Flag = not Flag\n else:\n QueryList = Query.split()\n if Flag:\n if QueryList[1] =="1":\n d.appendleft(QueryList[2])\n else:\n d.append(QueryList[2])\n else:\n if QueryList[1] =="2":\n d.append(QueryList[2])\n else:\n d.appendleft(QueryList[2])\n\nd_string = "".join(list(d))\n\nif not Flag:\n d_string = d_string[::-1] \nprint(d_string)\n ', 'import sys\ninput = sys.stdin.readline\n\nS = input()\nQ = int(input())\nFlag = True\n \nfor i in range(Q):\n Query = input()\n if Query[0] == "1":\n Flag = not Flag\n else:\n QueryList = Query.split()\n if Flag:\n if QueryList[1] =="1":\n S = QueryList[2]+S\n else:\n S = S+QueryList[2]\n else:\n if QueryList[1] =="2":\n S = QueryList[2]+S\n else:\n S = S+QueryList[2]\n\nif not Flag:\n S = S[::-1] \nprint(S)', 'from collections import deque\n\nd = deque()\nS = input()\nd.append(S)\nQ = int(input())\nFlag = True\n \nfor i in range(Q):\n Query = input()\n if Query[0] == "1":\n Flag = not Flag\n else:\n QueryList = Query.split()\n if Flag:\n if QueryList[1] =="1":\n d.appendleft(QueryList[2])\n else:\n d.append(QueryList[2])\n else:\n if QueryList[1] =="2":\n d.appendleft(QueryList[2])\n else:\n d.append(QueryList[2])\n\nd_string = "".join(list(d))\n\nif not Flag:\n d_string = d_string[::-1] \nprint(d_string)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s642343517', 's699552212', 's566473180']
[6900.0, 4156.0, 6900.0]
[424.0, 2104.0, 397.0]
[627, 532, 622]
p02756
u646412443
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()\nu = ""\nt = ""\nq = int(input())\nnum = 0\n\nfor _ in range(q):\n a = q.split()\n if len(a)==1:\n u,t = t,u\n num ^= 1\n else:\n f = int(a[1])\n c = a[2]\n if f==1:\n t += c\n else:\n u += c\n\nif num:\n print(t[::-1]+s[::-1]+u)\nelse:\n print(t[::-1]+s+u)\n', "s = input()\nqn = int(input())\nright = [s]\nleft = []\nfor i in range(qn):\n qfc = input().split()\n if qfc[0] == '1':\n right, left = left, right\n else:\n if qfc[1] == '1':\n left.append(qfc[2])\n else:\n right.append(qfc[2])\nprint(''.join(left) + ''.join(right))\n", 'import sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline\nread = sys.stdin.read\ns = input()\nu = ""\nt = ""\nq = int(input())\nnum = 0\n\nfor _ in range(q):\n a = readline.split()\n if len(a)==1:\n u,t = t,u\n num ^= 1\n else:\n f = int(a[1])\n c = a[2]\n if f==1:\n t += c\n else:\n u += c\n\nif num:\n print(t[::-1]+s[::-1]+u)\nelse:\n print(t[::-1]+s+u)\n', "s = input()\nqn = int(input())\nleft = ''\nright = s\nfor i in range(qn):\n q = input()\n if q[0] == '1':\n left, right = right, left\n else:\n _, f, c = q.split()\n if f == '1':\n left += c\n else:\n right += c\nprint(left[::-1] + right)\n"]
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s111875615', 's504786828', 's558411299', 's326766916']
[3188.0, 5700.0, 3188.0, 4596.0]
[18.0, 369.0, 18.0, 440.0]
[327, 307, 426, 284]
p02756
u651822741
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 _ in range(q):\n qi = input()\n if len(qi) <= 2:\n s = s[::-1]\n else:\n _,F,C = qi.split()\n if F == "1":\n s = C + s\n else:\n s = s + C \nprint(s)', 's = input()\nq = int(input())\n\nfor ss in range(q):\n qi = input()\n \n# =============================================================================\n# if len(qi) <= 2:\n\n# else:\n\n# if F == "1":\n\n# else:\n\n# =============================================================================\nprint(s)', 'import sys\ninput = sys.stdin.readline\ns = input()\nq = int(input())\nfor _ in range(q):\n qi = input()\n if len(qi) <= 2:\n s = s[::-1]\n else:\n _,F,C = qi.split()\n if F == "1":\n s = C + s\n else:\n s = s + C \nprint(s)', 'import sys\ns = sys.stdin.readline().rstrip()\nq = int(sys.stdin.readline())\nfor _ in range(q):\n qi = sys.stdin.readline() \nprint(s)', "from collections import deque\n\nS = input()\nQ = int(input())\n\nt = deque(S)\nreverse = False\nfor _ in range(Q):\n query = input()\n if query[0] == '1':\n reverse = not reverse\n elif query[0] == '2':\n _, F, C = query.split()\n if F == '1':\n if reverse:\n t.append(C)\n else:\n t.appendleft(C)\n elif F == '2':\n if reverse:\n t.appendleft(C)\n else:\n t.append(C)\nresult = ''.join(t)\nif reverse:\n result = result[::-1]\nprint(result)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s103475698', 's299589124', 's446284459', 's452775159', 's562547789']
[3960.0, 3316.0, 3772.0, 3316.0, 8564.0]
[2107.0, 260.0, 2104.0, 64.0, 416.0]
[279, 424, 279, 141, 560]
p02756
u652057333
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\ns = str(input().rstrip())\nans = deque(list(s))\n\nf = True\nq = int(input())\nfor i in range(q):\n q = list(map(str, input().split()))\n if int(q[0]) == 1:\n f = not f\n else:\n f_i = int(q[1])\n if f_i == 1 ^ f:\n ans.appendleft(q[2])\n else:\n ans.append(q[2])\nans = "".join(list(ans))\nif not f:\n ans = ans[::-1]\nprint(ans)\n', 'from collections import deque\nimport sys\ninput = sys.stdin.readline\ns = str(input().rstrip())\nans = deque(list(s))\n\nf = True\nq = int(input())\nfor i in range(q):\n q = list(map(str, input().split()))\n if int(q[0]) == 1:\n f = not f\n else:\n f_i = int(q[1])\n if (f_i == 1) ^ f:\n ans.append(q[2])\n else:\n ans.appendleft(q[2])\nans = "".join(list(ans))\nif not f:\n ans = ans[::-1]\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s931580404', 's803498063']
[8676.0, 8676.0]
[418.0, 435.0]
[443, 445]
p02756
u652569315
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 import sys\n input = sys.stdin.readline\n s=input()\n q=int(input())\n count=0\n for _ in [0]*q:\n a=input().split()\n if len(a)==1:\n count+=1\n else:\n if count%2==0:\n s=a[2]+s if a[1]=='1' else s+a[2]\n else:\n s=s+a[2] if a[1]=='1' else a[2]+s\n if count%2==1:\n s=s[::-1]\n print(s)\nif __name__=='__main__':\n main()", "def main():\n s=input()\n q=int(input())\n for _ in [0]*q:\n a=list(input().split())\n if len(a)==1:\n s=reversed(s)\n else:\n if a[1]=='1':\n s=a[2]+s\n else:\n s=s+a[2]\n print(s)\nif __name__=='__main__':\n main()", "def main():\n from collections import deque\n s=deque(input())\n q=int(input())\n count=0\n for _ in [0]*q:\n a=list(input().split())\n if len(a)==1:\n count+=1\n else:\n if count%2==0:\n if a[1]=='1':\n s.appendleft(a[2])\n else:\n s.append(a[2])\n else:\n if a[1]=='1':\n s.append(a[2])\n else:\n l=(a[2],s)\n s.appendleft(a[2])\n if count%2==1:\n s=list(s)[::-1]\n print(''.join(s))\nif __name__=='__main__':\n main()\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s164669289', 's482437098', 's702287718']
[5604.0, 5420.0, 10072.0]
[2104.0, 2104.0, 453.0]
[372, 245, 505]
p02756
u652656291
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 n = int(input())\n if n == 1:\n s = s[::-1]\n else:\n continue\nprint(s)\n \n', 's = input()\nq = int(input())\nfor i in range(q):\n n = int(input())\n if n == 1:\n s = s[::-1]\n else:\n f,c = int(input()),input()\n if f == 1:\n s = c + s\n else:\n s = s + c\nprint(s)\n ', 's = input()\nq = int(input())\nfor i in range(q):\n n = int(input())\n if n == 1:\n s = s[::-1]\n else:\n f,c = map(str,input().split())\n if int(f) == 1:\n s = c + s\n else:\n s = s + c\nprint(s)\n \n', 's = input()\nq = int(input())\nfor i in range(q):\n n = int(input())\n if n == 1:\n s = s[::-1]\n else:\n f,c = input().split()\n if int(f) == 1:\n s = c + s\n else:\n s = s + c\nprint(s)\n \n', "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 rev==False:\n if tmp[1]=='1':\n head.append(tmp[2])\n if tmp[1]=='2':\n tail.append(tmp[2])\n if rev==True:\n if tmp[1]=='1':\n tail.append(tmp[2])\n if tmp[1]=='2':\n head.append(tmp[2])\nhead=''.join(map(str,head))\ntail=''.join(map(str,tail))\nans=head[::-1]+s+tail\nif rev==True:\n ans=ans[::-1]\nprint(ans)\n"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s069669722', 's469176526', 's653711216', 's960335466', 's279159577']
[3188.0, 3188.0, 3188.0, 3188.0, 6344.0]
[18.0, 18.0, 17.0, 18.0, 506.0]
[131, 205, 215, 206, 550]
p02756
u652892331
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()\nquantity = int(input())\nL = [input().split() for i in range(quantity)]\nhanten = -1\natama = ""\nshiri = ""\nfor row in range(quantity):\n each = L[row]\n if each[0] == "1":\n hanten = hanten * -1\n else:\n if each[1] == "1":\n if hanten == -1:\n atama = atama + each[2]\n else:\n shiri = shiri + each[2]\n else:\n if hanten == -1:\n shiri = shiri + each[2]\n else:\n atama = atama + each[2]\n\nprint(atama)\n#print(shiri)\natama = atama[::-1]\nans = atama + S + shiri\nif hanten == 1:\n ans = ans[::-1]\n\nprint(ans)', 'a = input()\nn = int(input())\n\nhanten = -1\natama = ""\noshiri = ""\nfor i in range(n):\n List = list(input().split())\n if List[0] == "1":\n hanten = hanten * -1\n else:\n if List[1] == "1":\n if hanten == -1:\n atama = List[2] + atama\n else:\n oshiri = oshiri + List[2]\n else:\n if hanten == -1:\n oshiri = oshiri + List[2]\n else:\n atama = List[2] + atama\n\nans = atama + a + oshiri\nif hanten == 1:\n ans = ans[::-1]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s430253024', 's233714724']
[40744.0, 4436.0]
[464.0, 1598.0]
[639, 551]
p02756
u653041271
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, bisect, math, itertools, string, queue, copy\n#import numpy as np\n\nfrom collections import Counter,defaultdict,deque\nfrom itertools import permutations, combinations\nfrom heapq import heappop, heappush\nfrom fractions import gcd\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\ndef inp(): return int(input())\ndef inpm(): return map(int,input().split())\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\ndef inplm(n): return list(int(input()) for _ in range(n))\ndef inplL(n): return [list(input()) for _ in range(n)]\ndef inplT(n): return [tuple(input()) for _ in range(n)]\ndef inpll(n): return [list(map(int, input().split())) for _ in range(n)]\ndef inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])\n\ns=input().replace("\\n","")\nq=inp()\n\nql = []\nfor i in range(q):\n tmp = input()\n if tmp[0] == "1":\n ql.append("1")\n else:\n ql.append(tmp.split())\n\nisrev=False\nfor i in range(q):\n if ql[i][0] == \'1\':\n isrev = not isrev\n continue\n if (ql[i][1] == \'2\') == isrev:\n s=ql[i][2]+s\n else:\n s=s+ql[i][2]\nif isrev:\n s = s[::-1]\n\nprint(s)\n', 'import sys, bisect, math, itertools, string, queue, copy\n#import numpy as np\n\nfrom collections import Counter,defaultdict,deque\nfrom itertools import permutations, combinations\nfrom heapq import heappop, heappush\nfrom fractions import gcd\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\ndef inp(): return int(input())\ndef inpm(): return map(int,input().split())\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\ndef inplm(n): return list(int(input()) for _ in range(n))\ndef inplL(n): return [list(input()) for _ in range(n)]\ndef inplT(n): return [tuple(input()) for _ in range(n)]\ndef inpll(n): return [list(map(int, input().split())) for _ in range(n)]\ndef inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])\n\ns=input()\nq=inp()\n\nql = []\nfor i in range(q):\n tmp = input()\n if tmp[0] == "1":\n ql.append("1")\n else:\n ql.append(tmp.split())\n\nisrev=False\nfor i in range(q):\n if ql[i][0] == \'1\':\n isrev = not isrev\n continue\n if (ql[i][1] == \'2\') == isrev:\n s=ql[i][2]+s\n else:\n s=s+ql[i][2]\nif isrev:\n s = s[::-1]\n\nprint(s)\n', "import sys, bisect, math, itertools, string, queue, copy\n#import numpy as np\n\nfrom collections import Counter,defaultdict,deque\n# from itertools import permutations, combinations\n# from heapq import heappop, heappush\n# from fractions import gcd\n# input = sys.stdin.readline\n\n# mod = 10**9+7\ndef inp(): return int(input())\ndef inpm(): return map(int,input().split())\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\ndef inplm(n): return list(int(input()) for _ in range(n))\ndef inplL(n): return [list(input()) for _ in range(n)]\ndef inplT(n): return [tuple(input()) for _ in range(n)]\ndef inpll(n): return [list(map(int, input().split())) for _ in range(n)]\ndef inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])\n\ns = input()\nq = int(input())\nql = [input().split() for i in range(q)]\n\nans = deque(s)\nisrev=False\nfor i in range(q):\n if ql[i][0] == '1':\n isrev = not isrev\n continue\n if (ql[i][1] == '2') == isrev:\n ans.appendleft(ql[i][2])\n else:\n ans.append(ql[i][2])\n\nif isrev:\n ans.reverse()\n\ns = ''.join(ans)\n\nprint(s)\n"]
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s104741231', 's934725233', 's282671298']
[44860.0, 44604.0, 48448.0]
[2145.0, 2172.0, 397.0]
[1180, 1163, 1151]
p02756
u658915215
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(list(input()))\nq = int(input())\n\nisR = 1\nfor i in range(q):\n line = list(input().split())\n t = int(line[0])\n if t == 1:\n isR *= -1\n else:\n f = int(line[1])\n if isR + f == 0 or isR + f == 3:\n s.appendleft(line[2])\n else:\n s.append(line[2])\nif isR == -1:\n s.reverse()\nprint("".join(s))', 'from collections import deque\ns = deque(list(input()))\nq = int(input())\n\nisR = -1\nfor i in range(q):\n line = list(input().split())\n t = int(line[0])\n if t == 1:\n isR *= -1\n else:\n f = int(line[1])\n if isR + f == 0 or isR + f == 3:\n s.appendleft(line[2])\n else:\n s.append(line[2])\nif isR == 1:\n s.reverse()\nprint("".join(s))']
['Wrong Answer', 'Accepted']
['s087082518', 's048784030']
[14356.0, 14308.0]
[395.0, 391.0]
[423, 423]
p02756
u660899380
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()\nqueryNum = input()\nfor i in queryNum:\n\torder = input()\n\tif order == 1:\n\t\tS = S[::-1]\n\telse:\n\t\tif order[0] == 1:\n\t\t\tS = order[2] + S\n\t\telse:\n\t\t\tS = S + order[2]\nprint(S)', "from collections import deque\n\nS = deque(input())\nqueryNum = input()\nflip = False\nfor i in range(int(queryNum)):\n\torder = input()\n\tif order == '1':\n\t\tif flip:\n\t\t\tflip = False\n\t\telse:\n\t\t\tflip = True\n\telse:\n\t\tif order[2] == '1':\n\t\t\tif not flip:\n\t\t\t\tS.appendleft(order[4])\n\t\t\telif flip:\n\t\t\t\tS.append(order[4])\n\t\telse:\n\t\t\tif not flip:\n\t\t\t\tS.append(order[4])\n\t\t\telif flip:\n\t\t\t\tS.appendleft(order[4])\nS = ''.join(S)\nif flip:\n\tprint(S[::-1])\nelse: \n\tprint(S)"]
['Runtime Error', 'Accepted']
['s607869403', 's059572203']
[3316.0, 8564.0]
[18.0, 328.0]
[180, 451]
p02756
u664373116
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.
['head=deque()\ntail=deque()\nfor _ in range(q):\n Q=input().split()\n if len(Q)==1:\n rev=1-rev\n if len(Q)==3:\n if(rev==0 and Q[1]=="1" )or (rev==1 and Q[1]=="2"):\n head.appendleft(Q[2])\n else :\n tail.append(Q[2])\nif rev==0:\n ans="".join(head)+s+"".join(tail)\n\nelse:\n ans="".join(tail)[::-1]+s[::-1]+"".join(head)[::-1]\n\nprint(ans)', 'from collections import deque\ns=input()\nq=int(input())\nrev=0\nhead=deque()\ntail=deque()\nfor _ in range(q):\n Q=input().split()\n if len(Q)==1:\n rev=1-rev\n if len(Q)==3:\n if(rev==0 and Q[1]=="1" )or (rev==1 and Q[1]=="2"):\n head.appendleft(Q[2])\n else :\n tail.append(Q[2])\nif rev==0:\n ans="".join(head)+s+"".join(tail)\n\nelse:\n ans="".join(tail)[::-1]+s[::-1]+"".join(head)[::-1]\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s636549920', 's753079174']
[3064.0, 6516.0]
[17.0, 427.0]
[383, 444]
p02756
u666351996
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 i in range(Q):\n Query = input().split()\n if Query[0] == 1:\n I = I + 1\n else:\n if (int(Query[1]) + I) % 2 == 0:\n S = S + Query[2]\n else:\n S = Query[2] + S\nif I % 2:\n S = S[::-1]\nprint(S)\n', 'S = input()\nQ = int(input())\nI = 0\nL = \'\'\nR = \'\'\nfor i in range(Q):\n Query = input().split()\n if Query[0] == "1":\n I = I + 1\n else:\n if (int(Query[1]) + I) % 2 == 0:\n R = R + Query[2]\n else:\n L = L + Query[2]\nL = L[::-1]\nS = L + S + R\n\nif I % 2:\n S = S[::-1]\nprint(S)\n']
['Runtime Error', 'Accepted']
['s812943209', 's618192020']
[3720.0, 4304.0]
[2104.0, 549.0]
[280, 323]