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
|
---|---|---|---|---|---|---|---|---|---|---|
p03341 | u547608423 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['N=int(input())\nS=input()\nl=0\nr=S[1:].count("E")\nprint(r)\nanswer=N\n\nfor i in range(N-1):\n if l+r<answer:\n answer=l+r\n if S[i]=="W":\n l+=1\n if S[i+1]=="E":\n r-=1\nif l+r<answer:\n answer=l+r\nprint(answer)\n', 'N=int(input())\nS=input()\nl=0\nr=S[1:].count("E")\n#print(r)\nanswer=N\n\nfor i in range(N-1):\n if l+r<answer:\n answer=l+r\n if S[i]=="W":\n l+=1\n if S[i+1]=="E":\n r-=1\nif l+r<answer:\n answer=l+r\nprint(answer)\n'] | ['Wrong Answer', 'Accepted'] | ['s382292802', 's763039370'] | [3672.0, 3672.0] | [158.0, 160.0] | [234, 235] |
p03341 | u551909378 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["N = int(input())\nS = list(input())\nw = [0 for i in range(N)]\ne = [0 for i in range(N)]\n\nif S[0] == 'W':\n w[0] = 1\n\nfor i in range(1,N-1):\n if S[i] == 'W':\n w[i] = w[i-1] + 1\n e[i+1] = e[i] \n else:\n w[i] = w[i-1]\n e[i+1] = e[i] - 1\n\nif S[-1] == 'W':\n w[-1] = w[-2] + 1\nelse:\n w[-1] = w[-2] \n\nans = w[0] + e[0]\nscale = -e[-1]\nfor i in range(N):\n w[i] = w[i] + e[i]\n if ans > w[i]:\n ans = w[i]\n\nprint(ans + scale)\n", "N = int(input())\nS = list(input())\nw = [0 for i in range(N)]\ne = [0 for i in range(N)]\n\nif S[0] == 'W':\n w[0] = 1\n\nfor i in range(1,N-1):\n if S[i] == 'W':\n w[i] = w[i-1] + 1\n e[i+1] = e[i] \n else:\n w[i] = w[i-1]\n e[i+1] = e[i] - 1\n\nif S[-1] == 'W':\n w[-1] = w[-2] + 1\n scale = -e[-1]\nelse:\n w[-1] = w[-2]\n scale = -e[-1] +1\n\nans = w[0] + e[0]\nfor i in range(N):\n w[i] = w[i] + e[i]\n if ans > w[i]:\n ans = w[i]\n\nprint(ans + scale - 1)\n"] | ['Wrong Answer', 'Accepted'] | ['s332359443', 's136632251'] | [29404.0, 29412.0] | [278.0, 277.0] | [468, 497] |
p03341 | u574050882 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["def main():\n\tN = int(input())\n\ta = input()\n \n\tW = [0]\n\tE = [0]\n\tfor i in range(N):\n\t\tif a[i] == 'W':\n\t\t\tW[i+1] = W[i] + 1\n\t\t\tE[i+1] = E[i]\n\t\telse:\n\t\t\tW[i+1] = W[i]\n\t\t\tE[i+1] = E[i] + 1\n\tE_max = E[-1]\n\tn_min = N\n\tfor i in range(N):\n\t\tt = W[i] + E_max - E[i+1]\n\t\tif t < n_min:\n\t\t\tn_min = t\n\tprint (n_min)\nmain()", "def main():\n\tN = int(input())\n\ta = input()\n \n\tW = [0]*(N+1)\n\tE = [0]*(N+1)\n\tfor i in range(N):\n\t\tif a[i] == 'W':\n\t\t\tW[i+1] = W[i] + 1\n\t\t\tE[i+1] = E[i]\n\t\telse:\n\t\t\tW[i+1] = W[i]\n\t\t\tE[i+1] = E[i] + 1\n\tE_max = E[-1]\n\tn_min = N\n\tfor i in range(N):\n\t\tt = W[i] + E_max - E[i+1]\n\t\tif t < n_min:\n\t\t\tn_min = t\n\tprint (n_min)\nmain()"] | ['Runtime Error', 'Accepted'] | ['s952715467', 's500576619'] | [3784.0, 17608.0] | [18.0, 157.0] | [312, 324] |
p03341 | u593567568 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['N = int(input())\nS = list(input())\n\nCNT = []\nc = 0\nfor s in S:\n if s == "E":\n c += 1\n CNT.append(c)\n \nans = N + 10\nmn = N + 10\nfor i in range(N):\n c = 0\n if i > 0:\n c += i - 1 - CNT[i-1]\n if i < N - 1:\n c += N - i - 1 - (CNT[N] - CNT[i+1])\n \n if c < mn:\n ans = i+1\n\nprint(ans)\n \n\n ', 'N = int(input())\nS = list(input())\n\nCNT = []\nc = 0\nfor s in S:\n if s == "E":\n c += 1\n CNT.append(c)\n \nans = N + 10\nmn = N + 10\nfor i in range(N):\n c = 0\n if i > 0:\n c += i - 1 - CNT[i-1]\n if i < N - 1:\n c += N - i - 1 - (CNT[N-1] - CNT[i+1])\n \n if c < mn:\n ans = i+1\n\nprint(ans)\n \n\n \n', 'N = int(input())\nS = list(input())\n\nEAST = []\nWEST = []\ne = 0\nw = 0\nfor s in S:\n if s == "E":\n e += 1\n else:\n w += 1\n EAST.append(e)\n WEST.append(w)\n \nans = N - 1\nfor i in range(N):\n c = 0\n if i > 0:\n c += WEST[i-1]\n if i < N - 1:\n c += EAST[N-1] - EAST[i]\n \n ans = min(c,ans)\n\nprint(ans)\n \n\n \n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s050689709', 's498593772', 's767769864'] | [23236.0, 23228.0, 25536.0] | [82.0, 285.0, 275.0] | [308, 311, 320] |
p03341 | u623687794 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['n=int(input())\nw=input()\nans=[0 for i in range(n)]\nfor i in range(1,n):\n if w[i]=="E":\n ans[0]+=1\nfor i in range(1,n):\n if w[i]=="E":\n ans[i]=ans[i-1]-1\n if w[i-1]=="W":\n ans[i]=ans[i-1]+1\nprint(min(ans))\n ', 'n=int(input())\nw=input()\nans=[0 for i in range(n)]\nfor i in range(1,n):\n if w[i]=="E":\n ans[0]+=1\nfor i in range(1,n):\n ans[i]=ans[i-1]\n if w[i]=="E":\n ans[i]-=1\n if w[i-1]=="W":\n ans[i]+=1\nprint(min(ans))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s222747055', 's253115731'] | [15520.0, 15500.0] | [200.0, 215.0] | [221, 220] |
p03341 | u652498023 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["N = int(input())\nline = input()\n\nans = line[1:N].count('E')\ntmp = ans\nfor i in range(1,N):\n if line[i] == 'E':\n tmp -= 1\n if line[i-1] == 'W':\n tmp += 1\n if ans>tmp:\n ans = tmp\n print(i)\n\n\nprint(ans)", "N = int(input())\nline = input()\n\nans = line[1:N].count('E')\ntmp = ans\nfor i in range(1,N):\n if line[i] == 'E':\n tmp -= 1\n if line[i-1] == 'W':\n tmp += 1\n if ans>tmp:\n ans = tmp\n\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s218662647', 's269418268'] | [5660.0, 3672.0] | [360.0, 130.0] | [202, 191] |
p03341 | u671215535 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["import sys\n\nN = int(input())\nS = input()\n\nposition = []\nfor s in S:\n if s == 'W':\n position.append(-1)\n else:\n position.append(1)\ni = 0\nflips = N + 1\nwhile i < N:\n flips_temp = 0\n j = 0\n while j < N:\n if j < i:\n flips_temp += (1 - position[j]) / 2.\n if j > i:\n flips_temp += (1 + position[j]) / 2.\n j = j + 1\n if flips_temp < flips:\n flips = flips_temp\n i = i + 1\nprint(flips)", "import sys\n\nN = int(input())\nS = input()\n\nposition_L = []\nposition_R = []\nfor s in S:\n if s == 'W':\n position_R.append(0)\n else:\n position_R.append(1)\n \nflips = sum(position_R[1:])\nflips_temp = flips\n#print(0,flips_temp)\ni = 1\nwhile i < N:\n #print(i,flips_temp)\n flips_temp = flips_temp - position_R[i] + ((-1) * position_R[i-1] + 1)\n if flips_temp < flips:\n flips = flips_temp\n i = i + 1\nprint(flips)"] | ['Wrong Answer', 'Accepted'] | ['s976363122', 's583148824'] | [6048.0, 8352.0] | [2104.0, 199.0] | [462, 447] |
p03341 | u674569298 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["n = int(input())\na = list(input())\nfor i in range(n):\n if a[i] == 'E':\n a[i] = 1\n else:\n a[i] = 0\n\nans = 99999999999999999999\n# print(a)\nl = 0\nr = sum(a)\nfor i in range(n):\n\n if i == 0:\n if a[i] == 1:\n r -= a[i]\n a[i] = 0\n else:\n a[i] = 1\n l = 0\n else:\n if a[i] == 1:\n a[i] = 0\n r -= 1\n else:\n a[i] = 1\n l += a[i-1]\n\n ans = min(l+r,ans)\n print(i,l,r,ans)\nprint(ans)\n\n", "n = int(input())\na = list(input())\nfor i in range(n):\n if a[i] == 'E':\n a[i] = 1\n else:\n a[i] = 0\n\nans = 99999999999999999999\n# print(a)\nl = 0\nr = sum(a)\nfor i in range(n):\n\n if i == 0:\n if a[i] == 1:\n r -= a[i]\n a[i] = 0\n else:\n a[i] = 1\n l = 0\n else:\n if a[i] == 1:\n a[i] = 0\n r -= 1\n else:\n a[i] = 1\n l += a[i-1]\n\n ans = min(l+r,ans)\n # print(i,l,r,ans)\nprint(ans)\n\n"] | ['Wrong Answer', 'Accepted'] | ['s422664292', 's223132472'] | [13556.0, 5964.0] | [1012.0, 269.0] | [507, 509] |
p03341 | u698176039 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["N = int(input())\nS = input()\n\nEast = [0] * N\nWest = [0] * N\n\nfor i,s in enumerate(list(S)):\n if s == 'W' : \n if i==0:\n East[i] = 1\n else:\n East[i] = East[i-1] + 1\n else:\n East[i] = East[i-1]\ni = N-1\nfor s in reversed((list(S))):\n if s == 'E' : \n if i==N-1:\n West[i] = 1\n else:\n West[i] = West[i+1] + 1\n else:\n West[i] = West[i+1]\n i -= 1\n \nans = 2**31-1\n\nfor i in range(N):\n if i == 1:\n ans2 = West[1]\n elif i == N-1:\n ans2 = East[N-2]\n else:\n ans2 = East[i-1]+West[i+1]\n ans = min(ans,ans2)\n \nprint(ans)\n ", "N = int(input())\nS = input()\n\nEast = [0] * N\nWest = [0] * N\n\nfor i,s in enumerate(list(S)):\n if s == 'W' : \n if i==0:\n East[i] = 1\n else:\n East[i] = East[i-1] + 1\n else:\n if i == 0:\n East[i] = 0\n else:\n East[i] = East[i-1]\ni = N-1\nfor s in reversed((list(S))):\n if s == 'E' : \n if i==N-1:\n West[i] = 1\n else:\n West[i] = West[i+1] + 1\n else:\n if i == N-1:\n West[i] = 0\n else:\n West[i] = West[i+1]\n i -= 1\n \nans = 2**31-1\n\nfor i in range(N):\n if i == 1:\n ans2 = West[1]\n elif i == N-1:\n ans2 = East[N-2]\n else:\n ans2 = East[i-1]+West[i+1]\n ans = min(ans,ans2)\n \nprint(ans)\n "] | ['Runtime Error', 'Accepted'] | ['s037450477', 's028077907'] | [20176.0, 20088.0] | [414.0, 427.0] | [657, 781] |
p03341 | u710201258 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["def foo (s):\n ans = 0\n count = 0\n for i in s:\n if i == 'W':\n count += 1\n elif count :\n count -= 1\n ans += 1\n else:\n pass\n return ans\n \nn = input()\ns = input()\n \nprint(foo(s))", "def foo (s):\n\tans = 0\n\tcount = 0\n\tfor i in s:\n\t\tif (not count) and (i == 'E'):pass\n\t\telif not count: count += 1\n\t\telif i == 'E': count -= 1; ans += 1\n\t\telse: count += 1\n\treturn ans\n \n n = int(input())\n s = input()\n print(foo(s))", "def foo (s):\n ans = 0\n count = 0\n for i in s:\n if i == 'W':\n count += 1\n elif count :\n count -= 1\n ans += 1\n else:\n pass\n return ans\n \n n = input()\ns = input()\n \nprint(foo(s))", "def foo (s):\n ans = 0\n count = 0\n for i in s:\n if i == 'W':\n count += 1\n elif count :\n count -= 1\n ans += 1\n else:\n pass\n return ans\n\nn = input()\ns = input()\n \nprint(foo(s))", "def foo (s):\n ans = 0\n count = 0\n for i in s:\n if i == 'W':\n count += 1\n elif count :\n count -= 1\n ans += 1\n else:\n pass\n return ans\n \nn = input()\ns = input()\n\nprint(foo(s))", "def foo (s):\n ans = 0\n count = 0\n for i in s:\n if i == 'W':\n count += 1\n elif count :\n count -= 1\n ans += 1\n else:\n pass\n return ans\n\nn = input()\ns = input()\n \nprint(foo(s))"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s077055774', 's127887707', 's220191074', 's689024349', 's717168627', 's431512536'] | [2940.0, 2940.0, 2940.0, 3064.0, 2940.0, 3676.0] | [17.0, 17.0, 17.0, 17.0, 17.0, 45.0] | [232, 234, 234, 226, 226, 250] |
p03341 | u750651325 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float("inf")\n\nn=k()\np=X()\ne=[1 if i=="E" else 0 for i in p]\nw=[1 if i=="W" else 0 for i in p]\ne=list(itertools.accumulate(e))\nw=list(itertools.accumulate(w))\n\nfor i in range(n):\n mod = min(mod, e[-1]-e[i]+w[i])\n\n\n\nprint(e)\nprint(w)\nprint(mod)\n', 'import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 6)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float("inf")\nal = "abcdefghijklmnopqrstuvwxyz"\nAL = al.upper()\n\nn = k()\ns = v()\ne = list(itertools.accumulate([1 if i=="E" else 0 for i in s]))\nw = list(itertools.accumulate([1 if i=="W" else 0 for i in s]))\n\nfor i in range(n):\n cnt = e[-1]-e[i]+w[i]\n if mod > cnt:\n mod,ans = cnt,i\nif ans == 0:\n mod -= 1\n\nprint(mod)\n\n\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s506575802', 's393626886'] | [40908.0, 37928.0] | [241.0, 169.0] | [763, 856] |
p03341 | u767664985 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['N = int(input())\nS = input()\nans = [S[1:].count("E")]\nfor i in range(1, N):\n\ttmp = ans[i - 1]\n\tif S[i - 1] == "W":\n\t\ttmp += 1\n\tif S[i] == "E":\n\t\ttmp -= 1\n\tans.append(tmp)\nprint(ans)\n', 'N = int(input())\nS = input()\nans = [S[1:].count("E")]\nfor i in range(1, N):\n\ttmp = ans[i - 1]\n\tif S[i - 1] == "W":\n\t\ttmp += 1\n\tif S[i] == "E":\n\t\ttmp -= 1\n\tans.append(tmp)\nprint(min(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s064538761', 's393170626'] | [22552.0, 15564.0] | [217.0, 184.0] | [182, 187] |
p03341 | u779455925 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['N=int(input())\nS=list(input())\nfor i in range(len(S)):\n S[i]=-1 if S[i]=="W" else 1\ndata=[-1 for i in range(N)]\nstidx,endidx,maidx=0,N-1,int((N-1)/2)\nfor i in [stidx,endidx]:\n data[i]=-1*sum([S[m] for m in range(0,i) if S[m]==-1])+sum([S[m] for m in range(i+1,N) if S[m]==1])\nwhile endidx-stidx>3:\n\n t1=int(stidx+(endidx-stidx)*1/3)\n t2=int(stidx+(endidx-stidx)*2/3)\n print(stidx,endidx,t1,t2)\n for i in [t1,t2]:\n data[i]=-1*sum([S[m] for m in range(0,i) if S[m]==-1])+sum([S[m] for m in range(i+1,N) if S[m]==1])\n if data[t1]>data[t2]:\n stidx=t1\n else:\n endidx=t2\n\nprint(min([i for i in data if i>0]))\n', 'N=int(input())\nS=list(input())\ndata=[0 for i in range(N)]\ndata[0]=S[1:].count("E")\nfor i in range(N-1):\n if S[i]=="W":\n data[i+1]+=1\n if S[i+1]=="E":\n data[i+1]-=1\n data[i+1]+=data[i]\nprint(min([i for i in data]))\n'] | ['Wrong Answer', 'Accepted'] | ['s335618583', 's210763494'] | [10668.0, 21072.0] | [1809.0, 244.0] | [648, 237] |
p03341 | u798894056 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['\n# created: 22.09.2020 12:19:17\n\nimport sys\n\nfrom collections import Counter\n\nN = int(input())\n\nS = input()\n\nl = 0\nr = Counter(S[1:])["E"]\nprint(f"{l=}{r=}")\n\nans = l + r\nflg = False\n\nfor i in range(N):\n if flg:\n l += 1\n flg = False\n if S[i] == "E":\n r -= 1\n\n ans = min(ans, l + r)\n\n if S[i] == "W":\n flg = True\n\n\nprint(ans)\n', '\n# created: 22.09.2020 12:19:17\n\nimport sys\n\nfrom collections import Counter\n\nN = int(input())\n\nS = input()\n\ne = [0]\nw = [0]\n\nfor s in S:\n if s == "W":\n w += [w[-1] + 1]\n e += [e[-1]]\n elif s == "E":\n w += [w[-1]]\n e += [e[-1] + 1]\n\nans = 3 * (10 ** 5) + 1\n\nfor i in range(N):\n c = w[i]\n c += e[N] - e[i + 1]\n ans = min(c, ans)\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s748093894', 's997618340'] | [9948.0, 23788.0] | [170.0, 248.0] | [382, 404] |
p03341 | u820172510 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["input()\ns = input()\n\ndef f(i):\n return s[0:i].count('W') + s[i:].count('E')\n\nx = len(s)\n\nfor i in range(len(s)):\n x = min(x, f(i))\n\nprint(min(arr))", "input()\ns = input()\n\nl = 0\nr = s[1:].count('E')\nx = l + r\n\nfor i in range(1, len(s)):\n if s[i - 1] == 'W':\n l += 1\n\n if s[i] == 'E':\n r -= 1\n x = min(x, l + r)\n\nprint(x)\n"] | ['Runtime Error', 'Accepted'] | ['s972420098', 's077966348'] | [3672.0, 3672.0] | [2104.0, 216.0] | [149, 179] |
p03341 | u874333466 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["N = int(input())\nS = input()\n\n# [West, East]\nl = [0, 0]\nL = []\nm = [0, 0]\nM = [0] * N\nfor i in range(N):\n if S[i] == 'W':\n l[0] += 1\n L.append(list(l))\n print(l)\n else:\n l[1] += 1\n L.append(list(l))\n print(l)\n\nfor i in range(N-1, -1, -1):\n if S[i] == 'W':\n m[0] += 1\n M[i] = list(m)\n else:\n m[1] += 1\n M[i] = list(m)\n \ncount = []\nfor i in range(N):\n if i == 0:\n count.append(M[1][0])\n elif i == N-1:\n count.append(L[N-2][1])\n else:\n count.append(L[i-1][0]+M[i+1][1])\n\nprint(min(count))\n ", "N = int(input())\nS = input()\n\nl = 0\nL = []\nr = 0\nR = [0] * N\nfor i in range(N):\n if i == 0:\n L.append(0)\n else:\n if S[i-1] == 'W':\n l += 1\n L.append(l)\n \nfor i in range(N-1, -1, -1):\n if i == N-1:\n R[i] = 0\n else:\n if S[i+1] == 'E':\n r += 1\n R[i] = r\n \ncount = []\nfor i in range(N):\n count.append(L[i] + R[i])\n\nprint(min(count))\n\n"] | ['Wrong Answer', 'Accepted'] | ['s779156037', 's295248606'] | [109936.0, 29728.0] | [1140.0, 310.0] | [539, 369] |
p03341 | u941644149 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['N = int(input())\nS = input()\nstock = []\n#INF = 10**9\nfor i in range(1,len(S)-1):\n if (S[i-1] == "E") & (S[i+1] == "W"): stock.append(i)\n\ndic = {k:0 for k in stock}\ndic[0]= S.count("E")\ndic[len(S)-1] = S.count("W")\n\nfor i in stock:\n for j in range(i-1,0,-1):\n if j < 0: break\n else:\n if S[j] == "E" : dic[i] += 1\n else: break\n\n for j in range(i+1, len(S)):\n if j > len(S)-1: break\n else:\n if S[j] == "W" : dic[i] += 1\n else: break\n\nmax_k = max(dic, key=dic.get)\n\n\ncount = 0\nfor i in range(0,max_k):\n if S[i] == "W": count += 1\n\nfor i in range(max_k+1, len(S)):\n if S[i] == "E": count += 1\n\n\n\n\nprint(count)', 'N = int(input())\nS = input()\n\nsum_w = [0]\nsum_e = [0]\n\ncount = 0\nfor i in range(N-1):\n if S[i] == "W":\n count += 1\n sum_w.append(count)\n\ncount = 0\nfor i in range(N-1,0,-1):\n if S[i] == "E": \n count += 1\n sum_e.append(count)\nsum_e = sum_e[::-1]\n\n\nsumu = [x+y for x, y in zip(sum_w, sum_e)]\n\nprint(min(sumu))'] | ['Runtime Error', 'Accepted'] | ['s494803645', 's787153199'] | [2940.0, 30840.0] | [17.0, 197.0] | [643, 346] |
p03341 | u974944183 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["\tN = int(input())\nS = input()\n\ntmp = [int(p.replace('W', '-1')) if p == 'W' else int(p.replace('E', '1')) for p in list(S)]\n\nresult = []\ncnt = 0\nfor CTO in range(N):\n for MEM in range(N):\n print(CTO)\n if MEM == CTO:\n continue\n if CTO < MEM:\n if tmp[CTO] == -1:\n if (tmp[MEM] + tmp[CTO]) == 0:\n cnt += 1\n if tmp[CTO] == 1:\n if (tmp[MEM] + tmp[CTO]) != 0:\n cnt += 1\n\n if MEM < CTO:\n if tmp[CTO] == -1:\n if (tmp[MEM] + tmp[CTO]) != 0:\n cnt += 1\n if tmp[CTO] == 1:\n if (tmp[MEM] + tmp[CTO]) == 0:\n cnt += 1\n print(cnt)\n result.append(cnt)\n cnt = 0\n\nresult_x = [ result[i] for i in range(N) if result[i] != 0]\nprint(min(result_x))", "N = int(input())\nS = input()\n\ntmp = [int(p.replace('W', '-1')) if p == 'W' else int(p.replace('E', '1')) for p in list(S)]\n\nresult = []\ncnt = 0\nfor CTO in range(N):\n for MEM in range(N):\n print(CTO)\n if MEM == CTO:\n continue\n if CTO < MEM:\n if tmp[CTO] == -1:\n if (tmp[MEM] + tmp[CTO]) == 0:\n cnt += 1\n if tmp[CTO] == 1:\n if (tmp[MEM] + tmp[CTO]) != 0:\n cnt += 1\n\n if MEM < CTO:\n if tmp[CTO] == -1:\n if (tmp[MEM] + tmp[CTO]) != 0:\n cnt += 1\n if tmp[CTO] == 1:\n if (tmp[MEM] + tmp[CTO]) == 0:\n cnt += 1\n print(cnt)\n result.append(cnt)\n cnt = 0\n\nresult_x = [ result[i] for i in range(N) if result[i] != 0]\nprint(min(result_x))", "N = int(input())\nS = list(input())\n\nw = 0\ne = S[1:].count('E')\n\nleader = S[0]\nmin_mem=e\ncnt_mem=0\n\nfor i in range(1, N):\n if leader == 'W':\n w += 1\n leader = S[i]\n\n if leader == 'E':\n e -= 1\n\n cnt_mem = w + e\n if cnt_mem < min_mem:\n min_mem = cnt_mem\n\nprint(min_mem)"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s680207315', 's701708611', 's980696008'] | [2940.0, 15700.0, 8140.0] | [17.0, 2108.0, 160.0] | [861, 860, 303] |
p03341 | u983918956 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['N = int(input())\nS = list(input())\ncount_list = []\ncamu_west = []\nfor i in range(1,N+1):\n look_west = len([S[j] for j in range(i) if S[j] == "W"])\n camu_west.append(look_west)\nfor i in range(N):\n count_l = camu_west[i-1]\n if i == 0:\n count_l = 0\n count_r = N-1-i-(camu_west[N-1]-camu_west[i])\n if i == N:\n count_r = 0\n count = count_l + count_r \n count_list.append(count)\nans = min(count_list)\nprint("test")', 'N = int(input())\nS = list(input())\ncount_E = S.count("E")\ncount_W = 0\ncount = count_E + count_W\nans = count + 1\nfor e in S:\n if e == "E":\n count_E -= 1\n elif e == "w":\n count_w += 1\n if count < ans :\n ans = count\nprint(ans)', 'N = int(input())\nS = list(input())\ncount_E = S.count("E")\ncount_W = 0\ncount = count_E + count_W\nans = count + 1\nfor e in range S:\n if e == "E":\n count_E -= 1\n elif e == "W":\n count_W += 1\n if count < ans :\n ans = count\nprint(ans)', 'N = int(input())\nS = list(input())\ncount_E = S.count("E")\ncount_W = 0\ncount = count_E + count_W\nans = count + 1\nfor e in S:\n if e == "E":\n count_E -= 1\n elif e == "W":\n count_W += 1\n if count < ans :\n ans = count\nprint(ans)', 'N = int(input())\nS = list(input())\ncount_E = S.count("E")\ncount_W = 0\ncount = count_E + count_W\nans = count\nfor i in range(N):\n if i == 0 and S[i] == "E":\n count_E -= 1\n else:\n if S[i-1] == "E" and i != 1:\n count_E -= 1\n elif S[i-1] == "W":\n count_W += 1\n if count < ans :\n ans = count\nprint(ans)', 'N = int(input())\nS = list(input())\ncount_E = S.count("E")\ncount_W = 0\ncount = count_E + count_W\nans = count + 1\nfor e in range S:\n if e == "E":\n count_E -= 1\n elif e == "w":\n count_W += 1\n if count < ans :\n ans = count\nprint(ans)', 'N = int(input())\nS = input()\neast = [0]*N\nwest = [0]*N\n\ntmp1 = 0\nfor i in range(N-1,-1,-1):\n east[i] = tmp1\n if S[i] == "E":\n tmp1 += 1\n\ntmp2 = 0\nfor i in range(N):\n west[i] = tmp2\n if S[i] == "W":\n tmp2 += 1\n\nans = N\nfor e, w in zip(east,west):\n if ans > e + w:\n ans = e + w\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s334271239', 's432725904', 's441922202', 's458902280', 's707273663', 's847534010', 's520996774'] | [5920.0, 6048.0, 2940.0, 5792.0, 5792.0, 2940.0, 17596.0] | [2104.0, 72.0, 17.0, 89.0, 142.0, 17.0, 222.0] | [421, 253, 259, 253, 355, 259, 322] |
p03341 | u995062424 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ['N = int(input())\nS = input()\n\ns = S[::-1]\nw = [0]*(N+1)\ne = [0]*(N+1)\ncnt_w = 0\ncnt_e = 0\n\nfor i in range(N):\n if(S[i] == "W"):\n cnt_w += 1\n w[i+1] = cnt_w\n else:\n w[i+1] = cnt_w\n\nfor i in range(N):\n if(s[i] == "E"):\n cnt_e += 1\n e[i+1] = cnt_e\n else:\n e[i+1] = cnt_e\n\nprint(w)\nprint(e)\ne = e[::-1] \nans = 2*N\n\nfor i in range(N+1):\n ans = min(ans, e[i]+w[i])\nprint(ans)', 'N = int(input())\nS = input()\n\ns = S[::-1]\nw = [0]*(N+1)\ne = [0]*(N+1)\ncnt_w = 0\ncnt_e = 0\n\nfor i in range(N):\n if(S[i] == "W"):\n cnt_w += 1\n w[i+1] = cnt_w\n else:\n w[i+1] = cnt_w\n\nfor i in range(N):\n if(s[i] == "E"):\n cnt_e += 1\n e[i+1] = cnt_e\n else:\n e[i+1] = cnt_e\n\ne = e[::-1] \nans = 2*N\n\nfor i in range(N+1):\n ans = min(ans, e[i]+w[i])\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s307367657', 's382016227'] | [28944.0, 20152.0] | [351.0, 301.0] | [433, 415] |
p03341 | u997641430 | 2,000 | 1,048,576 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | ["n = int(input())\nS = [int(c == 'W') for c in list(input())]\nL = [0]\nfor i in range(n):\n L.append(L[-1]+S[i])\nR = [0]\nfor i in range(n-1, 0, -1):\n R.append(R[-1]+S[i])\nR.reverse()\nprint(min([L[i]+R[i] for i in range(n)]))\n", "n = int(input())\nS = [int(c == 'W') for c in list(input())]\nL = [0]\nfor i in range(n):\n L.append(L[-1]+S[i])\nR = [0]\nfor i in range(n-1, 0, -1):\n R.append(R[-1]+1-S[i])\nR.reverse()\nprint(min([L[i]+R[i] for i in range(n)]))\n"] | ['Wrong Answer', 'Accepted'] | ['s649328661', 's013154281'] | [41932.0, 42832.0] | [252.0, 259.0] | [227, 229] |
p03343 | u098240946 | 2,000 | 1,048,576 | You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times: * Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like). Let X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible. Find the smallest possible value of X-Y when the Q operations are performed optimally. | ['N,K,Q = a = map(int,input().split())\na = list(map(int,input().split()))\ninf = 10**10\nans = inf\nfor i in range(N):\n small = a[i]\n seq = []\n seqq = []\n for j in range(N):\n if a[j] < small:\n seq.append(seqq)\n seqq = []\n else:\n seqq.append(a[j])\n seq.append(seqq)\n aaa = []\n for s in seq:\n if len(s)>=K:\n s.sort()\n aaa += s[:len(s)-K+1]\n if len(aaa)>=Q:\n aaa.sort()\n ans = min(ans,aaa[Q-1]-aaa[0])\n print(i,a[i],aaa,ans)\nprint(ans)', 'N,K,Q = a = map(int,input().split())\na = list(map(int,input().split()))\ninf = 10**10\nans = inf\nfor i in range(N):\n small = a[i]\n seq = []\n seqq = []\n for j in range(N):\n if a[j] < small:\n seq.append(seqq)\n seqq = []\n else:\n seqq.append(a[j])\n seq.append(seqq)\n aaa = []\n for s in seq:\n if len(s)>=K:\n s.sort()\n aaa += s[:len(s)-K+1]\n if len(aaa)>=Q:\n aaa.sort()\n ans = min(ans,aaa[Q-1]-aaa[0])\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s256556489', 's108894240'] | [46196.0, 3316.0] | [1844.0, 1808.0] | [548, 518] |
p03343 | u174878451 | 2,000 | 1,048,576 | You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times: * Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like). Let X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible. Find the smallest possible value of X-Y when the Q operations are performed optimally. | ['def split_by_floor(arr, floor):\n ans = []\n tmp = []\n for e in arr:\n if e < floor and tmp:\n ans.append(tmp)\n tmp = []\n else:\n tmp.append(e)\n if tmp:\n ans.append(tmp)\n return ans\n\nN, K, Q = map(int, input().split())\narr = [int(x) for x in input().split()]\n\nfloor_cands = list(sorted(set(arr)))\nprint(floor_cands)\nans = floor_cands[-1] - floor_cands[0]\nprint(ans)\n\nfor floor in floor_cands:\n splitted_arrs = split_by_floor(arr, floor)\n cands = []\n for splitted in splitted_arrs:\n cands.extend(sorted(splitted)[:len(splitted) - K + 1])\n if len(cands) < Q:\n continue\n sorted_cands = list(sorted(cands))\n tmp_ans = sorted_cands[Q - 1] - sorted_cands[0]\n if ans > tmp_ans:\n ans = tmp_ans\n print(floor, tmp_ans)\n\nprint(ans)\n', 'def solve(N, K, Q, As, X):\n mins = []\n tmp = []\n for A in As:\n if A >= X:\n tmp.append(A)\n else:\n if len(tmp) >= K:\n tmp.sort()\n mins.extend(tmp[:len(tmp)-K+1])\n tmp = []\n if len(tmp) >= K:\n tmp.sort()\n mins.extend(tmp[:len(tmp)-K+1])\n\n if len(mins) < Q:\n return None\n mins.sort()\n taken = mins[:Q]\n return taken[-1] - taken[0]\n\n\nN, K, Q = map(int, input().split())\nAs = [int(x) for x in input().split()]\n\nans = -1\nfor A in As:\n cand = solve(N, K, Q, As, A)\n if cand is not None and (ans == -1 or ans > cand):\n ans = cand\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s833476257', 's702185517'] | [3604.0, 3316.0] | [1525.0, 822.0] | [830, 668] |
p03343 | u329709276 | 2,000 | 1,048,576 | You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times: * Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like). Let X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible. Find the smallest possible value of X-Y when the Q operations are performed optimally. | ['N,K,Q = map(int,input().split())\nA = tuple(map(int,input().split()))\nB = sorted(A)\nL = sorted([[i,B[i+Q-1] - B[i]] for i in range(N-Q+1)],key=lambda x:x[1])\nprint(A)\nprint(B)\nprint(L)\n\nif Q == 1:\n print(0)\n exit()\nif Q == N - K + 1:\n print(B[Q-1] - B[0])\n exit()\nif K == 1:\n print(L[0])\n exit()\nprint(B[Q-1] - B[0])\n', 'N,K,Q = map(int,input().split())\nA = list(map(int,input().split()))\nB = sorted(A) \nL = [[i,B[i+Q-1] - B[i]] for i in range(N-Q+1)] \nsL = sorted(L,key=lambda x:x[1]) \n\nif Q == 1:\n \n print(0)\n exit()\n\nif Q == N - K + 1:\n \n print(L[0][1])\n exit()\n\nif K == 1:\n \n print(sL[0][1])\n exit()\n\nif sL[0][0] == 0:\n \n print(sL[0][1])\n exit()\n\nif sL[0][1] == sL[len(sL)-1][1]:\n print(sL[0][1])\n exit()\n\n\nfor key,value in sL:\n max_value = B[key + Q - 1]\n min_value = B[key]\n C = [(i if i >= min_value else None) for i in A]\n i = 0\n j = 0\n count = 0\n min_OK = max_OK = False\n while i < N:\n if not C[i]:\n i += 1\n continue\n j = i + 1\n while j < N:\n if not C[j]:\n break\n j += 1\n tmp = (j-i) - K + 1\n if tmp < 1:\n \n i = j + 1\n continue\n sC = sorted(C[i:j])\n if not min_OK and (sC[0] == min_value):\n min_OK = True\n if not max_OK and max_value in sC[0:tmp]:\n max_OK = True\n count += tmp - len([i for i in sC[:tmp] if i > max_value])\n i = j +1\n if min_OK and max_OK and (count >= Q):\n print(value)\n exit()\n\nprint(L[0][1])\n\n'] | ['Wrong Answer', 'Accepted'] | ['s584618786', 's706517351'] | [3572.0, 3572.0] | [22.0, 731.0] | [334, 1612] |
p03343 | u652498023 | 2,000 | 1,048,576 | You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times: * Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one of them as you like). Let X and Y be the values of the largest and smallest element removed in the Q operations. You would like X-Y to be as small as possible. Find the smallest possible value of X-Y when the Q operations are performed optimally. | ['N, K, Q = map(int, input().split())\na = list(map(int, input().split()))\n\nd=[a]\na = sorted(a)\n\nans = a[Q-1] - a[0]\n\n\nwhile True:\n d_temp = list()\n sub_temp = list()\n for sub in d:\n for c in sub:\n if c != a[0]:\n sub_temp.append(c)\n else:\n d_temp.append(sub_temp)\n sub_temp = list()\n d_temp.append(sub_temp)\n sub_temp = list()\n\n d = list()\n a = list()\n for sub in d_temp:\n if len(sub) < K:\n continue\n else:\n d.append(sub)\n sub = sorted(sub)\n a.extend(sub[0:len(sub)-K+1])\n\n a.sort()\n\n if len(a) < Q:\n break\n else:\n ans = min(ans, a[Q-1] - a[0])\n\n#print(ans)\n', 'n, k, q = map(int, input().split())\na = list(map(int, input().split()))\n \nd = [a]\na.sort\nans = a[q - 1] - a[0]\n \nwhile True:\n newd = list()\n li = list()\n for sub in d:\n for c in sub:\n if c != a[0]:\n li.append(c)\n else:\n newd.append(li)\n li = list()\n newd.append(li)\n li = list()\n \n d = list()\n a = list()\n for li in newd:\n if len(li) < k:\n continue\n else:\n d.append(li)\n li.sort()\n a.extend(li[0:len(li) - k + 1])\n \n a.sort()\n \n if len(a) >= q:\n ans = min(a[q - 1] - a[0], ans)\n else:\n break\nprint(ans)\n', 'N, K, Q = map(int, input().split())\na = list(map(int, input().split()))\n\nd = [a]\na = sorted(a)\na.sort()\nans = a[Q-1] - a[0]\n\nwhile True:\n d_temp = list()\n sub_temp = list()\n for sub in d:\n for c in sub:\n if c != a[0]:\n sub_temp.append(c)\n else:\n d_temp.append(sub_temp)\n sub_temp = list()\n d_temp.append(sub_temp)\n sub_temp = list()\n\n d = list()\n a = list()\n for sub in d_temp:\n if len(sub) < K:\n continue\n else:\n d.append(sub)\n sub = sorted(sub)\n a.extend(sub[0:len(sub)-K+1])\n\n a = sorted(a)\n\n if len(a) < Q:\n break\n else:\n ans = min(ans, a[Q-1] - a[0])\n\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s848178344', 's920207117', 's813787994'] | [3188.0, 3188.0, 3316.0] | [918.0, 415.0, 832.0] | [636, 690, 649] |
p03345 | u002459665 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['n = int(input())\n\nl = len(str(n))\n# if n < 10:\n# ans = n\n# else:\nans1 = 9 * (l-1) + int(str(n)[0]) - 1\nans2 = sum([int(x) for x in list(str(n))])\nans = max(ans1, ans2)\n# print(ans1, ans2)\nprint(ans)', "A, B, C, K = list(map(int, input().split()))\n\nif K % 2 != 0:\n r = B - A\nelse:\n r = A - B\n\nif abs(r) > 10 ** 18:\n print('Unfair')\nelse:\n print(r)"] | ['Runtime Error', 'Accepted'] | ['s275177005', 's658634538'] | [3060.0, 2940.0] | [17.0, 17.0] | [202, 156] |
p03345 | u021916304 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\na,b,c,k = iim()\nprint((a-b)*(-1)**(k-1))', 'def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\na,b,c,k = iim()\nk = k%2\nprint(int((a-b)*(-1)**(k-1)))', 'def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\na,b,c,k = iim()\nk = k%2\nprint(int((a-b)*(-1)**k))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s276402630', 's877150593', 's890861375'] | [3060.0, 3060.0, 3060.0] | [17.0, 17.0, 17.0] | [250, 263, 259] |
p03345 | u048176319 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, input().split())\n\nif K % 2 == 0:\n ans = B - A\n if abs(ans) > 10**18:\n print("Unfair")\n else:\n print(ans)\nelse:\n ans = A - B\n if abs(ans) > 10**18:\n print("Unfair")\n else:\n print(ans)', 'A, B, C, K = map(int, input().split())\n\nif K % 2 == 1:\n ans = B - A\n if abs(ans) > 10**18:\n print("Unfair")\n else:\n print(ans)\nelse:\n ans = A - B\n if abs(ans) > 10**18:\n print("Unfair")\n else:\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s428171197', 's002442538'] | [3060.0, 2940.0] | [17.0, 18.0] | [250, 250] |
p03345 | u064408584 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['n=int(input())\na=[]\nfor i in range(n):\n a.append([int(input()),i+1])\na=sorted(a,key=lambda x:x[0])\n\nans=0\ncount=0\nbef=0\nfor i,j in a:\n if j>bef:\n count+=1\n ans=max(ans,count)\n else:\n count=1\n bef=j\nprint(n-ans)', "a,b,c,k=map(int,input().split())\nif abs(a-b)>10**18: print('Unfair')\nelse:\n if k%2 ==0:\n print(a-b)\n else:print(b-a)"] | ['Runtime Error', 'Accepted'] | ['s579556534', 's546370255'] | [3064.0, 2940.0] | [17.0, 17.0] | [244, 129] |
p03345 | u083874202 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["print('Unfair')", 'A, B, C, K = map(int, input().split())\n\n\nif K % 2 == 0:\n print(A-B)\nelse:\n print(B-A)'] | ['Wrong Answer', 'Accepted'] | ['s065640147', 's512761580'] | [2940.0, 2940.0] | [17.0, 17.0] | [15, 91] |
p03345 | u090406054 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k=map(int,input().split())\nif a-b>10**18:\n print("Unfair")\nelse:\n if k%2==1:\n print(a-b)\n else:\n print(b-a)\n \n', 'a,b,c,k=map(int,input().split())\nif a-b>10**18:\n print("Unfair")\nelse:\n if k%2=1:\n print(a-b)\n else:\n print(b-a)\n \n', 'a,b,c,k=map(int,input().split())\nif a-b>10**8:\n print("Unfair")\nelse:\n print(a-b if k%2=1 else b-a)\n \n', 'a,b,c,k=map(int,input().split())\nif a-b>10**18:\n print("Unfair")\nelse:\n if k%2==0:\n print(a-b)\n else:\n print(b-a)\n \n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s089645827', 's388821367', 's408899215', 's979966850'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0, 17.0] | [126, 125, 105, 126] |
p03345 | u102960641 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k = map(int, input().split())\nprint(a-b) if k % 2 else print(b-a)', 'a,b,c,k = map(int, input().split())\nprint(b-a) if k % 2 else print(a-b)\n'] | ['Wrong Answer', 'Accepted'] | ['s156519551', 's413063090'] | [2940.0, 2940.0] | [18.0, 18.0] | [71, 72] |
p03345 | u131453093 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import math\nA, B, C, K = map(int, input().split())\n\nend = int(math.log2(10**18))\n\nfor _ in range(end+1):\n A, B, C = B+C, A+C, A+B\n if abs(A-B) > 10**18:\n print("Unfair")\n exit()\n\nprint(A-B)', 'import math\nA, B, C, K = map(int, input().split())\n\nabs_ans = abs(A-B)\n\nif A <= B:\n if K % 2 == 0:\n print(-abs_ans)\n else:\n print(abs_ans)\nelse:\n if K % 2 == 0:\n print(abs_ans)\n else:\n print(-abs_ans)'] | ['Wrong Answer', 'Accepted'] | ['s432928767', 's908474438'] | [9140.0, 9108.0] | [28.0, 27.0] | [209, 240] |
p03345 | u133886644 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import sys\ninput = sys.stdin.readline\n\nA, B, C, K, = map(int, input().split())\n \nprint(A - B)', 'import sys\ninput = sys.stdin.readline\n\nA, B, C, K, = map(int, input().split())\n\nif K % 2 == 0:\n if A < B:\n print(A - B)\n else:\n print(abs(A - B))\nelse:\n print(A - B)', 'import sys\ninput = sys.stdin.readline\n\nL = [int(v) for v in input().split()]\n\nif L[3] % 2 == 0:\n print(L[0] - L[1])\nelse:\n print(L[1] - L[0])'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s060738937', 's576335992', 's225999113'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [96, 188, 147] |
p03345 | u135265051 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['# import math\n# import statistics\n#a=input()\n#b,c=int(input()),int(input())\n# c=[]\n\n# c.append(i)\ne1,e2,e3 ,e4= map(int,input().split())\n#K = input()\n# f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n\nif e4%2==0:\n print(-(e1-e4))\nelif e4%2==1:\n print(e1-e2)\nelif abs(e1-e2)>=10**18:\n print("Unfair")', '# import math\n# import statistics\n#a=input()\n#b,c=int(input()),int(input())\n# c=[]\n\n# c.append(i)\ne1,e2,e3 ,e4= map(int,input().split())\n#K = input()\n# f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n\nif e4%2==0:\n print(-(e1-e2))\nelif e4%2==1:\n print(e1-e2)\nelif abs(e1-e2)>=10**18:\n print("Unfair")', '# import math\n# import statistics\n#a=input()\n#b,c=int(input()),int(input())\n# c=[]\n\n# c.append(i)\ne1,e2,e3 ,e4= map(int,input().split())\n#K = input()\n# f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n\nif e4%2==0 or e4==0:\n print(e1-e2)\nelif e4%2==1 :\n print(-(e1-e2))\nelif abs(e1-e2)>=10**18:\n print("Unfair")'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s009334296', 's885149006', 's656004524'] | [9108.0, 9100.0, 8888.0] | [28.0, 28.0, 27.0] | [344, 344, 354] |
p03345 | u136090046 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import math\n\na, b, c, k = map(int, input().split())\n\nif k % 2 != 1:\n print(a - b if abs(math.log10(a-b)) <= 18 else "Unfair")\nelse:\n print(b - a if abs(math.log10(a-b)) <= 18 else "Unfair")\n', 'import math\n\na, b, c, k = map(int, input().split())\n\nif k % 2 != 1:\n if a-b == 0:\n print(0)\n else:\n print(a - b if abs(math.log10(abs(a-b))) <= 18 else "Unfair")\nelse:\n if a-b == 0:\n print(0)\n else:\n print(b - a if abs(math.log10(abs(a-b))) <= 18 else "Unfair")\n'] | ['Runtime Error', 'Accepted'] | ['s550901102', 's448029438'] | [2940.0, 3060.0] | [17.0, 18.0] | [196, 302] |
p03345 | u136395536 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A,B,C,K = (int(i) for i in input().split())\n\nif K==0:\n ans = B-A\nelif K==1:\n tmpA = A\n tmpB = B\n A = B+C\n B= tmpA + C\n C = tmpA + tmpB\n ans = B-A\nelse:\n ans = 0\n\nprint(ans)', 'A,B,C,K = (int(i) for i in input().split())\n\n\nif K%2 == 0:\n ans = A-B\nelse:\n ans = B-A\n\nif ans>10**18:\n print("Unfair")\nelse:\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s506548466', 's463874888'] | [3060.0, 2940.0] | [18.0, 17.0] | [196, 149] |
p03345 | u169138653 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k=map(int,input().split())\nprint((a-b)*(-1)**(k-1))', 'a,b,c,k=map(int,input().split())\nprint((a-b)*(-1)**k)\n'] | ['Wrong Answer', 'Accepted'] | ['s539090517', 's269510317'] | [2940.0, 2940.0] | [17.0, 17.0] | [57, 54] |
p03345 | u176463385 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['n = int(input())\nseq = []\nfor i in range(n):\n k=int(input())\n seq.append(k)\ni=0\ncount =0\nwhile i<n:\n k=i+1\n while k<n:\n if seq[k]-seq[i]==k-i:\n count = count + 1\n k=k+1\n i=i+1\n\nprint(n-count)', "a, b, c, k = map(int, input().split())\nd=(a-b)*(-1)**k\n\nif abs(d) < 10**18:\n print (d)\nelse:\n print('Unfair')"] | ['Runtime Error', 'Accepted'] | ['s880107405', 's081365526'] | [3060.0, 2940.0] | [17.0, 17.0] | [207, 109] |
p03345 | u183840468 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a,b,c,n = [int(i) for i in input().split()]\n\nif n%2 == 1:\n print((a-b) if (a-b) < 10**18 else 'Unfair')\nelse:\n print(abs(a-b) if abs((a-b)) < 10**18 else 'Unfair')\n", "a,b,c,n = [int(i) for i in input().split()]\n\nif n%2 == 1:\n print(a-b if abs((a-b)) < 10**18 else 'Unfair')\nelse:\n print(b-a if abs((a-b)) < 10**18 else 'Unfair')\n", "a,b,c,n = [int(i) for i in input().split()]\n\nif n%2 == 1:\n print((a-b) if (a-b) <= 10**18 else 'Unfair')\nelse:\n print(abs(a-b) if abs((a-b)) <= 10**18 else 'Unfair')\n", "a,b,c,n = [int(i) for i in input().split()]\n\nif n%2 == 1:\n print(b-a if abs(b-a) < 10**18 else 'Unfair')\nelse:\n print(a-b if abs(a-b) < 10**18 else 'Unfair')"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s473579573', 's739040709', 's944583871', 's046284880'] | [2940.0, 2940.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 17.0] | [170, 168, 172, 163] |
p03345 | u201234972 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['N = int( input())\nA = [ int( input()) for _ in range(N)]\nnow = 0\nans = 0\nif A[0] != 0:\n ans = -1\nelse:\n for i in range(1,N):\n a = A[i]\n # if a > i:\n # ans = -1\n # break\n #el\n if now + 1 == a:\n ans += 1\n now += 1\n elif now >= a:\n ans += a\n now = a\n else:\n ans = -1\n break\nprint(ans)\n', 'a, b, c, k = map( int, input().split())\nif k%2 == 0:\n print(a-b)\nelse:\n print(b-a)'] | ['Runtime Error', 'Accepted'] | ['s690714038', 's487530171'] | [3060.0, 2940.0] | [17.0, 17.0] | [403, 88] |
p03345 | u212328220 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a,b,c,k = map(int,input().split())\n\nx = abs(a-b)\nif x > 10**18:\n print('Unfair')\nelse:\n print(a-b)", "a,b,c,k = map(int,input().split())\n\nx = abs(a-b)\nif x > 10**18:\n print('Unfair')\nelse:\n if k % 2 == 0:\n print(a - b)\n else:\n print(b-a)"] | ['Wrong Answer', 'Accepted'] | ['s421203811', 's935749446'] | [9148.0, 9120.0] | [31.0, 29.0] | [104, 158] |
p03345 | u222207357 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = map(int, input().split())\n\nif result >=th:\n print("Unfair")\nelif k == 0:\n print(a - b)\nelse:\n print(b - a)', 'a, b, c, k = map(int, input().split())\n\nif abs(a - b) >= 10e18:\n print("Unfair")\nelif k//2 == 0:\n print(a - b)\nelse:\n print(b - a)', 'a, b, c, k = map(int, input().split())\n\nif abs(a - b) >=th:\n print("Unfair")\nelif k == 0:\n print(a - b)\nelse:\n print(b - a)', 'a, b, c, k = map(int, input().split())\n\nif abs(a - b) >= 10e18:\n print("Unfair")\nelif k%2 == 0:\n print(a - b)\nelse:\n print(b - a)'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s083043758', 's646007077', 's648918415', 's339774189'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0] | [128, 139, 132, 138] |
p03345 | u227170240 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = map(int, input().split())\nmemo = []\ndef culc(n, aa, bb, cc):\n global a\n global b\n global c\n if abs(a*aa+b*bb+c*cc - a*bb+b*aa+c*cc) > 10**18:\n print("Unfair")\n return 10**18\n if n == k:\n return a*aa+b*bb+c*cc - (a*bb+b*aa+c*cc)\n\n if n % 2 == 1:\n return culc(n+1, (aa-1)*2, bb*2+1, cc*2+1)\n else: \n return culc(n+1, (aa+1)*2, bb*2-1, cc*2-1)\n\nans = culc(0, 1, 0, 0)\nif ans < 10**18:\n print(ans)\n\n', 'a, b, c, k = map(int, input().split())\nif abs(a-b) > 10**18:\n print("Unfair")\nelif k % 2 == 0:\n print(a-b)\nelse:\n print(b-a)\n'] | ['Wrong Answer', 'Accepted'] | ['s943563015', 's978604712'] | [3064.0, 2940.0] | [17.0, 17.0] | [470, 134] |
p03345 | u240733052 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import numpy as np\n\nline = input()\n\nN = int(line)\nA = np.array([0]*N)\n\nfor i in range(N):\n line = input()\n A[i] = int(line)\n\n \ndef IsNotPossible(A):\n foo = 0\n \n if A[0] != 0:\n foo = 1\n return foo\n \n else:\n for i in range(N-1):\n if A[i] + 1 < A[i+1]:\n foo = 1\n break\n return foo\n\nif IsNotPossible(A):\n print(-1)\n \nelse:\n count = 0\n for i in range(N-1):\n a = A[N-1-i]\n \n if a == 0:\n continue\n elif a == A[N-2-i] + 1:\n count += 1\n else:\n count += a\n \n print(count)', 'line = input()\n\nN = int(line)\nA = np.array([0]*N)\n\nfor i in range(N):\n line = input()\n A[i] = int(line)\n\ndef IsNotPossible(A):\n foo = 0\n \n if A[0] != 0:\n foo = 1\n \n else:\n for i in range(N-1):\n if A[i] + 1 < A[i+1]:\n foo = 1\n break\n \n return foo\n\nif IsNotPossible(A):\n print(-1)\n \nelse:\n count = 0\n for i in range(N-1):\n a = A[N-1-i]\n \n if a == 0:\n continue\n elif a == A[N-2-i] + 1:\n count += 1\n else:\n count += a\n \n print(count)', 'line = input()\n\nN = int(line)\nA = np.array([0]*N)\n\nfor i in range(N):\n line = input()\n A[i] = int(line)\n\n \ndef IsNotPossible(A):\n foo = 0\n \n if A[0] != 0:\n foo = 1\n return foo\n \n else:\n for i in range(N-1):\n if A[i] + 1 < A[i+1]:\n foo = 1\n break\n return foo\n\nif IsNotPossible(A):\n print(-1)\n \nelse:\n count = 0\n for i in range(N-1):\n a = A[N-1-i]\n \n if a == 0:\n continue\n elif a == A[N-2-i] + 1:\n count += 1\n else:\n count += a\n \n print(count)', 'line = input().split()\n\nA = int( line[0] )\nB = int( line[1] )\nC = int( line[2] )\nK = int( line[3] )\n\nif K % 2 == 0:\n print(A-B)\n \nelse:\n print(B-A)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s273902541', 's509371425', 's699221547', 's558812492'] | [12856.0, 3064.0, 3064.0, 2940.0] | [157.0, 19.0, 17.0, 18.0] | [653, 610, 633, 156] |
p03345 | u253481827 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a,b,c,k = map(int, input().split())\n\nans = a - b\n\nif(k % 2 == 1):\n ans = abs(ans)\n\nif(len(ans) >= 18):\n ans = 'Unfair'\n\nprint(ans)", 'a,b,c,k = map(int, input().split())\n\nans = a - b\n\nif(k % 2 == 1):\n ans = b - a\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s303761001', 's373502348'] | [9072.0, 9104.0] | [23.0, 27.0] | [136, 93] |
p03345 | u276204978 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["A, B, C, K = map(int, input().split())\n\nif A == B == C:\n print(0)\nelse: \n for _ in range(K):\n a = B + C\n b = A + C\n c = A + C\n A = a\n B = b\n C = c\n\n if A - B > 10e18:\n print('Unfair')\n else:\n print(A)", "A, B, C, K = map(int, input().split())\n\nif K % 2 == 0:\n if A - B > 10e18:\n print('Unfair')\n else:\n print(A - B)\nelse:\n if B - A > 10e18:\n print('Unfair')\n else:\n print(B - A)"] | ['Wrong Answer', 'Accepted'] | ['s970015719', 's125397313'] | [3188.0, 2940.0] | [2104.0, 17.0] | [269, 214] |
p03345 | u280978334 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k = map(int,input().split())\nprint(a-b if a-b < 10**18 else "unfair")', 'a,b,c,k = map(int,input().split())\nif abs(a-b) < 10**18:\n if k%2==0:\n print(b-a)\n else:\n print(a-b)\nelse:\n print("unfair")', 'a,b,c,k = map(int,input().split())\nif abs(a-b) < 10**18:\n if k%2==1:\n print(b-a)\n else:\n print(a-b)\nelse:\n print("unfair")'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s485727564', 's645302162', 's071510977'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 18.0] | [75, 145, 145] |
p03345 | u281303342 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A,B,C,K = map(int,input().split())\nAns = 0\nif K%2==1:\n Ans = (B-A\nelse:\n Ans = A-B\nprint(Ans if Ans <= 10**18 else "Unfair")', 'A,B,C,K = map(int,input().split())\nAns = 0\nif K%2==1:\n Ans = B-A\nelse:\n Ans = A-B\nprint(Ans if Ans <= 10**18 else "Unfair")'] | ['Runtime Error', 'Accepted'] | ['s480013538', 's426702330'] | [2940.0, 3316.0] | [17.0, 20.0] | [130, 129] |
p03345 | u297046168 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A = list(map(int,input().split()))\nif A[3] == 0 or A[3]%2 == 0:\n print(A[0]-A{1])\nelse:\n print(A[1]-A[0])', 'A = list(map(int,input().split()))\nif A[3] == 0:\n print(A[0]-A[1])\nelif A[3]%2 == 0:\n print(A[0]-A[1])\nelse:\n print(A[1]-A[0])'] | ['Runtime Error', 'Accepted'] | ['s370487351', 's059821678'] | [2940.0, 3064.0] | [17.0, 18.0] | [111, 135] |
p03345 | u325282913 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, input().split())\nif K % 2 == 1:\n print(A-B)\nelse:\n print(B-A)', 'A, B, C, K = map(int, input().split())\nprint(A-B)', 'A, B, C, K = map(int, input().split())\nif K % 2 == 1:\n print(B-A)\nelse:\n print(A-B)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s821059596', 's883430114', 's569954146'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0] | [89, 49, 89] |
p03345 | u325956328 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['from sys import exit\n\nA, B, C, K = map(int, input().split())\n\n\nif A == B:\n print(0)\n exit()\n\nif abs(A - B) > 10 ** 18:\n print("Unfair")\n exit()\n\nsign = (A - B) // abs(A - B)\n\nprint(A, B, C, sign)\n\nif K % 2 == 0:\n print(abs(A - B) * sign)\nelse:\n print(abs(A - B) * sign * (-1))\n', 'from sys import exit\n\nA, B, C, K = map(int, input().split())\n\n\nif A == B:\n print(0)\n exit()\n\nif abs(A - B) > 10 ** 18:\n print("Unfair")\n exit()\n\nsign = (A - B) // abs(A - B)\n\n\nif K % 2 == 0:\n print(abs(A - B) * sign)\nelse:\n print(abs(A - B) * sign * (-1))\n'] | ['Wrong Answer', 'Accepted'] | ['s934838478', 's206111727'] | [3060.0, 2940.0] | [17.0, 17.0] | [295, 274] |
p03345 | u329706129 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["print('Unfair')", 'A, B, C, K = map(int, input().split())\nprint(B - A) if(K % 2) else print(A - B)\n'] | ['Wrong Answer', 'Accepted'] | ['s257481424', 's367719864'] | [2940.0, 2940.0] | [17.0, 17.0] | [15, 80] |
p03345 | u368563078 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["A,B,C,K = map(int,input().split())\nN = [A,B,C]\nN2 = N[:]\nfor i in range(K):\n N2[0] = N[1] + N[2]\n N2[1] = N[0] + N[2]\n N2[2] = N[0] + N[1]\n N = N2.copy\nprint(N2)\nans = N2[0] - N2[1]\nif abs(ans) > 10**18:\n print('Unfair')\nelse:\n print(ans)", 'a,b,c,k = map(int, input().split())\ncheak = 10**18\nans = a-b\ndef calc(a,b,c,k):\n if a == b:\n return 0\n elif ans < 0:\n if k % 2 == 1:\n return -ans\n else:\n return ans\n else:\n if k % 2 == 1:\n return -ans\n else:\n return ans\nans_n = calc(a,b,c,k)\nif ans_n > cheak:\n print("Unfair")\nelse:\n print(ans_n)\n'] | ['Runtime Error', 'Accepted'] | ['s304857037', 's601954089'] | [3064.0, 3060.0] | [17.0, 17.0] | [256, 391] |
p03345 | u370331385 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["A,B,C,K = map(int,input().split())\nif(K%2 == 0): ans = A-B\nelse: ans = B-A\n#if(abs(ans) > 10**8): \n#else: print(ans)\nprint('Unfair')", 'A,B,C,K = map(int,input().split())\nif(K%2 == 0): ans = A-B\nelse: ans = B-A\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s977060550', 's394276421'] | [2940.0, 2940.0] | [17.0, 17.0] | [132, 85] |
p03345 | u384679440 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, input().split())\nfor i in range(K):\n\ttemp_a = A\n\ttemp_b = B\n\ttemp_c = C\n\tprint(A, B, C)\n\tA = temp_b + temp_c\n\tB = temp_a + temp_c\n\tC = temp_a + temp_b\nif abs(A - B) <= 10 ** 18:\n\tprint(A - B)\nelse:\n\tprint("unfair")', 'A, B, C, K = map(int, input().split())\nif K % 2 != 0:\n\tres = B - A\nelse:\n\tres = A - B\nif res >= 10 ** 18:\n\tprint("Unfair")\nelse:\n\tprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s359947512', 's118441821'] | [56436.0, 2940.0] | [2103.0, 17.0] | [236, 140] |
p03345 | u391675400 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k = list(map(int,input().split()))\t\n\n if result > 10 **18:\n print("Unfair")\nelif k % 2 == 0:\n print(result)\nelif l % 2 == 1:\n result = result * -1\n print(result)', 'a,b,c,k = list(map(int,input().split()))\t\nx = 10 **18\nresult = a - b\nif result > x:\n print("Unfair")\nelif k % 2 == 0:\n print(result)\nelif k % 2 == 1:\n result = result * -1\n print(result)\n'] | ['Runtime Error', 'Accepted'] | ['s528104462', 's312301750'] | [3064.0, 2940.0] | [17.0, 19.0] | [179, 199] |
p03345 | u408375121 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = map(int, input().split())\nif k % 2 == 0:\n ans = a-b\nelse:\n ans = b-a', 'a, b, c, k = map(int, input().split())\nif k % 2 == 0:\n ans = a-b\nelse:\n ans = b-a\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s099607444', 's619841612'] | [2940.0, 2940.0] | [17.0, 17.0] | [83, 94] |
p03345 | u408620326 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["# 0:a, b, c, a-b\n# 1:b+c, a+c, a+b, b-a\n# 2:2a+b+c, a+2b+c, a+b+2c, a-b\n# 3:2a+3b+3c, 3a+2b+3c, 3a+3b+2c, b-a\n# 4:6a+5b+5c, 5a+6b+5c, 5a+5b+6c, a-b\nA, B, C, K = [int(x) for x in input().strip().split()]\nans = (a-b)*-1**(K%2)\nif ans > 10 ** 18:\n print('Unfair')\nelse:\n print(ans)\n ", "# 0:a, b, c, a-b\n# 1:b+c, a+c, a+b, b-a\n# 2:2a+b+c, a+2b+c, a+b+2c, a-b\n# 3:2a+3b+3c, 3a+2b+3c, 3a+3b+2c, b-a\n# 4:6a+5b+5c, 5a+6b+5c, 5a+5b+6c, a-b\nA, B, C, K = [int(x) for x in input().strip().split()]\nans = (A-B)*(-1)**(K%2)\nif ans > 10 ** 18:\n print('Unfair')\nelse:\n print(ans)\n"] | ['Runtime Error', 'Accepted'] | ['s178259686', 's885197888'] | [2940.0, 2940.0] | [17.0, 18.0] | [283, 283] |
p03345 | u411923565 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['if K%2 == 0:\n ans = A - B \nelse:\n ans = B - A\nprint(ans)', 'A,B,C,K = map(int,input().split())\n\nif K%2 == 0:\n ans = A - B \nelse:\n ans = B - A\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s319763955', 's407810508'] | [9024.0, 9076.0] | [25.0, 29.0] | [62, 98] |
p03345 | u422104747 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['s=input().split()\nprint((int(s[0])-int(s[1]))*(-1)**s[3])', 's=input().split()\nprint((int(s[0])-int(s[1]))*(-1)**int(s[3]))'] | ['Runtime Error', 'Accepted'] | ['s184204964', 's480403503'] | [2940.0, 2940.0] | [17.0, 24.0] | [57, 62] |
p03345 | u427344224 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, input().split())\n\nif K % 2 == 0:\n print(B-A)\nelse:\n print(A-B)', 'A, B, C, K = map(int, input().split())\n\nif K % 2 == 0:\n print(A-B)\nelse:\n print(B-A)'] | ['Wrong Answer', 'Accepted'] | ['s324512075', 's158805265'] | [2940.0, 2940.0] | [17.0, 17.0] | [90, 90] |
p03345 | u430928274 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = map(int, input().split())\nans = a -b\nif abs(ans) > 1e18 :\n print("Unfair")\nelif k % 2 == 1 :\n print(ans)\nelse :\n print(-ans)\n', 'a, b, c, k = map(int, input().split())\nans = a - b\nif abs(ans) > 1e18 :\n print("Unfair")\nelif k % 2 == 0 :\n print(ans)\nelse :\n print(-ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s235525833', 's812149724'] | [9156.0, 9152.0] | [32.0, 24.0] | [147, 148] |
p03345 | u434208140 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k=map(int,input().input())\nprint((a-b)*(-1)**k)', 'a,b,c,k=map(int,input().split())\nprint((a-b)*(-1)**k)'] | ['Runtime Error', 'Accepted'] | ['s432151843', 's096357821'] | [2940.0, 2940.0] | [18.0, 17.0] | [53, 53] |
p03345 | u452786862 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['\nn = int(input())\np = [int(input()) for _ in range(n)]\n\n\nlsi = list(0 for _ in range(n+1))\n\nfor i in range(n):\n num = p[i]\n lsi[num] = 1\n\n for j in range(num):\n if j + lsi[j] == num:\n lsi[j] += 1\n\nprint(n - max(lsi))', '\n\na, b, c, k = map(int, input().split())\n\nif k % 2 == 0:\n if a - b > pow(10,18):\n print("Unfair")\n else:\n print(a - b)\nelse:\n if b - a > pow(10,18):\n print("Unfair")\n else:\n print(b - a)\n'] | ['Runtime Error', 'Accepted'] | ['s100579640', 's441804434'] | [3060.0, 2940.0] | [17.0, 18.0] | [243, 227] |
p03345 | u539517139 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k=map(int,input().split())\nprint((b-a)*(-1)**k%2==0)', 'a,b,c,k=map(int,input().split());print((-1)**(k%2==0)*(b-a))'] | ['Wrong Answer', 'Accepted'] | ['s179869169', 's587221118'] | [2940.0, 2940.0] | [17.0, 17.0] | [58, 60] |
p03345 | u541161485 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import math\na, b, c, k = map(int, input().split())\n\nprint(a - b)\n\n\t\t', 'import math\na, b, c, k = map(int, input().split())\n\nif k % 2 == 0:\n\tprint(a - b)\nelse:\n\tprint(b - a)\n\n\t\t'] | ['Wrong Answer', 'Accepted'] | ['s149597376', 's311688267'] | [2940.0, 2940.0] | [17.0, 17.0] | [68, 104] |
p03345 | u550943777 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k =map(int,input().split())\nif abs(a-b) >= 10**8:\n print("Unfair")\nelse:\n print(a-b if k%2==0 else b-a)0', 'a,b,c,k =map(int,input().split())\nif abs(a-b) > 10**18:\n print("Unfair")\nelse:\n print(a-b if k%2==0 else b-a)\n'] | ['Runtime Error', 'Accepted'] | ['s643578665', 's975542439'] | [2940.0, 2940.0] | [18.0, 18.0] | [112, 112] |
p03345 | u552122040 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import math\n\na, b, c, k = list(map(int, input().split()))\n\nfor i in range(k):\n m = b + c\n n = a + c\n o = a + b\n a = m\n b = n\n c = o\n\nif math.fabs(a - b) > 1.0e18:\n print("Unfair")\nelse:\n print(math.fabs(int(a - b)))\n', 'a, b, c, k = list(map(int, input().split()))\n\ndiff = (a - b) * ((-1) ** k)\n\nif diff > 1.0e18:\n print("Unfair")\nelse:\n print(diff)\n'] | ['Wrong Answer', 'Accepted'] | ['s329961930', 's276580311'] | [3316.0, 2940.0] | [2104.0, 17.0] | [224, 132] |
p03345 | u568955728 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['inputs = split(input())\nans = inputs[0] - inputs[1] if inputs[3] % 2 == 0 else inputs[1] - inputs[0]\nif ans > 10**18:\n print("Unfair")\nelse:\n print(ans)', 'inputs = [int(c) for c in input().split()]\nans = inputs[0] - inputs[1] if inputs[3] % 2 == 0 else inputs[1] - inputs[0]\nif ans > 10**18:\n print("Unfair")\nelse:\n print(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s018752581', 's477947406'] | [3060.0, 2940.0] | [17.0, 17.0] | [154, 174] |
p03345 | u581403769 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a, b, c, k = map(int, input().split())\n\nfor i in range(10**18):\n A = a\n B = b\n C = c\n a = B + C\n b = A + C\n c = A + B\n if i = k - 1:\n break\nif abs(a - b) <= 10**18:\n print(a - b)\nelse:\n print('Unfair')", "a, b, c, k = map(int, input().split())\nx = a - b\nif x > 10**18:\n print('Unfair')\nelif k % 2 == 0:\n print(x)\nelse:\n print(-x)"] | ['Runtime Error', 'Accepted'] | ['s603854607', 's727536664'] | [2940.0, 2940.0] | [17.0, 17.0] | [235, 133] |
p03345 | u591503175 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['def resolve():\n \'\'\'\n code here\n \'\'\'\n A, B, C, K = [int(item) for item in input().split()]\n\n if K % 2 == 0:\n res = B - A\n else:\n res = A -B\n\n\n print(A-B)\nif __name__ == "__main__":\n resolve()\n', 'def resolve():\n \'\'\'\n code here\n \'\'\'\n A, B, C, K = [int(item) for item in input().split()]\n\n if K % 2 == 0:\n res = B - A\n else:\n res = A -B\n\n\n print(res)\nif __name__ == "__main__":\n resolve()\n', 'def resolve():\n \'\'\'\n code here\n \'\'\'\n A, B, C, K = [int(item) for item in input().split()]\n\n if K > 0:\n if K % 2 == 0:\n res = B - A\n else:\n res = A -B\n else:\n res = A -B\n\n print(A-B)\nif __name__ == "__main__":\n resolve()\n', 'def resolve():\n \'\'\'\n code here\n \'\'\'\n A, B, C, K = [int(item) for item in input().split()]\n\n if K % 2 == 0:\n res = A- B\n else:\n res = B -A\n\n print(res)\nif __name__ == "__main__":\n resolve()\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s004324770', 's193175736', 's595185378', 's634350633'] | [9168.0, 9160.0, 9072.0, 9108.0] | [25.0, 29.0, 31.0, 29.0] | [229, 229, 287, 227] |
p03345 | u603234915 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, input().split())\n\nprint(A-B)\n', 'A, B, C, K = map(int, input().split())\n\nsub = A - B\nif K % 2 == 1:\n sub *= -1\nprint(sub)\n'] | ['Wrong Answer', 'Accepted'] | ['s320408841', 's544161929'] | [2940.0, 2940.0] | [17.0, 17.0] | [51, 92] |
p03345 | u609176437 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k=map(int,input().split())\n\nif k%2 == 0:\n if abs(a-b)<=10**18:print(a-b)\nelif ans(b-a)<=10**18:print(b-a)\nelse:print("Unfair") ', 'a,b,c,k=map(int,input().split())\n\nif k%2 == 0:\n if abs(a-b)<=10**18:print(a-b)\nelif ans(b-a)<=10*18:print(b-a)\nelse:print("Unfair") ', 'a,b,c,k=map(int,input().split())\n\nif k%2 == 0:\n if abs(a-b)<=10**18:print(a-b)\n else:print("Unfair")\nelse:\n if ans(b-a)<=10*18:print(b-a)\n else:print("Unfair")', 'a,b,c,k=map(int,input().split())\n\nif k%2 == 0 and abs(a-b)<=10**8:print(a-b)\nelif k%2 != 0 abs(b-a)<=10**8:print(b-a)\nelse:print("Unfair")', 'a,b,c,k=map(int,input().split())\n\nif k%2 == 0 and abs(a-b)<=10**18:print(a-b)\nelif k%2 != 0 and ans(b-a)<=10**18:print(b-a)\nelse:print("Unfair")', 'a,b,c,k=map(int,input().split())\n\nif k%2 == 0:\n if abs(a-b)<=10**18:print(a-b)\n else:print("Unfair")\n \nelse:\n if ans(b-a)<=10*18:print(b-a)\n else:print("Unfair")', 'a,b,c,k=map(int,input().split())\n\nif k%2 == 0 and abs(a-b)<=10**18:print(a-b)\nelif k%2 != 0 and abs(b-a)<=10**18:print(b-a)\nelse:print("Unfair")'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s081374403', 's246539699', 's496452327', 's555103313', 's587167902', 's614975819', 's647483856'] | [9036.0, 9196.0, 9044.0, 8952.0, 9196.0, 9172.0, 9108.0] | [25.0, 33.0, 28.0, 27.0, 28.0, 25.0, 25.0] | [136, 135, 167, 138, 144, 171, 144] |
p03345 | u609814378 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import sys\nA,B,C,K = map(int, input().split())\n\nans_lis = [A,B,C]\n\nfor i in range(K):\n if K==0:\n print((ans_lis[0])-(ans_lis[1]))\n break\n ans_lis2 =[0,0,0]\n ans_lis2[0] = ans_lis[1] + ans_lis[2]\n ans_lis2[1] = ans_lis[0] + ans_lis[2]\n ans_lis2[2] = ans_lis[1] + ans_lis[0] \n\n ans_lis = ans_lis2\n \n if abs((ans_lis[0]) - (ans_lis[1])) < 10**18:\n print("Unfair")\n break\n \n if i == K-1:\n print((ans_lis[0]) - (ans_lis[1]))\n break', 'A, B, C, K = map(int, input().split())\nif K % 2 == 0:\n print(A - B)\nelse:\n print(B - A)\n'] | ['Wrong Answer', 'Accepted'] | ['s923513652', 's244655166'] | [3064.0, 2940.0] | [17.0, 17.0] | [498, 94] |
p03345 | u611090896 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k = map(int,input().split())\ncount = 0\nif k = 0:\n print(a-b)\n exit()\n\nwhile count = k:\n a1 = a\n b1 = b\n c1 = c\n a = b1+c1\n b = a1+c1\n c = a1+b1\n count +=1\nprint(a-b)\n', "a,b,c,k = map(int,input().split())\ncount = 0\nif k == 0:\n if abs(a-b) >= 10**8:\n print('Unfair')\n else:\n print(a-b)\n exit()\n\nwhile count == k:\n a1 = a\n b1 = b\n c1 = c\n a = b1 + c1\n b = a1 + c1\n c = a1 + b1\n count += 1\nif abs(a-b) >= 10**8:\n print('Unfair')\nelse:\n print(a-b)\n", "a,b,c,k = map(int,input().split())\ncount = 0\nwhile count == k:\n a1 = a\n b1 = b\n c1 = c\n a = b1 + c1\n b = a1 + c1\n c = a1 + b1\n count += 1\nif abs(a-b) >= 10**8:\n print('Unfair')\nelse:\n print(a-b)", 'a,b,c,k = map(int,input().split())\nif k % 2 == 0:\n print(a-b)\nelse:\n print(b-a)\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s455637375', 's826658213', 's912188341', 's359974727'] | [2940.0, 3060.0, 3060.0, 2940.0] | [17.0, 18.0, 17.0, 17.0] | [181, 292, 203, 82] |
p03345 | u623243044 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a,b,c,k = map(int,input().split())\nif (k % 2 == 0):\n ans = b-a\nelse:\n ans = a - b\nif (ans > 10**18):\n print('Unfair')\nelse:\n print(ans)\n", "a,b,c,k = map(int,input().split())\nif (k % 2 == 0):\n ans = a-b\nelse:\n ans = b-a\nif (ans > 10**18):\n print('Unfair')\nelse:\n print(ans)\n"] | ['Wrong Answer', 'Accepted'] | ['s916576041', 's077106700'] | [2940.0, 2940.0] | [17.0, 17.0] | [148, 146] |
p03345 | u627417051 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = list(map(int, input().split()))\nif K % 2 == 0:\n\tprint(A - B)\nelse:\n\tprint(A - B) * (-1)', 'A, B, C, K = list(map(int, input().split()))\nif K % 2 == 0:\n\tprint(A - B)\nelse:\n\tprint((A - B) * (-1))'] | ['Runtime Error', 'Accepted'] | ['s174297257', 's181370543'] | [3064.0, 2940.0] | [18.0, 17.0] | [100, 103] |
p03345 | u629540524 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['print((-1)**k*(a-b))', 'a,b,c,k=map(int,input().split())\nprint((-1)**k*(a-b))'] | ['Runtime Error', 'Accepted'] | ['s241432153', 's086265138'] | [8976.0, 9140.0] | [28.0, 28.0] | [20, 53] |
p03345 | u644360640 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a,b,c,k = map(int,input().split())\n\nif abs(a-b) >= 10**18:\n print('Unfair')\n exit()\nprint(a-b)", 'a,b,c,k = map(int,input().split())\nprint(a-b)', "a,b,c,k = map(int,input().split())\n\nif abs(a-b) > 10**18:\n print('Unfair')\n exit()\nprint(a-b)\n", 'a,b,c,k = map(int,input().split())\nans = a-b\nif k%2==0:\n print(ans)\nelse:\n print(ans*(-1))\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s106154241', 's231278231', 's901092421', 's605603089'] | [3064.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 18.0] | [100, 45, 100, 97] |
p03345 | u644972721 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = map(int, input().split())\nprint((k % 2) * (a - b))', 'a, b, c, k = map(int, input().split())\nprint(((-1) ** k) * (a - b))'] | ['Wrong Answer', 'Accepted'] | ['s159175985', 's584085006'] | [2940.0, 2940.0] | [18.0, 17.0] | [63, 67] |
p03345 | u651952230 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['n=int(input())\np=[]\nfor i in range (n):\n\tp.append(int(input()))\npos=0\nnum=0\nn_th = 0\ns={}\nfor i in p:\n\tif i-1 in s:\n\t\ts[i]=s[i-1]+1\n\telse:\n\t\ts[i]=1\nprint(n-max(s.values()))', 'a,b,c,k =map(int,input().split())\n\nif k%2==1:\n print(b-a)\nelse:\n print(a-b)'] | ['Runtime Error', 'Accepted'] | ['s719212272', 's995168724'] | [3064.0, 2940.0] | [17.0, 17.0] | [172, 81] |
p03345 | u654240084 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = map(int, input().split())\nif abs(a - b) > 1e18:\n print("Unfair")\nelif k % 2 == 0:\n print(b - a)\nelse:\n print(a - b)\n', 'a, b, c, k = map(int, input().split())\nif abs(a - b) > 1e18:\n print("Unfair")\nelif k % 2 == 1:\n print(b - a)\nelse:\n print(a - b)\n'] | ['Wrong Answer', 'Accepted'] | ['s960056825', 's850235483'] | [2940.0, 2940.0] | [18.0, 17.0] | [138, 138] |
p03345 | u657357805 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['def main():\n A,B,C,K=[int(x) for x in input().split()]\n if abs(A-B)>10**18:\n print("Unfair")\n else:\n print(A-B)\n\nif __name__ == "__main__":\n main()\n', 'def main():\n A,B,C,K=[int(x) for x in input().split()]\n if abs(A-B)>10**18:\n print("Unfair")\n else:\n if K%2==0:\n print(A-B)\n else:\n print(B-A)\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s155968499', 's253198544'] | [2940.0, 2940.0] | [18.0, 18.0] | [174, 234] |
p03345 | u657541767 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['n = int(input())\np = [int(input()) for _ in range(n)]\nq = [0] * (n+1)\n\nfor i in range(n):\n q[p[i]] = i\nmaxl = 1\ncnt = 1\nlast = p[0]\nfor i in range(1, n):\n if q[i+1] > q[i]:\n cnt += 1\n else:\n maxl = max(maxl, cnt)\n cnt = 1\n\nprint(n - maxl)\n', "a, b, c, k = map(int, input().split())\nres = b - a\nif k % 2 ==0:\n res = a - b\n\nif res > 10 ** 18:\n print('Unfair')\nelse:\n print(res) \n"] | ['Runtime Error', 'Accepted'] | ['s164771595', 's075657853'] | [3060.0, 2940.0] | [17.0, 17.0] | [269, 143] |
p03345 | u663710122 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, input().split())\n\nprint(A - B if K % 2 == 1 else B - A)\n', 'A, B, C, K = map(int, input().split())\n\nprint(A - B if K % 2 == 0 else B - A)\n'] | ['Wrong Answer', 'Accepted'] | ['s907191250', 's627797328'] | [2940.0, 2940.0] | [17.0, 17.0] | [78, 78] |
p03345 | u665038048 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a, b, c, k = map(int, input().split())\nif abs(a-b) > 10**18:\n print('Unfair')\n exit()\nif k % 2 == 0:\n print((a-b)*(-1))\nelse:\n print(a-b)", 'a, b, c, k = map(int, input().split())\nif k % 2 == 0:\n print((a-b)*(-1))\nelse:\n print(a-b)', "a, b, c, k = map(int, input().split())\nif abs(a-b) > 10**18:\n print('Unfair')\n exit()\nif k % 2 == 0:\n print(a-b)\nelse:\n print((a-b)*(-1))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s673920082', 's709259217', 's027357158'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 18.0] | [149, 96, 149] |
p03345 | u667024514 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k = map(int,input().split())\nprint((a-b)*(-1)**(k%2+1))', 'a,b,c,k=map(int,input().split());print((a-b)*(-1)**k)'] | ['Wrong Answer', 'Accepted'] | ['s342342336', 's918642818'] | [2940.0, 2940.0] | [17.0, 17.0] | [61, 53] |
p03345 | u671215535 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import sys\n\nA , B , C, K = map(int,input().split())\n\na_0 = 1\na_1 = 0\na_2 = 0\n\ni = 0\nwhile i < K:\n a_0 = a_1 + a_2\n a_1 = a_0 + a_2\n a_2 = a_0 + a_1\n \n i = i + 1\n \nres = (A - B) * (a[0] - a[1])\nif res < 10**18:\n print(res)\nelse:\n print("unfair")\n', 'import sys\n\nA , B , C, K = map(int,input().split())\n\na_0 = 1\na_1 = 0\na_2 = 0\n\ni = 0\nwhile i < K:\n a_0 = a_1 + a_2\n a_1 = a_0 + a_2\n a_2 = a_0 + a_1\n \n i = i + 1\n \nres = (A - B) * (a_0 - a_1)\nif res < 10**18:\n print(res)\nelse:\n print("unfair")', 'import sys\n\nA , B , C, K = map(int,input().split())\n\na = K % 2\nres = (A - B)\nif abs(res) > 10**18:\n print("unfair")\nif a == 1:\n print(B - A)\nelif a == 0:\n print(A - B)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s588074283', 's738335733', 's914508202'] | [3060.0, 3064.0, 2940.0] | [2104.0, 2104.0, 20.0] | [269, 266, 176] |
p03345 | u674569298 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a,b,c,k = list(map(int,input().split()))\nans = 0\nprint(a,b,c,k)\nif k%2 == 0:\n ans = a -b\nelse:\n if k == 1:\n ans = b-a\n else:\n if int(k/2)%2 == 0:\n ans = -a +b\n else:\n ans = a+b\n\nif ans > pow(10,18):\n ans = 'Unfair'\nprint(ans)", "a,b,c,k = list(map(int,input().split()))\nans = 0\nl = [0b11,0b101,0b110]\nif k%2 == 1:\n ans = b -a\nelse:\n ans = a-b \nif abs(ans) > pow(10,18):\n ans = 'Unfair'\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s114529888', 's721023634'] | [3064.0, 2940.0] | [17.0, 17.0] | [280, 193] |
p03345 | u692336506 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, split().input())\nprint(A - B if K % 2 == 0 else B - A)', 'A, B, C, K = map(int, input().split())\nprint(A - B if K % 2 == 0 else B - A)'] | ['Runtime Error', 'Accepted'] | ['s037472035', 's771950996'] | [8984.0, 9056.0] | [24.0, 27.0] | [76, 76] |
p03345 | u699944218 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["def abs(k):\n if k >= 0:\n return k\n else:\n return -k\n\na, b, c ,n = list(map(int,input().split()))\ni for i in range(n):\n a = b + c\n b = c + a \n c = a + b\nres = a - b\nif abs(res) > 10 ** 18:\n print('Unfair')\nelse:\n print(res)", "def abs(k):\n if k >= 0:\n return k\n else:\n return -k\n \ndef main():\n a, b, c ,n = list(map(int,input().split()))\n i for i in range(n):\n a = b + c\n b = c + a \n c = a + b\n res = a - b\n if abs(res) > 10 ** 18:\n print('Unfair')\n else:\n print(res)", 'A, B, C, K = map(int, input().split())\nprint(A - B if K % 2 == 0 else B - A)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s560619297', 's721378078', 's441793490'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [235, 269, 76] |
p03345 | u704252625 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = (int(i) for i in input().split())\nif 0 == (k & 1):\n print(b - a)\nelse:\n print(a - b)\n ', 'a, b, c, k = (int(i) for i in input().split())\nif 1 == (k & 1):\n print(b - a)\nelse:\n print(a - b)\n '] | ['Wrong Answer', 'Accepted'] | ['s721354463', 's982413102'] | [2940.0, 2940.0] | [17.0, 17.0] | [102, 102] |
p03345 | u713914478 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['for i in range(K):\n\tA2 = B + C\n\tB2 = C + A\n\tC2 = A + B\t\n\n\tA,B,C = A2, B2, C2\n\n\nif abs(A-B) > 10**18:\n\tprint(Unfair)\nelse:\n\tprint(A-B)', 'A,B,C,K = map(int,input().split())\n\nif K % 2 == 0:\n\tprint(A-B) if abs(A-B)<=10**18 else print("Unfair")\nelse:\n\tprint(B-A) if abs(A-B)<=10**18 else print("Unfair")\n'] | ['Runtime Error', 'Accepted'] | ['s698948193', 's483483412'] | [2940.0, 2940.0] | [17.0, 17.0] | [133, 163] |
p03345 | u729133443 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a,b,c,k=map(int,input().split());a=a-b*(-1**k%2);print(a)', 'a,b,c,k=map(int,input().split());print((-1)**k*(a-b))'] | ['Wrong Answer', 'Accepted'] | ['s553800612', 's412246766'] | [2940.0, 2940.0] | [17.0, 17.0] | [57, 53] |
p03345 | u738835924 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['N = int(input())\n\nstart = int(input())\nflag = 0\nif start != 0:\n flag = 1\nt = 0\n\nfor i in range(N-1):\n k = int(input())\n if k == start:\n t += start\n elif k == start + 1:\n t += 1\n start = k\n elif k == 0:\n start = 0\n elif k > start + 1:\n t = -1\n break\n else:\n t += k\n start = k\n\nif flag ==1:\n t = -1\nprint(t)', 'A,B,C,K= map(int, input().split())\n\nif (A-B) ** 2 **0.5 > 10e18:\n print("Unfair")\nelif K % 2 == 1:\n print(A-B)\nelse:\n print(B-A)\n', 'A,B,C,K= map(int, input().split())\n \nif (A-B) > 10e18 or (B-A) > 10e18:\n print("Unfair")\nelif K % 2 == 1:\n print(B-A)\nelse:\n print(A-B)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s087719865', 's340453537', 's393200586'] | [3064.0, 3060.0, 3060.0] | [17.0, 18.0, 19.0] | [313, 129, 135] |
p03345 | u751488284 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['A, B, C, K = map(int, input().split())\nprint(A - B if K % 2 == 1 else B - A)', 'A, B, C, K = map(int, input().split())\nprint(A - B if K % 2 == 0 else B - A)'] | ['Wrong Answer', 'Accepted'] | ['s553440866', 's438921232'] | [2940.0, 2940.0] | [18.0, 17.0] | [76, 76] |
p03345 | u771532493 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ["a,b,c,k=(int(i) for i in input().split())\ndef ans(x):\n if abs(x)>=10e18:\n return 'Unfair'\n else:\n return x\nif k==0\n print(ans(a-b))\nelse:\n print(ans(b-a))\n ", "a,b,c,k=(int(i) for i in input().split())\ndef ans(x):\n if abs(x)>=10e18:\n return 'Unfair'\n else:\n return x\nif k%2==0:\n print(ans(a-b))\nelse:\n print(ans(b-a))"] | ['Runtime Error', 'Accepted'] | ['s752269272', 's383171177'] | [2940.0, 2940.0] | [17.0, 18.0] | [167, 167] |
p03345 | u775623741 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['import copy\ns=input().split()\nnum=[int(i) for i in s[:3]]\nK=int(s[3])\nnum_=[0,0,0]\nfor i in range(K):\n\tfor j in range(3):\n\t\tnum_[j]=num[(j+1)%3]+num[(j+2)%3]\n\t\tnum=copy.deepcopy(num_)\n\tif i%10000==0:\n\t\tif abs(num[0]-num[1])>10**18:\n\t\t\tprint("Unfair")\n\t\t\tbreak\nelse:\n\tprint(num[0]-num[1])\n', 's=input().split()\nif int(s[3])%2==0:\n print(-1*(int(s[0])-int(s[1])))\nelse:\n print(int(s[0])-int(s[1]))', 's=input().split()\nans=int(s[0])-int(s[1])\nif abs(ans)>10**18:\n print("Unfair")\nelif int(s[3])%2==0:\n print(-1*(int(s[0])-int(s[1])))\nelse:\n print(int(s[0])-int(s[1]))', 's=input().split()\nans=int(s[0])-int(s[1])\nif abs(ans)>10**18:\n print("Unfair")\nelif int(s[3])%2==0:\n print((int(s[0])-int(s[1])))\nelse:\n print(-1*int(s[0])-int(s[1]))', 's=input().split()\nans=int(s[0])-int(s[1])\nif abs(ans)>10**18:\n print("Unfair")\nelif int(s[3])%2==0:\n print(int(s[0])-int(s[1]))\nelse:\n print(-1*(int(s[0])-int(s[1])))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s394531639', 's692523476', 's903486419', 's923145183', 's416745363'] | [3444.0, 2940.0, 3060.0, 3060.0, 3060.0] | [194.0, 17.0, 18.0, 17.0, 17.0] | [288, 105, 169, 169, 169] |
p03345 | u777283665 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result. However, if the absolute value of the answer exceeds 10^{18}, print `Unfair` instead. | ['a, b, c, k = map(int, input().split())\n\nif k % 2:\n print(a-c)\nelse:\n print(c-a)', 'a, b, c, k = map(int, input().split())\n\nprint(a-c)', 'a, b, c, k = map(int, input().split())\n\nif k % 2 == 0:\n print(a-b)\nelse:\n print(-(a-b))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s533519917', 's621593619', 's504275358'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [81, 50, 89] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.