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
p02755
u936050991
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
["import math\na, b = list(map(int, input().split()))\n\nc = max((a/0.08),(b/0.1))\nif math.floor(c*0.1) - math.floor(c*0.08) < abs(a-b):\n print('-1')\nelse:\n print(c)", "import math\na, b = list(map(int, input().split()))\n\n\na1 = a/0.08\na2 = (a+1)/0.08\nb1 = b/0.1\nb2 = (b+1)/0.1\nc = 0\n\nfor i in range(1001):\n if a1<= i <a2 and b1<= i <b2:\n print(i)\n c = 1\n break\n \nif c==0:\n print('-1')"]
['Wrong Answer', 'Accepted']
['s637060548', 's545659892']
[3060.0, 3064.0]
[18.0, 18.0]
[166, 248]
p02755
u936285815
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\n\nc =0 \nfor n in range(0,10000):\n taxa = n*0.08\n taxb = n*0.1\n if a == taxa and b == taxb:\n print(n)\n break\n else:\n c += 1\nif c > 999:\n print(-1)\n \n ', 'a, b = map(int, input().split())\n\nc =0 \nfor n in range(0,10000):\n taxa = n*0.08\n taxb = n*0.1\n if a == taxa and b == taxb:\n print(n)\n break\n else:\n c += 1\nif c > 9999:\n print(-1)\n ', '\na, b = map(int, input().split())\n\nc =0 \nfor n in range(0,10000):\n taxa = int(n*8/100)\n taxb = int(n*10/100)\n if a == taxa and b == taxb:\n print(n)\n break\n else:\n c += 1\nif c > 9999:\n print(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s143682255', 's150081106', 's502904822']
[3060.0, 2940.0, 3060.0]
[24.0, 22.0, 24.0]
[227, 219, 229]
p02755
u939585142
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['A, B = map(int,input().split())\n\nfor i in range(10000):\n if i * 0.08 == A and i * 0.1 == B:\n print(i)\n exit()\n \nprint(-1)', 'A, B = map(int,input().split())\n\nfor i in range(10000):\n if i * 0.08 == A and i ** 0.1 == B:\n print(i)\n exit()\n \nprint(-1)', 'A, B = map(int,input().split())\n\nfor i in range(10000):\n if int(i * 0.08) == A and int(i * 0.1) == B:\n print(i)\n exit()\n \nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s466241928', 's582518302', 's513116883']
[2940.0, 2940.0, 2940.0]
[20.0, 20.0, 21.0]
[131, 132, 141]
p02755
u944886577
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a,b =map(int,input().split())\n \nfor x in range(101):\n if (x*0.08*100)//1==a*100 and (x*1.10*100)//1==b*100 and x//1==int(x):\n print(int(x))\n exit()\n \nprint(-1)', 'a,b =map(int,input().split())\n \nfor x in range(1010):\n if (x*0.08*100)//1==a*100 and (x*0.10*100)//1==b*100 and x//1==int(x):\n print(int(x))\n exit()\n \nprint(-1)', 'a,b =map(int,input().split())\n\nfor x in range(100):\n if x*1.08==a+x and x*1.10==b+x:\n print(x)\n else:\n print(-1)', 'a,b =map(int,input().split())\n \nfor x in range(101):\n if (x*0.08)//1==a and (x*1.10)//1==b and x//1==int(x):\n print(int(x))\n exit()\n \nprint(-1)', 'a,b =map(int,input().split())\n \nfor x in range(1009):\n if (x*0.08*100)//1==a*100 and (x*0.10*100)//1==b*100 and x//1==int(x):\n print(int(x))\n exit()\n \nprint(-1)', 'a,b =map(int,input().split())\n \nfor x in range(101):\n if (x*0.08*100)//1==a*100 and (x*0.10*100)//1==b*100 and x//1==int(x):\n print(int(x))\n exit()\n \nprint(-1)', 'a,b =map(int,input().split())\n \nfor x in range(101):\n if (x*1.08)//1==a+x and (x*1.10)//1==b+x and x//1=int(x):\n print(int(x))\n exit()\n \nprint(-1)', 'a,b =map(int,input().split())\n \nfor x in range(1009):\n if (x*0.08)//1==a and (x*0.10)//1==b and x//1==int(x):\n print(int(x))\n exit()\n \nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s033005511', 's216840626', 's261295694', 's340792416', 's489892782', 's821059017', 's922963588', 's148855667']
[9224.0, 9220.0, 9164.0, 9196.0, 9180.0, 9152.0, 8956.0, 9224.0]
[31.0, 29.0, 29.0, 30.0, 33.0, 30.0, 28.0, 29.0]
[162, 163, 114, 146, 163, 162, 149, 147]
p02755
u946996108
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['ret = -1\n\nA, B = [int(i) for i in input().split()]\n\nif A<0 or B<0:\n print("-1")\n exit()\n\nminA = int(A/0.08)\nmaxA = int((A+1)/0.08)\nminB = int(B/0.1)\nmaxB = int((B+1)/0.1)\n\nprint(minA, maxA, minB, maxB)\n\nfor i in range(minA, maxA):\n if i >= minB and i < maxB:\n ret = i\n break\n\nprint(ret)', 'ret = -1\n\nA, B = [int(i) for i in input().split()]\n\nminA = int(A/0.08)\nmaxA = int((A+1)/0.08)\nminB = int(B/0.1)\nmaxB = int((B+1)/0.1)\n\nprint(minA, maxA, minB, maxB)\n\nfor i in range(minA, maxA):\n if i >= minB and i <= maxB:\n ret = i\n break\n\nprint(ret)', 'ret = "-1"\n\nA, B = [int(i) for i in input().split(" ")]\n\nfor i in range(1,2000):\n if int(i*0.08) == A and int(i * 0.1) == B:\n ret = str(i)\n break\n\nprint(ret)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s186240776', 's273054760', 's667122137']
[3064.0, 3064.0, 3060.0]
[17.0, 18.0, 18.0]
[309, 267, 174]
p02755
u949115942
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\n\na_tax = int(a / 0.08)\nb_tax = int(b / 0.1)\nn = min([a_tax, b_tax])\n\nif b_tax / a_tax > 1.3 or b_tax / a_tax < 1.2:\n n = -1\nelse:\n while True:\n if a == int(n * 0.08) and b == int(n * 0.1):\n break\n\n n += 1\n\nprint(n)', 'a, b = map(int, input().split())\nfor i in range(2000):\n if int(i * 0.08) == a and int(i * 0.1) == b:\n print(i)\n break\nelse:\n print(-1)']
['Wrong Answer', 'Accepted']
['s586701375', 's622068110']
[3060.0, 3060.0]
[19.0, 18.0]
[279, 154]
p02755
u952467214
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\n\npa = int(a * 100/8)\npb = int(b * 100/10)\n\nans1 = None\nans2 = None\n\nprint(pa,pb)\n\nfor price in range(pb-1, pa+2):\n if int(price * 0.08) == a and int(price * 0.1) == b:\n ans1 = price\n break\n\nfor price in range(pa-1, pb+2):\n if int(price * 0.08) == a and int(price * 0.1) == b:\n ans2 = price\n break\n\nif ans1 is None and ans2 is None:\n print(-1)\nelif ans2 is None:\n print(ans1)\nelif ans1 is None:\n print(ans2)\nelse:\n print(min(ans1,ans2))\n', 'a, b = map(int, input().split())\n\npa = int(a * 100/8)\npb = int(b * 100/10)\n\nfor price in range(pb, pa+1):\n if int(pa * 0.08) == a and int(pb * 0.1) == b:\n print(price)\n exit()\n\nprint(-1)', 'a, b = map(int, input().split())\n\npa = int(a * 100/8)\npb = int(b * 100/10)\n\nans1 = None\nans2 = None\n\nfor price in range(pb-1, pa+2):\n if int(price * 0.08) == a and int(price * 0.1) == b:\n ans1 = price\n break\n\nfor price in range(pa-1, pb+2):\n if int(price * 0.08) == a and int(price * 0.1) == b:\n ans2 = price\n break\n\nif ans1 is None and ans2 is None:\n print(-1)\nelif ans2 is None:\n print(ans1)\nelif ans1 is None:\n print(ans2)\nelse:\n print(min(ans1,ans2))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s156871249', 's468007618', 's199886133']
[3064.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0]
[515, 203, 501]
p02755
u952708174
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['def c_tax_increase():\n A, B = [int(i) for i in input().split()]\n lower = max((25 * A + 2 - 1) / 2, 10 * B)\n upper = min(25 * (A + 1) // 2, 10 * (B + 1))\n return lower if lower < upper else -1\n\nprint(c_tax_increase())', 'def c_tax_increase():\n A, B = [int(i) for i in input().split()]\n lower = max((25 * A + 2 - 1) // 2, 10 * B)\n upper = min(25 * (A + 1) // 2, 10 * (B + 1))\n return lower if lower < upper else -1\n\nprint(c_tax_increase())']
['Wrong Answer', 'Accepted']
['s357027269', 's752068224']
[3060.0, 3060.0]
[17.0, 17.0]
[228, 229]
p02755
u953379577
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['def tax8(n):\n return int(n*(25/2))\n \ndef tax10(n):\n return int(n*(10/1))\n\na , b = map(int,input().split())\n\nans = -1\n\nx = []\nfor i in range(1,a+1):\n if tax8(i) == a:\n x.append(i)\n \ny = []\nfor i in range(1,b+1):\n if tax10(i) == b:\n y.append(i)\n \nfor i in x:\n if i in y:\n ans = i\n break\n \nprint(ans)', 'def tax8(n):\n return list(range(int((n-1)*(25/2))),int((n+1)*(25/2))))\n \ndef tax10(n):\n return list(range(int((n-1)*(10/1))),int((n+1)*(10/1))))\n\na , b = map(int,input().split())\n\nans = -1\n\nx = []\nfor i in range(1,a+1):\n if tax8(i) == a:\n x.extend(i)\n \ny = []\nfor i in range(1,b+1):\n if tax10(i) == b:\n y.extend(i)\n \nfor i in x:\n if i in y:\n if int(i*(2/25)) == int(i*(1/10)):\n ans = i\n break\n \nprint(ans)', 'def tax8(n):\n return int(n*(1.08))\n \ndef tax10(n):\n return int(n*(1.1))\n\na , b = map(int,input().split())\n\nans = -1\n\nx = []\nfor i in range(1,a+1):\n if tax8(i) == a:\n x.append(i)\n \ny = []\nfor i in range(1,b+1):\n if tax10(i) == b:\n y.append(i)\n \nfor i in x:\n if i in y:\n ans = i\n break\n \nprint(ans)', 'def tax8(n):\n return list(range(int((n-1)*(25/2)),int((n+1)*(25/2))))\n \ndef tax10(n):\n return list(range(int((n-1)*(10/1)),int((n+1)*(10/1))))\n\na , b = map(int,input().split())\n\nans = -1\n\nx = []\n\nx.extend(tax8(a))\n \ny = []\n\ny.extend(tax10(b))\n\nfor i in x:\n if i in y:\n if int(i*(27/25))-i == a and int(i*(11/10))-i == b:\n ans = i\n break\n \nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s388233523', 's489150074', 's515910779', 's766525727']
[3064.0, 2940.0, 3064.0, 3064.0]
[17.0, 18.0, 19.0, 18.0]
[360, 483, 359, 400]
p02755
u953499988
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['A,B=map(int,input().split())\nimport math\na=math.ceil(A*100/8)\nb=math.ceil((A+1)*100/8)\nwhile math.floor(a*0.1)!=B and a<b:\n a+=1\n if a==b:\n print(-1)\n else:\n print(a)', 'A,B=map(int,input().split())\nimport math\na=math.ceil(A*100/8)\nb=math.ceil((A+1)*100/8)\nwhile math.floor(a*0.1)!=B and a<b:\n a+=1\nif a==b:\n print(-1)\nelse:\n print(a)']
['Wrong Answer', 'Accepted']
['s672191389', 's722793815']
[3060.0, 3060.0]
[18.0, 18.0]
[175, 167]
p02755
u955488057
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['import sys\n\ndef input():\n return sys.stdin.readline()[:-1]\n\n\nA, B = map(int, input().split())\n\nA_ = []\nB_ = []\nfor i in range(1, 1001):\n\tif i*8 //100 == A:\n\t\tA_.append(i)\n\n\tif i//10 == B:\n\t\tB_.append(i)\n\nA_ = set(A_)\nB_ = set(B_)\nsel = A_ & B_\nprint(A_, B_)\nif sel == set():\n\tprint(-1)\nelse:\n\tprint(min(sel))\n', 'import sys\n\ndef input():\n return sys.stdin.readline()[:-1]\n\n\nA, B = map(int, input().split())\n\nA_ = []\nB_ = []\nend = False\nfor i in range(1, 1001):\n\tif i*8//100 == A and i//10 == B:\n\t\tprint(i)\n\t\tend = True\n\t\tbreak\n\telse:\n\t\tcontinue\nif end:\n\tpass\nelse:\n\tprint(-1)\n']
['Wrong Answer', 'Accepted']
['s128452652', 's629561098']
[3064.0, 3060.0]
[18.0, 18.0]
[312, 266]
p02755
u955547613
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['def main():\n a, b = map(int, input().split())\n x = 13\n while x <= int(a/0.08):\n x+=1\n if int(x*0.08) == a:\n if int(x*0.1) == b:\n return x\n return -1\n\n\n\nif __name__ == "__main__":\n print(main()', 'import math\ndef main():\n a, b = map(int, input().split())\n ra = [math.ceil(i/0.08) for i in range(1, 102)]\n rb = [math.ceil(i/0.1) for i in range(1, 102)]\n x = ra[a-1] \n while x < ra[a] :\n if int(x*0.1) == b:\n return x\n x+=1\n return -1\n\n\n\nif __name__ == "__main__":\n print(main())']
['Runtime Error', 'Accepted']
['s008086638', 's092731354']
[3064.0, 3064.0]
[18.0, 19.0]
[247, 326]
p02755
u956223466
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split(" "))\nfor i in range(1, 1009):\n if int(i * 0.08) == a and int(i * 0.1) == b:\n print(i)\n return\nprint(-1)', 'a, b = map(int, input().split(" "))\nfor i in range(1, 10000):\n if int(i * 0.08) == a and int(i * 0.1) == b:\n print(i)\n break\n\nprint(-1)', 'a, b = map(int, input().split(" "))\nfor i in range(1, 10000):\n if i * 0.08 == a and i * 0.1 == b:\n print(i)\n break\n\nprint(-1)\n', 'a, b = map(int, input().split(" "))\nfor i in range(1, 10000):\n if int(i * 0.08) == a and int(i * 0.1) == b:\n print(i)\n return\nprint(-1)', 'a, b = map(int, input().split(" "))\nfor i in range(1, 1009):\n if i * 0.08 == a and i * 0.1 == b:\n print(i)\n return\nprint(-1)', 'a, b = map(int, input().split(" "))\n\nfound = False\nfor i in range(1, 10000):\n if int(i * 0.08) == a and int(i * 0.1) == b:\n print(i)\n found = True\n break\n\nif not found:\n print(-1)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s053766800', 's217546834', 's599337453', 's949660939', 's958898873', 's590489780']
[2940.0, 2940.0, 2940.0, 2940.0, 3064.0, 2940.0]
[17.0, 20.0, 19.0, 18.0, 18.0, 20.0]
[151, 152, 143, 152, 141, 206]
p02755
u957055646
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
["A, B = list(map(int, input().split(' '))) \n\nres = -1\n\nfor i in range(1, 1010):\n q_A = int(i / A)\n q_B = int(i / B)\n if q_A == q_B:\n res = i\n break\n else:\n continue\n\nprint(i)", "A, B = list(map(int, input().split(' '))) \n \nres = -1\n\nfor i in range(1, 1010):\n q_A = int(i * 0.08)\n q_B = int(i * 0.1)\n if q_A == A and q_B == B:\n res = i\n break\n else:\n continue\n \nprint(res)"]
['Wrong Answer', 'Accepted']
['s368387514', 's792759845']
[3064.0, 2940.0]
[18.0, 18.0]
[210, 230]
p02755
u959340534
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
["a, b = map(int, input().split())\n\nstart = b * 10\nflg = True\nfor i in range(10):\n tmp = (start + i) * 0.08\n if tmp == a:\n flg = False\n break\nif flg:\n print('-1')\nelse:\n print(int(tmp))", "a, b = map(int, input().split())\n\nstart = b * 10\nflg = True\nfor i in range(10):\n tmp = (start + i) * 0.08\n if int(tmp) == a:\n flg = False\n break\nif flg:\n print('-1')\nelse:\n print(int(tmp))\n", "a, b = map(int, input().split())\n\nstart = b * 10\nflg = True\nfor i in range(10):\n tmp = start + i\n if int(tmp*0.08) == a:\n flg = False\n break\nif flg:\n print('-1')\nelse:\n print(int(tmp))"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s277439059', 's717862511', 's754221968']
[2940.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0]
[193, 199, 194]
p02755
u961945062
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['i = list(map(int, input().split()))\n\nA = int(i[0])\nB = int(i[1])\n\nA_min = A // 0.08 + 1\nA_max = ((A + 1) // 0.08)\nB_min = B // 0.1 + 1\nB_max = ((B+1) // 0.1)\n\nif A_max < B_min:\n print(-1)\nelif A_min > B_max:\n print(-1)\nelif A_min < B_min:\n print(B_min)\nelse:\n print(A_min)', 'A, B = map(int, input().split())\n\nfor i in range(2000):\n if int(i * 0.08) == A and int(i * 0.1) == B:\n print(i)\n exit()\nprint(-1)']
['Wrong Answer', 'Accepted']
['s556468029', 's342805157']
[3064.0, 2940.0]
[17.0, 18.0]
[284, 146]
p02755
u962423738
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a,b=map(int,input())\n\ne=0\nt=0\n\nfor i in range(1,100):\n\tif a<=i*0.08<a+1:\n\t\te=i\n\tif b<=i*0.1<b+1:\n\t\tt=i\n\tif e==t:\n\t\tprint(e)\n \nprint(-1)', 'A, B = map(int, input().split())\n\nfor i in range(2000):\n if int(i * 0.08) == A and int(i * 0.1) == B:\n print(i)\n exit()\nprint(-1)']
['Runtime Error', 'Accepted']
['s670455726', 's937573703']
[9036.0, 9044.0]
[27.0, 30.0]
[142, 146]
p02755
u967864815
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\n\nfor n in range(10000):\n xa = n * 0.08\n xb = n * 0.1\n if a == xa and b == xb:\n print(n)\n exit()\nprint(-1)', 'a, b = map(int, input().split())\n\nfor n in range(1000):\n xa = n * 0.08\n xb = n * 0.1\n if a == xa and b == xb:\n print(n)\n exit()\nprint(-1)', 'a, b = map(int, input().split())\n\nfor n in range(1500):\n xa = int(n * 0.08)\n xb = int(n * 0.1)\n if a == xa and b == xb:\n print(n)\n exit()\nprint(-1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s560222718', 's674808196', 's313329599']
[9128.0, 9160.0, 9128.0]
[33.0, 29.0, 31.0]
[161, 160, 171]
p02755
u969708690
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['import sys\nA,B=map(int,input().split())\nfor i in range(1,1010):\n if i*0.1==B and i*0.08==A:\n print(i)\n sys.exit()\nprint(-1)', 'import sys\nA,B=map(int,input().split())\nfor i in range(1,10000):\n if i*0.1==B and i*0.08==A:\n print(i)\n sys.exit()\nprint(-1)', 'import sys\nA,B=map(int,input().split())\nfor i in range(1010):\n if int(i*0.1)==B and int(i*0.08)==A:\n print(i)\n sys.exit()\nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s052375275', 's085956236', 's185026813']
[3064.0, 2940.0, 2940.0]
[17.0, 19.0, 17.0]
[130, 131, 138]
p02755
u969848070
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\nmoney = 1\nwhile money <1010:\n if money==a//0.08 and money == b//0.10:\n print(money)\n money+=1\n if money == 1010:\n print(-1)', 'a, b = map(int, input().split())\n \nmoney = 1\nwhile money < 1010:\n if money ==int(0.08*a) and money == int(0.10*b):\n print(money)\n break\n money+=1\n if money ==1010:\n print(-1)', 'a, b = map(int, input().split())\n\nmoney = 1\nwhile money < 1010:\n if money ==int(0.08*a) and money == int(0.10*b):\n print(money)\n money+=1\n if money ==1010:\n print(-1)', 'a, b = map(int, input().split())\n \nmoney = 1\nwhile money < 1010:\n if a ==int(0.08*money) and b == int(0.10*money):\n print(money)\n break\n money+=1\n if money ==1010:\n print(-1)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s578979162', 's694691842', 's767077071', 's639477219']
[2940.0, 3060.0, 2940.0, 2940.0]
[17.0, 19.0, 17.0, 18.0]
[165, 186, 175, 186]
p02755
u970133396
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['A, B = map(int, input().strip().split())\n\nAmin=A*8//100\nAmax=(A+1)*8//100\nif (A+1)%0.08==0:\n Amax-=1\n\nBmin=B*10\nBmax=(B+1)*10\nif (B+1)%0.1==0:\n Bmax-=1\n\nans=-1\nflag=False\nfor a in range(Amin,Amax+1):\n for b in range(Bmin,Bmax+1):\n if a==b:\n ans=a\n flag=True\n break\n if flag:\n break\nprint(ans)', 'import math\nA, B = map(int, input().strip().split())\n\nAmin=math.ceil(A*100/8)\nAmax=(A+1)*100//8\nif Amax*8/100 == Amax*8//100:\n Amax-=1\n\nBmin=B*10\nBmax=(B+1)*10\nif Bmax/10 == Bmax//10:\n Bmax-=1\n\nans=-1\nflag=False\nfor a in range(Amin,Amax+1):\n for b in range(Bmin,Bmax+1):\n if a==b:\n ans=a\n flag=True\n break\n if flag:\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s695575117', 's864956029']
[3064.0, 3064.0]
[17.0, 17.0]
[351, 392]
p02755
u973758681
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['#include <stdio.h>\n\nint main() {\n int a, b, x=-1;\n scanf("%d %d", &a, &b);\n for(int i=b*10; i<(b+1)*10; ++i) {\n if ((int)(i*0.08) == a) {\n x = i;\n break;\n }\n }\n printf("%d", x);\n return 0;\n}\n', '#include <stdio.h>\n\nint main() {\n int a, b, x=-1;\n scanf("%d %d", &a, &b);\n for(int i=b*10; i<(b+1)*10; ++i) {\n if ((int)(i*0.08) == a) {\n x = i;\n break;\n }\n }\n printf("%d", x);\n return 0;\n}\n', 'a, b = map(int, input().split())\nfor i in range(b*10, (b+1)*10):\n if int(i*0.08) == a:\n print(i)\n break\nelse:\n print(-1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s148165505', 's748535459', 's916883993']
[2940.0, 2940.0, 2940.0]
[18.0, 18.0, 17.0]
[213, 213, 128]
p02755
u974792613
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\n\nupper = 1300\n\nprice = -1\nfor i in range(1, upper):\n tax8 = int(i*0.08)\n tax10 = int(i*0.1)\n if a == tax8 ans b == tax10:\n price = i\n break\n \nprint(price)', 'a, b = map(int, input().split())\n\nupper = 1300\n\nprice = -1\nfor i in range(1, upper):\n tax8 = int(i * 0.08)\n tax10 = int(i * 0.1)\n if a == tax8 and b == tax10:\n price = i\n break\n\nprint(price)\n']
['Runtime Error', 'Accepted']
['s821458320', 's874036172']
[3064.0, 2940.0]
[18.0, 18.0]
[199, 214]
p02755
u975039852
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\nfor x in range(1000):\n if int((x + 1) * 0.08) == a and int((x + 1) * 0.1 == b):\n print(x)\n break\nelse:\n print(-1)', 'a, b = map(int, input().split())\nfor x in range(1, 1001):\n if int(x * 0.08) == a and int(x * 0.1) == b:\n print(x)\n break\nelse:\n print(-1)\n']
['Wrong Answer', 'Accepted']
['s702589665', 's054981824']
[2940.0, 2940.0]
[18.0, 17.0]
[154, 146]
p02755
u976169012
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['import math\na,b = map(int,input().split())\na1 = math.round(a/0.08)\nb1 = math.round(b/0.1)\nc = min(a1,b1)\nwhile True:\n\tif math.floor(c*0.08) == a and math.floor(c*0.1) == b:\n\t\tprint(c)\n\t\tbreak\n\telif math.floor(c*0.08) != a and math.floor(c*0.1) != b:\n\t\tprint(-1)\n\t\tbreak\n\telse:\n\t\tc+=1\n', 'import math\na,b = map(int,input().split())\na1 = round(a/0.08)\nb1 = round(b/0.1)\nc = min(a1,b1)\nwhile True:\n\tif math.floor(c*0.08) == a and math.floor(c*0.1) == b:\n\t\tprint(c)\n\t\tbreak\n\telif math.floor(c*0.08) > a and math.floor(c*0.1) > b:\n\t\tprint(-1)\n\t\tbreak\n\telse:\n\t\tc+=1\n']
['Runtime Error', 'Accepted']
['s765071183', 's357758572']
[3060.0, 3060.0]
[17.0, 18.0]
[284, 272]
p02755
u977193988
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['import math\n\nA, B = map(int, input().split())\na = math.ceil(A / 0.08)\nb = math.ceil(B / 0.1)\nans = max(a, b)\n\nif ans ** 0.08 == A and ans ** 0.1 == B:\n print(ans)\nelse:\n print(-1)', 'import math\n\nA, B = map(int, input().split())\na = math.ceil(A / 0.08)\nb = math.ceil(B / 0.1)\nans = max(a, b)\n\nif math.floor(ans * 0.08) == A and math.floor(ans * 0.1) == B:\n print(ans)\nelse:\n print(-1)\n']
['Wrong Answer', 'Accepted']
['s612482491', 's161901252']
[3060.0, 2940.0]
[18.0, 17.0]
[185, 208]
p02755
u977771109
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['#!/usr/bin/env python\nimport sys\n\ninput = sys.stdin\n\ndef tax(pct8, pct10):\n pct8low = pct8 / 0.08\n pct8high_x10 = (pct8 + 1) * 125\n if pct8high_x10 % 10 == 0:\n pct8high = pct8high_x10 / 10 - 1\n else:\n pct8high = pct8high_x10 / 10\n\n\n pct10low = pct10 * 10\n pct10high = (pct10 + 1) * 10\n\n # 8 H---------------L\n # 10 H-----------*----L\n # <or>\n # 8 H------------*--L\n # 10 H----------------L\n # <or>\n # 8 H---------------L\n # 10 H-------------------*-----L\n # <or>\n # 8 H-------------------*-----L\n # 10 H---------------L\n if pct8high < pct10low or pct10high < pct8low:\n return -1\n else:\n return max(pct8low, pct10low)\n\n\npct8, pct10 = map(int, input.readline().split(" "))\nprint(tax(pct8, pct10))\n', '#!/usr/bin/env python\nimport sys\n\ninput = sys.stdin\n\ndef tax(pct8, pct10):\n pct8low = pct8 / 0.08\n pct8high = (pct8 + 1) / 0.08\n\n pct10low = pct10 / 0.1\n pct10high = (pct10 + 1) / 0.1\n\n # 8 H---------------L\n # 10 H-----------*----L\n # <or>\n # 8 H------------*--L\n # 10 H----------------L\n # <or>\n # 8 H---------------L\n # 10 H-------------------*-----L\n # <or>\n # 8 H-------------------*-----L\n # 10 H---------------L\n if pct8high < pct10low or pct10high < pct8low:\n return -1\n else:\n return max(pct8low, pct10low)\n\n\npct8, pct10 = map(int, input.readline().split(" "))\nprint(tax(pct8, pct10))\n\n\n', '#!/usr/bin/env python\nimport sys\n\ninput = sys.stdin\n\ndef tax(pct8, pct10):\n pct8low_x10 = pct8 * 125\n if pct8low_x10 % 10 == 0:\n pct8low = pct8low_x10 // 10\n else:\n pct8low = pct8low_x10 // 10 + 1\n\n pct8high_x10 = (pct8 + 1) * 125\n\n if pct8high_x10 % 10 == 0:\n pct8high = pct8high_x10 // 10 - 1\n else:\n pct8high = pct8high_x10 // 10\n\n pct10low = pct10 * 10\n pct10high = (pct10 + 1) * 10 - 1\n\n if pct8high < pct10low or pct10high < pct8low:\n return -1\n else:\n return max(pct8low, pct10low)\n\n#def test():\n\n# for j in range(1, 100+1):\n# price = tax(i, j)\n# if price > 0:\n# if int(price *.08) != i or int(price * .1) != j:\n# print(f"Wrong! tax({i},{j}) -> {price} but price*0.8={int(price*0.08)} and price*0.1={int(price*0.1)}")\n\npct8, pct10 = map(int, input.readline().split(" "))\nprint(tax(pct8, pct10))\n#test()\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s504959932', 's632885169', 's196188293']
[3060.0, 2940.0, 3064.0]
[18.0, 17.0, 17.0]
[809, 690, 975]
p02755
u978640776
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['import math\n\na = list(map(int, input().split()))\nb = -1\nfor i in range(1250):\n x = math.floor(i*0.08)\n y = math.floor(i*0.1)\n if a[0] == x and a[1] == y:\n b = x\n break\n\nprint(b)', 'import math\n\na = list(map(int, input().split()))\nb = -1\nfor i in range(1001):\n x = math.floor(i*0.08)\n y = math.floor(i*0.1)\n if a[0] == x and a[1] == y:\n b = i\n break\n\nprint(b)']
['Wrong Answer', 'Accepted']
['s238523069', 's159484042']
[2940.0, 3064.0]
[20.0, 21.0]
[200, 200]
p02755
u981040490
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
["# -*- coding: utf-8 -*-\ndef main():\n A,B = map(int,input().split())\n for i in range(1,1010):\n if (0.08*i)==A and (0.1*i)==B:\n print(i)\n return\n print('-1')\n\nif __name__ == '__main__':\n main()", "# -*- coding: utf-8 -*-\ndef main():\n A,B = map(int,input().split())\n for i in range(1,1010):\n if int(0.08*i)==A and int(0.1*i)==B:\n print(i)\n return\n print('-1')\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s876720126', 's916224235']
[3064.0, 2940.0]
[18.0, 17.0]
[232, 238]
p02755
u981206782
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a,b=map(int,input().split())\nxa=a/0.08\nxb=b/0.1\nif xa*0.08==xb*0.1:\n print(xa*0.08)\nelse:\n print(-1)', 'import math\na,b=map(int,input().split())\nxa=math.ceil(a/0.08)\nxb=int(b/0.1)\nif int(max(xa,xb)*0.08)==a and int(max(xa,xb)*0.1)==b:\n print(max(xa,xb))\nelse:\n print(-1)']
['Wrong Answer', 'Accepted']
['s050058918', 's435925353']
[3064.0, 3060.0]
[18.0, 17.0]
[106, 172]
p02755
u984276646
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['A, B = map(int, input().split())\np = -1\nfor i in range(101):\n if (108 * i) // 100 == A and (11 * i) // 10 == B:\n p = i\n break\nprint(p)', 'A, B = map(int, input().split())\np = -1\nfor i in range(100001):\n if (108 * i) // 100 - i == A and (11 * i) // 10 - i == B:\n p = i\n break\nprint(p)\n']
['Wrong Answer', 'Accepted']
['s458732133', 's007249274']
[3064.0, 3060.0]
[18.0, 39.0]
[141, 153]
p02755
u987164499
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a,b = map(int,input())\n\nfor i in range(0,100):\n if int(i*1.08) == a and int(i*1.1) == b:\n print(i)\n exit()\n \nprint(-1)', 'a,b = map(int,input().split())\n\nfor i in range(100):\n if int(i*1.08) == a and int(i*1.1) == b:\n print(i)\n exit()\n\nprint(-1)', 'from sys import stdin\na,b = map(int,stdin.readline().rstrip().split())\nfor i in range(1001):\n if int(i*0.08) == a and int(i*0.1) == b:\n print(i)\n exit()\nprint(-1)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s917813826', 's946915051', 's127468231']
[2940.0, 2940.0, 2940.0]
[17.0, 18.0, 19.0]
[142, 140, 179]
p02755
u987326700
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['import sys\nA,B = map(int,input().split())\nif A<13:\n print(-1)\n sys.exit()\nlast = 2000\n\nfor i in range(last):\n mA = int(i*0.08)\n mB = int(i*0.10)\n print(mA,mB,i)\n\n \n if mA==A and mB==B:\n print("match")\n print(i)\n break\n if i==last-1:\n print("-1")', 'import sys\nA,B = map(int,input().split())\nif A<13:\n print(-1)\n sys.exit()\nlast = 2000\n\nfor i in range(last):\n mA = int(i*0.08)\n mB = int(i*0.10)\n\n \n if mA==A and mB==B:\n print(i)\n break\n if i==last-1:\n print("-1")', 'A,B = map(int,input().split())\n\nlast = 2000\nfor i in range(last):\n mA = int(i*0.08)\n mB = int(i*0.10)\n\n \n if mA==A and mB==B:\n print("match")\n print(i)\n break\n if i==last-1:\n print("-1")', 'A,B = map(int,input().split())\n\nlast = 2000\n\nfor i in range(12,last):\n mA = int(i*0.08)\n mB = int(i*0.10)\n \n if mA==A and mB==B:\n print(i)\n break\n if i==last-1:\n print("-1")']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s805302524', 's866918188', 's999976244', 's860236435']
[3444.0, 3064.0, 3060.0, 2940.0]
[23.0, 19.0, 24.0, 18.0]
[265, 229, 203, 187]
p02755
u989348352
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
["\nA, B = [int(i) for i in input().split()]\n\naa = A / 0.08\nbb = B / 0.1\n\n\nif aa > (bb + 10) or bb > (aa + 12.5):\n print('-1')\nelse:\n if aa > bb:\n print(aa)\n else:\n print(bb)\n ", "\nA, B = [int(i) for i in input().split()]\n\naa = A / 0.08\nbb = B / 0.1\n\n\nif aa > bb:\n if B == int(aa * 0.1):\n print(aa)\n else:\n print('-1')\nelse:\n if A == int(bb*0.08):\n print(bb)\n else:\n print('-1') \n \n\n", "A, B = [int(i) for i in input().split()]\n\naa = A / 0.08\nbb = B / 0.1\n\n\nif aa > bb:\n if B == int(aa * 0.1):\n print(aa)\n else:\n print(-1)\nelse:\n if A == int(bb*0.08):\n print(bb)\n else:\n print('-1') \n ", "import math\n\nA, B = [int(i) for i in input().split()]\n\naa = math.ceil(A / 0.08)\nbb = math.ceil(B / 0.1)\n\n\nif aa > bb:\n if int(aa * 0.08) != A or int(aa * 0.1) != B:\n print('-1')\n else:\n print(aa)\nelse:\n if int(bb * 0.08) != A or int(bb * 0.1) != B:\n print('-1')\n else:\n print(bb)\n "]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s633193580', 's941172879', 's979436933', 's368780350']
[2940.0, 3060.0, 2940.0, 3060.0]
[20.0, 19.0, 17.0, 19.0]
[203, 257, 252, 328]
p02755
u991567869
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['a, b = map(int, input().split())\n\npa = 0 - -a//0.08\npb = b/0.1\nans = pa\n\nta = pa//12.5\ntb = pa//10\n\nprint(ta, tb)\n\nif ta == a and tb == b:\n for i in range(100):\n ans = pa - 1\n if ans//12.5 != a or ans//10 != b:\n ans = ans + 1\n print(int(ans))\n break\nelse:\n print(-1)', 'a, b = map(int, input().split())\n\npa = 0 - -a//0.08\npb = b/0.1\nans = pa\n\nta = pa//12.5\ntb = pa//10\n\nif ta == a and tb == b:\n for i in range(100):\n ans = pa - 1\n if ans//12.5 != a or ans//10 != b:\n ans = pa + 1\n print(int(ans))\n break\nelse:\n print(-1)', 'a, b = map(int, input().split())\n\nfor i in range(1100):\n if i//12.5 == a and i//10 == b:\n print(i)\n exit()\n\nprint(-1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s739485146', 's882216252', 's886982623']
[3064.0, 3064.0, 3064.0]
[19.0, 17.0, 18.0]
[319, 303, 134]
p02755
u995419623
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['import math\n\na,b = map(int,input().split())\n\nif math.floor(a*12.5) == math.floor(b*10):\n print(math.floor(b*10)\nelse:\n print("-1")', 'a,b=map(int,input().split())\nc=[]\n\nfor i in range(1240):\n if int(i*0.08) == a and int(i*0.1) == b:\n c.append(i)\nc.append(-1)\n\nprint(c[0])']
['Runtime Error', 'Accepted']
['s430086731', 's906574847']
[2940.0, 3060.0]
[18.0, 18.0]
[132, 141]
p02755
u996506712
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
["a,b=map(int,input().split())\nam=a*(100/108)\naM=(a+1)*(100/108)\nbm=b*(100/110)\nbM=(b+1)/(100/110)\nfor i in range(101):\n if am<=i<aM and bm<=i<bM:\n print(i)\n exit(0)\n elif i==100:\n print('-1')", 'a, b = map(int, input().split())\nfor i in range(1, 2000):\n if int(i * 0.08) == a and int(i * 0.1) == b:\n print(i)\n exit()\nprint(-1)\n ']
['Wrong Answer', 'Accepted']
['s773259080', 's861793310']
[9164.0, 9092.0]
[29.0, 30.0]
[217, 143]
p02755
u998741086
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['#!/usr/bin/env python3\nimport math\n\na, b = map(int, input().split())\nx = math.floor((a-1)/0.08)\ny = math.floor((a+1)/0.08)\nz = math.floor((b-1)/0.1)\nw = math.floor((b+1)/0.1)\n\nif y<z:\n print(-1)\n exit(0)\n\nans = []\nfor i in range(min(x,z), min(y,w)):\n if math.floor(i*0.08) == a and math.floor(i*0.1) == b:\n ans.append(i)\n\nif len(ans) == 0:\n print(-1):\nelse:\n print(min(ans))\n', '#!/usr/bin/env python3\nimport math\n\na, b = map(int, input().split())\nx = math.floor((a-1)/0.08)\ny = math.floor((a+1)/0.08)\nz = math.floor((b-1)/0.1)\nw = math.floor((b+1)/0.1)\n\nif y<z:\n print(-1)\n exit(0)\n\nans = []\nfor i in range(min(x,z), min(y,w)):\n if math.floor(i*0.08) == a and math.floor(i*0.1) == b:\n ans.append(i)\n\nif len(ans) == 0:\n print(-1)\nelse:\n print(min(ans))\n']
['Runtime Error', 'Accepted']
['s222567634', 's970692812']
[3064.0, 3064.0]
[17.0, 17.0]
[397, 396]
p02755
u999482355
2,000
1,048,576
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.) Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer. If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print `-1`.
['from math import *\nA,B=list(map(input().split()))\nx=ceil(max(A/0.08,B/0.1))\ny=min((A+1)/0.08,(B+1)/0.1)\nif x<y:\n print(x)\nelse:\n print(-1)', 'from math import *\nA,B=list(map(int, input().split()))\nx=ceil(max(A/0.08,B/0.1))\ny=min((A+1)/0.08,(B+1)/0.1)\nif x<y:\n print(x)\nelse:\n print(-1)']
['Runtime Error', 'Accepted']
['s308983378', 's723610338']
[3060.0, 3060.0]
[18.0, 18.0]
[140, 149]
p02756
u001839988
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())\nS_r = []\nS_l = []\n\nn = 0\n\nfor i in range(Q):\n q = list(input().split())\n if int(q[0]) == 1:\n n += 1\n else:\n if int(q[1]) == 1:\n S_l.append(q[2])\n S_r = S\n n += 1\n break\n else:\n S_r.append(q[2])\n S_l = S\n n += 1\n break\n\n if i == Q-1:\n print(\'\'.join(S_l[::-1]), end="")\n print(\'\'.join(S), end="")\n print(\'\'.join(S_r))\n\nfor i in range(Q - n):\n q = list(input().split())\n if int(q[0]) == 1:\n temp = S_r[-1]\n S_r[-1] = S_l[-1]\n S_l[-1] = temp\n else:\n if int(q[1]) == 1:\n S_l.append(q[2])\n else:\n S_r.append(q[2])\n\nprint(S_l)\nprint(S_r)\nprint(\'\'.join(S_l[::-1]), end="")\nprint(\'\'.join(S_r))', 'S = list(input())\nQ = int(input())\nS_r = []\nS_l = []\n\nn = 0\n\nfor i in range(Q):\n q = list(input().split())\n if int(q[0]) == 1:\n n += 1\n else:\n if int(q[1]) == 1:\n S_l.append(q[2])\n S_r = S\n n += 1\n break\n else:\n S_r.append(q[2])\n S_l = S\n n += 1\n break\n\n if i == Q-1:\n if not S_r and not S_l\n print(\'\'.join(S))\n elif not S_r\n print(\'\'.join(S_l[::-1]), end="")\n print(\'\'.join(S))\n elif not S_l\n print(\'\'.join(S), end="")\n print(\'\'.join(S_r))\n\nfor i in range(Q - n):\n q = list(input().split())\n if int(q[0]) == 1:\n temp = S_r[-1]\n S_r[-1] = S_l[-1]\n S_l[-1] = temp\n else:\n if int(q[1]) == 1:\n S_l.append(q[2])\n else:\n S_r.append(q[2])\n\nprint(\'\'.join(S_l[::-1]), end="")\nprint(\'\'.join(S_r))', 'S = list(input())\nS_r = []\nQ = int(input())\nR = True\n\nfor i in range(Q):\n q = list(input().split())\n if int(q[0]) == 1:\n R = not R\n else:\n if int(q[1]) == 1:\n if R:\n S_r.append(q[2])\n else:\n S.append(q[2])\n else:\n if R:\n S.append(q[2])\n else:\n S_r.append(q[2])\n\nif not S_r:\n if R:\n print(\'\'.join(S))\n else:\n print(\'\'.join(S[::-1]))\nelse:\n if R:\n print(\'\'.join(S_r[::-1]), end="")\n print(\'\'.join(S))\n else:\n print(\'\'.join(S[::-1]), end="")\n print(\'\'.join(S_r))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s214902299', 's866090430', 's795405300']
[9556.0, 3064.0, 7068.0]
[592.0, 18.0, 554.0]
[729, 822, 541]
p02756
u003644389
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
['s = input()\nq = int(input())\n\nquery = []\nrev=1\n\nfor i in range(q):\n query.append(input().split())\n\nfor i in range(q):\n if query[i][0]=="1":\n rev*=-1\n else:\n if rev==1:\n if query[i][1]=="1":\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n else:\n if query[i][1]=="2":\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n\nif rev==-1:\n s = s[::-1]\nprint(s)', 's = input()\nq = int(input())\n\nquery = [""]*q\n\nfor i in range(q):\n query[i] = input()\n if query[i]=="1":\n s = list(reversed(s))\n else:\n r = query[i].split()\n if r[1]=="1":\n s = r[2]+s\n else:\n s += r[2]\n\nprint(s)', 's = input()\nq = int(input())\n\nquery = [""]*q\n\nrev=1\n\nfor i in range(q):\n query[i] = input()\n if query[i]=="1":\n rev*=-1\n else:\n r = query[i].split()\n if rev=1:\n if r[1]=="1":\n s = r[2]+s\n else:\n s += r[2]\n else:\n if r[1]=="2":\n s = r[2]+s\n else:\n s += r[2]\n\nif rev=-1:\n s = s[::-1]\nprint(s)', 's = input()\nq = int(input())\n\nquery = []\nt = []\nf = []\nc = []\n\nfor i in range(q):\n query[i] = input()\n if query[i]=="1":\n t.append(1)\n else:\n r = query[i].split()\n t.append(2)\n f.append(int(r[1]))\n c.append(r[2])\n\nfor i in range(q):\n if t[i]==1:\n s = s[::-1]\n elif t[i]==2:\n if f[i]==1:\n s = c[i]+s\n elif t[i]==2:\n s = s+c[i]\nprint(s)', 'from collections import deque\n\ns = deque(input())\nq = int(input())\n\nquery = []\nrev=1\n\nfor i in range(q):\n query.append(input().split())\n\nfor i in range(q):\n if query[i][0]=="1":\n rev*=-1\n else:\n if rev==1:\n if query[i][1]=="1":\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n else:\n if query[i][1]=="2":\n s.appendleft(query[i][2])\n else:\n s.append(query[i][2])\n\nresult="".join(list(s))\nif rev==-1:\n result = result[::-1]\nprint(result)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s159728697', 's458908941', 's658576873', 's983775937', 's513431062']
[39156.0, 12492.0, 3064.0, 3188.0, 44524.0]
[406.0, 2108.0, 17.0, 18.0, 487.0]
[504, 269, 434, 427, 581]
p02756
u004423772
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().rstrip('\\r\\n')\nS_list = deque(S)\nreverse_flg = False\n\nQ = int(input())\nfor _ in range(Q):\n query = input().rstrip('\\r\\n')\n t, f, c = '', '', ''\n if len(query) == 1:\n t = query\n else:\n t, f, c = query.split(' ')\n if t == '1':\n reverse_flg = not reverse_flg\n else:\n if f == '1':\n S_list.appendleft(c)\n else:\n S_list.append(c)\nif reverse_flg:\n S_list.reverse()\nprint(''.join(S_list))", "from collections import deque\n\nS = input().rstrip('\\r\\n')\nS_list = deque(S)\nis_reverse = False\n\nQ = int(input())\nfor _ in range(Q):\n query = input().rstrip('\\r\\n')\n t, f, c = '', '', ''\n if len(query) == 1:\n t = query\n else:\n t, f, c = query.split(' ')\n if t == '1':\n is_reverse = not is_reverse\n else:\n if f == '1':\n if is_reverse:\n S_list.append(c)\n else:\n S_list.appendleft(c)\n else:\n if is_reverse:\n S_list.appendleft(c)\n else:\n S_list.append(c)\nif is_reverse:\n S_list.reverse()\nprint(''.join(S_list))"]
['Wrong Answer', 'Accepted']
['s518443241', 's592438895']
[8564.0, 8820.0]
[470.0, 483.0]
[501, 665]
p02756
u004482945
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())\njudge = 1\nfront = []\nback = []\nfor i in range(q):\n d = input()\n if d == '1':\n judge *= -1\n else:\n a, b, c = list(d.split())\n b = int(b)\n if (b == 1 and judge ==1) or (b == 2 and judge == -1):\n front.append(c)\n else:\n back.append(c)\nans = front + s + back\nif judge == 1:\n print(*ans,sep='')\nelse:\n print(*ans[::-1], sep='')", "s = list(input())\nq = int(input())\njudge = 1\nfront = []\nback = []\nfor i in range(q):\n a = list(map(str,input().split()))\n if int(a[0]) == 1:\n judge *= -1\n else: \n if (int(a[1]) == 1 and judge == 1) or (int(a[1]) == 2 and judge == -1):\n front.append(a[2])\n else:\n back.append(a[2])\nans = front[::-1] + s + back\nif judge == -1:\n ans.reverse()\nprint(*ans, sep='')"]
['Wrong Answer', 'Accepted']
['s584912308', 's363637252']
[14076.0, 14176.0]
[637.0, 812.0]
[387, 385]
p02756
u007627455
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\n\na, b = map(int, input().split())\n# print(a,b)\n# x=-1\n# y=-1\n\nxr=[]\nyr=[]\nfor i in range(101):\n if i*0.08//1==a:\n # print("x:{}".format(i))\n x=i\n xr.append(x)\nfor i in range(101):\n if i *0.1//1==b:\n # print("y:{}".format(i))\n y=i\n yr.append(y)\nflag=False\n\nfor i in xr:\n for j in yr:\n if i==j:\n print(i)\n flag=True\n break\n if flag:\n break\nif not flag:\n print(-1)\n', '# coding: utf-8\n\nS = input()\nQ = int(input())\n# print("S:{}".format(S))\n# print("Q:{}".format(Q))\nquery = []\n\nfor i in range(Q):\n query.append(input().split())\n\n# print(i)\n\n\n# if len(i) == 1:\n# S = S[::-1]\n# else:\n# if i[1]=="1":\n# S = i[2]+S\n# else:\n# S += i[2]\n# print(S)\nleft = True\nfor i in query:\n if len(i) == 1:\n left = not left\n print(left)\n else:\n if i[1]=="1":\n if left:\n S = i[2]+S\n else:\n S += i[2]\n else:\n if left:\n S += i[2]\n else:\n S = i[2]+S\nif left:\n print(S)\nelse:\n print(S[::-1])\n', '# coding: utf-8\n\nS = input()\nQ = int(input())\n\nquery = []\n\nfor i in range(Q):\n query.append(input().split())\n\n\nbool = True\npre =\'\'\nsuf =\'\'\n\nfor i in query:\n if len(i) == 1:\n bool = not(bool)\n\n else:\n if i[1]=="1":\n if bool:\n pre = i[2]+pre\n else:\n suf += i[2]\n else:\n if bool:\n suf += i[2]\n else:\n pre = i[2]+pre\n\nS = pre+ S +suf\nprint(S) if bool else print(S[::-1])\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s109393324', 's223387889', 's565049052']
[3188.0, 42284.0, 40628.0]
[18.0, 2106.0, 1332.0]
[482, 740, 501]
p02756
u015593272
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())\nreverse = 1\n\n\nfor i in range(Q):\n \n q = input()\n \n if (q == 1):\n reverse *= -1\n else:\n integer, judge, cha = q.split()\n \n if (judge == '1'):\n if (reverse == 1):\n S.appendleft(cha)\n else:\n S.append(cha)\n elif (judge == '2'):\n if (reverse == -1):\n S.append(cha)\n else:\n S.appendleft(cha)\n\nif (reverse == -1):\n S.reverse()\n\nprint(''.join(list(S)))", "from collections import deque\n\nS = deque(input())\nQ = int(input())\nreverse = 1\n\n\nfor i in range(Q):\n \n q = input()\n \n if (q == '1'):\n reverse *= -1\n else:\n integer, judge, cha = q.split()\n \n if (judge == '1'):\n if (reverse == 1):\n S.appendleft(cha)\n else:\n S.append(cha)\n \n elif (judge == '2'):\n if (reverse == 1):\n S.append(cha)\n else:\n S.appendleft(cha)\n\nif (reverse == -1):\n S.reverse()\n\nprint(''.join(list(S)))"]
['Runtime Error', 'Accepted']
['s856438947', 's621717493']
[8436.0, 8436.0]
[405.0, 398.0]
[568, 578]
p02756
u017050982
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 = 0\nans = []\nT = []\n\nfor i in range(Q):\n TS = input()\n if TS == "1":\n revcount += 1\n else:\n T.append(TS.rstrip().split(" "))\n T[len()-1][1] = str((int(T[len(T)-1][1]) + revcount % 2 + 1) % 2 + 1)\nif revcount % 2 == 1:\n ans.append(S[::-1])\nelse:\n ans.append(S)\nfor i in range(len(T)):\n if (int(T[iinput()\nQ = int(input())\nrevcount = 0\nans = []\nT = []\n\nfor i in range(Q):\n TS = input()\n if TS == "1":\n revcount += 1\n else:\n T.append(TS.rstrip().split(" "))\n T[len(T)-1][1] = str((int(T[len(T)-1][1]) + revcount % 2 + 1) % 2 + 1)\nif revcount % 2 == 1:\n ans.append(S[::-1])\nelse:\n ans.append(S)\n \nfor i in range(len(T)):\n if (int(T[i][1]) == 1 and revcount % 2 == 0) or (int(T[i][1]) == 2 and revcount % 2 == 1):\n ans.insert(0,T[i][2])\n else:\n ans.append(T[i][2])\nans2 = "".join(ans2 1]) == 1 and revcount % 2 == 0) or (int(T[i][1]) == 2 and revcount % 2 == 1)\n ans.insert(0,T[i][2])\n else:\n ans.append(T[i][2])\nans2 = "".join(ans)\nprint(ans2)\n \n', 'S = list(input())\nmae = []\nato = []\nrev = False\nQ = int(input())\nfor i in range(Q):\n A = list(input().rstrip().split(" "))\n if int(A[0]) == 1:\n if rev:\n rev = False\n else:\n rev = True\n else:\n if (rev and int(A[1]) == 2 or not rev and int(A[1]) == 1):\n mae.append(A[2])\n else:\n ato.append(A[2])\nif rev:\n ato.reverse()\n S.reverse()\n print("".join(ato) + "".join(S) + "".join(mae))\nelse:\n mae.reverse()\n print("".join(mae) + "".join(S) + "".join(ato))']
['Runtime Error', 'Accepted']
['s617063881', 's521621772']
[2940.0, 6432.0]
[17.0, 591.0]
[1029, 544]
p02756
u017415492
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())\nque=[list(map(str,input().split())) for i in range(q)]\ncount=0\nfor i in que:\n if i[0]=="1":\n count+=1\nans=[[],[]]\n \nfor i in que:\n if i[0]=="1":\n count-=1\n else:\n if i[1]=="1":\n ans[count%2].append(i[2])\n else:\n ans[(count+1)%2].append(i[2])\nprint("".join(ans[0])+s+"".join(ans[1]))', 's=input()\nq=int(input())\nque=[]\ncount=0\nleft=[]\nright=[]\nfor i in range(q):\n qu=list(map(str,input().split()))\n if qu[0]=="1":\n count+=1\n que.append(qu)\nhan=0\nfor i in range(q):\n if que[i][0]=="1":\n han+=1\n else:\n if que[i][1]=="1": \n if (count-han)%2==0:\n left.append(que[i][2])\n else:\n right.append(que[i][2])\n elif que[i][1]=="2": \n if (count-han)%2==0:\n left.append(que[i][2])\n else:\n right.append(que[i][2])\nls="".join(left[::-1])\nlr="".join(right)\nprint(ls+s+lr)', 's=input()\nq=int(input())\nque=[list(map(str,input().split())) for i in range(q)]\ncount=0\nfor i in que:\n if i[0]=="1":\n count+=1\nans=[[],[]]\nak=count\nfor i in que:\n if i[0]=="1":\n count-=1\n else:\n if i[1]=="1":\n ans[count%2].append(i[2])\n else:\n ans[(count+1)%2].append(i[2])\nif ak%2==0:\n print("".join(reversed(ans[0]))+s+"".join(ans[1]))\nelse:\n print("".join(reversed(ans[0]))+"".join(reversed(list(s)))+"".join(ans[1]))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s953844961', 's957381233', 's301226248']
[35176.0, 42648.0, 35864.0]
[449.0, 774.0, 454.0]
[335, 535, 447]
p02756
u021916304
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()\nn = int(input())\nquery = [0]*n\nrev = 0\nfor i in range(n):\n query[i] = list(map(str, input().split()))\n if query[i][0] == '1':\n rev = rev + 1\n\nbegin = deque()\nend = deque()\npal = 0\n\nfor i in range(n):\n if int(query[i][0]) == 1:\n pal = (pal+1)%2\n else:\n if pal == 0:\n if int(query[i][1]) == 1:\n begin.appendleft(query[i][2])\n else:\n end.append(query[i][2])\n else:\n if int(query[i][1]) == 1:\n end.append(query[i][2])\n else:\n begin.appendleft(query[i][2])\n# print('--------'+str(i+1)+'th try-----')\n# print(begin)\n# print(end)\n# print('pal:'+str(pal))\nprint(s)\n\nif rev%2 == 1:\n print(''.join(deque(reversed(end)))+s[::-1]+''.join(deque(reversed(begin))))\nelse:\n print(''.join(begin)+s+''.join(end))", "s = input()\nn = int(input())\nquery = [0]*n\nrev = 0\nfor i in range(n):\n query[i] = list(map(str, input().split()))\n if query[i][0] == '1':\n rev = rev + 1\n\nbegin = []\nend = []\npal = 0\n\nfor i in range(n):\n if int(query[i][0]) == 1:\n pal = (pal+1)%2\n else:\n if pal == 0:\n if int(query[i][1]) == 1:\n begin.append(query[i][2])\n else:\n end.append(query[i][2])\n else:\n if int(query[i][1]) == 1:\n end.append(query[i][2])\n else:\n begin.append(query[i][2])\n# print('--------'+str(i+1)+'th try-----')\n# print(begin)\n# print(end)\n# print('pal:'+str(pal))\n#print(s)\n\nif rev%2 == 1:\n print(''.join(end[::-1])+s[::-1]+''.join(begin))\nelse:\n print(''.join(begin[::-1])+s+''.join(end))"]
['Wrong Answer', 'Accepted']
['s230754914', 's249436240']
[43060.0, 42336.0]
[826.0, 811.0]
[899, 829]
p02756
u023762741
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()\n\ninput_line = int(input())\n\nflag0 = ""\nflag1 = ""\nflag = 0\n\n\nfor i in range(input_line):\n action = list(input())\n # print(flag0,flag1)\n # print(action)\n if action[0]=="1":\n if flag == 0:\n flag = 1\n else:\n flag = 0\n else:\n # print("check")\n if action[2] == "2":\n \n if flag == 0:\n flag0 = flag0 + action[4]\n elif flag ==1:\n flag1 = action[4] + flag1\n else:\n if flag == 0:\n flag0 = action[4] + flag0\n \n elif flag == 1:\n flag1 += action[4]\n \nS = flag0 + S + flag1\nif flag == 1:\n S = S[::-1]\nprint(S)', 'S =input()\n\ninput_line = int(input())\n\nflag0 = ""\nflag1 = ""\n\nfor i in range(input_line):\n action = list(input())\n \n flag = 0\n \n\n # print(flag0,flag1)\n # print(action)\n if action[0]=="1":\n if flag == 0:\n flag = 1\n else:\n flag = 0\n else:\n # print("check")\n if action[2] == "2":\n \n if flag == 0:\n flag1 = flag1 + action[4]\n elif flag ==1:\n flag0 = action[4]+flag0\n else:\n if flag == 1:\n flag1 += action[4]\n \n elif flag == 0:\n flag0 = action[4]+flag0\n\nif flag == 1:\n S = S[::-1]\nprint(flag1)\nS = flag1 + S + flag0\n \nprint(S)', 'S =input()\n\ninput_line = int(input())\n\nflag0 = ""\nflag1 = ""\nflag = 0\n\n\nfor i in range(input_line):\n action = list(input())\n # print(flag0,flag1)\n # print(action)\n if action[0]=="1":\n if flag == 0:\n flag = 1\n else:\n flag = 0\n else:\n # print("check")\n if action[2] == "2":\n \n if flag == 0:\n flag1 = flag1 + action[4]\n elif flag ==1:\n flag0 = action[4] + flag0\n else:\n if flag == 0:\n flag0 = action[4] + flag0\n \n elif flag == 1:\n flag1 += action[4]\n \nS = flag0 + S + flag1\nif flag == 1:\n S = S[::-1]\nprint(S)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s061763778', 's969460412', 's480940209']
[4320.0, 4464.0, 4380.0]
[2104.0, 1628.0, 1617.0]
[722, 734, 722]
p02756
u024782094
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
['import sys\ninput = sys.stdin.readline\n\ns=input()\nq=int(input())\nfor i in range(q):\n l=list(map(str,input().split()))\n if l[0]=="1":\n s=s[::-1]\n elif l[1]=="1":\n s=l[2]+s\n else:\n s=s+l[2]\nprint(s)', 's=input()\nq=int(input())\nl = [list(input().split()) for i in range(q)]\nc=0\nfor i in range(q):\n if l[i][0]=="1":\n c+=1\n elif c%2=0 and l[i][1]=="1":\n s=l[i][2]+s\n elif c%2=0:\n s=s+l[i][2]\n elif c%2=1 and l[i][1]=="1":\n s=s+l[i][2]\n else:\n s=l[i][2]+s\nif c%2=1:\n s=s[::-1]\nprint(s)', 'from collections import deque\ns=deque(list(input()))\nq=int(input())\nl = [list(input().split()) for i in range(q)]\nc=0\nfor i in range(q):\n if l[i][0]=="1":\n c+=1\n elif c%2==0 and l[i][1]=="1":\n s.appendleft(l[i][2])\n elif c%2==0:\n s.append(l[i][2])\n elif c%2==1 and l[i][1]=="1":\n s.append(l[i][2])\n else:\n s.appendleft(l[i][2])\ns=list(s)\nif c%2==1:\n s=s[::-1]\nprint(*s, sep="")']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s397611325', 's803124127', 's356252460']
[3756.0, 2940.0, 40036.0]
[2104.0, 17.0, 602.0]
[208, 300, 398]
p02756
u027561659
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())\nfb=True\nforward=""\nback=""\n\nfor i in range(Q):\n query=input()\n if(query=="1"):\n fb=False if(fb) else True\n print("query=1")\n else:\n query, F, C =query.split()\n if((F=="1")==fb):\n forward=C+forward\n else:\n back=back+C\n print("query=2")\nprint((forward+S+back)[::1 if(fb) else -1])', 'S=input()\nQ=int(input())\nfb=True\nforward=""\nback=""\n\nfor i in range(Q):\n query=input()\n if(query=="1"):\n fb=False if(fb) else True\n else:\n query, F, C =query.split()\n if((F=="1")==fb):\n forward=C+forward\n else:\n back=back+C\nprint((forward+S+back)[::1 if(fb) else -1])']
['Wrong Answer', 'Accepted']
['s785885827', 's850802585']
[6124.0, 4404.0]
[2104.0, 1451.0]
[376, 326]
p02756
u029399657
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 = input()\ninp = []\nn = int(input())\nflag = 1\nfor i in range(n):\n j = input().split()\n if len(j) == 3 and j[1] == "1" and flag == 1:\n inp.insert(0,j[2])\n elif len(j) == 3 and j[1] == "2" and flag == 1:\n inp.append(j[2])\n elif len(j) == 3 and j[1] == "2" and flag == -1:\n inp.insert(0,j[2])\n elif len(j) == 3 and j[1] == "1" and flag == -1:\n inp.append(j[2])\n else:\n flag *= -1\nif flag == -1:\n inp = inp[::-1]\ns = ""\nfor j in inp:\n s = s + j\nprint(s)', "s = input()\nif('A' in s and 'B' in s):\n print('Yes')\nelse:\n print('No')", "s=list(input())\nq=int(input())\nc=0\nleft=[]\nright=[]\nfor i in range(q):\n s1=input()\n if s1[0]=='1':\n c+=1\n else:\n if s1[2] == '1':\n if c % 2 == 0:\n left.append(s1[4])\n else:\n right.append(s1[4])\n else:\n if c % 2 == 0:\n right.append(s1[4])\n else:\n left.append(s1[4])\nleft=left[::-1]\nleft.extend(s)\nleft.extend(right)\nif c%2==0:\n print(''.join(left))\nelse:\n left=left[::-1]\n print(''.join(left))\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s069641478', 's429439922', 's021869708']
[4088.0, 3188.0, 9036.0]
[2104.0, 18.0, 335.0]
[514, 77, 536]
p02756
u037098269
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())\n\nflag = 1\nfor i in range(Q):\n qry = input().split()\n\n if qry[0] == '1':\n if flag:\n flag = 0\n else:\n flag = 1\n \n elif qry[0] == '2':\n if flag:\n if qry[1] == '1':\n S.append(qry[2])\n else:\n S.appendleft(qry[2])\n else:\n if qry[1] == '1':\n S.append(qry[2])\n else:\n S.appendleft(qry[2])\n\nif flag:\n print(ans)\nelse:\n print(ans[::-1])", "from collections import deque\n\nS = deque(input())\nQ = int(input())\n\nflag = 1\nfor i in range(Q):\n qry = input().split()\n\n if qry[0] == '1':\n if flag:\n flag = 0\n else:\n flag = 1\n \n elif qry[0] == '2':\n if flag:\n if qry[1] == '1':\n S.appendleft(qry[2])\n else:\n S.append(qry[2])\n else:\n if qry[1] == '1':\n S.append(qry[2])\n else:\n S.appendleft(qry[2])\n\nS = ''.join(S)\n\nif flag:\n print(S)\nelse:\n print(S[::-1])"]
['Runtime Error', 'Accepted']
['s696949619', 's371094451']
[5876.0, 8564.0]
[411.0, 407.0]
[565, 577]
p02756
u038021590
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()\nque = deque()\nque.append(S)\nQ = int(input())\nFront_flag = 1\n\nfor i in range(Q):\n Query = tuple(input().split())\n if len(Query) == 1:\n Front_flag = 1 - Front_flag\n else:\n a, b, c = Query\n if (Front_flag + int(b)) % 2 == 1:\n que.append(c)\n else:\n que.appendleft(c)\nif not Front_flag:\n que.reverse()\n\nfor i in que:\n print(i, end='')", "from collections import deque\nS = input()\nque = deque()\nque.append(S)\nQ = int(input())\nFront_flag = 1\n\nfor i in range(Q):\n Query = tuple(input().split())\n if len(Query) == 1:\n Front_flag = 1 - Front_flag\n else:\n a, b, c = Query\n if (Front_flag + int(b)) % 2 == 1:\n que.append(c)\n else:\n que.appendleft(c)\n\nans = ''.join(que)\nif Front_flag:\n print(ans)\nelse:\n print(ans[::-1])"]
['Wrong Answer', 'Accepted']
['s220233945', 's149646974']
[6768.0, 6900.0]
[765.0, 568.0]
[436, 440]
p02756
u044220565
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().split()\nQ = int(input())\n\ndef pop(left, right, rev, f, c):\n left_ = left\n if rev == 1:\n if f == '1':\n #left_ = [c] + left\n left.append(c)\n else:\n right.append(c)\n else:\n if f == '1':\n right.append(c)\n else:\n #left_ = [c] + left\n left.append(c)\n return left_, right\n\n\nleft, right = [], []\nrev = 1\nfor _ in range(Q):\n que = input().split()\n if que[0] == '1':\n rev *= -1\n continue\n if que[0] == '2':\n left, right = pop(left, right, rev, *que[1:])\nprint(''.join(left+S+right)[::rev])", "# coding: utf-8\nS = input().split()\nQ = int(input())\n\ndef pop(left, right, rev, f, c):\n if rev == 1:\n if f == '1':\n left.append(c)\n else:\n right.append(c)\n else:\n if f == '1':\n right.append(c)\n else:\n left.append(c)\n return left, right\n\n\nleft, right = [], []\nrev = 1\nfor _ in range(Q):\n que = input().split()\n if que[0] == '1':\n rev *= -1\n continue\n if que[0] == '2':\n left, right = pop(left, right, rev, *que[1:])\nprint(''.join(left[::-1]+S+right)[::rev])"]
['Wrong Answer', 'Accepted']
['s676238057', 's941915681']
[7680.0, 7656.0]
[528.0, 532.0]
[643, 567]
p02756
u044964932
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\n\ndef main():\n s = deque([list(input())])\n q = int(input())\n rev = False\n for _ in range(q):\n query = input().split()\n if query[0] == "1":\n if not rev:\n rev = True\n else:\n rev = False\n else:\n if query[1] == \'1\':\n pass\n if rev:\n s.append(query[2])\n else:\n s.appendleft(query[2])\n else:\n if rev:\n s.appendleft(query[2])\n else:\n s.append(query[2])\n if rev:\n s.reverse()\n print(*s, sep="")\n\n\nif __name__ == "__main__":\n main()\n', 'from collections import deque\n\n\ndef main():\n s = deque(list(input()))\n q = int(input())\n rev = False\n for _ in range(q):\n query = input().split()\n if query[0] == "1":\n if not rev:\n rev = True\n else:\n rev = False\n else:\n if query[1] == \'1\':\n pass\n if rev:\n s.append(query[2])\n else:\n s.appendleft(query[2])\n else:\n if rev:\n s.appendleft(query[2])\n else:\n s.append(query[2])\n if rev:\n s.reverse()\n print(*s, sep="")\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s173204638', 's476105062']
[11808.0, 12256.0]
[434.0, 454.0]
[727, 725]
p02756
u045408189
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
["s=list(input())\nq=int(input())\nfor i in range(q):\n query=input().split()\n print(query)\n if query==['1']:\n s.reverse()\n else:\n if query[1]=='1':\n s.insert(0,query[2])\n else:\n s.append(query[2])\nprint(''.join(s))\n", "s=list(input())\nq=int(input())\nans=0\nmae=[]\nato=[]\nfor i in range(q):\n query=input().split()\n if query==['1']:\n ans+=1\n else:\n if query[1]=='1' and ans%2==0:\n mae.append(query[2])\n elif query[1]=='1' and ans%2==1:\n ato.append(query[2])\n elif query[1]=='2' and ans%2==0:\n ato.append(query[2])\n else:\n mae.append(query[2])\nif ans%2==1:\n s.reverse()\n ato.reverse()\n s=ato+s+mae\nelse:\n mae.reverse()\n s=mae+s+ato\nprint(''.join(s))\n"]
['Wrong Answer', 'Accepted']
['s133610005', 's679993211']
[4900.0, 9892.0]
[2104.0, 429.0]
[266, 530]
p02756
u046592970
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())\nr = 0\nz = 0\nto = 0\nfor i in range(q):\n \n try:\n t,f,c = input().split()\n if (r + int(f)) % 2 == 1:\n s.appendleft(c)\n \n else:\n s.append(c)\n r = 0\n z = 1\n except:\n if z == 0:\n pass\n else:\n r += 1\n z = 1\n to += 1\n print(s)\nif to % 2 == 1:\n s = reversed(s)\nprint("".join(s))', 'from collections import deque\ns = deque(input())\nq = int(input())\nlis = [list(input().split()) for _ in range(q)]\nrev = 0\nz = 0\n\nfor i in lis:\n if i[0] == "2":\n if (rev + int(i[1])) % 2 == 1:\n s.appendleft(i[2])\n else:\n s.append(i[2])\n z = 1\n else:\n if z == 1:\n rev += 1\n \nif rev % 2 == 1:\n s = reversed(s)\nprint("".join(s))\n ']
['Runtime Error', 'Accepted']
['s586608180', 's369190190']
[137116.0, 35444.0]
[1844.0, 544.0]
[460, 406]
p02756
u047197186
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\nllst = []\nrlst = []\nfor i in range(q):\n line = input()\n if line == '1':\n cnt += 1\n else:\n elems = line.split()\n if cnt % 2 == 0:\n \n if elems[1] == '1':\n llst.append(elems[2])\n else:\n rlst.append(elems[2])\n else:\n \n if elems[1] == '1':\n rlst.append(elems[2])\n else:\n llst = [elems[2]] + llst\n \nif cnt % 2 == 0:\n res = ''.join(llst[::-1]) + s + ''.join(rlst)\n print(res)\nelse:\n res = ''.join(llst[::-1]) + s + ''.join(rlst)\n print(res[::-1])", "s = input()\nq = int(input())\n\ncnt = 0\nllst = []\nrlst = []\nfor i in range(q):\n line = input()\n if line == '1':\n cnt += 1\n else:\n elems = line.split()\n if cnt % 2 == 0:\n \n if elems[1] == '1':\n llst.append(elems[2])\n else:\n rlst.append(elems[2])\n else:\n \n if elems[1] == '1':\n rlst.append(elems[2])\n else:\n llst.append(elems[2])\n \nif cnt % 2 == 0:\n res = ''.join(llst[::-1]) + s + ''.join(rlst)\n print(res)\nelse:\n res = ''.join(llst[::-1]) + s + ''.join(rlst)\n print(res[::-1])"]
['Wrong Answer', 'Accepted']
['s227303943', 's879257411']
[6252.0, 6384.0]
[2104.0, 404.0]
[613, 610]
p02756
u050087249
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())\nnum = int(input())\nfor i in range(num):\n a = deque(input().split())\n start = int(a[0])\n if start == 2:\n ns = int(a[1])\n if ns == 1:\n s.appendleft(a[2])\n #s = a[2] + s\n else:\n \n s.append(a[2])\n else:\n s.reverse()\nfor i in range(len(s)):\n print(s[i], end='')", "from collections import deque\ns = deque(input())\nnum = int(input())\nfor i in range(num):\n a = deque(input().split())\n start = int(a[0])\n if start == 2:\n ns = int(a[1])\n if ns == 1:\n s.appendleft(a[2])\n #s = a[2] + s\n else:\n \n s.append(a[2])\n else:\n s = s[::-1]\nfor i in range(len(s)):\n print(s[i], end='')", 'from collections import deque\ns = deque(input())\nnum = int(input())\ncnt = 0\nfor i in range(num):\n a = input().split()\n\n if a[0] == \'2\':\n if (int(a[1])+cnt)%2==1:\n s.appendleft(a[2])\n else:\n s.append(a[2])\n else:\n cnt += 1\nif cnt%2 == 1: \n\ts.reverse()\nprint("".join(s))\n ']
['Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s393621678', 's667269138', 's735830614']
[7408.0, 7408.0, 8428.0]
[2108.0, 2104.0, 517.0]
[355, 355, 296]
p02756
u052221988
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())\nflag = 0b0\nfor i in range(q) :\n t = input()\n if t == 1 :\n flag ^= 1\n continue\n if (int(t[2]) - flag) == 1 :\n s = t[4] + s\n else :\n s = s + t[4]\nif flag == 0 :\n print(s)\nelse :\n print(s[::-1])', 'right = input()\nflag = 1\nleft = ""\nfor i in range(int(input())):\n t = input()\n if t == "1":\n flag ^= 1\n continue\n t, f, c = t.split(" ")\n if not ((f=="1")^flag):\n left += c\n else:\n right += c\nans = left[::-1] + right\nif not flag:\n ans = ans[::-1]\nprint(ans)']
['Runtime Error', 'Accepted']
['s101682912', 's464075021']
[3888.0, 4480.0]
[2104.0, 495.0]
[266, 303]
p02756
u054556734
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
['import numpy as np\nimport scipy.sparse as sps\nimport scipy.misc as spm\nimport collections as col\nimport functools as func\nimport itertools as ite\nimport fractions as frac\nimport math as ma\nimport cmath as cma\nimport copy as cp\nimport sys\ndef sinput(): return sys.stdin.readline().strip()\ndef iinput(): return int(sinput())\ndef imap(): return map(int, sinput().split())\ndef fmap(): return map(float, sinput().split())\ndef iarr(n=0):\n if n: return [0 for _ in range(n)]\n else: return list(imap())\ndef farr(): return list(fmap())\ndef sarr(n=0):\n if n: return ["" for _ in range(n)]\n else: return sinput().split()\ndef barr(n): return [False for _ in range(n)]\nsys.setrecursionlimit(10**7)\nMOD = 10**9 + 7; EPS = sys.float_info.epsilon\nPI = np.pi; EXP = np.e; INF = np.inf\n\ns = sinput()\nq = iinput()\ncnt = 0\nfor i in range(q):\n try: t,f,c = sarr()\n except: cnt += 1; cnt %= 2; continue\n print("====", t,f,c)\n if cnt:\n if f == 1: s = s + c\n if f == 2: s = c + s\n else:\n if f == 1: s = c + s\n if f == 2: s = s + c\n print(s)\n\ns = s[::-1] if cnt else s\nprint(s)\n', 'import numpy as np\nimport scipy.sparse as sps\nimport scipy.misc as spm\nimport collections as col\nimport functools as func\nimport itertools as ite\nimport fractions as frac\nimport math as ma\nimport cmath as cma\nimport copy as cp\nimport sys\ndef sinput(): return sys.stdin.readline().strip()\ndef iinput(): return int(sinput())\ndef imap(): return map(int, sinput().split())\ndef fmap(): return map(float, sinput().split())\ndef iarr(n=0):\n if n: return [0 for _ in range(n)]\n else: return list(imap())\ndef farr(): return list(fmap())\ndef sarr(n=0):\n if n: return ["" for _ in range(n)]\n else: return sinput().split()\ndef barr(n): return [False for _ in range(n)]\nsys.setrecursionlimit(10**7)\nMOD = 10**9 + 7; EPS = sys.float_info.epsilon\nPI = np.pi; EXP = np.e; INF = np.inf\n\ns = col.deque(sinput().split())\nq = iinput()\ncnt = 0\nfor i in range(q):\n try: t,f,c = sarr()\n except: cnt += 1; cnt %= 2; continue\n if cnt: \n if f == "1": s.append(c)\n if f == "2": s.appendleft(c)\n else: \n if f == "1": s.appendleft(c)\n if f == "2": s.append(c)\n #print(s)\n\ns = "".join(s)\ns = s[::-1] if cnt else s\nprint(s)\n\n']
['Runtime Error', 'Accepted']
['s801498595', 's280726942']
[146196.0, 28972.0]
[302.0, 501.0]
[1111, 1183]
p02756
u056830573
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\nQ = []\nfor i in range(q):\n Q.append(input())\n\n\nprint(s)\nfor operation in Q:\n if (operation[0] == '1'):\n s = s[::-1]\n else:\n if (operation[2] == '1'):\n\n s = operation[4] + s\n else:\n s += operation[4]\n\n\nprint(s)\n", 's = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft= right = ""\nfor operation in qs:\n if operation[0] == \'1\':\n n = not n\n if operation[0] == \'2\':\n t , f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left=c+left\n elif f == 2:\n right+=c\ns = left+s+right\nprint(s[::-1] if n else s)']
['Wrong Answer', 'Accepted']
['s268463659', 's674604130']
[16620.0, 40640.0]
[2104.0, 1372.0]
[292, 417]
p02756
u060793972
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())\nr = False\nfor i in range(q):\n t=list(input().split())\n if len(t) == 1:\n r = not(r)\n else:\n if t[1] == '1' and r = False\n s = t[2] + s\n elif t[1] == '2' and r = True:\n s = t[2] + s\n else:\n s = s + t[2]\nprint(s)", "s = input()\nq = int(input())\nr = False\nf = ''\nb = '' #behind\nfor i in range(q):\n t=list(input().split())\n if len(t) == 1:\n r = not(r)\n else:\n if (t[1] == '1' and r == False):\n f += t[2]\n elif (t[1] == '2' and r == True):\n f += t[2]\n else:\n b += t[2]\ns = f[::-1] + s + b\nif r:\n print(s[::-1])\nelse:\n print(s)"]
['Runtime Error', 'Accepted']
['s398395677', 's858596593']
[2940.0, 4596.0]
[18.0, 513.0]
[333, 468]
p02756
u062655521
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())\nis_r = False\nf_list = []\nb_list = []\n\nfor i in range(q):\n q_i = input().split(' ')\n t_i = q_i[0]\n if t_i == '1':\n is_r = not is_r\n else:\n f_i = q_i[1]\n if (f_i == '1' and not is_r) or (f_i == '2' and is_r):\n f_list.append(q_i[2])\n else:\n b_list.append(q_i[2])\n\nf_list = f_list[::-1]\nf_list.append(s)\nf_list.extend(b_list)\ns = f_list.join('') if not is_r else f_list[::-1].join('')\nprint(s)", "s = input()\nq = int(input())\nis_r = False\nf_list = []\nb_list = []\n\nfor i in range(q):\n q_i = input().split(' ')\n t_i = q_i[0]\n if t_i == '1':\n is_r = not is_r\n else:\n f_i = q_i[1]\n if (f_i == '1' and not is_r) or (f_i == '2' and is_r):\n f_list.append(q_i[2])\n else:\n b_list.append(q_i[2])\n\nf_list = f_list[::-1]\nf_list.append(s)\nf_list.extend(b_list)\ns = ''.join(f_list) if not is_r else ''.join(f_list)[::-1]\nprint(s)"]
['Runtime Error', 'Accepted']
['s773818161', 's613143531']
[6756.0, 6144.0]
[417.0, 418.0]
[480, 480]
p02756
u063896676
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\n\nS = input()\nQ = int(input())\n\n\nrev = False\nfor _ in range(Q):\n line = input()\n\n if line[0] == "1":\n rev = not rev\n\n else:\n if line[2] == "1":\n if rev:\n S = "".join(S, line[4])\n else:\n S = "".join(line[4], S)\n else:\n if rev:\n S = "".join(line[4], S)\n else:\n S = "".join(S, line[4])\n\nif rev:\n print(S[::-1])\nelse:\n print(S)\n', '# coding: utf-8\n\nS = input()\nQ = int(input())\n\n\nheads = {}\ntails = {}\nh = 0\nt = 0\nrev = False\nfor _ in range(Q):\n line = input()\n\n if line[0] == "1":\n rev = not rev\n\n else:\n if line[2] == "1":\n if rev:\n # S = "".join([S, line[4]])\n tails[t] = line[4]\n t += 1\n else:\n # S = "".join([line[4], S])\n heads[h] = line[4]\n h += 1\n else:\n if rev:\n # S = "".join([line[4], S])\n heads[h] = line[4]\n h += 1\n else:\n # S = "".join([S, line[4]])\n tails[t] = line[4]\n t += 1\n\nhead = [None] * h\ntail = [None] * t\n\nfor i in range(h):\n head[i] = heads[i]\nhead = head[::-1]\n\nfor i in range(t):\n tail[i] = tails[i]\n\nhead_joint = "".join(head)\ntail_joint = "".join(tail)\njoint = "".join([head_joint, S, tail_joint])\n\nif rev:\n print(joint[::-1])\nelse:\n print(joint)\n']
['Runtime Error', 'Accepted']
['s349391465', 's941940637']
[3188.0, 24336.0]
[18.0, 391.0]
[479, 1010]
p02756
u064434060
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=1\nt = [input().split() for l in range(q)]\nfor i in range(q):\n if t[i][0]=='1':\n flag=flag*(-1)\n else:\n if t[i][1]=='1' and flag==1:\n s=t[i][2]+s\n elif t[i][1]=='1' and flag==-1:\n s=s+t[i][2]\n elif t[i][1]=='2' and flag==1:\n s=s+t[i][2]\n elif t[i][1]=='2' and flag==-1:\n s=t[i][2]+s\nif flag==-1:\n new_s = ''.join(list(reversed(s)))\nprint(new_s)", 'from collections import deque\n\nd=deque()\ns=input()\nfor i in s:\n d.append(i)\nq=int(input())\nflag=1\nt = [input().split() for l in range(q)]\nfor i in range(q):\n if t[i][0]==\'1\':\n flag=flag*(-1)\n else:\n if t[i][1]==\'1\' and flag==1:\n d.appendleft(t[i][2])\n elif t[i][1]==\'1\' and flag==-1:\n d.append(t[i][2])\n elif t[i][1]==\'2\' and flag==1:\n d.append(t[i][2])\n elif t[i][1]==\'2\' and flag==-1:\n d.appendleft(t[i][2])\nif flag==-1:\n d.reverse()\nd="".join(list(d))\nprint(d)\n']
['Runtime Error', 'Accepted']
['s883881198', 's515993319']
[42216.0, 44660.0]
[2106.0, 466.0]
[464, 503]
p02756
u066855390
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 l = input().split()\n if len(l) == 1:\n s[0], s[-1] = s[-1], s[0]\n else:\n pos = int(l[1])\n c = l[2]\n if pos == 1:\n s.insert(1, c)\n else:\n s.append(c)\nprint("".join(s))\n', 'from collections import deque\n\ns = list(input())\nd = deque(s)\nforward = True\nq = int(input())\nfor i in range(q):\n l = input().split()\n if len(l) == 1:\n forward = not forward\n else:\n pos = int(l[1])\n c = l[2]\n if pos == 1:\n if forward:\n d.appendleft(c)\n else:\n d.append(c)\n else:\n if forward:\n d.append(c)\n else:\n d.appendleft(c)\nprint("".join(s))\n', 'from collections import deque\n\ns = list(input())\nd = deque(s)\nforward = True\nq = int(input())\nfor i in range(q):\n l = input().split()\n if len(l) == 1:\n forward = not forward\n else:\n pos = int(l[1])\n c = l[2]\n if pos == 1:\n if forward:\n d.appendleft(c)\n else:\n d.append(c)\n else:\n if forward:\n d.append(c)\n else:\n d.appendleft(c)\n\nif forward == False:\n d.reverse()\n\nprint("".join(d))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s186615374', 's693258732', 's998282712']
[4260.0, 6900.0, 9460.0]
[2104.0, 509.0, 521.0]
[287, 495, 534]
p02756
u068727970
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())\nQUE = []\nstart_index = None\nend_index = None\nfor i in range(Q):\n query = input()\n if query == "1" and start_index == None:\n start_index = i\n elif query == "1":\n end_index = i\n else:\n if start_index == None:\n QUE.append(query)\n else:\n if end_index == None:\n QUE.append("1")\n else:\n for _ in range(end_index - start_index + 1):\n QUE.append("1")\n QUE.append(query)\n start_index = None\n end_index = None\n\nfor query in QUE:\n if query == "1":\n S = S[::-1]\n else:\n query = list(query)\n F = query[2]\n C = query[4]\n if F == "1":\n \n S = C + S\n else:\n \n S = S + C\n\nprint(S)\n', 'S = list(input())\nQ = int(input())\nfront = []\nback = []\nifZyun = True\n\nfor _ in range(Q):\n query = input()\n if query == "1":\n ifZyun = not ifZyun\n else:\n query = list(query)\n F = query[2]\n C = query[4]\n if (F == "1" and ifZyun) or (F == "2" and not ifZyun):\n front.append(C)\n else:\n back.append(C)\n\nif not ifZyun:\n S = S[::-1]\n print("".join(back[::-1] + S + front))\nelse:\n front = front[::-1]\n print("".join(front + S + back))\n']
['Wrong Answer', 'Accepted']
['s912217779', 's996248952']
[16512.0, 9984.0]
[2104.0, 466.0]
[873, 513]
p02756
u075595666
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())\nc = []\nfor i in range(q):\n que = input().split()\n c_append = c.append\n c_append(que)\n \nfor i in c:\n if i[0] == '1':\n s = s[::-1]\n else:\n if i[1] == '1':\n s = i[2] + s\n else:\n s = s + i[2]\nprint(s)", "def main():\n import sys\n input = sys.stdin.readline\n from collections import deque\n s = list(input())\n s = s[:-1]\n s = deque(s)\n q = int(input())\n c = [[i for i in input().split()] for j in range(q)]\n cnt = 1\n for i in c:\n if i[0] == '1':\n cnt *= -1\n else:\n if (i[1] == '1' and cnt == 1) or (i[1] == '2' and cnt == -1):\n s.appendleft(i[2])\n else:\n s.append(i[2])\n if cnt == 1:\n print(''.join(s))\n else:\n print(''.join(s)[::-1])\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s466290828', 's921977436']
[41680.0, 32088.0]
[2106.0, 246.0]
[288, 518]
p02756
u080364835
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())\ns0 = []\ns1 = []\nfor _ in range(q):\n ql = list(input().split())\n if ql[0] == '1':\n s0[-1:], s1[-1:] = s1[-1:], s0[-1:]\n else:\n if ql[1] == '1':\n s0 += ql[2]\n else:\n s1 += ql[2]\n\nans = s0 + s + s1\nprint(*ans, sep='')", "s = input()\nq = int(input())\nhead = ''\ntail = ''\nrev = 0\n\nfor _ in range(q):\n T = list(input().split())\n if T[0] == '1':\n head, tail = tail, head\n rev += 1\n else:\n if T[1] == '1':\n head += T[2]\n else:\n tail += T[2]\n\nif rev%2 == 0:\n print(head[::-1]+s+tail)\nelse:\n print(head[::-1]+s[::-1]+tail)\n"]
['Wrong Answer', 'Accepted']
['s321446082', 's880487471']
[15980.0, 10048.0]
[625.0, 340.0]
[301, 360]
p02756
u086438369
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())\nexchange = 0\n\nfor _ in range(q):\n query = input()\n if query == '1':\n excnange += 1\n else:\n t, f, c = query.split()\n if f == '1':\n s = c + s\n else:\n s = s + c\n \nif exchange % 2 == 0:\n print(s)\nelse:\n print(s[::-1])\n", "import sys\ninput = sys.stdin.readline\n\ns = input().strip()\nq = int(input())\nquery = [list(input().strip().split()) for _ in range(q)]\n\nleft = ''\nright = ''\nt = False\nfor ls in query:\n if len(ls) == 1:\n t = not t\n else:\n two, f, c = ls\n if f == '1':\n if t:\n right += c\n else:\n left += c\n else:\n if t:\n left += c\n else:\n right += c\n\nif t:\n print(right[::-1] + s[::-1] + left)\nelse:\n print(left[::-1] + s + right)\n "]
['Runtime Error', 'Accepted']
['s401078039', 's047705558']
[3740.0, 30964.0]
[2104.0, 276.0]
[275, 559]
p02756
u086503932
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())\nQ = [input().split() for _ in range(N)]\nstart = ''\nend = ''\n\n\ndirect = 0\nfor i in range(N):\n if Q[i][0] =='1':\n direct^=1\n else:\n if direct == int(Q[i][1])-1:\n start += Q[i][2]\n print('start',start)\n else:\n end += Q[i][2]\n print('end',end)\n \nans = start[::-1]+S+end\nprint(ans) if direct == 0 else print(ans[::-1])", "S = input()\nN = int(input())\nQ = [input().split() for _ in range(N)]\nstart = ''\nend = ''\n\n\ndirect = 0\nfor i in range(N):\n if Q[i][0] =='1':\n direct^=1\n else:\n if direct == int(Q[i][1])-1:\n start += Q[i][2]\n else:\n end += Q[i][2]\n \nans = start[::-1]+S+end\nprint(ans) if direct == 0 else print(ans[::-1])"]
['Runtime Error', 'Accepted']
['s837000440', 's036714660']
[170356.0, 40692.0]
[588.0, 491.0]
[424, 374]
p02756
u088552457
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 w = input()\n s = collections.deque(w)\n n = int(input())\n \n reverse_count = 0\n for i in range(n):\n t = list(input_list_str())\n if len(t) == 1:\n reverse_count = 1 - reverse_count\n continue\n q, f, c = t\n if int(f) == 1:\n s.append(c)\n else:\n s.appendleft(c)\n if reverse_count == 1:\n s.reverse()\n print(''.join(s))\n exit()\n a = pre_s + s + after_s\n if reverse_count % 2 != 0:\n a = a[::-1]\n print(a)\n \ndef input_list():\n return map(int, input().split())\n\ndef input_list_str():\n return map(str, input().split())\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(fractions.gcd, numbers)\n\nimport math\nimport fractions\nimport collections\nfrom functools import reduce\nmain()", "def main():\n w = input()\n s = collections.deque(w)\n n = int(input())\n \n order = True\n for _ in range(n):\n q = list(input_list_str())\n if len(q) == 1:\n order = False if order else True\n continue\n t, f, c = q\n if int(f) == 1:\n if order:\n s.appendleft(c)\n else:\n s.append(c)\n else:\n if order:\n s.append(c)\n else:\n s.appendleft(c)\n if order is False:\n s.reverse()\n print(''.join(s))\n\n \ndef input_list():\n return map(int, input().split())\n\ndef input_list_str():\n return map(str, input().split())\n\ndef lcm_base(x, y):\n return (x * y) // fractions.gcd(x, y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base, numbers, 1)\n\ndef gcd(*numbers):\n return reduce(fractions.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(fractions.gcd, numbers)\n\nimport math\nimport fractions\nimport collections\nfrom functools import reduce\nmain()"]
['Wrong Answer', 'Accepted']
['s852983992', 's198218937']
[10452.0, 10556.0]
[687.0, 700.0]
[915, 919]
p02756
u089925107
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())\nflip = 0\nfor i in range(Q):\n j = input()\n if len(j) == 1:\n flip += 1\n continue\n else:\n if flip % 2 == 0:\n if j[2] == '1':\n S = j[4] + S\n continue\n elif j[2] == '2':\n S = S + j[4]\n continue\n elif flip % 2 == '1':\n if j[2] == 1:\n S = S + j[4]\n continue\n elif j[2] == '2':\n S = j[4] + S\n continue\nif flip % 2 == 1:\n S = S[::-1]\nprint(S)", "S = str(input())\nQ = int(input())\nflip = 0\nfront,back = '',''\nfor i in range(Q):\n j = input()\n if len(j) == 1:\n flip += 1\n continue\n else:\n if j[2] == '1' and flip % 2 == 0:\n front = j[4] + front\n continue\n elif j[2] == '2' and flip % 2 == 0:\n back = back + j[4]\n continue\n elif j[2] == '1' and flip % 2 ==1:\n back= back + j[4]\n continue\n elif j[2] == '2' and flip % 2 ==1:\n front = j[4] + front\n continue\nS = front + S + back\nif flip % 2 == 1:\n S = S[::-1]\nprint(S)"]
['Wrong Answer', 'Accepted']
['s294284972', 's430877077']
[9696.0, 9936.0]
[2205.0, 870.0]
[459, 528]
p02756
u091051505
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())\nback = 1\nfor i in range(q):\n query = input().split()\n if query[0] == '1':\n back *= -1\n else:\n if query[1] == '1':\n if back == 1:\n s = query[2] + s\n else:\n s = s + (query[2]\n else:\n if back == 1:\n s = s + query[2]\n else:\n s = query[2] + s\nif back == -1:\n s = s[-1::-1]\nprint(s)", "import collections\ns = input()\nq = int(input())\nback = 1\nt = collections.deque()\nfor ss in s:\n t.append(ss)\nfor i in range(q):\n query = input().split()\n if query[0] == '1':\n back *= -1\n else:\n if query[1] == '1':\n if back == 1:\n t.appendleft(query[2])\n else:\n t.append(query[2])\n else:\n if back == 1:\n t.append(query[2])\n else:\n t.appendleft(query[2])\nans = ''\nif back == -1:\n for i in range(len(t)):\n ans += t.pop()\nelse:\n for i in range(len(t)):\n ans += t.popleft()\nprint(ans)"]
['Runtime Error', 'Accepted']
['s778718050', 's881009535']
[2940.0, 6636.0]
[17.0, 445.0]
[442, 635]
p02756
u092387689
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
["s = input()\nq = int(input())\n\nquery = [[x for x in input().split()] for i in range(q)]\n\nT2query = []\ncnt=0\nfor i in range(q-1,-1,-1):\n if(query[i][0]=='1'):\n cnt+=1\n continue\n if(cnt%2!=0):\n if(query[i][1]=='1'):\n query[i][1]='2'\n else:\n query[i][1]='1' \n T2query.append(query[i])\nprint(cnt)\nif(cnt%2!=0):\n s = s[::-1]\n\n\nfor _,i,word in reversed(T2query):\n \n if(i=='1'):\n s = word + s\n else:\n s = s + word\n\nprint(s)", "s = input()\nq = int(input())\n\nquery = [[x for x in input().split()] for i in range(q)]\n\nT2query = []\nbegin = []\nend = []\ncnt=0\nfor i in range(q-1,-1,-1):\n if(query[i][0]=='1'):\n cnt+=1\n continue\n if(cnt%2==1):\n if(query[i][1]=='1'):\n end.append(query[i][2])\n else:\n begin.append(query[i][2])\n else:\n if(query[i][1]=='1'):\n begin.append(query[i][2])\n else:\n end.append(query[i][2])\nwb = ''.join(begin)\nwe = ''.join(end)\nwe = we[::-1] \n\nif(cnt%2!=0):\n s = s[::-1]\n\ns = wb + s + we\n\nprint(s)"]
['Wrong Answer', 'Accepted']
['s240022374', 's372884927']
[30096.0, 29448.0]
[2105.0, 533.0]
[501, 586]
p02756
u092646083
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\nfor i in range(Q):\n Query = list(input().split())\n if Query[0] == "1":\n reverse = (reverse + 1) % 2\n if Query[0] == "2":\n f = int(Query[1])\n c = query[2]\n if (f + reverse) % 2 == 1:\n S = c + S\n else:\n S = S + c\n\nif reverse == 0:\n print(S)\nelse:\n print(S[::-1])', 'from collections import deque\nS = deque(input())\nQ = int(input())\nreverse = 0\nfor i in range(Q):\n Query = list(input().split())\n if Query[0] == "1":\n reverse = (reverse + 1) % 2\n if Query[0] == "2":\n f = int(Query[1])\n c = Query[2]\n if (f + reverse) % 2 == 1:\n S.appendleft(c)\n else:\n S.append(c)\n\nS = "".join(list(S))\n \nif reverse == 0:\n print(S)\nelse:\n print(S[::-1])']
['Runtime Error', 'Accepted']
['s688136653', 's154258223']
[3188.0, 8692.0]
[17.0, 638.0]
[331, 399]
p02756
u094999522
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
['#!/usr/bin/env python3\ns = input()\nQ = int(input())\nq = [input().split() for _ in range(Q)]\nreverse = 0\nstart = ""\nend = ""\nfor i in q:\n if i[0] == "1":\n reverse ^= 1\n else:\n if int(i[1]) + reverse >> 0 ^ 0:\n end += i[2]\n else:\n start += i[2]\nprint(start[::-1] + s[::1 - reverse * 2] + end)\n', '#!/usr/bin/env python3\ns = input()\nQ = int(input())\nq = [input().split() for _ in range(Q)]\nreverse = 0\nstart = ""\nend = ""\nfor i in q:\n if i[0] == "1":\n reverse ^= 1\n else:\n if int(i[1]) + reverse >> 0 ^ 0:\n end += i[2]\n else:\n start += i[2]\ns = start[::-1] + s + end\nprint(s[::1 - reverse * 2])\n', '#!/usr/bin/env python3\ns = input()\nQ = int(input())\nq = [input().split() for _ in range(Q)]\nreverse = 0\nstart = ""\nend = ""\nfor i in q:\n if i[0] == "1":\n reverse ^= 1\n else:\n if (int(i[1]) + reverse) % 2:\n start += i[2]\n else:\n end += i[2]\ns = start[::-1] + s + end\nprint(s[::1 - reverse * 2])\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s218059701', 's864463220', 's687358542']
[43092.0, 43228.0, 43420.0]
[380.0, 372.0, 382.0]
[340, 346, 343]
p02756
u096983897
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())\nis_reversed = False\nappend_first = []\nmy_first = append_first.append\nappend_end = []\nmy_end = append_end.append\n\nfor i in range(Q):\n q = list(input())\n if q[0] == '1':\n is_reversed = True if is_reversed == False else False\n else:\n if q[2] == '1' and is_reversed:\n append_end.append(q[4])\n elif q[2] == '1': \n append_first.append(q[4])\n elif is_reversed:\n append_first.append(q[4]) \n else:\n append_end.append(q[4])\n \nappend_first.extend(S) \nappend_first.extend(append_end)\n\nif is_reversed:\n append_first.reverse()\nprint(''.join(append_first))", "S = list(input())\nQ = int(input())\nis_reversed = False\nappend_first = []\nmy_first = append_first.append\nappend_end = []\nmy_end = append_end.append\n\nfor i in range(Q):\n q = list(input())\n if q[0] == '1':\n is_reversed = True if is_reversed == False else False\n else:\n if q[2] == '1' and is_reversed:\n append_end.append(q[4])\n elif q[2] == '1': \n append_first.append(q[4])\n elif is_reversed:\n append_first.append(q[4]) \n else:\n append_end.append(q[4])\n \nappend_first.reverse()\nappend_first.extend(S) \nappend_first.extend(append_end)\n\nif is_reversed:\n append_first.reverse()\nprint(''.join(append_first))"]
['Wrong Answer', 'Accepted']
['s819092352', 's814813838']
[7696.0, 7696.0]
[471.0, 482.0]
[622, 645]
p02756
u103198430
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 random\nimport sys\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict, deque\nfrom functools import lru_cache, reduce\nfrom heapq import heapify, heappop, heappush\nfrom itertools import (chain, combinations, combinations_with_replacement,\n permutations)\n\nMAX_INT = 2**62-1\nsys.setrecursionlimit(10**7)\n\ninput = sys.stdin.readline\n\n\ndef read_n_int():\n return map(int, input().split())\n\n\ndef main():\n s = input()\n q = int(input())\n queue = deque(s)\n is_reversed = 0\n\n for _ in range(q):\n t, *x = input().split()\n if t == \'1\':\n is_reversed ^= 1\n else:\n where, c = x\n where = int(where)\n if where ^ is_reversed:\n queue.appendleft(c)\n else:\n queue.append(c)\n if is_reversed:\n queue.reverse()\n print(\'\'.join(queue))\n\n\nif __name__ == "__main__":\n main()\n', 'import math\nimport random\nimport sys\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict, deque\nfrom functools import lru_cache, reduce\nfrom heapq import heapify, heappop, heappush\nfrom itertools import (chain, combinations, combinations_with_replacement,\n permutations)\n\nMAX_INT = 2**62-1\nsys.setrecursionlimit(10**7)\n\ninput = sys.stdin.readline\n\n\ndef read_n_int():\n return map(int, input().split())\n\n\ndef main():\n s = input()\n q = int(input())\n queue = deque(s)\n is_reversed = 0\n\n for _ in range(q):\n t, *x = input().split()\n if t == \'1\':\n is_reversed ^= 1\n else:\n where, c = x\n where = int(where) & 1\n if where ^ is_reversed:\n queue.appendleft(c)\n else:\n queue.append(c)\n if is_reversed:\n queue.reverse()\n print(\'\'.join(queue))\n\n\nif __name__ == "__main__":\n main()\n', 'import math\nimport random\nimport sys\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict, deque\nfrom functools import lru_cache, reduce\nfrom heapq import heapify, heappop, heappush\nfrom itertools import (chain, combinations, combinations_with_replacement,\n permutations)\n\nMAX_INT = 2**62-1\nsys.setrecursionlimit(10**7)\n\ninput = sys.stdin.readline\n\n\ndef read_n_int():\n return map(int, input().split())\n\n\ndef main():\n s = input().strip()\n q = int(input())\n queue = deque(s)\n is_reversed = 0\n\n for _ in range(q):\n t, *x = input().strip().split()\n \n if t == \'1\':\n is_reversed ^= 1\n else:\n where, c = x\n where = int(where) & 1\n if where ^ is_reversed:\n queue.appendleft(c)\n else:\n queue.append(c)\n if is_reversed:\n queue.reverse()\n\n print(\'\'.join(queue))\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s445950825', 's941533051', 's388730758']
[9332.0, 9204.0, 9204.0]
[250.0, 271.0, 271.0]
[964, 968, 1014]
p02756
u103208639
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
['import sys\ninput=sys.stdin.readline\nfrom collections import deque\ns=deque([input()])\nq=int(input())\n\nfor _ in range(q):\n\tt=input()\n\tif t[0]=="1":\n\t\ts.reverse()\n\telse:\n\t\tt,f,c=t.split()\n\t\tif f=="1":\n\t\t\ts.appendleft(c)\n\t\telse:\n\t\t\ts.append(c)\nprint(*s,sep="")\n', 'from collections import deque\n\ns=deque(input())\nn=int(input())\nr=False\nfor i in range(n):\n q=input()\n if q[0]=="1":\n r= not r\n else:\n t,f,c=map(str,q.split())\n if f=="1":\n if r==False:\n s.appendleft(c)\n else:\n s.append(c)\n else:\n if r==True:\n s.appendleft(c)\n else:\n s.append(c)\ns=list(s)\nif r==True:\n s=s[::-1]\nprint(*s,sep="")']
['Wrong Answer', 'Accepted']
['s818409426', 's326654455']
[9968.0, 12144.0]
[2104.0, 652.0]
[257, 472]
p02756
u103902792
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
["import sys\ninput = sys.stdin.readline\nfrom collections import deque\n\ns = deque(input())\nreverse = 0\nq = int(input())\n\nfor _ in range(q):\n query = input()\n if query == '1':\n reverse = 1 - reverse\n else:\n _,f,c = query.split()\n if f == '1':\n if reverse:\n s.appendleft(c)\n else:\n s.append(c)\n else:\n if reverse:\n s.append(c)\n else:\n s.appendleft(c)\nif not reverse:\n s.reverse()\n\nprint(''.join(s))", "from collections import deque\n\ns = deque(input())\nreverse = 0\nq = int(input())\n\nfor _ in range(q):\n query = input()\n if query == '1':\n reverse = 1 - reverse\n else:\n _,f,c = query.split()\n if f == '1':\n if reverse:\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if reverse:\n s.appendleft(c)\n else:\n s.append(c)\n \n \nif reverse:\n s.reverse()\n\nprint(''.join(s))"]
['Runtime Error', 'Accepted']
['s743694081', 's809432372']
[8436.0, 8692.0]
[168.0, 409.0]
[458, 427]
p02756
u106181248
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\ndef main():\n s = input()\n n = int(input())\n li = [input().split() for i in range(n)]\n a = 0 \n\n for x in li:\n if x[0] == "1":\n if a == 0:\n a = 1\n else:\n a = 0\n else:\n if (x[1] == "1" and a == 0) or (x[1] == "2" and a == 1):\n s = x[2] + s\n else:\n s = s + x[2]\n\n if a == 0: \n print(s)\n else: \n print(s[::-1])\n\nif __name__ == \'__main__\':\n main()', 'ans = input()\nq = int(input())\ntop = 0\nfirst = str()\nlast = str()\n\nfor i in range(q):\n li =input().split()\n if li[0] =="1":\n top = (top+1)%2\n else:\n if li[1] == "1":\n if top ==0:\n first += li[2]\n else:\n last += li[2]\n else:\n if top ==1:\n first += li[2]\n else:\n last += li[2]\n\nif top == 0:\n ans = first[::-1] + ans + last\nelse:\n ans = last[::-1] + ans[::-1] + first\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s733048060', 's892841063']
[41828.0, 4340.0]
[2106.0, 435.0]
[611, 517]
p02756
u110199424
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
["S = str(input())\nQ = int(input())\n\n#Que = [list(map(str, input().split())) for _ in range(Q)]\n\nfor i in range(Q):\n flag, F, C = map(str, input().split())\n\n if flag == '1':\n S = S[::-1]\n\n if flag == '2':\n if F == '1':\n S = C + S\n if F == '2':\n S = S + C\n\n\nprint(S)", "from collections import deque\n\nS = str(input())\nQ = int(input())\n\n#Que = [list(map(str, input().split())) for _ in range(Q)]\n\ndeque_S = deque(S)\nre_flag = 1\nfor i in range(Q):\n que = str(input())\n\n if len(que) == 1:\n #S = S[::-1]\n re_flag *= -1\n\n else:\n if que[2] == '1':\n if re_flag == 1:\n \n deque_S.appendleft(que[4:])\n else:\n \n deque_S.append(que[-1:3:-1])\n if que[2] == '2':\n if re_flag == 1:\n \n deque_S.append(que[4:])\n else:\n \n deque_S.appendleft(que[-1:3:-1])\n\nans = ''\nif re_flag == 1:\n ans = ''.join(deque_S)\nelse:\n ans = ''.join(deque_S)[::-1]\n#print(deque_S)\n\nprint(ans)"]
['Runtime Error', 'Accepted']
['s244031076', 's303321266']
[3824.0, 13288.0]
[2103.0, 440.0]
[315, 864]
p02756
u111473084
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())\nprint(s)\nQ = int(input())\n\nreverse = False\nfor i in range(Q):\n q = input()\n if q == "1":\n reverse = False if reverse else True\n else:\n t, f, c = q.split(" ")\n if f == "1":\n if reverse:\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if reverse:\n s.appendleft(c)\n else:\n s.append(c)\nans = \'\'.join(s)\nif reverse:\n print(ans[::-1])\nelse:\n print(ans)\n', 'from collections import deque\ns = deque(input())\nQ = int(input())\n\nreverse = False\nfor i in range(Q):\n q = input()\n if q == "1":\n reverse = False if reverse else True\n else:\n t, f, c = q.split(" ")\n if f == "1":\n if reverse:\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if reverse:\n s.appendleft(c)\n else:\n s.append(c)\nans = \'\'.join(s)\nif reverse:\n print(ans[::-1])\nelse:\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s049139415', 's144089865']
[8972.0, 8436.0]
[418.0, 434.0]
[540, 531]
p02756
u111652094
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=list(S)\n\nQ=int(input())\n\nq=[]\nright=[]\nleft=[]\n\nrev=1\n\nfor i in range(Q):\n q.append(input().split())\n if q[i][0]=="1":\n rev=rev*(-1)\n elif q[i][0]=="2":\n if q[i][1]=="1":\n if rev==1:\n right.insert(0,q[i][2])\n else:\n left.append(q[i][2])\n elif q[i][1]=="2":\n if rev==1:\n left.append(q[i][2])\n else:\n right.insert(0,q[i][2])\nif rev==1:\n S_list.append(left)\n S_list.insert(0,right)\nelse:\n S_list.reverse()\n S_list.append(left)\n S_list.insert(0,right)\n \nS=\'\'.join(S_list)\nprint(S)', 'S=str(input())\nS_list=list(S)\n\nQ=int(input())\n\nq=[]\nright=[]\nleft=[]\n\nrev=1\n\nfor i in range(Q):\n q.append(input().split())\n if q[i][0]=="1":\n rev=rev*(-1)\n elif q[i][0]=="2":\n if q[i][1]=="1":\n if rev==1:\n right.insert(0,q[i][2])\n else:\n left.append(q[i][2])\n elif q[i][1]=="2":\n if rev==1:\n left.append(q[i][2])\n else:\n right.insert(0,q[i][2])\nprint(right,left)\n\nif rev==1:\n S_list=right+S_list+left\nelse:\n S_list=right+S_list+left\n S_list.reverse()\n\nS=\'\'.join(S_list)\nprint(S)', 'S=str(input())\nS_list=list(S)\n\nQ=int(input())\n\nq=[]\nright=[]\nleft=[]\n\nrev=1\n\nfor i in range(Q):\n q.append(input().split())\n if q[i][0]=="1":\n rev=rev*(-1)\n elif q[i][0]=="2":\n if q[i][1]=="1":\n if rev==1:\n right.append(q[i][2])\n else:\n left.append(q[i][2])\n elif q[i][1]=="2":\n if rev==1:\n left.append(q[i][2])\n else:\n right.append(q[i][2])\nright.reverse()\nif rev==1:\n S_list=right+S_list+left\nelse:\n S_list=right+S_list+left\n S_list.reverse()\n\nS=\'\'.join(S_list)\nprint(S)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s214727221', 's916860879', 's240746128']
[41076.0, 44936.0, 45940.0]
[2106.0, 2106.0, 519.0]
[650, 621, 614]
p02756
u115110170
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())\njun = 1\nf = t = ""\nfor _ in range(q):\n \n tmp = input()\n if len(tmp)==1:\n jun = 1 if jun==0 else 0 \n else:\n _,f,c = tmp.split()\n if jun+int(f) ==2:\n f = c+f\n else:\n t += c\nif jun==1:\n print(f+s+t)\nelse:\n print((f+s+t)[::-1])\n \n \n', 's = input()\nq = int(input())\n\njun = 1\nfor _ in range(q):\n \n tmp = input()\n if len(tmp)==1:\n jun = int(jun*(-1/2)+1/2)\n else:\n _,f,c = tmp.split()\n f = int(f)\n if jun+f ==2:\n s = c+s\n else:\n s += c\nif jun==1:\n print(s)\nelse:\n print(s[::-1])\n \n ', 's = input()\nq = int(input())\njun = 1\nf = "";t = ""\nfor _ in range(q):\n \n tmp = input()\n if len(tmp)==1:\n jun = 1 if jun==0 else 0 \n else:\n _,ff,c = tmp.split()\n if jun+int(ff) ==2:\n f = c+f\n else:\n t += c\nif jun==1:\n print(f+s+t)\nelse:\n print((f+s+t)[::-1])\n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s600889472', 's771779765', 's003623965']
[3896.0, 4132.0, 4500.0]
[528.0, 2104.0, 1649.0]
[293, 282, 292]
p02756
u116038906
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\ninput = sys.stdin.readline\nS = input()\nQ = int(input())\nFQ_dic =tuple()\nrev =0\nfor i in range(Q):\n FQ_dic =tuple(input().split())\n\n if FQ_dic[0] =="1": \n rev +=1\n else: \n if FQ_dic[1]=="1": \n if rev %2 ==0:\n S = FQ_dic[2] + S\n else:\n S = S +FQ_dic[2] \n else: \n if rev %2 ==0:\n S = S + FQ_dic[2]\n else: \n S = FQ_dic[2] + S\nif rev %2 ==0:\n print(S)\nelse:\n print(S[::-1])', '\nimport sys\ninput = sys.stdin.readline\nS = input()\nQ = int(input())\nFQ_dic =tuple()\nrev =0\nfor i in range(Q):\n FQ_dic =tuple(input().split())\n\n if FQ_dic[0] =="1": \n rev +=1\n else: \n if FQ_dic[1]=="1": \n if rev %2 ==0:\n S = FQ_dic[2] + S\n else:\n S = S +FQ_dic[2] \n else: \n if rev %2 ==0:\n S = S + FQ_dic[2]\n else: \n S = FQ_dic[2] + S\nif rev %2 ==0:\n print(S)\nelse:\n print(S[::-1])', '\n\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\nS = input().strip()\nQ = int(input())\nFQ_dic={}\nfor i in range(Q):\n FQ_dic[i] =input().split()\n\nrev =0 \ndq =deque(S)\nfor i in range(Q):\n if FQ_dic[i][0] =="1":\n rev +=1\n else:\n a,b,c =FQ_dic[i]\n if rev %2 ==0 and b =="1" :\n dq.appendleft(c)\n elif rev %2 ==0 and b =="2":\n dq.append(c)\n elif rev %2 ==1 and b =="1":\n dq.append(c)\n elif rev %2 ==1 and b =="2":\n dq.appendleft(c)\nif rev %2 ==1:\n dq.reverse()\nans ="".join(dq)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s344150331', 's658153789', 's463207384']
[4148.0, 4120.0, 62236.0]
[2104.0, 2104.0, 308.0]
[683, 683, 676]
p02756
u119982001
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\n\nS = input()\nQ = int(input())\nq = deque([S])\nreverse = False\n\nfor i in range(Q):\n X = sys.stdin.readline().split()\n if X[0] == "1":\n if reverse:\n reverse = False\n else:\n reverse = True\n elif X[0] == "2":\n if reverse:\n print(reverse)\n X[1] = str(3-int(X[1]))\n if X[1] == "1":\n q.appendleft(X[2])\n else:\n q.append(X[2])\n print(reverse, X[1], q)\n\nif reverse: q.reverse()\n\nfor i in range(len(q)):\n print(q[i],end="")\nprint()', '#include <bits/stdc++.h>\n\nusing namespace std;\nusing ll = long long;\nusing P = pair<int,int>;\n\nint main(){\n string s;\n cin >> s;\n string t;\n int q;\n cin >> q;\n rep(qi,q){\n int ty;\n cin >> ty;\n if (ty == 1){\n swap(s,t);\n }else{\n int f; char c;\n cin >> f >> c;\n if (f == 1){\n\tt += c;\n }else{\n\ts+=c;\n }}\n }\n reverse(t.begin(), t.end());\n t += s;\n cout << t << endl;\n return 0;\n}', 'from collections import deque\n\nS = input()\nQ = int(input())\nq = deque([S])\nreverse = -1\n\nfor i in range(Q):\n print(reverse)\n X = input().split()\n if X[0] == "1":\n reverse *= -1\n # if X[1] == "1":\n elif X[1] == "1":\n if reverse == -1:\n q.appendleft(X[2])\n else:\n q.append(X[2])\n elif X[1] == "2":\n if reverse == -1:\n q.append(X[2])\n else:\n q.appendleft(X[2])\n print(reverse, q)\nif reverse == 1: q.reverse()\n\nfor i in range(len(q)):\n print(q[i],end="")\nprint()\n \n', 'from collections import deque\n\nq = deque(input())\nQ = int(input())\nreverse = -1\n\nfor i in range(Q):\n X = input().split()\n if X[0] == "1":\n reverse *= -1\n # if X[1] == "1":\n elif X[1] == "1":\n if reverse == -1:\n q.appendleft(X[2])\n else:\n q.append(X[2])\n elif X[1] == "2":\n if reverse == -1:\n q.append(X[2])\n else:\n q.appendleft(X[2])\n\n\nif reverse == -1:\n print(\'\'.join(q))\nelse:\n print(\'\'.join(list(q)[::-1]))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s152344056', 's490034606', 's491602878', 's849467198']
[134848.0, 2940.0, 134868.0, 10100.0]
[702.0, 17.0, 708.0, 412.0]
[581, 474, 571, 539]
p02756
u121698457
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\np = ''\nq = ''\nfor i in range(Q):\n A = list(input().split())\n if A[0] == '1':\n x += 1\n elif x%2 ==0:\n if A[1] == '1':\n p = A[2] + p\n else:\n q = q + A[2]\n else:\n if A[1] == '1':\n q = q + A[2] \n else:\n p = A[2] + p\nif x%2 == 1:\n S = ''.join(reversed(list(S)))\nprint(S)", "S = input()\nQ = int(input())\nx = 0\np = ''\nq = ''\nfor i in range(Q):\n A = list(input().split())\n if A[0] == '1':\n x += 1\n elif x%2 ==0:\n if A[1] == '1':\n p = A[2] + p\n else:\n q = q + A[2]\n else:\n if A[1] == '1':\n q = q + A[2] \n else:\n p = A[2] + p\nS = p + S + q\nif x%2 == 1:\n S = ''.join(reversed(list(S)))\nprint(S)"]
['Wrong Answer', 'Accepted']
['s249361891', 's125698033']
[5004.0, 8224.0]
[1619.0, 1629.0]
[394, 408]
p02756
u123756661
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\ndef sol():\n s=input()\n q=int(input())\n x=0\n for i in range(q):\n l=[i for i in input().split()]\n if l[0]=="1":\n x=(x+1)%2\n elif l[1]=="1":\n if x==0: s=l[2]+s\n else: s=s+l[2]\n elif l[1]=="2":\n if x==0: s=s+l[2]\n else: s=l[2]+s\n print(s if x==0 else s[::-1])\n\nif __name__=="__main__":\n sol()', 'import sys\ninput = sys.stdin.readline\n\ndef sol():\n s=input().rstrip()\n q=int(input())\n x=0\n for i in range(q):\n l=[i for i in input().split()]\n print(l)\n if l[0]=="1":\n x=(x+1)%2\n elif l[1]=="1":\n if x==0: s=l[2]+s\n else: s=s+l[2]\n elif l[1]=="2":\n if x==0: s=s+l[2]\n else: s=l[2]+s\n print(s if x==0 else s[::-1])\n\nif __name__=="__main__":\n sol()\n', 'import sys\ninput = sys.stdin.readline\n\ndef sol():\n s=input().rstrip()\n q=int(input())\n x=0\n a,b="",""\n for i in range(q):\n l=tuple([i for i in input().split()])\n if l[0]=="1":\n x=(x+1)%2\n elif l[1]=="1":\n if x==0: a=l[2]+a\n else: b=b+l[2]\n elif l[1]=="2":\n if x==0: b=b+l[2]\n else: a=l[2]+a\n s=a+s+b\n print(s if x==0 else s[::-1])\n\nif __name__=="__main__":\n sol()\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s529261556', 's700018236', 's248624524']
[4044.0, 6816.0, 4608.0]
[2104.0, 2104.0, 1261.0]
[428, 455, 471]
p02756
u125545880
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
["\n\nfrom collections import deque\n\nS = deque(input())\nQ = int(input())\n\nT = 0\nfor _ in range(Q):\n Query = list(input().split())\n if len(Query) == 1:\n T ^= 1\n elif T == 0:\n m = Query[2]\n if Query[1] == '1':\n S.append(m)\n else:\n S.appendleft(m)\n else:\n m = Query[2]\n if Query[1] == '2':\n S.append(m)\n else:\n S.appendleft(m)\n\nif T==1:\n S.reverse()\n\nprint(''.join(S))\n", "\n\nS = input()\nQ = int(input())\n\nT = 0\nl = []\nr = []\nfor _ in range(Q):\n Query = list(input().split())\n if len(Query) == 1:\n T ^= 1\n elif T == 0:\n s = Query[2]\n if Query[1] == '1':\n l.append(s)\n else:\n r.append(s)\n else:\n s = Query[2]\n if Query[1] == '1':\n r.append(s)\n else:\n l.append(s)\n\nif T == 1:\n r.reverse()\n ans = ''.join(r) + S[::-1] + ''.join(l)\nelse:\n l.reverse()\n ans = ''.join(l) + S + ''.join(r)\n\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s647077750', 's734708959']
[8436.0, 5740.0]
[483.0, 471.0]
[508, 576]
p02756
u127499732
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
['def main():\n s,q,*r = [list(k.split()) for k in open(0)]\n s=s[0]\n p = False\n for x in r:\n if len(x)==1:\n p = True\n continue\n if (p == False and x[1]==\'1\') or (p == True and x[1]==\'2\'):\n s = x[2] + s\n else:\n s = s + x[2]\n \n print("".join(s) if p==False else "".join(s)[::-1])\n \nif __name__==\'__main__\':\n main()', 'def main():\n s = list( input() )\n q = int(input())\n r = [list(input().split()) for _ in range(q)]\n p = False\n for x in r:\n if len(x)==1:\n p = True\n continue\n if (p == False and x[1]==\'1\') or (p == True and x[1]==\'2\'):\n s = [x[2]] + s\n else:\n s = s + [x[2]]\n \n print("".join(s) if p==False else "".join(s[::-1]))\n \nif __name__==\'__main__\':\n main()', 'def main():\n from collections import deque\n \n s,q,*r = [list(k.split()) for k in open(0)]\n que = deque(s[0])\n p = False\n for x in r:\n if len(x)==1:\n p = not p\n continue\n if (p==False and x[1]==\'1\') or (p==True and x[1]==\'2\'):\n que.appendleft(x[2])\n else:\n que.append(x[2])\n print("".join(que) if p==False else "".join(que)[::-1])\n \nif __name__==\'__main__\':\n main()']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s367553113', 's444766514', 's477506820']
[32472.0, 33864.0, 35416.0]
[2105.0, 2105.0, 194.0]
[348, 386, 406]
p02756
u130900604
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\ninput = sys.stdin.readline\n\ns=input()\nq=int(input())\n\nfor i in range(q):\n qi=list(input().split())\n if qi[0]=="1":\n s=s[::-1]\n else:\n f,c=qi[1],qi[2]\n if f=="1":\n s=c+s\n else:\n s=s+c\nprint(s)', 'from collections import deque\ns=deque(input())\nq=int(input())\nrev=0\nfor i in range(q):\n p=list(map(str,input().split()))\n if p[0]=="1":\n rev^=1\n else:\n z,f,c=p\n if f=="1":\n if rev:\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if rev:\n s.appendleft(c)\n else:\n s.append(c)\nif rev:\n s=list(s)[::-1]\nelse:\n s=list(s)\nprint("".join(s))\n\n']
['Wrong Answer', 'Accepted']
['s087136955', 's171481207']
[3956.0, 10228.0]
[2104.0, 664.0]
[271, 479]
p02756
u137226361
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 ten = 0\n r = []\n l = []\n for _ in range(q):\n ls = tuple(map(str, input().split()))\n if len(ls)==1:\n ten +=1\n else:\n if ls[1] =='1':\n if ten%2 ==0:\n l.append(ls[2])\n else:\n r.append(ls[2])\n else:\n if ten%2 ==1:\n l.append(ls[2])\n else:\n r.append(ls[2])\n s = ''.join(reversed(l))+s+''.join(r)\n if ten%2 ==1:\n s = s[::-1]\n print(s)\nif __name__ == '__main__':\n main()", "def main():\n import sys\n input = sys.stdin.readline\n s = str(input().rstrip())\n q =int(input())\n ten = 0\n r = []\n l = []\n la = l.append\n ra =r.append\n for _ in range(q):\n ls = tuple(map(str, sys.stdin.readline().split()))\n if len(ls)==1:\n ten +=1\n else:\n if ls[1] =='1':\n if ten%2 ==0:\n la(ls[2])\n else:\n ra(ls[2])\n else:\n if ten%2 ==1:\n la(ls[2])\n else:\n ra(ls[2])\n s = ''.join(reversed(l))+s+''.join(r)\n if ten%2 ==1:\n s = s[::-1]\n print(s)\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s011844210', 's020627006']
[12336.0, 12280.0]
[187.0, 200.0]
[678, 716]
p02756
u137912513
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 = sys.stdin.readline()\nq = int(input())\nFlag = True\nfor i in range(q):\n xxx = input()\n if len(xxx) == 1:\n if Flag == True:\n Flag = False\n else:\n Flag = True\n else:#T=2\n T,F,C=xxx.split()\n F = int(F)\n if F == 1:\n if Flag == True:\n s = C+s\n else:\n s = s+C\n else:#F=2\n if Flag == True:\n s = s + C\n else:\n s = C + s\nif Flag == True:\n print(s)\nelse:\n s = s[::-1]\n print(s)\n', "s = input()\nq = int(input())\nadv = ''\nbac = ''\nFlag = True\nfor i in range(q):\n xxx = input()\n if len(xxx) == 1:\n if Flag == True:\n Flag = False\n else:\n Flag = True\n else:#T=2\n T,F,C=xxx.split()\n F = int(F)\n if F == 1:\n if Flag == True:\n adv +=C\n else:\n bac +=C\n else:#F=2\n if Flag == True:\n bac +=C\n else:\n adv +=C\nif Flag == True:\n s = adv[::-1] + s + bac\n print(s)\nelse:\n s = bac[::-1] + s[::-1] + adv\n print(s)\n"]
['Wrong Answer', 'Accepted']
['s589861387', 's418663676']
[3896.0, 4340.0]
[2104.0, 528.0]
[567, 603]
p02756
u140191608
2,000
1,048,576
Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
["S = input()\nQ = int(input())\nflg = 0\nsenntou = ''\nushiro = ''\nfor i in range(Q):\n A = list(input().split())\n if int(A[0]) == 1 and flg == 0:\n flg = 1\n continue\n elif int(A[0]) == 1 and flg == 1:\n flg = 0\n continue\n if (int(A[1]) == 1 and if flg == 0) or (int(A[1]) == 2 and if flg == 1):\n senntou = A[2] + senntou\n else:\n ushiro = ushiro + A[2]\nif flg == 0:\n print(senntou + S + ushiro)\nif flg == 1:\n print(ushiro[::-1] + S + senntou[::-1])", 'S = input()\nQ = int(input())\nflg = 0\nfor i in range(Q):\n A = list(input().split())\n if int(A[0]) == 1 and flg == 0:\n flg = 1\n continue\n elif int(A[0]) == 1 and flg == 1:\n flg = 0\n continue\n if int(A[1]) == 1:\n if flg == 0:\n S.insert(0,A[2])\n else:\n S.append(A[2])\n else:\n if flg == 0:\n S.append(A[2])\n else:\n S.insert(0,A[2])\nif flg == 0:\n print(S)\nif flg == 1:\n print(S[::-1])', "S = input()\nQ = int(input())\nflg = 0\nsenntou = ''\nushiro = ''\nfor i in range(Q):\n A = list(input().split())\n if int(A[0]) == 1 and flg == 0:\n flg = 1\n continue\n elif int(A[0]) == 1 and flg == 1:\n flg = 0\n continue\n if (int(A[1]) == 1 and flg == 0) or (int(A[1]) == 2 and flg == 1):\n senntou = A[2] + senntou\n else:\n ushiro = ushiro + A[2]\nif flg == 0:\n print(senntou + S + ushiro)\nif flg == 1:\n print(ushiro[::-1] + S[::-1] + senntou[::-1])"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s577108705', 's843935301', 's637461511']
[2940.0, 3188.0, 4444.0]
[17.0, 18.0, 1816.0]
[503, 498, 503]
p02756
u155659281
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())\n \nalpha_map = {chr(i):i for i in range(97,123)}\nalpha_map_inv = {i:chr(i) for i in range(97,123)}\na = deque()\nfor s in S:\n a.append(s)\nprint(a)\nreversed = False\n \nfor _ in range(Q):\n query = list(map(str, input().split()))\n if query[0] == '1':\n if reversed:\n reversed = False\n else:\n reversed = True\n else:\n if (query[1] == '1')&(not reversed):\n a.appendleft(query[2])\n elif (query[1] == '2')&(reversed):\n a.appendleft(query[2])\n else:\n a.append(query[2])\nif reversed:\n a.reverse()\nprint(''.join(list(a)))", "from collections import deque\nS = input()\nQ = int(input())\n \nalpha_map = {chr(i):i for i in range(97,123)}\nalpha_map_inv = {i:chr(i) for i in range(97,123)}\na = deque()\nfor s in S:\n a.append(s)\nreversed = False\n \nfor _ in range(Q):\n query = list(map(str, input().split()))\n if query[0] == '1':\n if reversed:\n reversed = False\n else:\n reversed = True\n else:\n if (query[1] == '1')&(not reversed):\n a.appendleft(query[2])\n elif (query[1] == '2')&(reversed):\n a.appendleft(query[2])\n else:\n a.append(query[2])\nif reversed:\n a.reverse()\nprint(''.join(list(a)))"]
['Wrong Answer', 'Accepted']
['s362349260', 's979414648']
[9348.0, 8692.0]
[696.0, 718.0]
[609, 600]
p02756
u158583803
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 iq in range(1,q+1):\n\tt=input().split()\n\tif t[0]==\'1\':\n\t\ts=s[::-1]\n\telse:\n\t\tif t[1]==\'1\':\n#\t\t\ts=t[2]+s\n s=\'{}{}\'.format(t[2],s)\n#\t\t\ts=f"{t[2]}{s}"\n#\t\t\tlist1=[t[2],s]\n#\t\t\ts="".join(list1)\n#\t\t\ts="".join(t[2],s)\n\t\telse:\n#\t\t\ts=s+t[2]\n s=\'{}{}\'.format(s,t[2])\n#\t\t\ts=f"{s}{t[2]}" \n#\t\t\tlist2=[s,t[2]]\n#\t\t\ts="".join(list2)\n#\t\t\ts="".join(s,t[2])\n\nprint (s)', 's=input()\nq= int(input())\n\ntop=""\nbtm=""\n\niturn=0\nfor iq in range(1,q+1):\n\tt=input().split()\n\tif t[0]==\'1\':\n\t\titurn=iturn+1 \t\n\telse:\n\t\titurn2=iturn%2\n\t\tif (t[1]==\'1\' and iturn2==0) or (t[1]==\'2\' and iturn2==1):\n#\t\t\ts=t[2]+s\n#\t\t\ts=\'{}{}\'.format(t[2],s)\n\t\t\ttop=t[2]+top\n\t\telse:\n#\t\t\ts=s+t[2]\n#\t\t\ts=\'{}{}\'.format(s,t[2])\n\t\t\tbtm=btm+t[2]\n\nif iturn%2==0:\n\ts=top+s+btm\nelse:\n\ts=btm[::-1]+s[::-1]+top[::-1]\nprint (s)']
['Runtime Error', 'Accepted']
['s340205994', 's396284536']
[2940.0, 4424.0]
[18.0, 1512.0]
[399, 410]