node_ids
sequencelengths
4
1.4k
edge_index
sequencelengths
1
2.22k
text
sequencelengths
4
1.4k
source
stringlengths
14
427k
[ 7, 15, 13, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 18, 18, 13, 13, 13, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 18, 4, 18, 18, 13, 13, 13, 13, 13, 14, 2, 4, 13, 13, 17, 4, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 0, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 4, 13, 4, 13, 17, 2, 2, 18, 13, 17, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 84, 4 ], [ 84, 20 ], [ 87, 22 ], [ 88, 44 ], [ 88, 50 ], [ 88, 55 ], [ 59, 58 ], [ 90, 61 ], [ 88, 65 ], [ 88, 76 ], [ 91, 78 ], [ 84, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ] ]
[ "import sys\n\nK, T = map(int, sys.stdin.readline().strip().split())\nA = list(map(int, sys.stdin.readline().strip().split()))\n\nif len(A) == 1:\n print(A[0] - 1)\nelse: \n A.sort(reverse=True)\n other_sum = sum(A[1:])\n print(max(0, A[0] - other_sum - 1))", "import sys", "sys", "K, T = map(int, sys.stdin.readline().strip().split())", "K", "map(int, sys.stdin.readline().strip().split())", "map", "int", "sys.stdin.readline().strip().split()", "sys.stdin.readline().strip().split", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "split", "T", "A = list(map(int, sys.stdin.readline().strip().split()))", "A", "list(map(int, sys.stdin.readline().strip().split()))", "list", "map(int, sys.stdin.readline().strip().split())", "map", "int", "sys.stdin.readline().strip().split()", "sys.stdin.readline().strip().split", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "split", "if len(A) == 1:\n print(A[0] - 1)\nelse: \n A.sort(reverse=True)\n other_sum = sum(A[1:])\n print(max(0, A[0] - other_sum - 1))", "len(A) == 1", "len(A)", "len", "A", "1", "print(A[0] - 1)", "print", "A[0] - 1", "A[0]", "A", "0", "1", "A.sort(reverse=True)", "A.sort", "A", "sort", "reverse=True", "reverse", "True", "other_sum = sum(A[1:])", "other_sum", "sum(A[1:])", "sum", "A[1:]", "A", "1:", "1", "print(max(0, A[0] - other_sum - 1))", "print", "max(0, A[0] - other_sum - 1)", "max", "0", "A[0] - other_sum - 1", "A[0] - other_sum", "A[0]", "A", "0", "other_sum", "1", "K, T = map(int, sys.stdin.readline().strip().split())", "map(int, sys.stdin.readline().strip().split())", "K", "T = map(int, sys.stdin.readline().strip().split())", "map(int, sys.stdin.readline().strip().split())", "T", "A = list(map(int, sys.stdin.readline().strip().split()))", "list(map(int, sys.stdin.readline().strip().split()))", "A", "other_sum = sum(A[1:])", "sum(A[1:])", "other_sum" ]
import sys K, T = map(int, sys.stdin.readline().strip().split()) A = list(map(int, sys.stdin.readline().strip().split())) if len(A) == 1: print(A[0] - 1) else: A.sort(reverse=True) other_sum = sum(A[1:]) print(max(0, A[0] - other_sum - 1))
[ 7, 15, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 18, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 39, 17, 41, 28, 13, 4, 13, 13, 4, 17, 0, 13, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 28, 13, 4, 13, 13, 14, 40, 13, 2, 2, 13, 17, 17, 0, 18, 13, 2, 17, 13, 13, 0, 18, 13, 2, 2, 17, 2, 13, 2, 13, 17, 17, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 17, 13, 14, 2, 18, 13, 2, 13, 17, 18, 13, 13, 0, 13, 17, 4, 13, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 122, 4 ], [ 134, 13 ], [ 123, 20 ], [ 134, 22 ], [ 137, 24 ], [ 123, 36 ], [ 43, 42 ], [ 129, 45 ], [ 140, 49 ], [ 143, 52 ], [ 138, 59 ], [ 62, 61 ], [ 144, 67 ], [ 132, 67 ], [ 129, 70 ], [ 79, 74 ], [ 141, 75 ], [ 144, 78 ], [ 132, 78 ], [ 92, 81 ], [ 141, 82 ], [ 144, 87 ], [ 132, 87 ], [ 129, 89 ], [ 131, 94 ], [ 125, 97 ], [ 101, 100 ], [ 129, 104 ], [ 141, 108 ], [ 100, 110 ], [ 141, 113 ], [ 100, 114 ], [ 146, 116 ], [ 147, 120 ], [ 126, 120 ], [ 122, 123 ], [ 125, 126 ], [ 134, 129 ], [ 131, 132 ], [ 134, 135 ], [ 137, 138 ], [ 140, 141 ], [ 143, 144 ], [ 146, 147 ] ]
[ "import sys\n\nreadline = sys.stdin.buffer.readline\n\nK, T = map(int, readline().split())\nA = sorted(list(map(int, readline().split())))[::-1]\n\nB = [-1 for _ in range(K)]\n\nj = 0\nfor i, a in enumerate(A):\n for _ in range(a):\n if j <= K // 2 - 1:\n B[2 * j] = i\n else:\n B[2 * (j - K // 2) - 1] = i\n j += 1\n\ncnt = 0\nfor i in range(1, K):\n if B[i - 1] == B[i]:\n cnt += 1\n\nprint(cnt)", "import sys", "sys", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "K, T = map(int, readline().split())", "K", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "T", "A = sorted(list(map(int, readline().split())))[::-1]", "A", "sorted(list(map(int, readline().split())))[::-1]", "(list(map(int, readline().split())))", "sorted", "list(map(int, readline().split()))", "list", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "::-1", "-1", "-1 for _ in range(K)", "for _ in range(K)", "_", "range(K)", "range", "K", "for _ in range(K)", "-1", "B = [-1 for _ in range(K)]", "B", "[-1 for _ in range(K)]", "j = 0", "j", "0", "for i, a in enumerate(A):\n for _ in range(a):\n if j <= K // 2 - 1:\n B[2 * j] = i\n else:\n B[2 * (j - K // 2) - 1] = i\n j += 1", "i", "a", "enumerate(A)", "enumerate", "A", "for _ in range(a):\n if j <= K // 2 - 1:\n B[2 * j] = i\n else:\n B[2 * (j - K // 2) - 1] = i\n j += 1", "_", "range(a)", "range", "a", "if j <= K // 2 - 1:\n B[2 * j] = i\n else:\n B[2 * (j - K // 2) - 1] = i\n ", "j <= K // 2 - 1", "j", "K // 2 - 1", "K // 2", "K", "2", "1", "B[2 * j] = i", "B[2 * j]", "B", "2 * j", "2", "j", "i", "B[2 * (j - K // 2) - 1] = i", "B[2 * (j - K // 2) - 1]", "B", "2 * (j - K // 2) - 1", "2 * (j - K // 2)", "2", "j - K // 2", "j", "K // 2", "K", "2", "1", "i", "j += 1", "j", "1", "cnt = 0", "cnt", "0", "for i in range(1, K):\n if B[i - 1] == B[i]:\n cnt += 1", "i", "range(1, K)", "range", "1", "K", "if B[i - 1] == B[i]:\n cnt += 1", "B[i - 1] == B[i]", "B[i - 1]", "B", "i - 1", "i", "1", "B[i]", "B", "i", "cnt += 1", "cnt", "1", "print(cnt)", "print", "cnt", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline", "cnt = 0", "0", "cnt", "K, T = map(int, readline().split())", "map(int, readline().split())", "K", "j += 1", "1", "j", "T = map(int, readline().split())", "map(int, readline().split())", "T", "A = sorted(list(map(int, readline().split())))[::-1]", "sorted(list(map(int, readline().split())))[::-1]", "A", "B = [-1 for _ in range(K)]", "[-1 for _ in range(K)]", "B", "j = 0", "0", "j", "cnt += 1", "1", "cnt" ]
import sys readline = sys.stdin.buffer.readline K, T = map(int, readline().split()) A = sorted(list(map(int, readline().split())))[::-1] B = [-1 for _ in range(K)] j = 0 for i, a in enumerate(A): for _ in range(a): if j <= K // 2 - 1: B[2 * j] = i else: B[2 * (j - K // 2) - 1] = i j += 1 cnt = 0 for i in range(1, K): if B[i - 1] == B[i]: cnt += 1 print(cnt)
[ 7, 15, 13, 13, 15, 4, 18, 13, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 29, 18, 4, 18, 18, 13, 13, 13, 39, 17, 12, 13, 29, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 0, 13, 13, 41, 28, 13, 4, 13, 31, 13, 4, 4, 13, 13, 29, 13, 23, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 4, 13, 17, 2, 2, 4, 13, 13, 17, 2, 13, 4, 13, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 120, 13 ], [ 115, 40 ], [ 115, 48 ], [ 54, 53 ], [ 79, 56 ], [ 127, 61 ], [ 64, 63 ], [ 68, 67 ], [ 63, 71 ], [ 67, 75 ], [ 79, 79 ], [ 117, 81 ], [ 127, 83 ], [ 117, 84 ], [ 123, 86 ], [ 127, 90 ], [ 124, 100 ], [ 118, 103 ], [ 124, 106 ], [ 117, 112 ], [ 117, 118 ], [ 120, 121 ], [ 123, 124 ] ]
[ "import sys, math\nfrom functools import lru_cache\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return map(int, input().split())\n\ndef ii():\n return int(input())\n\ndef i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]\n\nK, T = mi()\na = list(mi())\n\nprint(max(0, max(a)-1-(K-max(a))))", "import sys, math", "sys", "math", "from functools import lru_cache", "sys.setrecursionlimit(10**9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**9", "10", "9", "MOD = 10**9+7", "MOD", "10**9+7", "10**9", "10", "9", "7", "def input():\n return sys.stdin.readline()[:-1]", "input", "return sys.stdin.readline()[:-1]", "sys.stdin.readline()[:-1]", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", ":-1", "-1", "def mi():\n return map(int, input().split())", "mi", "return map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def ii():\n return int(input())", "ii", "return int(input())", "int(input())", "int", "input()", "input", "def i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]", "i2", "list(mi()) for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "list(mi())", "list", "mi()", "mi", "tmp = [list(mi()) for i in range(n)]", "tmp", "[list(mi()) for i in range(n)]", "list(i) for i in zip(*tmp)", "for i in zip(*tmp)", "i", "zip(*tmp)", "zip", "*tmp", "tmp", "for i in zip(*tmp)", "list(i)", "list", "i", "return [list(i) for i in zip(*tmp)]", "[list(i) for i in zip(*tmp)]", "n", "n", "K, T = mi()", "K", "mi()", "mi", "T", "a = list(mi())", "a", "list(mi())", "list", "mi()", "mi", "print(max(0, max(a)-1-(K-max(a))))", "print", "max(0, max(a)-1-(K-max(a)))", "max", "0", "max(a)-1-(K-max(a))", "max(a)-1", "max(a)", "max", "a", "1", "K-max(a)", "K", "max(a)", "max", "a", "def i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]", "def i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]", "i2", "T = mi()", "mi()", "T", "def input():\n return sys.stdin.readline()[:-1]", "def input():\n return sys.stdin.readline()[:-1]", "input", "K, T = mi()", "mi()", "K", "MOD = 10**9+7", "10**9+7", "MOD", "a = list(mi())", "list(mi())", "a", "def mi():\n return map(int, input().split())", "def mi():\n return map(int, input().split())", "mi", "def ii():\n return int(input())", "def ii():\n return int(input())", "ii" ]
import sys, math from functools import lru_cache sys.setrecursionlimit(10**9) MOD = 10**9+7 def input(): return sys.stdin.readline()[:-1] def mi(): return map(int, input().split()) def ii(): return int(input()) def i2(n): tmp = [list(mi()) for i in range(n)] return [list(i) for i in zip(*tmp)] K, T = mi() a = list(mi()) print(max(0, max(a)-1-(K-max(a))))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 2, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 39, 40, 13, 0, 13, 13, 0, 13, 13, 28, 13, 4, 13, 13, 0, 13, 13, 28, 13, 4, 13, 13, 14, 2, 13, 13, 14, 2, 40, 18, 13, 13, 18, 13, 13, 2, 18, 13, 13, 17, 14, 2, 13, 13, 0, 18, 13, 13, 17, 0, 13, 2, 40, 13, 13, 2, 13, 17, 0, 13, 13, 4, 13, 13, 10, 13, 13, 10, 13, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 13, 13, 10, 13, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 120, 4 ], [ 123, 11 ], [ 121, 18 ], [ 123, 20 ], [ 108, 22 ], [ 121, 32 ], [ 106, 36 ], [ 117, 38 ], [ 124, 39 ], [ 99, 41 ], [ 106, 42 ], [ 45, 44 ], [ 106, 47 ], [ 102, 49 ], [ 124, 50 ], [ 53, 52 ], [ 124, 55 ], [ 52, 58 ], [ 118, 59 ], [ 115, 59 ], [ 79, 63 ], [ 109, 64 ], [ 103, 65 ], [ 109, 67 ], [ 52, 68 ], [ 109, 71 ], [ 52, 72 ], [ 103, 76 ], [ 124, 77 ], [ 82, 79 ], [ 109, 80 ], [ 103, 81 ], [ 111, 84 ], [ 103, 87 ], [ 118, 88 ], [ 115, 88 ], [ 44, 90 ], [ 114, 93 ], [ 103, 94 ], [ 112, 97 ], [ 100, 97 ], [ 106, 99 ], [ 99, 100 ], [ 124, 102 ], [ 102, 103 ], [ 123, 106 ], [ 108, 109 ], [ 111, 112 ], [ 103, 114 ], [ 114, 115 ], [ 124, 117 ], [ 117, 118 ], [ 120, 121 ], [ 123, 124 ] ]
[ "import sys\ninput = sys.stdin.readline\nN, T = map(int, input().split())\na = list(map(int, input().split())) + [-N]\nlast = T\nres = N\nfor t in range(N):\n x = T\n for i in range(T):\n if i == last: continue\n if a[x] <= a[i] and (a[i] > 0): x = i\n if x == T: x = last\n a[x] -= 1\n res -= x != last or (t == 0)\n last = x\nprint(res)", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "N, T = map(int, input().split())", "N", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = list(map(int, input().split())) + [-N]", "a", "list(map(int, input().split())) + [-N]", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "[-N]", "-N", "N", "last = T", "last", "T", "res = N", "res", "N", "for t in range(N):\n x = T\n for i in range(T):\n if i == last: continue\n if a[x] <= a[i] and (a[i] > 0): x = i\n if x == T: x = last\n a[x] -= 1\n res -= x != last or (t == 0)\n last = x", "t", "range(N)", "range", "N", "x = T", "x", "T", "for i in range(T):\n if i == last: continue\n if a[x] <= a[i] and (a[i] > 0): x = i\n ", "i", "range(T)", "range", "T", "if i == last: continue\n ", "i == last", "i", "last", "if a[x] <= a[i] and (a[i] > 0): x = i\n ", "a[x] <= a[i] and (a[i] > 0)", "a[x] <= a[i]", "a[x]", "a", "x", "a[i]", "a", "i", "a[i] > 0", "a[i]", "a", "i", "0", "if x == T: x = last\n ", "x == T", "x", "T", "a[x] -= 1", "a[x]", "a", "x", "1", "res -= x != last or (t == 0)", "res", "x != last or (t == 0)", "x != last", "x", "last", "t == 0", "t", "0", "last = x", "last", "x", "print(res)", "print", "res", "res = N", "N", "res", "x = T", "T", "x", "N, T = map(int, input().split())", "map(int, input().split())", "N", "a = list(map(int, input().split())) + [-N]", "list(map(int, input().split())) + [-N]", "a", "res -= x != last or (t == 0)", "x != last or (t == 0)", "res", "last = x", "x", "last", "last = T", "T", "last", "input = sys.stdin.readline", "sys.stdin.readline", "input", "T = map(int, input().split())", "map(int, input().split())", "T" ]
import sys input = sys.stdin.readline N, T = map(int, input().split()) a = list(map(int, input().split())) + [-N] last = T res = N for t in range(N): x = T for i in range(T): if i == last: continue if a[x] <= a[i] and (a[i] > 0): x = i if x == T: x = last a[x] -= 1 res -= x != last or (t == 0) last = x print(res)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 14, 40, 13, 2, 2, 4, 13, 13, 13, 17, 4, 13, 2, 2, 13, 2, 4, 13, 13, 13, 17, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 60, 2 ], [ 60, 11 ], [ 57, 13 ], [ 63, 25 ], [ 58, 28 ], [ 64, 31 ], [ 58, 36 ], [ 64, 37 ], [ 64, 43 ], [ 58, 47 ], [ 64, 48 ], [ 60, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "k,t=map(int,input().split())\na=list(map(int,input().split()))\nma=max(a)\nif ma >= sum(a)-ma+1:\n print(ma-(sum(a)-ma)-1)\nelse:\n print(0)\n \n ", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ma=max(a)", "ma", "max(a)", "max", "a", "if ma >= sum(a)-ma+1:\n print(ma-(sum(a)-ma)-1)\nelse:\n print(0)\n \n ", "ma >= sum(a)-ma+1", "ma", "sum(a)-ma+1", "sum(a)-ma", "sum(a)", "sum", "a", "ma", "1", "print(ma-(sum(a)-ma)-1)", "print", "ma-(sum(a)-ma)-1", "ma-(sum(a)-ma)", "ma", "sum(a)-ma", "sum(a)", "sum", "a", "ma", "1", "print(0)", "print", "0", "t=map(int,input().split())", "map(int,input().split())", "t", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "k,t=map(int,input().split())", "map(int,input().split())", "k", "ma=max(a)", "max(a)", "ma" ]
k,t=map(int,input().split()) a=list(map(int,input().split())) ma=max(a) if ma >= sum(a)-ma+1: print(ma-(sum(a)-ma)-1) else: print(0)
[ 7, 15, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 31, 13, 4, 13, 4, 13, 17, 2, 2, 2, 17, 4, 13, 13, 13, 17, 10, 4, 13, 10, 18, 13, 10, 18, 13, 10, 4, 13, 10, 18, 13 ]
[ [ 71, 4 ], [ 77, 13 ], [ 68, 22 ], [ 74, 38 ], [ 72, 45 ], [ 74, 47 ], [ 74, 48 ], [ 75, 62 ], [ 74, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ] ]
[ "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nk, t, *a = map(int, read().split())\nprint(max(0, 2 * max(a) - k - 1))", "import sys", "sys", "read = sys.stdin.buffer.read", "read", "sys.stdin.buffer.read", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "read", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "readlines = sys.stdin.buffer.readlines", "readlines", "sys.stdin.buffer.readlines", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readlines", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "k, t, *a = map(int, read().split())", "k", "map(int, read().split())", "map", "int", "read().split()", "().split", "()", "read", "split", "t", "*a", "a", "print(max(0, 2 * max(a) - k - 1))", "print", "max(0, 2 * max(a) - k - 1)", "max", "0", "2 * max(a) - k - 1", "2 * max(a) - k", "2 * max(a)", "2", "max(a)", "max", "a", "k", "1", "t, *a = map(int, read().split())", "map(int, read().split())", "t", "readlines = sys.stdin.buffer.readlines", "sys.stdin.buffer.readlines", "readlines", "read = sys.stdin.buffer.read", "sys.stdin.buffer.read", "read", "k, t, *a = map(int, read().split())", "map(int, read().split())", "k", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline" ]
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) k, t, *a = map(int, read().split()) print(max(0, 2 * max(a) - k - 1))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 51, 11 ], [ 48, 13 ], [ 57, 25 ], [ 49, 28 ], [ 54, 30 ], [ 52, 32 ], [ 58, 33 ], [ 58, 41 ], [ 55, 43 ], [ 51, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "k,t = map(int,input().split())\nL = list(map(int,input().split()))\n\nmax1 = max(L)\nzan = k-max1\n\nprint(max(0,(max1-1)-zan))", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "L = list(map(int,input().split()))", "L", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "max1 = max(L)", "max1", "max(L)", "max", "L", "zan = k-max1", "zan", "k-max1", "k", "max1", "print(max(0,(max1-1)-zan))", "print", "max(0,(max1-1)-zan)", "max", "0", "(max1-1)-zan", "max1-1", "max1", "1", "zan", "t = map(int,input().split())", "map(int,input().split())", "t", "L = list(map(int,input().split()))", "list(map(int,input().split()))", "L", "k,t = map(int,input().split())", "map(int,input().split())", "k", "zan = k-max1", "k-max1", "zan", "max1 = max(L)", "max(L)", "max1" ]
k,t = map(int,input().split()) L = list(map(int,input().split())) max1 = max(L) zan = k-max1 print(max(0,(max1-1)-zan))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 14, 2, 13, 2, 17, 13, 4, 13, 17, 4, 13, 2, 2, 2, 17, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 54, 2 ], [ 54, 11 ], [ 57, 13 ], [ 48, 25 ], [ 58, 28 ], [ 49, 31 ], [ 55, 34 ], [ 49, 44 ], [ 55, 45 ], [ 48, 49 ], [ 54, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "K,T=map(int,input().split())\na=list(map(int,input().split()))\nA=max(a)\nif A<0.5*K:\n print(0)\nelse:\n print(2*A-K-1)", "K,T=map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "A=max(a)", "A", "max(a)", "max", "a", "if A<0.5*K:\n print(0)\nelse:\n print(2*A-K-1)", "A<0.5*K", "A", "0.5*K", "0.5", "K", "print(0)", "print", "0", "print(2*A-K-1)", "print", "2*A-K-1", "2*A-K", "2*A", "2", "A", "K", "1", "A=max(a)", "max(a)", "A", "T=map(int,input().split())", "map(int,input().split())", "T", "K,T=map(int,input().split())", "map(int,input().split())", "K", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
K,T=map(int,input().split()) a=list(map(int,input().split())) A=max(a) if A<0.5*K: print(0) else: print(2*A-K-1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 13, 31, 13, 4, 13, 4, 13, 2, 2, 17, 4, 13, 13, 40, 13, 17, 10, 4, 13, 10, 4, 13 ]
[ [ 35, 2 ], [ 35, 15 ], [ 35, 16 ], [ 33, 29 ], [ 35, 33 ], [ 35, 36 ] ]
[ "k,t,*A=map(int,open(0).read().split());print(max(2*max(A)+~k,0))", "k,t,*A=map(int,open(0).read().split())", "k", "map(int,open(0).read().split())", "map", "int", "open(0).read().split()", "(0).read().split", "(0).read()", "(0).read", "(0)", "open", "0", "read", "split", "t", "*A", "A", "print(max(2*max(A)+~k,0))", "print", "max(2*max(A)+~k,0)", "max", "2*max(A)+~k", "2*max(A)", "2", "max(A)", "max", "A", "~k", "k", "0", "k,t,*A=map(int,open(0).read().split())", "map(int,open(0).read().split())", "k", "t,*A=map(int,open(0).read().split())", "map(int,open(0).read().split())", "t" ]
k,t,*A=map(int,open(0).read().split());print(max(2*max(A)+~k,0))
[ 7, 15, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 4, 18, 13, 13, 13, 28, 13, 4, 13, 13, 4, 18, 13, 13, 13, 39, 2, 17, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 13, 0, 13, 17, 14, 2, 2, 2, 13, 13, 2, 4, 13, 13, 17, 40, 18, 18, 13, 17, 17, 17, 0, 13, 4, 18, 13, 13, 13, 13, 0, 13, 17, 0, 13, 17, 4, 18, 13, 13, 13, 39, 2, 17, 13, 13, 0, 13, 13, 0, 13, 17, 14, 2, 13, 13, 0, 13, 17, 0, 13, 13, 4, 18, 13, 13, 13, 39, 2, 17, 13, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 160, 4 ], [ 160, 13 ], [ 157, 15 ], [ 145, 27 ], [ 146, 33 ], [ 36, 35 ], [ 161, 38 ], [ 146, 43 ], [ 158, 48 ], [ 35, 49 ], [ 169, 52 ], [ 172, 55 ], [ 59, 58 ], [ 149, 61 ], [ 190, 63 ], [ 146, 68 ], [ 190, 69 ], [ 154, 71 ], [ 176, 77 ], [ 170, 78 ], [ 194, 78 ], [ 164, 78 ], [ 146, 82 ], [ 146, 87 ], [ 187, 92 ], [ 146, 97 ], [ 187, 98 ], [ 184, 100 ], [ 166, 103 ], [ 146, 109 ], [ 167, 113 ], [ 185, 113 ], [ 182, 113 ], [ 163, 116 ], [ 188, 117 ], [ 178, 119 ], [ 170, 123 ], [ 194, 123 ], [ 164, 123 ], [ 176, 124 ], [ 151, 126 ], [ 193, 129 ], [ 176, 130 ], [ 146, 135 ], [ 179, 139 ], [ 155, 139 ], [ 191, 139 ], [ 152, 143 ], [ 173, 143 ], [ 145, 146 ], [ 160, 149 ], [ 151, 152 ], [ 154, 155 ], [ 157, 158 ], [ 160, 161 ], [ 188, 163 ], [ 163, 164 ], [ 166, 167 ], [ 169, 170 ], [ 172, 173 ], [ 190, 176 ], [ 178, 179 ], [ 187, 182 ], [ 184, 185 ], [ 187, 188 ], [ 190, 191 ], [ 176, 193 ], [ 193, 194 ] ]
[ "import heapq\nK, T = map(int, input().split())\na = tuple(map(int, input().split()))\ncakes = []\nheapq.heapify(cakes)\nfor i in range(T):\n heapq.heappush(cakes, [-1*a[i], i])\n# print(cakes)\nnow = -1\nans = 0\nfor _ in range(K):\n cake_num, cake_idx = heapq.heappop(cakes)\n cake_num *= -1\n if cake_idx == now and len(cakes) > 1 and cakes[0][0] != 0:\n next_cake_num, next_cake_idx = heapq.heappop(cakes)\n next_cake_num *= -1\n next_cake_num -= 1\n heapq.heappush(cakes, [-1 * next_cake_num, next_cake_idx])\n now = next_cake_idx\n else:\n cake_num -= 1\n if now == cake_idx:\n ans += 1\n now = cake_idx\n heapq.heappush(cakes, [-1 * cake_num, cake_idx])\n# print(cakes)\nprint(ans)", "import heapq", "heapq", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = tuple(map(int, input().split()))", "a", "tuple(map(int, input().split()))", "tuple", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cakes = []", "cakes", "[]", "heapq.heapify(cakes)", "heapq.heapify", "heapq", "heapify", "cakes", "for i in range(T):\n heapq.heappush(cakes, [-1*a[i], i])\n# print(cakes)", "i", "range(T)", "range", "T", "heapq.heappush(cakes, [-1*a[i], i])", "heapq.heappush", "heapq", "heappush", "cakes", "[-1*a[i], i]", "-1*a[i]", "-1", "a[i]", "a", "i", "i", "now = -1", "now", "-1", "ans = 0", "ans", "0", "for _ in range(K):\n cake_num, cake_idx = heapq.heappop(cakes)\n cake_num *= -1\n if cake_idx == now and len(cakes) > 1 and cakes[0][0] != 0:\n next_cake_num, next_cake_idx = heapq.heappop(cakes)\n next_cake_num *= -1\n next_cake_num -= 1\n heapq.heappush(cakes, [-1 * next_cake_num, next_cake_idx])\n now = next_cake_idx\n else:\n cake_num -= 1\n if now == cake_idx:\n ans += 1\n now = cake_idx\n heapq.heappush(cakes, [-1 * cake_num, cake_idx])\n# print(cakes)", "_", "range(K)", "range", "K", "cake_num, cake_idx = heapq.heappop(cakes)", "cake_num", "heapq.heappop(cakes)", "heapq.heappop", "heapq", "heappop", "cakes", "cake_idx", "cake_num *= -1", "cake_num", "-1", "if cake_idx == now and len(cakes) > 1 and cakes[0][0] != 0:\n next_cake_num, next_cake_idx = heapq.heappop(cakes)\n next_cake_num *= -1\n next_cake_num -= 1\n heapq.heappush(cakes, [-1 * next_cake_num, next_cake_idx])\n now = next_cake_idx\n else:\n cake_num -= 1\n if now == cake_idx:\n ans += 1\n now = cake_idx\n ", "cake_idx == now and len(cakes) > 1 and cakes[0][0] != 0", "cake_idx == now and len(cakes) > 1", "cake_idx == now", "cake_idx", "now", "len(cakes) > 1", "len(cakes)", "len", "cakes", "1", "cakes[0][0] != 0", "cakes[0][0]", "[0]", "cakes", "0", "0", "0", "next_cake_num, next_cake_idx = heapq.heappop(cakes)", "next_cake_num", "heapq.heappop(cakes)", "heapq.heappop", "heapq", "heappop", "cakes", "next_cake_idx", "next_cake_num *= -1", "next_cake_num", "-1", "next_cake_num -= 1", "next_cake_num", "1", "heapq.heappush(cakes, [-1 * next_cake_num, next_cake_idx])", "heapq.heappush", "heapq", "heappush", "cakes", "[-1 * next_cake_num, next_cake_idx]", "-1 * next_cake_num", "-1", "next_cake_num", "next_cake_idx", "now = next_cake_idx", "now", "next_cake_idx", "cake_num -= 1", "cake_num", "1", "if now == cake_idx:\n ans += 1\n ", "now == cake_idx", "now", "cake_idx", "ans += 1", "ans", "1", "now = cake_idx", "now", "cake_idx", "heapq.heappush(cakes, [-1 * cake_num, cake_idx])", "heapq.heappush", "heapq", "heappush", "cakes", "[-1 * cake_num, cake_idx]", "-1 * cake_num", "-1", "cake_num", "cake_idx", "print(ans)", "print", "ans", "cakes = []", "[]", "cakes", "K, T = map(int, input().split())", "map(int, input().split())", "K", "ans += 1", "1", "ans", "cake_num *= -1", "-1", "cake_num", "a = tuple(map(int, input().split()))", "tuple(map(int, input().split()))", "a", "T = map(int, input().split())", "map(int, input().split())", "T", "now = next_cake_idx", "next_cake_idx", "now", "next_cake_num -= 1", "1", "next_cake_num", "now = -1", "-1", "now", "ans = 0", "0", "ans", "cake_idx = heapq.heappop(cakes)", "heapq.heappop(cakes)", "cake_idx", "cake_num -= 1", "1", "cake_num", "next_cake_num, next_cake_idx = heapq.heappop(cakes)", "heapq.heappop(cakes)", "next_cake_num", "next_cake_num *= -1", "-1", "next_cake_num", "next_cake_idx = heapq.heappop(cakes)", "heapq.heappop(cakes)", "next_cake_idx", "cake_num, cake_idx = heapq.heappop(cakes)", "heapq.heappop(cakes)", "cake_num", "now = cake_idx", "cake_idx", "now" ]
import heapq K, T = map(int, input().split()) a = tuple(map(int, input().split())) cakes = [] heapq.heapify(cakes) for i in range(T): heapq.heappush(cakes, [-1*a[i], i]) # print(cakes) now = -1 ans = 0 for _ in range(K): cake_num, cake_idx = heapq.heappop(cakes) cake_num *= -1 if cake_idx == now and len(cakes) > 1 and cakes[0][0] != 0: next_cake_num, next_cake_idx = heapq.heappop(cakes) next_cake_num *= -1 next_cake_num -= 1 heapq.heappush(cakes, [-1 * next_cake_num, next_cake_idx]) now = next_cake_idx else: cake_num -= 1 if now == cake_idx: ans += 1 now = cake_idx heapq.heappush(cakes, [-1 * cake_num, cake_idx]) # print(cakes) print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 14, 40, 4, 13, 13, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 13, 2, 17, 2, 13, 4, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 55, 2 ], [ 55, 11 ], [ 15, 14 ], [ 14, 23 ], [ 58, 25 ], [ 59, 31 ], [ 56, 33 ], [ 56, 42 ], [ 56, 46 ], [ 59, 49 ], [ 55, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "k,t = map(int, input().split())\na = [int(s) for s in input().split()]\n\nif max(a) <= k / 2:\n print(0)\nelse:\n print(k - 2*(k-max(a)) - 1)", "k,t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "int(s) for s in input().split()", "for s in input().split()", "s", "input().split()", "().split", "()", "input", "split", "for s in input().split()", "int(s)", "int", "s", "a = [int(s) for s in input().split()]", "a", "[int(s) for s in input().split()]", "if max(a) <= k / 2:\n print(0)\nelse:\n print(k - 2*(k-max(a)) - 1)", "max(a) <= k / 2", "max(a)", "max", "a", "k / 2", "k", "2", "print(0)", "print", "0", "print(k - 2*(k-max(a)) - 1)", "print", "k - 2*(k-max(a)) - 1", "k - 2*(k-max(a))", "k", "2*(k-max(a))", "2", "k-max(a)", "k", "max(a)", "max", "a", "1", "t = map(int, input().split())", "map(int, input().split())", "t", "k,t = map(int, input().split())", "map(int, input().split())", "k", "a = [int(s) for s in input().split()]", "[int(s) for s in input().split()]", "a" ]
k,t = map(int, input().split()) a = [int(s) for s in input().split()] if max(a) <= k / 2: print(0) else: print(k - 2*(k-max(a)) - 1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 2, 13, 17, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 59, 2 ], [ 59, 11 ], [ 47, 13 ], [ 50, 25 ], [ 48, 28 ], [ 56, 30 ], [ 48, 33 ], [ 57, 42 ], [ 51, 44 ], [ 47, 48 ], [ 50, 51 ], [ 59, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "k, t = map(int, input().split())\nalst = list(map(int, input().split()))\ntotal = sum(alst)\nmax_num = max(alst)\n\nprint(max(0, max_num * 2 - total - 1))", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "alst = list(map(int, input().split()))", "alst", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "total = sum(alst)", "total", "sum(alst)", "sum", "alst", "max_num = max(alst)", "max_num", "max(alst)", "max", "alst", "print(max(0, max_num * 2 - total - 1))", "print", "max(0, max_num * 2 - total - 1)", "max", "0", "max_num * 2 - total - 1", "max_num * 2 - total", "max_num * 2", "max_num", "2", "total", "1", "alst = list(map(int, input().split()))", "list(map(int, input().split()))", "alst", "total = sum(alst)", "sum(alst)", "total", "k, t = map(int, input().split())", "map(int, input().split())", "k", "max_num = max(alst)", "max(alst)", "max_num", "t = map(int, input().split())", "map(int, input().split())", "t" ]
k, t = map(int, input().split()) alst = list(map(int, input().split())) total = sum(alst) max_num = max(alst) print(max(0, max_num * 2 - total - 1))
[ 7, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 18, 13, 17, 13, 4, 13, 4, 13, 39, 2, 2, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 58, 2 ], [ 52, 14 ], [ 49, 26 ], [ 53, 29 ], [ 55, 31 ], [ 59, 34 ], [ 50, 36 ], [ 50, 44 ], [ 56, 45 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "N = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nmaxQ = max(Q)\nrest = N[0] - maxQ\nprint(max([maxQ-rest-1, 0]))", "N = list(map(int, input().split()))", "N", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "Q = list(map(int, input().split()))", "Q", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "maxQ = max(Q)", "maxQ", "max(Q)", "max", "Q", "rest = N[0] - maxQ", "rest", "N[0] - maxQ", "N[0]", "N", "0", "maxQ", "print(max([maxQ-rest-1, 0]))", "print", "max([maxQ-rest-1, 0])", "max", "[maxQ-rest-1, 0]", "maxQ-rest-1", "maxQ-rest", "maxQ", "rest", "1", "0", "maxQ = max(Q)", "max(Q)", "maxQ", "Q = list(map(int, input().split()))", "list(map(int, input().split()))", "Q", "rest = N[0] - maxQ", "N[0] - maxQ", "rest", "N = list(map(int, input().split()))", "list(map(int, input().split()))", "N" ]
N = list(map(int, input().split())) Q = list(map(int, input().split())) maxQ = max(Q) rest = N[0] - maxQ print(max([maxQ-rest-1, 0]))
[ 7, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 14, 2, 13, 2, 2, 13, 13, 17, 0, 13, 2, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 61, 2 ], [ 61, 13 ], [ 64, 15 ], [ 70, 27 ], [ 65, 30 ], [ 58, 32 ], [ 71, 36 ], [ 62, 39 ], [ 71, 40 ], [ 67, 43 ], [ 71, 45 ], [ 62, 48 ], [ 71, 49 ], [ 68, 53 ], [ 59, 53 ], [ 61, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "K,T = list(map(int,input().split()))\nA = list(map(int,input().split()))\nMA = max(A)\nout = 0\nif MA > K-MA+1:\n out += MA-(K-MA+1)\nprint(out)", "K,T = list(map(int,input().split()))", "K", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "MA = max(A)", "MA", "max(A)", "max", "A", "out = 0", "out", "0", "if MA > K-MA+1:\n out += MA-(K-MA+1)", "MA > K-MA+1", "MA", "K-MA+1", "K-MA", "K", "MA", "1", "out += MA-(K-MA+1)", "out", "MA-(K-MA+1)", "MA", "K-MA+1", "K-MA", "K", "MA", "1", "print(out)", "print", "out", "T = list(map(int,input().split()))", "list(map(int,input().split()))", "T", "out = 0", "0", "out", "K,T = list(map(int,input().split()))", "list(map(int,input().split()))", "K", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "out += MA-(K-MA+1)", "MA-(K-MA+1)", "out", "MA = max(A)", "max(A)", "MA" ]
K,T = list(map(int,input().split())) A = list(map(int,input().split())) MA = max(A) out = 0 if MA > K-MA+1: out += MA-(K-MA+1) print(out)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 4, 13, 17, 2, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 59, 2 ], [ 59, 11 ], [ 53, 13 ], [ 62, 25 ], [ 54, 28 ], [ 65, 30 ], [ 54, 34 ], [ 63, 35 ], [ 50, 37 ], [ 63, 43 ], [ 66, 44 ], [ 51, 48 ], [ 50, 51 ], [ 53, 54 ], [ 59, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nAmax = max(A)\nAsum = sum(A) - Amax\n\nans = max(0, Amax - Asum - 1)\nprint(ans)", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "Amax = max(A)", "Amax", "max(A)", "max", "A", "Asum = sum(A) - Amax", "Asum", "sum(A) - Amax", "sum(A)", "sum", "A", "Amax", "ans = max(0, Amax - Asum - 1)", "ans", "max(0, Amax - Asum - 1)", "max", "0", "Amax - Asum - 1", "Amax - Asum", "Amax", "Asum", "1", "print(ans)", "print", "ans", "ans = max(0, Amax - Asum - 1)", "max(0, Amax - Asum - 1)", "ans", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "T = map(int, input().split())", "map(int, input().split())", "T", "K, T = map(int, input().split())", "map(int, input().split())", "K", "Amax = max(A)", "max(A)", "Amax", "Asum = sum(A) - Amax", "sum(A) - Amax", "Asum" ]
K, T = map(int, input().split()) A = list(map(int, input().split())) Amax = max(A) Asum = sum(A) - Amax ans = max(0, Amax - Asum - 1) print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 2, 18, 13, 17, 17, 0, 13, 4, 13, 18, 13, 39, 2, 13, 17, 4, 13, 4, 13, 2, 13, 13, 17, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 63, 2 ], [ 63, 11 ], [ 66, 13 ], [ 67, 26 ], [ 54, 29 ], [ 67, 32 ], [ 57, 36 ], [ 67, 40 ], [ 64, 43 ], [ 55, 50 ], [ 58, 51 ], [ 54, 55 ], [ 57, 58 ], [ 63, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "num_cakes, num_kinds = map(int,input().split())\nkinds_ls = list(map(int, input().split()))\nkinds_ls.sort()\nmax_value = kinds_ls[-1] - 1\nelse_sum = sum(kinds_ls[:num_kinds-1])\n\nprint(max(max_value-else_sum,0))", "num_cakes, num_kinds = map(int,input().split())", "num_cakes", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "num_kinds", "kinds_ls = list(map(int, input().split()))", "kinds_ls", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "kinds_ls.sort()", "kinds_ls.sort", "kinds_ls", "sort", "max_value = kinds_ls[-1] - 1", "max_value", "kinds_ls[-1] - 1", "kinds_ls[-1]", "kinds_ls", "-1", "1", "else_sum = sum(kinds_ls[:num_kinds-1])", "else_sum", "sum(kinds_ls[:num_kinds-1])", "sum", "kinds_ls[:num_kinds-1]", "kinds_ls", ":num_kinds-1", "num_kinds-1", "num_kinds", "1", "print(max(max_value-else_sum,0))", "print", "max(max_value-else_sum,0)", "max", "max_value-else_sum", "max_value", "else_sum", "0", "max_value = kinds_ls[-1] - 1", "kinds_ls[-1] - 1", "max_value", "else_sum = sum(kinds_ls[:num_kinds-1])", "sum(kinds_ls[:num_kinds-1])", "else_sum", "num_cakes, num_kinds = map(int,input().split())", "map(int,input().split())", "num_cakes", "num_kinds = map(int,input().split())", "map(int,input().split())", "num_kinds", "kinds_ls = list(map(int, input().split()))", "list(map(int, input().split()))", "kinds_ls" ]
num_cakes, num_kinds = map(int,input().split()) kinds_ls = list(map(int, input().split())) kinds_ls.sort() max_value = kinds_ls[-1] - 1 else_sum = sum(kinds_ls[:num_kinds-1]) print(max(max_value-else_sum,0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 14, 40, 2, 13, 17, 13, 4, 13, 17, 4, 13, 2, 2, 13, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 68, 2 ], [ 68, 11 ], [ 65, 13 ], [ 62, 25 ], [ 66, 28 ], [ 60, 31 ], [ 69, 36 ], [ 69, 43 ], [ 63, 45 ], [ 63, 53 ], [ 69, 55 ], [ 63, 56 ], [ 68, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\nmaxa = max(a)\nif t == 1:\n print(k-1)\n exit()\nif k//2 >= maxa:\n print(0)\nelse:\n print(maxa-(k-maxa)-1)", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "maxa = max(a)", "maxa", "max(a)", "max", "a", "if t == 1:\n print(k-1)\n exit()", "t == 1", "t", "1", "print(k-1)", "print", "k-1", "k", "1", "exit()", "exit", "if k//2 >= maxa:\n print(0)\nelse:\n print(maxa-(k-maxa)-1)", "k//2 >= maxa", "k//2", "k", "2", "maxa", "print(0)", "print", "0", "print(maxa-(k-maxa)-1)", "print", "maxa-(k-maxa)-1", "maxa-(k-maxa)", "maxa", "k-maxa", "k", "maxa", "1", "t = map(int,input().split())", "map(int,input().split())", "t", "maxa = max(a)", "max(a)", "maxa", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "k,t = map(int,input().split())", "map(int,input().split())", "k" ]
k,t = map(int,input().split()) a = list(map(int,input().split())) maxa = max(a) if t == 1: print(k-1) exit() if k//2 >= maxa: print(0) else: print(maxa-(k-maxa)-1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 14, 2, 4, 13, 13, 17, 0, 13, 2, 18, 13, 17, 4, 13, 18, 13, 39, 17, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 17, 4, 13, 2, 18, 13, 17, 17, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 82, 2 ], [ 82, 11 ], [ 79, 13 ], [ 70, 25 ], [ 80, 28 ], [ 31, 30 ], [ 71, 36 ], [ 80, 36 ], [ 73, 39 ], [ 71, 42 ], [ 80, 42 ], [ 71, 47 ], [ 80, 47 ], [ 74, 52 ], [ 74, 57 ], [ 71, 66 ], [ 80, 66 ], [ 70, 71 ], [ 73, 74 ], [ 82, 77 ], [ 79, 80 ], [ 82, 83 ] ]
[ "k,t=map(int,input().split())\na=list(map(int,input().split()))\na=sorted(a, reverse=True)\n\nif len(a)>1:\n x=a[0]-sum(a[1:])\n if x>0:\n print(x-1)\n else:\n print(0)\nelse:\n print(a[0]-1)", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a=sorted(a, reverse=True)", "a", "sorted(a, reverse=True)", "sorted", "a", "reverse=True", "reverse", "True", "if len(a)>1:\n x=a[0]-sum(a[1:])\n if x>0:\n print(x-1)\n else:\n print(0)\nelse:\n print(a[0]-1)", "len(a)>1", "len(a)", "len", "a", "1", "x=a[0]-sum(a[1:])", "x", "a[0]-sum(a[1:])", "a[0]", "a", "0", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "if x>0:\n print(x-1)\n else:\n print(0)", "x>0", "x", "0", "print(x-1)", "print", "x-1", "x", "1", "print(0)", "print", "0", "print(a[0]-1)", "print", "a[0]-1", "a[0]", "a", "0", "1", "a=sorted(a, reverse=True)", "sorted(a, reverse=True)", "a", "x=a[0]-sum(a[1:])", "a[0]-sum(a[1:])", "x", "k,t=map(int,input().split())", "map(int,input().split())", "k", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "t=map(int,input().split())", "map(int,input().split())", "t" ]
k,t=map(int,input().split()) a=list(map(int,input().split())) a=sorted(a, reverse=True) if len(a)>1: x=a[0]-sum(a[1:]) if x>0: print(x-1) else: print(0) else: print(a[0]-1)
[ 7, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 41, 28, 13, 13, 4, 2, 13, 17, 0, 13, 13, 15, 13, 0, 13, 17, 4, 18, 13, 13, 13, 28, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 17, 4, 18, 13, 13, 13, 13, 0, 13, 13, 41, 28, 13, 13, 40, 13, 17, 4, 13, 0, 13, 13, 14, 2, 4, 13, 13, 17, 4, 13, 2, 2, 13, 17, 13, 4, 13, 10, 13, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 120, 2 ], [ 120, 13 ], [ 114, 15 ], [ 29, 28 ], [ 115, 28 ], [ 28, 32 ], [ 123, 35 ], [ 117, 40 ], [ 124, 46 ], [ 115, 46 ], [ 49, 48 ], [ 121, 51 ], [ 105, 53 ], [ 124, 58 ], [ 115, 58 ], [ 103, 58 ], [ 108, 60 ], [ 124, 66 ], [ 115, 66 ], [ 103, 66 ], [ 118, 67 ], [ 100, 67 ], [ 99, 69 ], [ 109, 70 ], [ 106, 70 ], [ 74, 73 ], [ 124, 73 ], [ 115, 73 ], [ 103, 73 ], [ 73, 76 ], [ 73, 79 ], [ 102, 81 ], [ 103, 87 ], [ 124, 87 ], [ 115, 87 ], [ 121, 93 ], [ 48, 95 ], [ 109, 99 ], [ 106, 99 ], [ 99, 100 ], [ 102, 103 ], [ 105, 106 ], [ 108, 109 ], [ 120, 112 ], [ 114, 115 ], [ 117, 118 ], [ 120, 121 ], [ 123, 124 ] ]
[ "H,W=list(map(int,input().split()))\nl=list(map(int,input().split()))\nl=[i*-1 for i in l]\nimport heapq\nB=0\nheapq.heapify(l)\nfor i in range(H):\n A=heapq.heappop(l)\n A+=1\n heapq.heappush(l,B)\n B=A\n l=[i for i in l if i!=0]\n if len(l)==0:\n print(H-1-i)\n exit()", "H,W=list(map(int,input().split()))", "H", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "W", "l=list(map(int,input().split()))", "l", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "i*-1 for i in l", "for i in l", "i", "l", "for i in l", "i*-1", "i", "-1", "l=[i*-1 for i in l]", "l", "[i*-1 for i in l]", "import heapq", "heapq", "B=0", "B", "0", "heapq.heapify(l)", "heapq.heapify", "heapq", "heapify", "l", "for i in range(H):\n A=heapq.heappop(l)\n A+=1\n heapq.heappush(l,B)\n B=A\n l=[i for i in l if i!=0]\n if len(l)==0:\n print(H-1-i)\n exit()", "i", "range(H)", "range", "H", "A=heapq.heappop(l)", "A", "heapq.heappop(l)", "heapq.heappop", "heapq", "heappop", "l", "A+=1", "A", "1", "heapq.heappush(l,B)", "heapq.heappush", "heapq", "heappush", "l", "B", "B=A", "B", "A", "i for i in l if i!=0", "for i in l if i!=0", "i", "l", "i!=0", "i", "0", "if i!=0", "i", "l=[i for i in l if i!=0]", "l", "[i for i in l if i!=0]", "if len(l)==0:\n print(H-1-i)\n exit()", "len(l)==0", "len(l)", "len", "l", "0", "print(H-1-i)", "print", "H-1-i", "H-1", "H", "1", "i", "exit()", "exit", "B=A", "A", "B", "l=[i for i in l if i!=0]", "[i for i in l if i!=0]", "l", "A=heapq.heappop(l)", "heapq.heappop(l)", "A", "A+=1", "1", "A", "W=list(map(int,input().split()))", "list(map(int,input().split()))", "W", "l=list(map(int,input().split()))", "list(map(int,input().split()))", "l", "B=0", "0", "B", "H,W=list(map(int,input().split()))", "list(map(int,input().split()))", "H", "l=[i*-1 for i in l]", "[i*-1 for i in l]", "l" ]
H,W=list(map(int,input().split())) l=list(map(int,input().split())) l=[i*-1 for i in l] import heapq B=0 heapq.heapify(l) for i in range(H): A=heapq.heappop(l) A+=1 heapq.heappush(l,B) B=A l=[i for i in l if i!=0] if len(l)==0: print(H-1-i) exit()
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 13, 13, 29, 39, 13, 13, 13, 12, 13, 14, 2, 13, 17, 29, 2, 13, 17, 4, 18, 13, 13, 29, 4, 13, 2, 2, 18, 13, 17, 4, 13, 18, 13, 39, 17, 17, 17, 23, 13, 23, 13, 23, 13, 14, 2, 13, 17, 0, 13, 4, 13, 0, 13, 4, 13, 31, 13, 14, 40, 13, 17, 4, 13, 2, 17, 4, 13, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13 ]
[ [ 120, 4 ], [ 14, 13 ], [ 121, 22 ], [ 14, 25 ], [ 28, 27 ], [ 121, 38 ], [ 79, 50 ], [ 77, 54 ], [ 81, 58 ], [ 81, 66 ], [ 81, 71 ], [ 77, 77 ], [ 79, 79 ], [ 81, 81 ], [ 114, 87 ], [ 112, 89 ], [ 117, 91 ], [ 109, 93 ], [ 115, 95 ], [ 118, 98 ], [ 118, 106 ], [ 114, 115 ], [ 117, 118 ], [ 120, 121 ] ]
[ "import sys\ninput = sys.stdin.readline\n\n\ndef read():\n K, T = map(int, input().strip().split())\n A = list(map(int, input().strip().split()))\n return K, T, A\n\n\ndef solve(K, T, A):\n if T == 1:\n return K-1\n A.sort()\n return max(A[-1] - sum(A[:-1]) - 1, 0)\n\n\nif __name__ == '__main__':\n inputs = read()\n outputs = solve(*inputs)\n if outputs is not None:\n print(\"%s\" % str(outputs))", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def read():\n K, T = map(int, input().strip().split())\n A = list(map(int, input().strip().split()))\n return K, T, A", "read", "K, T = map(int, input().strip().split())", "K", "map(int, input().strip().split())", "map", "int", "input().strip().split()", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "T", "A = list(map(int, input().strip().split()))", "A", "list(map(int, input().strip().split()))", "list", "map(int, input().strip().split())", "map", "int", "input().strip().split()", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "return K, T, A", "return K, T, A", "K", "T", "A", "def solve(K, T, A):\n if T == 1:\n return K-1\n A.sort()\n return max(A[-1] - sum(A[:-1]) - 1, 0)", "solve", "if T == 1:\n return K-1\n ", "T == 1", "T", "1", "return K-1", "K-1", "K", "1", "A.sort()", "A.sort", "A", "sort", "return max(A[-1] - sum(A[:-1]) - 1, 0)", "max(A[-1] - sum(A[:-1]) - 1, 0)", "max", "A[-1] - sum(A[:-1]) - 1", "A[-1] - sum(A[:-1])", "A[-1]", "A", "-1", "sum(A[:-1])", "sum", "A[:-1]", "A", ":-1", "-1", "1", "0", "K", "K", "T", "T", "A", "A", "if __name__ == '__main__':\n inputs = read()\n outputs = solve(*inputs)\n if outputs is not None:\n print(\"%s\" % str(outputs))", "__name__ == '__main__'", "__name__", "'__main__'", "inputs = read()", "inputs", "read()", "read", "outputs = solve(*inputs)", "outputs", "solve(*inputs)", "solve", "*inputs", "inputs", "if outputs is not None:\n print(\"%s\" % str(outputs))", "outputs is not None", "outputs", "None", "print(\"%s\" % str(outputs))", "print", "\"%s\" % str(outputs)", "\"%s\"", "str(outputs)", "str", "outputs", "def solve(K, T, A):\n if T == 1:\n return K-1\n A.sort()\n return max(A[-1] - sum(A[:-1]) - 1, 0)", "def solve(K, T, A):\n if T == 1:\n return K-1\n A.sort()\n return max(A[-1] - sum(A[:-1]) - 1, 0)", "solve", "def read():\n K, T = map(int, input().strip().split())\n A = list(map(int, input().strip().split()))\n return K, T, A", "def read():\n K, T = map(int, input().strip().split())\n A = list(map(int, input().strip().split()))\n return K, T, A", "read", "inputs = read()", "read()", "inputs", "outputs = solve(*inputs)", "solve(*inputs)", "outputs", "input = sys.stdin.readline", "sys.stdin.readline", "input" ]
import sys input = sys.stdin.readline def read(): K, T = map(int, input().strip().split()) A = list(map(int, input().strip().split())) return K, T, A def solve(K, T, A): if T == 1: return K-1 A.sort() return max(A[-1] - sum(A[:-1]) - 1, 0) if __name__ == '__main__': inputs = read() outputs = solve(*inputs) if outputs is not None: print("%s" % str(outputs))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 4, 13, 2, 2, 17, 18, 13, 17, 2, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 47, 2 ], [ 47, 11 ], [ 41, 13 ], [ 42, 34 ], [ 48, 37 ], [ 41, 42 ], [ 47, 45 ], [ 47, 48 ] ]
[ "K, T = map(int, input().split())\nA = sorted(list(map(int, input().split())))\nprint(max((2 * A[-1]) - (K + 1), 0))", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = sorted(list(map(int, input().split())))", "A", "sorted(list(map(int, input().split())))", "sorted", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max((2 * A[-1]) - (K + 1), 0))", "print", "max((2 * A[-1]) - (K + 1), 0)", "max", "(2 * A[-1]) - (K + 1)", "2 * A[-1]", "2", "A[-1]", "A", "-1", "K + 1", "K", "1", "0", "A = sorted(list(map(int, input().split())))", "sorted(list(map(int, input().split())))", "A", "T = map(int, input().split())", "map(int, input().split())", "T", "K, T = map(int, input().split())", "map(int, input().split())", "K" ]
K, T = map(int, input().split()) A = sorted(list(map(int, input().split()))) print(max((2 * A[-1]) - (K + 1), 0))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 18, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 17, 4, 13, 4, 13, 17, 2, 2, 13, 17, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 18, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 71, 4 ], [ 74, 11 ], [ 72, 20 ], [ 74, 22 ], [ 65, 24 ], [ 72, 35 ], [ 68, 38 ], [ 66, 40 ], [ 77, 43 ], [ 66, 47 ], [ 69, 58 ], [ 78, 60 ], [ 74, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ] ]
[ "import sys\ninput = sys.stdin.readline\n\nK,T = list(map(int,input().split()))\na = sorted(list(map(int,input().split())))\namax = a[-1]\nasub = sum(a[0:-1])\n\nprint(max(0,amax-1-asub))", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "K,T = list(map(int,input().split()))", "K", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = sorted(list(map(int,input().split())))", "a", "sorted(list(map(int,input().split())))", "sorted", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "amax = a[-1]", "amax", "a[-1]", "a", "-1", "asub = sum(a[0:-1])", "asub", "sum(a[0:-1])", "sum", "a[0:-1]", "a", "0:-1", "0", "-1", "print(max(0,amax-1-asub))", "print", "max(0,amax-1-asub)", "max", "0", "amax-1-asub", "amax-1", "amax", "1", "asub", "K,T = list(map(int,input().split()))", "list(map(int,input().split()))", "K", "a = sorted(list(map(int,input().split())))", "sorted(list(map(int,input().split())))", "a", "amax = a[-1]", "a[-1]", "amax", "input = sys.stdin.readline", "sys.stdin.readline", "input", "T = list(map(int,input().split()))", "list(map(int,input().split()))", "T", "asub = sum(a[0:-1])", "sum(a[0:-1])", "asub" ]
import sys input = sys.stdin.readline K,T = list(map(int,input().split())) a = sorted(list(map(int,input().split()))) amax = a[-1] asub = sum(a[0:-1]) print(max(0,amax-1-asub))
[ 7, 15, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 4, 18, 13, 13, 13, 28, 13, 4, 13, 13, 4, 18, 13, 13, 13, 39, 2, 18, 13, 13, 17, 13, 0, 13, 17, 0, 13, 17, 42, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 13, 14, 2, 2, 13, 13, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 13, 4, 18, 13, 13, 13, 39, 13, 13, 0, 13, 13, 13, 13, 14, 2, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 4, 18, 13, 13, 13, 39, 2, 13, 17, 13, 0, 13, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 39, 13, 10, 17, 13, 10, 13, 13, 10, 13, 13, 10, 4, 13 ]
[ [ 157, 4 ], [ 157, 13 ], [ 163, 15 ], [ 169, 27 ], [ 170, 33 ], [ 36, 35 ], [ 158, 38 ], [ 170, 43 ], [ 164, 47 ], [ 35, 48 ], [ 136, 52 ], [ 160, 55 ], [ 170, 61 ], [ 181, 64 ], [ 170, 69 ], [ 181, 70 ], [ 155, 74 ], [ 167, 74 ], [ 161, 75 ], [ 176, 75 ], [ 170, 79 ], [ 151, 82 ], [ 170, 87 ], [ 151, 88 ], [ 170, 93 ], [ 178, 98 ], [ 152, 99 ], [ 166, 100 ], [ 149, 101 ], [ 167, 104 ], [ 155, 104 ], [ 161, 105 ], [ 176, 105 ], [ 172, 107 ], [ 145, 110 ], [ 142, 113 ], [ 143, 117 ], [ 146, 117 ], [ 179, 117 ], [ 182, 117 ], [ 170, 123 ], [ 143, 126 ], [ 146, 126 ], [ 179, 126 ], [ 182, 126 ], [ 175, 130 ], [ 167, 131 ], [ 155, 131 ], [ 173, 134 ], [ 137, 134 ], [ 136, 137 ], [ 157, 140 ], [ 142, 143 ], [ 145, 146 ], [ 151, 149 ], [ 151, 152 ], [ 181, 155 ], [ 157, 158 ], [ 160, 161 ], [ 163, 164 ], [ 149, 166 ], [ 166, 167 ], [ 169, 170 ], [ 172, 173 ], [ 167, 175 ], [ 155, 175 ], [ 175, 176 ], [ 152, 178 ], [ 178, 179 ], [ 181, 182 ] ]
[ "import heapq\n\nk, t = map(int, input().split())\na = list(map(int, input().split()))\n\nq = []\nheapq.heapify(q)\n\nfor i in range(t):\n heapq.heappush(q, [a[i] * -1, i])\n\nans = 0\nprev = -1\n\nwhile len(q) > 0:\n num, idx = heapq.heappop(q)\n if idx == prev and len(q) > 0:\n num2, idx2 = heapq.heappop(q)\n heapq.heappush(q, [num, idx])\n num, idx = num2, idx2\n\n if idx == prev:\n ans += 1\n num *= -1\n num -= 1\n if num > 0:\n heapq.heappush(q, [num * -1, idx])\n prev = idx\n\nprint(ans)", "import heapq", "heapq", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "q = []", "q", "[]", "heapq.heapify(q)", "heapq.heapify", "heapq", "heapify", "q", "for i in range(t):\n heapq.heappush(q, [a[i] * -1, i])", "i", "range(t)", "range", "t", "heapq.heappush(q, [a[i] * -1, i])", "heapq.heappush", "heapq", "heappush", "q", "[a[i] * -1, i]", "a[i] * -1", "a[i]", "a", "i", "-1", "i", "ans = 0", "ans", "0", "prev = -1", "prev", "-1", "while len(q) > 0:\n num, idx = heapq.heappop(q)\n if idx == prev and len(q) > 0:\n num2, idx2 = heapq.heappop(q)\n heapq.heappush(q, [num, idx])\n num, idx = num2, idx2\n\n if idx == prev:\n ans += 1\n num *= -1\n num -= 1\n if num > 0:\n heapq.heappush(q, [num * -1, idx])\n prev = idx", "len(q) > 0", "len(q)", "len", "q", "0", "num, idx = heapq.heappop(q)", "num", "heapq.heappop(q)", "heapq.heappop", "heapq", "heappop", "q", "idx", "if idx == prev and len(q) > 0:\n num2, idx2 = heapq.heappop(q)\n heapq.heappush(q, [num, idx])\n num, idx = num2, idx2\n\n ", "idx == prev and len(q) > 0", "idx == prev", "idx", "prev", "len(q) > 0", "len(q)", "len", "q", "0", "num2, idx2 = heapq.heappop(q)", "num2", "heapq.heappop(q)", "heapq.heappop", "heapq", "heappop", "q", "idx2", "heapq.heappush(q, [num, idx])", "heapq.heappush", "heapq", "heappush", "q", "[num, idx]", "num", "idx", "num, idx = num2, idx2", "num", "num2", "idx", "idx2", "if idx == prev:\n ans += 1\n ", "idx == prev", "idx", "prev", "ans += 1", "ans", "1", "num *= -1", "num", "-1", "num -= 1", "num", "1", "if num > 0:\n heapq.heappush(q, [num * -1, idx])\n ", "num > 0", "num", "0", "heapq.heappush(q, [num * -1, idx])", "heapq.heappush", "heapq", "heappush", "q", "[num * -1, idx]", "num * -1", "num", "-1", "idx", "prev = idx", "prev", "idx", "print(ans)", "print", "ans", "ans = 0", "0", "ans", "k, t = map(int, input().split())", "map(int, input().split())", "k", "num -= 1", "1", "num", "num *= -1", "-1", "num", "idx2 = heapq.heappop(q)", "heapq.heappop(q)", "idx2", "num2, idx2 = heapq.heappop(q)", "heapq.heappop(q)", "num2", "idx = heapq.heappop(q)", "heapq.heappop(q)", "idx", "t = map(int, input().split())", "map(int, input().split())", "t", "prev = -1", "-1", "prev", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "idx = num2, idx2", "idx2", "idx", "q = []", "[]", "q", "ans += 1", "1", "ans", "prev = idx", "idx", "prev", "num, idx = num2, idx2", "num2", "num", "num, idx = heapq.heappop(q)", "heapq.heappop(q)", "num" ]
import heapq k, t = map(int, input().split()) a = list(map(int, input().split())) q = [] heapq.heapify(q) for i in range(t): heapq.heappush(q, [a[i] * -1, i]) ans = 0 prev = -1 while len(q) > 0: num, idx = heapq.heappop(q) if idx == prev and len(q) > 0: num2, idx2 = heapq.heappop(q) heapq.heappush(q, [num, idx]) num, idx = num2, idx2 if idx == prev: ans += 1 num *= -1 num -= 1 if num > 0: heapq.heappush(q, [num * -1, idx]) prev = idx print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 17, 13, 14, 2, 18, 13, 13, 18, 13, 13, 0, 13, 18, 13, 13, 0, 13, 13, 0, 13, 18, 13, 13, 4, 13, 4, 13, 17, 2, 2, 18, 13, 13, 13, 17, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 18, 13, 10, 18, 13 ]
[ [ 76, 2 ], [ 76, 11 ], [ 79, 13 ], [ 82, 25 ], [ 70, 28 ], [ 32, 31 ], [ 74, 35 ], [ 80, 39 ], [ 83, 40 ], [ 86, 40 ], [ 80, 42 ], [ 31, 43 ], [ 91, 45 ], [ 80, 47 ], [ 83, 48 ], [ 86, 48 ], [ 85, 50 ], [ 31, 51 ], [ 88, 53 ], [ 80, 55 ], [ 31, 56 ], [ 80, 65 ], [ 86, 66 ], [ 83, 66 ], [ 89, 67 ], [ 92, 67 ], [ 71, 67 ], [ 70, 71 ], [ 76, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 31, 85 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ] ]
[ "k,t=map(int,input().split())\na=list(map(int,input().split()))\na_m=0\nsm =0\nfor i in range(1,t):\n if a[a_m] < a[i]:\n sm += a[a_m]\n a_m = i\n else:\n sm += a[i]\n\nprint(max(0, a[a_m]-sm-1))", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a_m=0", "a_m", "0", "sm =0", "sm", "0", "for i in range(1,t):\n if a[a_m] < a[i]:\n sm += a[a_m]\n a_m = i\n else:\n sm += a[i]", "i", "range(1,t)", "range", "1", "t", "if a[a_m] < a[i]:\n sm += a[a_m]\n a_m = i\n else:\n sm += a[i]", "a[a_m] < a[i]", "a[a_m]", "a", "a_m", "a[i]", "a", "i", "sm += a[a_m]", "sm", "a[a_m]", "a", "a_m", "a_m = i", "a_m", "i", "sm += a[i]", "sm", "a[i]", "a", "i", "print(max(0, a[a_m]-sm-1))", "print", "max(0, a[a_m]-sm-1)", "max", "0", "a[a_m]-sm-1", "a[a_m]-sm", "a[a_m]", "a", "a_m", "sm", "1", "sm =0", "0", "sm", "t=map(int,input().split())", "map(int,input().split())", "t", "k,t=map(int,input().split())", "map(int,input().split())", "k", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "a_m=0", "0", "a_m", "a_m = i", "i", "a_m", "sm += a[i]", "a[i]", "sm", "sm += a[a_m]", "a[a_m]", "sm" ]
k,t=map(int,input().split()) a=list(map(int,input().split())) a_m=0 sm =0 for i in range(1,t): if a[a_m] < a[i]: sm += a[a_m] a_m = i else: sm += a[i] print(max(0, a[a_m]-sm-1))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 4, 13, 2, 2, 2, 17, 4, 13, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 42, 2 ], [ 42, 11 ], [ 45, 13 ], [ 46, 34 ], [ 40, 35 ], [ 42, 40 ], [ 42, 43 ], [ 45, 46 ] ]
[ "K,T = map(int,input().split())\nA = list(map(int,input().split()))\nprint(max(2*max(A)-K-1,0))", "K,T = map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max(2*max(A)-K-1,0))", "print", "max(2*max(A)-K-1,0)", "max", "2*max(A)-K-1", "2*max(A)-K", "2*max(A)", "2", "max(A)", "max", "A", "K", "1", "0", "K,T = map(int,input().split())", "map(int,input().split())", "K", "T = map(int,input().split())", "map(int,input().split())", "T", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A" ]
K,T = map(int,input().split()) A = list(map(int,input().split())) print(max(2*max(A)-K-1,0))
[ 7, 12, 13, 0, 13, 17, 28, 13, 13, 4, 18, 13, 13, 14, 2, 2, 13, 17, 2, 13, 13, 0, 13, 13, 0, 13, 13, 29, 13, 23, 13, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 41, 28, 13, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 4, 13, 13, 0, 13, 13, 0, 13, 17, 42, 2, 4, 13, 13, 17, 41, 28, 13, 13, 4, 18, 13, 13, 14, 40, 13, 13, 4, 13, 13, 0, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 18, 13, 13, 17, 24, 18, 13, 13, 4, 13, 2, 18, 4, 13, 4, 18, 13, 13, 17, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 30, 11 ], [ 4, 16 ], [ 22, 16 ], [ 25, 20 ], [ 23, 22 ], [ 26, 25 ], [ 22, 28 ], [ 4, 28 ], [ 30, 30 ], [ 35, 34 ], [ 35, 43 ], [ 64, 63 ], [ 67, 66 ], [ 63, 72 ], [ 63, 80 ], [ 66, 85 ], [ 90, 85 ], [ 91, 90 ], [ 128, 92 ], [ 101, 96 ], [ 63, 97 ], [ 90, 98 ], [ 66, 98 ], [ 104, 101 ], [ 63, 102 ], [ 90, 103 ], [ 66, 103 ], [ 101, 106 ], [ 63, 107 ], [ 90, 108 ], [ 66, 108 ], [ 63, 117 ], [ 125, 122 ] ]
[ "def get_max(aa):\n mi = None\n for i,v in aa.items():\n if mi is None or v > mv:\n mi = i\n mv = v\n return mi\n\ndef main():\n k,t=map(int,input().split())\n aa={i:v for i,v in enumerate(map(int,input().split()),1)}\n mi = None\n while len(aa) > 1:\n mi = get_max({i:v for i,v in aa.items() if i != mi})\n if aa[mi] > 1:\n aa[mi]-=1\n else:\n del aa[mi]\n print(list(aa.values())[0]-1)\n\nmain()", "def get_max(aa):\n mi = None\n for i,v in aa.items():\n if mi is None or v > mv:\n mi = i\n mv = v\n return mi", "get_max", "mi = None", "mi", "None", "for i,v in aa.items():\n if mi is None or v > mv:\n mi = i\n mv = v\n ", "i", "v", "aa.items()", "aa.items", "aa", "items", "if mi is None or v > mv:\n mi = i\n mv = v\n ", "mi is None or v > mv", "mi is None", "mi", "None", "v > mv", "v", "mv", "mi = i", "mi", "i", "mv = v", "mv", "v", "return mi", "mi", "aa", "aa", "def main():\n k,t=map(int,input().split())\n aa={i:v for i,v in enumerate(map(int,input().split()),1)}\n mi = None\n while len(aa) > 1:\n mi = get_max({i:v for i,v in aa.items() if i != mi})\n if aa[mi] > 1:\n aa[mi]-=1\n else:\n del aa[mi]\n print(list(aa.values())[0]-1)", "main", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "i:v for i,v in enumerate(map(int,input().split()),1)", "for i,v in enumerate(map(int,input().split()),1)", "i", "v", "enumerate(map(int,input().split()),1)", "enumerate", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "1", "for i,v in enumerate(map(int,input().split()),1)", "i", "v", "aa={i:v for i,v in enumerate(map(int,input().split()),1)}", "aa", "{i:v for i,v in enumerate(map(int,input().split()),1)}", "mi = None", "mi", "None", "while len(aa) > 1:\n mi = get_max({i:v for i,v in aa.items() if i != mi})\n if aa[mi] > 1:\n aa[mi]-=1\n else:\n del aa[mi]\n ", "len(aa) > 1", "len(aa)", "len", "aa", "1", "i:v for i,v in aa.items() if i != mi", "for i,v in aa.items() if i != mi", "i", "v", "aa.items()", "aa.items", "aa", "items", "i", "i != mi", "i", "mi", "if i != mi", "i", "v", "mi = get_max({i:v for i,v in aa.items() if i != mi})", "mi", "get_max({i:v for i,v in aa.items() if i != mi})", "get_max", "{i:v for i,v in aa.items() if i != mi}", "if aa[mi] > 1:\n aa[mi]-=1\n else:\n del aa[mi]\n ", "aa[mi] > 1", "aa[mi]", "aa", "mi", "1", "aa[mi]-=1", "aa[mi]", "aa", "mi", "1", "del aa[mi]", "aa[mi]", "aa", "mi", "print(list(aa.values())[0]-1)", "print", "list(aa.values())[0]-1", "list(aa.values())[0]", "(aa.values())", "list", "aa.values()", "aa.values", "aa", "values", "0", "1", "main()", "main", "def main():\n k,t=map(int,input().split())\n aa={i:v for i,v in enumerate(map(int,input().split()),1)}\n mi = None\n while len(aa) > 1:\n mi = get_max({i:v for i,v in aa.items() if i != mi})\n if aa[mi] > 1:\n aa[mi]-=1\n else:\n del aa[mi]\n print(list(aa.values())[0]-1)", "def main():\n k,t=map(int,input().split())\n aa={i:v for i,v in enumerate(map(int,input().split()),1)}\n mi = None\n while len(aa) > 1:\n mi = get_max({i:v for i,v in aa.items() if i != mi})\n if aa[mi] > 1:\n aa[mi]-=1\n else:\n del aa[mi]\n print(list(aa.values())[0]-1)", "main", "def get_max(aa):\n mi = None\n for i,v in aa.items():\n if mi is None or v > mv:\n mi = i\n mv = v\n return mi", "def get_max(aa):\n mi = None\n for i,v in aa.items():\n if mi is None or v > mv:\n mi = i\n mv = v\n return mi", "get_max" ]
def get_max(aa): mi = None for i,v in aa.items(): if mi is None or v > mv: mi = i mv = v return mi def main(): k,t=map(int,input().split()) aa={i:v for i,v in enumerate(map(int,input().split()),1)} mi = None while len(aa) > 1: mi = get_max({i:v for i,v in aa.items() if i != mi}) if aa[mi] > 1: aa[mi]-=1 else: del aa[mi] print(list(aa.values())[0]-1) main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 2, 2, 13, 17, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 54, 2 ], [ 54, 11 ], [ 48, 13 ], [ 57, 25 ], [ 49, 28 ], [ 45, 30 ], [ 58, 35 ], [ 55, 38 ], [ 58, 39 ], [ 46, 43 ], [ 45, 46 ], [ 48, 49 ], [ 54, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "K, T = map(int, input().split())\na = list(map(int, input().split()))\n\nM = max(a)\nans = max(M - 1 - (K - M), 0)\nprint(ans)", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "M = max(a)", "M", "max(a)", "max", "a", "ans = max(M - 1 - (K - M), 0)", "ans", "max(M - 1 - (K - M), 0)", "max", "M - 1 - (K - M)", "M - 1", "M", "1", "K - M", "K", "M", "0", "print(ans)", "print", "ans", "ans = max(M - 1 - (K - M), 0)", "max(M - 1 - (K - M), 0)", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "T = map(int, input().split())", "map(int, input().split())", "T", "K, T = map(int, input().split())", "map(int, input().split())", "K", "M = max(a)", "max(a)", "M" ]
K, T = map(int, input().split()) a = list(map(int, input().split())) M = max(a) ans = max(M - 1 - (K - M), 0) print(ans)
[ 7, 12, 13, 15, 13, 0, 13, 18, 18, 13, 13, 13, 41, 28, 13, 4, 18, 4, 18, 4, 13, 13, 13, 4, 4, 13, 13, 0, 13, 13, 13, 41, 28, 13, 4, 18, 4, 18, 4, 13, 13, 13, 4, 4, 13, 13, 0, 13, 13, 4, 13, 4, 13, 17, 2, 2, 4, 13, 13, 2, 4, 13, 13, 4, 13, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 15, 14 ], [ 6, 20 ], [ 14, 26 ], [ 29, 28 ], [ 29, 30 ], [ 34, 33 ], [ 6, 39 ], [ 33, 45 ], [ 48, 47 ], [ 47, 58 ], [ 47, 62 ], [ 47, 65 ], [ 75, 72 ] ]
[ "def main():\n import sys\n input = sys.stdin.readline\n K, T = [int(x) for x in input().strip().split()]\n A = [int(x) for x in input().strip().split()]\n print(max(0, max(A)-(sum(A)-max(A))-1))\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n input = sys.stdin.readline\n K, T = [int(x) for x in input().strip().split()]\n A = [int(x) for x in input().strip().split()]\n print(max(0, max(A)-(sum(A)-max(A))-1))", "main", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "int(x) for x in input().strip().split()", "for x in input().strip().split()", "x", "input().strip().split()", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "for x in input().strip().split()", "int(x)", "int", "x", "K, T = [int(x) for x in input().strip().split()]", "K", "[int(x) for x in input().strip().split()]", "T", "int(x) for x in input().strip().split()", "for x in input().strip().split()", "x", "input().strip().split()", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "for x in input().strip().split()", "int(x)", "int", "x", "A = [int(x) for x in input().strip().split()]", "A", "[int(x) for x in input().strip().split()]", "print(max(0, max(A)-(sum(A)-max(A))-1))", "print", "max(0, max(A)-(sum(A)-max(A))-1)", "max", "0", "max(A)-(sum(A)-max(A))-1", "max(A)-(sum(A)-max(A))", "max(A)", "max", "A", "sum(A)-max(A)", "sum(A)", "sum", "A", "max(A)", "max", "A", "1", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n import sys\n input = sys.stdin.readline\n K, T = [int(x) for x in input().strip().split()]\n A = [int(x) for x in input().strip().split()]\n print(max(0, max(A)-(sum(A)-max(A))-1))", "def main():\n import sys\n input = sys.stdin.readline\n K, T = [int(x) for x in input().strip().split()]\n A = [int(x) for x in input().strip().split()]\n print(max(0, max(A)-(sum(A)-max(A))-1))", "main" ]
def main(): import sys input = sys.stdin.readline K, T = [int(x) for x in input().strip().split()] A = [int(x) for x in input().strip().split()] print(max(0, max(A)-(sum(A)-max(A))-1)) if __name__ == '__main__': main()
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 15, 4, 18, 13, 13, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 17, 0, 13, 4, 13, 17, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 12, 4, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 14, 40, 13, 4, 18, 13, 13, 2, 13, 17, 4, 13, 17, 14, 2, 2, 13, 17, 17, 4, 13, 2, 2, 17, 2, 13, 4, 18, 13, 13, 2, 13, 17, 17, 4, 13, 2, 17, 2, 13, 4, 18, 13, 13, 2, 13, 17, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 152, 17 ], [ 164, 24 ], [ 167, 27 ], [ 158, 32 ], [ 176, 44 ], [ 159, 49 ], [ 173, 51 ], [ 159, 59 ], [ 170, 62 ], [ 174, 67 ], [ 161, 69 ], [ 159, 72 ], [ 77, 76 ], [ 174, 78 ], [ 77, 79 ], [ 82, 81 ], [ 171, 83 ], [ 86, 85 ], [ 81, 88 ], [ 79, 91 ], [ 76, 96 ], [ 85, 100 ], [ 76, 106 ], [ 76, 114 ], [ 85, 123 ], [ 76, 129 ], [ 85, 137 ], [ 76, 143 ], [ 156, 150 ], [ 152, 153 ], [ 158, 159 ], [ 161, 162 ], [ 164, 165 ], [ 167, 168 ], [ 170, 171 ], [ 173, 174 ], [ 176, 177 ] ]
[ "import sys\nimport math\nimport itertools\nimport collections\nfrom collections import deque\nfrom collections import defaultdict\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\nMOD2 = 998244353\nINF = float('inf')\ninput = lambda: sys.stdin.readline().strip()\n\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\ndef main():\n K, T = NMI()\n A = NLI()\n\n max_A = max(A)\n \n if T == 1:\n print(K-1)\n else:\n if max_A <= math.ceil(K/2):\n print(0)\n else:\n if K % 2 == 0:\n print(2*(max_A-math.ceil(K/2))-1)\n else:\n print(2*(max_A-math.ceil(K/2)))\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "import math", "math", "import itertools", "itertools", "import collections", "collections", "from collections import deque", "from collections import defaultdict", "sys.setrecursionlimit(1000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "1000000", "MOD = 10 ** 9 + 7", "MOD", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "MOD2 = 998244353", "MOD2", "998244353", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "input = lambda: sys.stdin.readline().strip()", "input", "lambda: sys.stdin.readline().strip()", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "NI = lambda: int(input())", "NI", "lambda: int(input())", "int(input())", "int", "input()", "input", "NMI = lambda: map(int, input().split())", "NMI", "lambda: map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "NLI = lambda: list(NMI())", "NLI", "lambda: list(NMI())", "list(NMI())", "list", "NMI()", "NMI", "SI = lambda: input()", "SI", "lambda: input()", "input()", "input", "def main():\n K, T = NMI()\n A = NLI()\n\n max_A = max(A)\n \n if T == 1:\n print(K-1)\n else:\n if max_A <= math.ceil(K/2):\n print(0)\n else:\n if K % 2 == 0:\n print(2*(max_A-math.ceil(K/2))-1)\n else:\n print(2*(max_A-math.ceil(K/2)))", "main", "K, T = NMI()", "K", "NMI()", "NMI", "T", "A = NLI()", "A", "NLI()", "NLI", "max_A = max(A)", "max_A", "max(A)", "max", "A", "if T == 1:\n print(K-1)\n else:\n if max_A <= math.ceil(K/2):\n print(0)\n else:\n if K % 2 == 0:\n print(2*(max_A-math.ceil(K/2))-1)\n else:\n print(2*(max_A-math.ceil(K/2)))", "T == 1", "T", "1", "print(K-1)", "print", "K-1", "K", "1", "if max_A <= math.ceil(K/2):\n print(0)\n else:\n if K % 2 == 0:\n print(2*(max_A-math.ceil(K/2))-1)\n else:\n print(2*(max_A-math.ceil(K/2)))", "max_A <= math.ceil(K/2)", "max_A", "math.ceil(K/2)", "math.ceil", "math", "ceil", "K/2", "K", "2", "print(0)", "print", "0", "if K % 2 == 0:\n print(2*(max_A-math.ceil(K/2))-1)\n else:\n print(2*(max_A-math.ceil(K/2)))", "K % 2 == 0", "K % 2", "K", "2", "0", "print(2*(max_A-math.ceil(K/2))-1)", "print", "2*(max_A-math.ceil(K/2))-1", "2*(max_A-math.ceil(K/2))", "2", "max_A-math.ceil(K/2)", "max_A", "math.ceil(K/2)", "math.ceil", "math", "ceil", "K/2", "K", "2", "1", "print(2*(max_A-math.ceil(K/2)))", "print", "2*(max_A-math.ceil(K/2))", "2", "max_A-math.ceil(K/2)", "max_A", "math.ceil(K/2)", "math.ceil", "math", "ceil", "K/2", "K", "2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "MOD = 10 ** 9 + 7", "10 ** 9 + 7", "MOD", "def main():\n K, T = NMI()\n A = NLI()\n\n max_A = max(A)\n \n if T == 1:\n print(K-1)\n else:\n if max_A <= math.ceil(K/2):\n print(0)\n else:\n if K % 2 == 0:\n print(2*(max_A-math.ceil(K/2))-1)\n else:\n print(2*(max_A-math.ceil(K/2)))", "def main():\n K, T = NMI()\n A = NLI()\n\n max_A = max(A)\n \n if T == 1:\n print(K-1)\n else:\n if max_A <= math.ceil(K/2):\n print(0)\n else:\n if K % 2 == 0:\n print(2*(max_A-math.ceil(K/2))-1)\n else:\n print(2*(max_A-math.ceil(K/2)))", "main", "input = lambda: sys.stdin.readline().strip()", "lambda: sys.stdin.readline().strip()", "input", "SI = lambda: input()", "lambda: input()", "SI", "MOD2 = 998244353", "998244353", "MOD2", "INF = float('inf')", "float('inf')", "INF", "NLI = lambda: list(NMI())", "lambda: list(NMI())", "NLI", "NMI = lambda: map(int, input().split())", "lambda: map(int, input().split())", "NMI", "NI = lambda: int(input())", "lambda: int(input())", "NI" ]
import sys import math import itertools import collections from collections import deque from collections import defaultdict sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD2 = 998244353 INF = float('inf') input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() def main(): K, T = NMI() A = NLI() max_A = max(A) if T == 1: print(K-1) else: if max_A <= math.ceil(K/2): print(0) else: if K % 2 == 0: print(2*(max_A-math.ceil(K/2))-1) else: print(2*(max_A-math.ceil(K/2))) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 48, 2 ], [ 48, 11 ], [ 51, 13 ], [ 42, 25 ], [ 52, 28 ], [ 43, 36 ], [ 49, 38 ], [ 43, 39 ], [ 42, 43 ], [ 48, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "k,t = map(int,input().split())\na_input = list(map(int,input().split()))\n\n#最も多いケーキをAtとする,a=4,b=1,c=1の場合を考えると\n#a,b,a,c,a,aのようになる。よってa-(b+c)-1\nmax_a = max(a_input)\nprint(max(0,max_a-(k-max_a)-1))", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a_input = list(map(int,input().split()))", "a_input", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "max_a = max(a_input)", "max_a", "max(a_input)", "max", "a_input", "print(max(0,max_a-(k-max_a)-1))", "print", "max(0,max_a-(k-max_a)-1)", "max", "0", "max_a-(k-max_a)-1", "max_a-(k-max_a)", "max_a", "k-max_a", "k", "max_a", "1", "max_a = max(a_input)", "max(a_input)", "max_a", "t = map(int,input().split())", "map(int,input().split())", "t", "k,t = map(int,input().split())", "map(int,input().split())", "k", "a_input = list(map(int,input().split()))", "list(map(int,input().split()))", "a_input" ]
k,t = map(int,input().split()) a_input = list(map(int,input().split())) #最も多いケーキをAtとする,a=4,b=1,c=1の場合を考えると #a,b,a,c,a,aのようになる。よってa-(b+c)-1 max_a = max(a_input) print(max(0,max_a-(k-max_a)-1))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 4, 13, 13, 14, 2, 13, 13, 9, 14, 2, 13, 13, 0, 13, 13, 0, 13, 13, 14, 2, 13, 17, 0, 13, 18, 13, 13, 3, 0, 18, 13, 13, 17, 0, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 18, 13 ]
[ [ 104, 4 ], [ 14, 13 ], [ 105, 20 ], [ 14, 22 ], [ 25, 24 ], [ 105, 33 ], [ 37, 36 ], [ 40, 39 ], [ 43, 42 ], [ 13, 45 ], [ 48, 47 ], [ 51, 50 ], [ 24, 57 ], [ 36, 61 ], [ 89, 61 ], [ 50, 66 ], [ 68, 66 ], [ 69, 68 ], [ 72, 71 ], [ 68, 75 ], [ 50, 75 ], [ 79, 78 ], [ 24, 80 ], [ 36, 81 ], [ 89, 81 ], [ 87, 84 ], [ 24, 85 ], [ 71, 86 ], [ 47, 86 ], [ 90, 89 ], [ 71, 90 ], [ 47, 90 ], [ 78, 93 ], [ 39, 93 ], [ 102, 99 ], [ 104, 105 ] ]
[ "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n prev_idx = -1\n ans = 0\n for _ in range(K):\n cur_idx = -1\n max_num = 0\n for i, a in enumerate(A):\n if i == prev_idx:\n continue\n if a > max_num:\n max_num = a\n cur_idx = i\n if max_num == 0:\n ans = A[prev_idx]\n break\n A[cur_idx] -= 1\n prev_idx = cur_idx\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n prev_idx = -1\n ans = 0\n for _ in range(K):\n cur_idx = -1\n max_num = 0\n for i, a in enumerate(A):\n if i == prev_idx:\n continue\n if a > max_num:\n max_num = a\n cur_idx = i\n if max_num == 0:\n ans = A[prev_idx]\n break\n A[cur_idx] -= 1\n prev_idx = cur_idx\n\n print(ans)", "main", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "prev_idx = -1", "prev_idx", "-1", "ans = 0", "ans", "0", "for _ in range(K):\n cur_idx = -1\n max_num = 0\n for i, a in enumerate(A):\n if i == prev_idx:\n continue\n if a > max_num:\n max_num = a\n cur_idx = i\n if max_num == 0:\n ans = A[prev_idx]\n break\n A[cur_idx] -= 1\n prev_idx = cur_idx\n\n ", "_", "range(K)", "range", "K", "cur_idx = -1", "cur_idx", "-1", "max_num = 0", "max_num", "0", "for i, a in enumerate(A):\n if i == prev_idx:\n continue\n if a > max_num:\n max_num = a\n cur_idx = i\n ", "i", "a", "enumerate(A)", "enumerate", "A", "if i == prev_idx:\n continue\n ", "i == prev_idx", "i", "prev_idx", "continue", "if a > max_num:\n max_num = a\n cur_idx = i\n ", "a > max_num", "a", "max_num", "max_num = a", "max_num", "a", "cur_idx = i", "cur_idx", "i", "if max_num == 0:\n ans = A[prev_idx]\n break\n ", "max_num == 0", "max_num", "0", "ans = A[prev_idx]", "ans", "A[prev_idx]", "A", "prev_idx", "break", "A[cur_idx] -= 1", "A[cur_idx]", "A", "cur_idx", "1", "prev_idx = cur_idx", "prev_idx", "cur_idx", "print(ans)", "print", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n prev_idx = -1\n ans = 0\n for _ in range(K):\n cur_idx = -1\n max_num = 0\n for i, a in enumerate(A):\n if i == prev_idx:\n continue\n if a > max_num:\n max_num = a\n cur_idx = i\n if max_num == 0:\n ans = A[prev_idx]\n break\n A[cur_idx] -= 1\n prev_idx = cur_idx\n\n print(ans)", "def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n prev_idx = -1\n ans = 0\n for _ in range(K):\n cur_idx = -1\n max_num = 0\n for i, a in enumerate(A):\n if i == prev_idx:\n continue\n if a > max_num:\n max_num = a\n cur_idx = i\n if max_num == 0:\n ans = A[prev_idx]\n break\n A[cur_idx] -= 1\n prev_idx = cur_idx\n\n print(ans)", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input" ]
import sys input = sys.stdin.readline def main(): K, T = map(int, input().split()) A = list(map(int, input().split())) prev_idx = -1 ans = 0 for _ in range(K): cur_idx = -1 max_num = 0 for i, a in enumerate(A): if i == prev_idx: continue if a > max_num: max_num = a cur_idx = i if max_num == 0: ans = A[prev_idx] break A[cur_idx] -= 1 prev_idx = cur_idx print(ans) if __name__ == "__main__": main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 4, 13, 4, 13, 2, 2, 2, 17, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13 ]
[ [ 39, 2 ], [ 39, 11 ], [ 40, 32 ], [ 39, 37 ], [ 39, 40 ] ]
[ "n,k=map(int,input().split())\nprint(max(2*max(list(map(int,input().split())))-n-1,0))", "n,k=map(int,input().split())", "n", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "k", "print(max(2*max(list(map(int,input().split())))-n-1,0))", "print", "max(2*max(list(map(int,input().split())))-n-1,0)", "max", "2*max(list(map(int,input().split())))-n-1", "2*max(list(map(int,input().split())))-n", "2*max(list(map(int,input().split())))", "2", "max(list(map(int,input().split())))", "max", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "n", "1", "0", "k=map(int,input().split())", "map(int,input().split())", "k", "n,k=map(int,input().split())", "map(int,input().split())", "n" ]
n,k=map(int,input().split()) print(max(2*max(list(map(int,input().split())))-n-1,0))
[ 7, 15, 13, 0, 13, 18, 13, 13, 0, 13, 2, 17, 17, 0, 13, 17, 0, 13, 12, 4, 13, 4, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 0, 13, 12, 13, 23, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 18, 13, 13, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 0, 13, 12, 13, 23, 0, 13, 12, 4, 13, 4, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 0, 13, 12, 13, 23, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 18, 13, 13, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 0, 13, 12, 13, 23, 0, 13, 12, 4, 18, 4, 18, 13, 13, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 0, 13, 12, 13, 23, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 0, 13, 12, 13, 23, 0, 13, 12, 4, 18, 4, 18, 13, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 4, 18, 13, 13, 0, 13, 18, 13, 17, 14, 40, 2, 18, 13, 17, 13, 17, 4, 13, 17, 4, 13, 2, 2, 18, 13, 17, 13, 17, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 18, 13, 10, 4, 13, 10, 18, 13, 10, 12, 13, 10, 4, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 249, 4 ], [ 258, 9 ], [ 240, 14 ], [ 237, 17 ], [ 26, 25 ], [ 238, 31 ], [ 213, 33 ], [ 216, 38 ], [ 250, 49 ], [ 55, 54 ], [ 217, 60 ], [ 261, 62 ], [ 225, 67 ], [ 76, 75 ], [ 226, 81 ], [ 231, 83 ], [ 228, 88 ], [ 250, 99 ], [ 105, 104 ], [ 229, 110 ], [ 252, 112 ], [ 234, 117 ], [ 250, 123 ], [ 129, 128 ], [ 235, 134 ], [ 210, 136 ], [ 143, 142 ], [ 235, 150 ], [ 264, 152 ], [ 219, 157 ], [ 250, 163 ], [ 255, 167 ], [ 217, 169 ], [ 255, 170 ], [ 267, 172 ], [ 217, 174 ], [ 222, 176 ], [ 268, 179 ], [ 268, 182 ], [ 243, 185 ], [ 268, 187 ], [ 268, 193 ], [ 244, 195 ], [ 223, 195 ], [ 268, 205 ], [ 244, 207 ], [ 223, 207 ], [ 210, 211 ], [ 213, 214 ], [ 216, 217 ], [ 219, 220 ], [ 222, 223 ], [ 225, 226 ], [ 228, 229 ], [ 231, 232 ], [ 234, 235 ], [ 237, 238 ], [ 240, 241 ], [ 243, 244 ], [ 255, 247 ], [ 249, 250 ], [ 252, 253 ], [ 255, 256 ], [ 258, 259 ], [ 261, 262 ], [ 264, 265 ], [ 267, 268 ] ]
[ "import sys\n\nstdin = sys.stdin\ninf = 1 << 60\nmod = 1000000007\n\nni = lambda: int(ns())\nnin = lambda y: [ni() for _ in range(y)]\nna = lambda: list(map(int, stdin.readline().split()))\nnan = lambda y: [na() for _ in range(y)]\nnf = lambda: float(ns())\nnfn = lambda y: [nf() for _ in range(y)]\nnfa = lambda: list(map(float, stdin.readline().split()))\nnfan = lambda y: [nfa() for _ in range(y)]\nns = lambda: stdin.readline().rstrip()\nnsn = lambda y: [ns() for _ in range(y)]\nncl = lambda y: [list(ns()) for _ in range(y)]\nnas = lambda: stdin.readline().split()\n\nk, t = na()\na = na()\n\ns = sum(a)\na.sort()\ns -= a[-1]\nif a[-1] - s <= 0:\n print(0)\nelse:\n print(a[-1] - s - 1)", "import sys", "sys", "stdin = sys.stdin", "stdin", "sys.stdin", "sys", "stdin", "inf = 1 << 60", "inf", "1 << 60", "1", "60", "mod = 1000000007", "mod", "1000000007", "ni = lambda: int(ns())", "ni", "lambda: int(ns())", "int(ns())", "int", "ns()", "ns", "ni() for _ in range(y)", "for _ in range(y)", "_", "range(y)", "range", "y", "for _ in range(y)", "ni()", "ni", "nin = lambda y: [ni() for _ in range(y)]", "nin", "lambda y: [ni() for _ in range(y)]", "[ni() for _ in range(y)]", "y", "na = lambda: list(map(int, stdin.readline().split()))", "na", "lambda: list(map(int, stdin.readline().split()))", "list(map(int, stdin.readline().split()))", "list", "map(int, stdin.readline().split())", "map", "int", "stdin.readline().split()", "stdin.readline().split", "stdin.readline()", "stdin.readline", "stdin", "readline", "split", "na() for _ in range(y)", "for _ in range(y)", "_", "range(y)", "range", "y", "for _ in range(y)", "na()", "na", "nan = lambda y: [na() for _ in range(y)]", "nan", "lambda y: [na() for _ in range(y)]", "[na() for _ in range(y)]", "y", "nf = lambda: float(ns())", "nf", "lambda: float(ns())", "float(ns())", "float", "ns()", "ns", "nf() for _ in range(y)", "for _ in range(y)", "_", "range(y)", "range", "y", "for _ in range(y)", "nf()", "nf", "nfn = lambda y: [nf() for _ in range(y)]", "nfn", "lambda y: [nf() for _ in range(y)]", "[nf() for _ in range(y)]", "y", "nfa = lambda: list(map(float, stdin.readline().split()))", "nfa", "lambda: list(map(float, stdin.readline().split()))", "list(map(float, stdin.readline().split()))", "list", "map(float, stdin.readline().split())", "map", "float", "stdin.readline().split()", "stdin.readline().split", "stdin.readline()", "stdin.readline", "stdin", "readline", "split", "nfa() for _ in range(y)", "for _ in range(y)", "_", "range(y)", "range", "y", "for _ in range(y)", "nfa()", "nfa", "nfan = lambda y: [nfa() for _ in range(y)]", "nfan", "lambda y: [nfa() for _ in range(y)]", "[nfa() for _ in range(y)]", "y", "ns = lambda: stdin.readline().rstrip()", "ns", "lambda: stdin.readline().rstrip()", "stdin.readline().rstrip()", "stdin.readline().rstrip", "stdin.readline()", "stdin.readline", "stdin", "readline", "rstrip", "ns() for _ in range(y)", "for _ in range(y)", "_", "range(y)", "range", "y", "for _ in range(y)", "ns()", "ns", "nsn = lambda y: [ns() for _ in range(y)]", "nsn", "lambda y: [ns() for _ in range(y)]", "[ns() for _ in range(y)]", "y", "list(ns()) for _ in range(y)", "for _ in range(y)", "_", "range(y)", "range", "y", "for _ in range(y)", "list(ns())", "list", "ns()", "ns", "ncl = lambda y: [list(ns()) for _ in range(y)]", "ncl", "lambda y: [list(ns()) for _ in range(y)]", "[list(ns()) for _ in range(y)]", "y", "nas = lambda: stdin.readline().split()", "nas", "lambda: stdin.readline().split()", "stdin.readline().split()", "stdin.readline().split", "stdin.readline()", "stdin.readline", "stdin", "readline", "split", "k, t = na()", "k", "na()", "na", "t", "a = na()", "a", "na()", "na", "s = sum(a)", "s", "sum(a)", "sum", "a", "a.sort()", "a.sort", "a", "sort", "s -= a[-1]", "s", "a[-1]", "a", "-1", "if a[-1] - s <= 0:\n print(0)\nelse:\n print(a[-1] - s - 1)", "a[-1] - s <= 0", "a[-1] - s", "a[-1]", "a", "-1", "s", "0", "print(0)", "print", "0", "print(a[-1] - s - 1)", "print", "a[-1] - s - 1", "a[-1] - s", "a[-1]", "a", "-1", "s", "1", "nsn = lambda y: [ns() for _ in range(y)]", "lambda y: [ns() for _ in range(y)]", "nsn", "nin = lambda y: [ni() for _ in range(y)]", "lambda y: [ni() for _ in range(y)]", "nin", "na = lambda: list(map(int, stdin.readline().split()))", "lambda: list(map(int, stdin.readline().split()))", "na", "nas = lambda: stdin.readline().split()", "lambda: stdin.readline().split()", "nas", "s = sum(a)", "sum(a)", "s", "nf = lambda: float(ns())", "lambda: float(ns())", "nf", "nfa = lambda: list(map(float, stdin.readline().split()))", "lambda: list(map(float, stdin.readline().split()))", "nfa", "nfn = lambda y: [nf() for _ in range(y)]", "lambda y: [nf() for _ in range(y)]", "nfn", "ns = lambda: stdin.readline().rstrip()", "lambda: stdin.readline().rstrip()", "ns", "ni = lambda: int(ns())", "lambda: int(ns())", "ni", "mod = 1000000007", "1000000007", "mod", "s -= a[-1]", "a[-1]", "s", "t = na()", "na()", "t", "stdin = sys.stdin", "sys.stdin", "stdin", "nfan = lambda y: [nfa() for _ in range(y)]", "lambda y: [nfa() for _ in range(y)]", "nfan", "k, t = na()", "na()", "k", "inf = 1 << 60", "1 << 60", "inf", "nan = lambda y: [na() for _ in range(y)]", "lambda y: [na() for _ in range(y)]", "nan", "ncl = lambda y: [list(ns()) for _ in range(y)]", "lambda y: [list(ns()) for _ in range(y)]", "ncl", "a = na()", "na()", "a" ]
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdin.readline().split())) nfan = lambda y: [nfa() for _ in range(y)] ns = lambda: stdin.readline().rstrip() nsn = lambda y: [ns() for _ in range(y)] ncl = lambda y: [list(ns()) for _ in range(y)] nas = lambda: stdin.readline().split() k, t = na() a = na() s = sum(a) a.sort() s -= a[-1] if a[-1] - s <= 0: print(0) else: print(a[-1] - s - 1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 17, 2, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 59, 2 ], [ 59, 11 ], [ 53, 13 ], [ 47, 25 ], [ 54, 28 ], [ 50, 30 ], [ 54, 33 ], [ 51, 41 ], [ 48, 44 ], [ 51, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 59, 57 ], [ 59, 60 ] ]
[ "K, T = map(int, input().split())\na = list(map(int, input().split()))\ns = sum(a)\nmx = max(a)\nprint(max(0, mx-1-(s-mx)))", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "s = sum(a)", "s", "sum(a)", "sum", "a", "mx = max(a)", "mx", "max(a)", "max", "a", "print(max(0, mx-1-(s-mx)))", "print", "max(0, mx-1-(s-mx))", "max", "0", "mx-1-(s-mx)", "mx-1", "mx", "1", "s-mx", "s", "mx", "s = sum(a)", "sum(a)", "s", "mx = max(a)", "max(a)", "mx", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "K, T = map(int, input().split())", "map(int, input().split())", "K", "T = map(int, input().split())", "map(int, input().split())", "T" ]
K, T = map(int, input().split()) a = list(map(int, input().split())) s = sum(a) mx = max(a) print(max(0, mx-1-(s-mx)))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 4, 13, 13, 14, 2, 2, 13, 13, 40, 13, 13, 0, 13, 13, 0, 13, 13, 14, 40, 13, 17, 0, 18, 13, 13, 17, 0, 13, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13 ]
[ [ 116, 2 ], [ 116, 11 ], [ 119, 13 ], [ 125, 25 ], [ 98, 28 ], [ 32, 31 ], [ 117, 34 ], [ 92, 36 ], [ 120, 39 ], [ 122, 41 ], [ 120, 44 ], [ 93, 46 ], [ 102, 46 ], [ 96, 46 ], [ 95, 48 ], [ 113, 51 ], [ 120, 58 ], [ 96, 62 ], [ 93, 62 ], [ 102, 62 ], [ 126, 66 ], [ 129, 66 ], [ 101, 68 ], [ 104, 71 ], [ 105, 75 ], [ 114, 75 ], [ 81, 78 ], [ 120, 79 ], [ 105, 80 ], [ 114, 80 ], [ 128, 83 ], [ 105, 84 ], [ 114, 84 ], [ 110, 86 ], [ 111, 90 ], [ 99, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 116, 108 ], [ 110, 111 ], [ 113, 114 ], [ 116, 117 ], [ 119, 120 ], [ 122, 123 ], [ 125, 126 ], [ 105, 128 ], [ 114, 128 ], [ 128, 129 ] ]
[ "k,t = map(int, input().split())\nal = list(map(int, input().split()))\n\nprev = -1\nans = 0\nfor i in range(k):\n max_v = max(al)\n max_ind = al.index(max_v)\n max_v = 0\n max_i = -1\n for j, v in enumerate(al):\n if max_v < v and j != prev:\n max_v = v\n max_i = j\n if max_i != -1:\n al[max_i] -= 1\n prev = max_i\n else:\n ans += 1\n\nprint(ans)", "k,t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "al = list(map(int, input().split()))", "al", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "prev = -1", "prev", "-1", "ans = 0", "ans", "0", "for i in range(k):\n max_v = max(al)\n max_ind = al.index(max_v)\n max_v = 0\n max_i = -1\n for j, v in enumerate(al):\n if max_v < v and j != prev:\n max_v = v\n max_i = j\n if max_i != -1:\n al[max_i] -= 1\n prev = max_i\n else:\n ans += 1", "i", "range(k)", "range", "k", "max_v = max(al)", "max_v", "max(al)", "max", "al", "max_ind = al.index(max_v)", "max_ind", "al.index(max_v)", "al.index", "al", "index", "max_v", "max_v = 0", "max_v", "0", "max_i = -1", "max_i", "-1", "for j, v in enumerate(al):\n if max_v < v and j != prev:\n max_v = v\n max_i = j\n ", "j", "v", "enumerate(al)", "enumerate", "al", "if max_v < v and j != prev:\n max_v = v\n max_i = j\n ", "max_v < v and j != prev", "max_v < v", "max_v", "v", "j != prev", "j", "prev", "max_v = v", "max_v", "v", "max_i = j", "max_i", "j", "if max_i != -1:\n al[max_i] -= 1\n prev = max_i\n else:\n ans += 1", "max_i != -1", "max_i", "-1", "al[max_i] -= 1", "al[max_i]", "al", "max_i", "1", "prev = max_i", "prev", "max_i", "ans += 1", "ans", "1", "print(ans)", "print", "ans", "max_v = max(al)", "max(al)", "max_v", "max_v = 0", "0", "max_v", "ans = 0", "0", "ans", "max_v = v", "v", "max_v", "max_i = j", "j", "max_i", "t = map(int, input().split())", "map(int, input().split())", "t", "ans += 1", "1", "ans", "max_i = -1", "-1", "max_i", "k,t = map(int, input().split())", "map(int, input().split())", "k", "al = list(map(int, input().split()))", "list(map(int, input().split()))", "al", "max_ind = al.index(max_v)", "al.index(max_v)", "max_ind", "prev = -1", "-1", "prev", "prev = max_i", "max_i", "prev" ]
k,t = map(int, input().split()) al = list(map(int, input().split())) prev = -1 ans = 0 for i in range(k): max_v = max(al) max_ind = al.index(max_v) max_v = 0 max_i = -1 for j, v in enumerate(al): if max_v < v and j != prev: max_v = v max_i = j if max_i != -1: al[max_i] -= 1 prev = max_i else: ans += 1 print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 17, 14, 2, 13, 13, 4, 13, 17, 4, 13, 14, 2, 13, 17, 4, 13, 2, 13, 13, 4, 13, 0, 13, 18, 13, 17, 0, 13, 18, 13, 17, 28, 13, 4, 13, 17, 13, 14, 40, 13, 13, 0, 13, 18, 13, 13, 0, 13, 18, 13, 13, 4, 13, 4, 13, 2, 4, 13, 2, 13, 13, 17, 17, 10, 18, 13, 10, 18, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 18, 13 ]
[ [ 103, 2 ], [ 103, 11 ], [ 106, 13 ], [ 107, 26 ], [ 30, 29 ], [ 101, 33 ], [ 104, 34 ], [ 104, 42 ], [ 101, 47 ], [ 104, 48 ], [ 112, 52 ], [ 107, 54 ], [ 97, 57 ], [ 107, 59 ], [ 63, 62 ], [ 104, 66 ], [ 113, 69 ], [ 95, 69 ], [ 98, 70 ], [ 110, 70 ], [ 109, 72 ], [ 107, 74 ], [ 62, 75 ], [ 94, 77 ], [ 107, 79 ], [ 62, 80 ], [ 95, 89 ], [ 113, 89 ], [ 110, 90 ], [ 98, 90 ], [ 94, 95 ], [ 97, 98 ], [ 103, 101 ], [ 103, 104 ], [ 106, 107 ], [ 109, 110 ], [ 112, 113 ] ]
[ "K, T = map(int, input().split())\na = list(map(int, input().split()))\na.sort(reverse=True)\nif K == T:\n print(0)\n exit()\n\nif T == 1:\n print(K - T)\n exit()\n\nb = a[0]\nc = a[1]\n\nfor i in range(2, T):\n if b >= c:\n c += a[i]\n else:\n b += a[i]\n\nprint(max(abs(b - c) - 1, 0))", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "if K == T:\n print(0)\n exit()", "K == T", "K", "T", "print(0)", "print", "0", "exit()", "exit", "if T == 1:\n print(K - T)\n exit()", "T == 1", "T", "1", "print(K - T)", "print", "K - T", "K", "T", "exit()", "exit", "b = a[0]", "b", "a[0]", "a", "0", "c = a[1]", "c", "a[1]", "a", "1", "for i in range(2, T):\n if b >= c:\n c += a[i]\n else:\n b += a[i]", "i", "range(2, T)", "range", "2", "T", "if b >= c:\n c += a[i]\n else:\n b += a[i]", "b >= c", "b", "c", "c += a[i]", "c", "a[i]", "a", "i", "b += a[i]", "b", "a[i]", "a", "i", "print(max(abs(b - c) - 1, 0))", "print", "max(abs(b - c) - 1, 0)", "max", "abs(b - c) - 1", "abs(b - c)", "abs", "b - c", "b", "c", "1", "0", "b += a[i]", "a[i]", "b", "c = a[1]", "a[1]", "c", "K, T = map(int, input().split())", "map(int, input().split())", "K", "T = map(int, input().split())", "map(int, input().split())", "T", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "c += a[i]", "a[i]", "c", "b = a[0]", "a[0]", "b" ]
K, T = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) if K == T: print(0) exit() if T == 1: print(K - T) exit() b = a[0] c = a[1] for i in range(2, T): if b >= c: c += a[i] else: b += a[i] print(max(abs(b - c) - 1, 0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 13, 4, 13, 13, 14, 40, 4, 13, 13, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 13, 2, 13, 17, 17, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 61, 2 ], [ 61, 11 ], [ 58, 13 ], [ 52, 25 ], [ 56, 27 ], [ 59, 30 ], [ 59, 35 ], [ 56, 37 ], [ 56, 46 ], [ 53, 48 ], [ 52, 53 ], [ 61, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "k, t = map(int, input().split())\na = list(map(int, input().split()))\nn = k - max(a)\nif max(a) <= k // 2:\n print(0)\nelse:\n print(k - n * 2 - 1)", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "n = k - max(a)", "n", "k - max(a)", "k", "max(a)", "max", "a", "if max(a) <= k // 2:\n print(0)\nelse:\n print(k - n * 2 - 1)", "max(a) <= k // 2", "max(a)", "max", "a", "k // 2", "k", "2", "print(0)", "print", "0", "print(k - n * 2 - 1)", "print", "k - n * 2 - 1", "k - n * 2", "k", "n * 2", "n", "2", "1", "n = k - max(a)", "k - max(a)", "n", "k, t = map(int, input().split())", "map(int, input().split())", "k", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "t = map(int, input().split())", "map(int, input().split())", "t" ]
k, t = map(int, input().split()) a = list(map(int, input().split())) n = k - max(a) if max(a) <= k // 2: print(0) else: print(k - n * 2 - 1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 18, 13, 13, 0, 13, 17, 14, 2, 13, 17, 4, 13, 2, 18, 13, 17, 17, 14, 40, 2, 18, 13, 17, 2, 13, 18, 13, 17, 17, 4, 13, 2, 2, 18, 13, 17, 2, 4, 13, 13, 18, 13, 17, 17, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 87, 2 ], [ 87, 11 ], [ 81, 13 ], [ 84, 25 ], [ 82, 28 ], [ 82, 31 ], [ 35, 34 ], [ 79, 38 ], [ 82, 44 ], [ 82, 51 ], [ 85, 54 ], [ 82, 56 ], [ 82, 64 ], [ 82, 69 ], [ 82, 71 ], [ 87, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ] ]
[ "K,T=map(int,input().split())\na=list(map(int,input().split()))\nb=sum(a)\na.sort(reverse=True)\nif T==1:\n print(a[0]-1)\nelse:\n if a[0]-(b-a[0])>=2:\n print(a[0]-(sum(a)-a[0])-1)\n else:\n print(0)", "K,T=map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "b=sum(a)", "b", "sum(a)", "sum", "a", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "if T==1:\n print(a[0]-1)\nelse:\n if a[0]-(b-a[0])>=2:\n print(a[0]-(sum(a)-a[0])-1)\n else:\n print(0)", "T==1", "T", "1", "print(a[0]-1)", "print", "a[0]-1", "a[0]", "a", "0", "1", "if a[0]-(b-a[0])>=2:\n print(a[0]-(sum(a)-a[0])-1)\n else:\n print(0)", "a[0]-(b-a[0])>=2", "a[0]-(b-a[0])", "a[0]", "a", "0", "b-a[0]", "b", "a[0]", "a", "0", "2", "print(a[0]-(sum(a)-a[0])-1)", "print", "a[0]-(sum(a)-a[0])-1", "a[0]-(sum(a)-a[0])", "a[0]", "a", "0", "sum(a)-a[0]", "sum(a)", "sum", "a", "a[0]", "a", "0", "1", "print(0)", "print", "0", "T=map(int,input().split())", "map(int,input().split())", "T", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "b=sum(a)", "sum(a)", "b", "K,T=map(int,input().split())", "map(int,input().split())", "K" ]
K,T=map(int,input().split()) a=list(map(int,input().split())) b=sum(a) a.sort(reverse=True) if T==1: print(a[0]-1) else: if a[0]-(b-a[0])>=2: print(a[0]-(sum(a)-a[0])-1) else: print(0)
[ 7, 15, 13, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 12, 39, 40, 4, 13, 18, 13, 17, 2, 18, 13, 17, 17, 23, 4, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 13, 0, 13, 17, 42, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 14, 2, 4, 13, 13, 17, 4, 13, 2, 40, 18, 13, 17, 17, 3, 14, 2, 2, 13, 18, 13, 17, 2, 4, 13, 13, 17, 0, 13, 13, 0, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 39, 2, 18, 13, 17, 17, 18, 13, 17, 0, 13, 18, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 7, 15 ], [ 18, 17 ], [ 17, 47 ], [ 50, 49 ], [ 17, 55 ], [ 59, 58 ], [ 17, 63 ], [ 17, 68 ], [ 58, 75 ], [ 95, 75 ], [ 49, 82 ], [ 128, 82 ], [ 58, 84 ], [ 95, 84 ], [ 17, 89 ], [ 93, 92 ], [ 58, 93 ], [ 95, 93 ], [ 96, 95 ], [ 17, 100 ], [ 17, 105 ], [ 92, 106 ], [ 95, 110 ], [ 58, 110 ], [ 17, 117 ], [ 95, 121 ], [ 58, 121 ], [ 95, 125 ], [ 58, 125 ], [ 129, 128 ], [ 95, 130 ], [ 58, 130 ], [ 140, 137 ] ]
[ "import heapq\ndef main():\n k,t=map(int,input().split())\n a=list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split())))\n heapq.heapify(a)\n p=None\n while len(a) > 0:\n n=heapq.heappop(a)\n if len(a) == 0:\n print(-n[0]-1)\n break\n if p == n[1] and len(a) > 0:\n n2 = n\n n = heapq.heappop(a)\n heapq.heappush(a, n2)\n if n[0] < -1:\n heapq.heappush(a, (n[0]+1, n[1]))\n p = n[1]\n \nif __name__ == \"__main__\":\n main()", "import heapq", "heapq", "def main():\n k,t=map(int,input().split())\n a=list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split())))\n heapq.heapify(a)\n p=None\n while len(a) > 0:\n n=heapq.heappop(a)\n if len(a) == 0:\n print(-n[0]-1)\n break\n if p == n[1] and len(a) > 0:\n n2 = n\n n = heapq.heappop(a)\n heapq.heappush(a, n2)\n if n[0] < -1:\n heapq.heappush(a, (n[0]+1, n[1]))\n p = n[1]\n ", "main", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split())))", "a", "list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split())))", "list", "map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split()))", "map", "lambda x: (-int(x[1]), x[0]+1)", "(-int(x[1]), x[0]+1)", "-int(x[1])", "int(x[1])", "int", "x[1]", "x", "1", "x[0]+1", "x[0]", "x", "0", "1", "x", "enumerate(input().split())", "enumerate", "input().split()", "().split", "()", "input", "split", "heapq.heapify(a)", "heapq.heapify", "heapq", "heapify", "a", "p=None", "p", "None", "while len(a) > 0:\n n=heapq.heappop(a)\n if len(a) == 0:\n print(-n[0]-1)\n break\n if p == n[1] and len(a) > 0:\n n2 = n\n n = heapq.heappop(a)\n heapq.heappush(a, n2)\n if n[0] < -1:\n heapq.heappush(a, (n[0]+1, n[1]))\n p = n[1]\n ", "len(a) > 0", "len(a)", "len", "a", "0", "n=heapq.heappop(a)", "n", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "if len(a) == 0:\n print(-n[0]-1)\n break\n ", "len(a) == 0", "len(a)", "len", "a", "0", "print(-n[0]-1)", "print", "-n[0]-1", "-n[0]", "n[0]", "n", "0", "1", "break", "if p == n[1] and len(a) > 0:\n n2 = n\n n = heapq.heappop(a)\n heapq.heappush(a, n2)\n ", "p == n[1] and len(a) > 0", "p == n[1]", "p", "n[1]", "n", "1", "len(a) > 0", "len(a)", "len", "a", "0", "n2 = n", "n2", "n", "n = heapq.heappop(a)", "n", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "heapq.heappush(a, n2)", "heapq.heappush", "heapq", "heappush", "a", "n2", "if n[0] < -1:\n heapq.heappush(a, (n[0]+1, n[1]))\n ", "n[0] < -1", "n[0]", "n", "0", "-1", "heapq.heappush(a, (n[0]+1, n[1]))", "heapq.heappush", "heapq", "heappush", "a", "(n[0]+1, n[1])", "n[0]+1", "n[0]", "n", "0", "1", "n[1]", "n", "1", "p = n[1]", "p", "n[1]", "n", "1", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n k,t=map(int,input().split())\n a=list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split())))\n heapq.heapify(a)\n p=None\n while len(a) > 0:\n n=heapq.heappop(a)\n if len(a) == 0:\n print(-n[0]-1)\n break\n if p == n[1] and len(a) > 0:\n n2 = n\n n = heapq.heappop(a)\n heapq.heappush(a, n2)\n if n[0] < -1:\n heapq.heappush(a, (n[0]+1, n[1]))\n p = n[1]\n ", "def main():\n k,t=map(int,input().split())\n a=list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split())))\n heapq.heapify(a)\n p=None\n while len(a) > 0:\n n=heapq.heappop(a)\n if len(a) == 0:\n print(-n[0]-1)\n break\n if p == n[1] and len(a) > 0:\n n2 = n\n n = heapq.heappop(a)\n heapq.heappush(a, n2)\n if n[0] < -1:\n heapq.heappush(a, (n[0]+1, n[1]))\n p = n[1]\n ", "main" ]
import heapq def main(): k,t=map(int,input().split()) a=list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split()))) heapq.heapify(a) p=None while len(a) > 0: n=heapq.heappop(a) if len(a) == 0: print(-n[0]-1) break if p == n[1] and len(a) > 0: n2 = n n = heapq.heappop(a) heapq.heappush(a, n2) if n[0] < -1: heapq.heappush(a, (n[0]+1, n[1])) p = n[1] if __name__ == "__main__": main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 4, 13, 13, 17, 4, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 0, 13, 17, 42, 40, 18, 13, 17, 17, 0, 13, 18, 13, 17, 0, 18, 13, 17, 13, 0, 18, 13, 17, 17, 4, 18, 13, 13, 0, 13, 17, 14, 2, 18, 13, 17, 17, 4, 13, 17, 4, 13, 2, 18, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 108, 2 ], [ 108, 11 ], [ 123, 13 ], [ 124, 26 ], [ 30, 29 ], [ 114, 32 ], [ 111, 35 ], [ 117, 38 ], [ 124, 44 ], [ 124, 50 ], [ 124, 55 ], [ 59, 58 ], [ 124, 63 ], [ 120, 67 ], [ 124, 69 ], [ 75, 72 ], [ 124, 73 ], [ 121, 75 ], [ 80, 77 ], [ 124, 78 ], [ 124, 83 ], [ 87, 86 ], [ 124, 91 ], [ 124, 101 ], [ 108, 106 ], [ 108, 109 ], [ 111, 112 ], [ 114, 115 ], [ 117, 118 ], [ 120, 121 ], [ 123, 124 ] ]
[ "k, t = map(int, input().split())\ndat = list(map(int, input().split()))\ndat.sort(reverse=True)\nprev = -1\nres = 0\neat = 0\nif len(dat) == 1:\n print(dat[0] - 1)\nelse:\n dat.sort(reverse=True)\n while dat[1] != 0:\n x = dat[1]\n dat[0] -= x\n dat[1] = 0\n dat.sort(reverse=True)\n if dat[0] == 0:\n print(0)\n else:\n print(dat[0] - 1)", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "dat = list(map(int, input().split()))", "dat", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "dat.sort(reverse=True)", "dat.sort", "dat", "sort", "reverse=True", "reverse", "True", "prev = -1", "prev", "-1", "res = 0", "res", "0", "eat = 0", "eat", "0", "if len(dat) == 1:\n print(dat[0] - 1)\nelse:\n dat.sort(reverse=True)\n while dat[1] != 0:\n x = dat[1]\n dat[0] -= x\n dat[1] = 0\n dat.sort(reverse=True)\n if dat[0] == 0:\n print(0)\n else:\n print(dat[0] - 1)", "len(dat) == 1", "len(dat)", "len", "dat", "1", "print(dat[0] - 1)", "print", "dat[0] - 1", "dat[0]", "dat", "0", "1", "dat.sort(reverse=True)", "dat.sort", "dat", "sort", "reverse=True", "reverse", "True", "while dat[1] != 0:\n x = dat[1]\n dat[0] -= x\n dat[1] = 0\n dat.sort(reverse=True)\n ", "dat[1] != 0", "dat[1]", "dat", "1", "0", "x = dat[1]", "x", "dat[1]", "dat", "1", "dat[0] -= x", "dat[0]", "dat", "0", "x", "dat[1] = 0", "dat[1]", "dat", "1", "0", "dat.sort(reverse=True)", "dat.sort", "dat", "sort", "reverse=True", "reverse", "True", "if dat[0] == 0:\n print(0)\n else:\n print(dat[0] - 1)", "dat[0] == 0", "dat[0]", "dat", "0", "0", "print(0)", "print", "0", "print(dat[0] - 1)", "print", "dat[0] - 1", "dat[0]", "dat", "0", "1", "k, t = map(int, input().split())", "map(int, input().split())", "k", "t = map(int, input().split())", "map(int, input().split())", "t", "res = 0", "0", "res", "prev = -1", "-1", "prev", "eat = 0", "0", "eat", "x = dat[1]", "dat[1]", "x", "dat = list(map(int, input().split()))", "list(map(int, input().split()))", "dat" ]
k, t = map(int, input().split()) dat = list(map(int, input().split())) dat.sort(reverse=True) prev = -1 res = 0 eat = 0 if len(dat) == 1: print(dat[0] - 1) else: dat.sort(reverse=True) while dat[1] != 0: x = dat[1] dat[0] -= x dat[1] = 0 dat.sort(reverse=True) if dat[0] == 0: print(0) else: print(dat[0] - 1)
[ 7, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 2, 13, 2, 2, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 53, 2 ], [ 53, 13 ], [ 47, 15 ], [ 50, 27 ], [ 48, 30 ], [ 51, 36 ], [ 45, 39 ], [ 51, 40 ], [ 53, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "k, t = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nlargest = max(a)\nprint(max(largest-(k-largest+1), 0))", "k, t = list(map(int, input().split()))", "k", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "largest = max(a)", "largest", "max(a)", "max", "a", "print(max(largest-(k-largest+1), 0))", "print", "max(largest-(k-largest+1), 0)", "max", "largest-(k-largest+1)", "largest", "k-largest+1", "k-largest", "k", "largest", "1", "0", "k, t = list(map(int, input().split()))", "list(map(int, input().split()))", "k", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "largest = max(a)", "max(a)", "largest", "t = list(map(int, input().split()))", "list(map(int, input().split()))", "t" ]
k, t = list(map(int, input().split())) a = list(map(int, input().split())) largest = max(a) print(max(largest-(k-largest+1), 0))
[ 7, 15, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 17, 15, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 2, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 13, 17, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 24, 23 ], [ 99, 29 ], [ 33, 33 ], [ 89, 42 ], [ 110, 47 ], [ 104, 51 ], [ 99, 53 ], [ 104, 54 ], [ 83, 56 ], [ 81, 58 ], [ 86, 60 ], [ 84, 63 ], [ 113, 65 ], [ 96, 67 ], [ 87, 68 ], [ 87, 76 ], [ 114, 77 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 104, 96 ], [ 104, 105 ], [ 110, 111 ], [ 113, 114 ] ]
[ "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\n#mod = 10 ** 9 + 7 \nmod = 998244353\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\nK, T = MAP()\na = LIST()\nma = max(a)\nleft = K-ma\nprint(max(0, ma-left-1))", "import sys, re", "sys", "re", "from collections import deque, defaultdict, Counter", "from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd", "from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby", "from operator import itemgetter, mul", "from copy import deepcopy", "from string import ascii_lowercase, ascii_uppercase, digits", "from bisect import bisect, bisect_left, insort, insort_left", "from heapq import heappush, heappop", "from functools import reduce", "def input(): return sys.stdin.readline().strip()", "input", "def INT(): return int(input())", "INT", "def MAP(): return map(int, input().split())", "MAP", "def LIST(): return list(map(int, input().split()))", "LIST", "MAP() for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "MAP()", "MAP", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "n", "n", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "mod = 998244353", "mod", "998244353", "from decimal import *", "K, T = MAP()", "K", "MAP()", "MAP", "T", "a = LIST()", "a", "LIST()", "LIST", "ma = max(a)", "ma", "max(a)", "max", "a", "left = K-ma", "left", "K-ma", "K", "ma", "print(max(0, ma-left-1))", "print", "max(0, ma-left-1)", "max", "0", "ma-left-1", "ma-left", "ma", "left", "1", "def LIST(): return list(map(int, input().split()))", "def LIST(): return list(map(int, input().split()))", "LIST", "a = LIST()", "LIST()", "a", "ma = max(a)", "max(a)", "ma", "INF = float('inf')", "float('inf')", "INF", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "K, T = MAP()", "MAP()", "K", "def MAP(): return map(int, input().split())", "def MAP(): return map(int, input().split())", "MAP", "def INT(): return int(input())", "def INT(): return int(input())", "INT", "T = MAP()", "MAP()", "T", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "mod = 998244353", "998244353", "mod", "left = K-ma", "K-ma", "left" ]
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left, insort, insort_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') #mod = 10 ** 9 + 7 mod = 998244353 from decimal import * #import numpy as np #decimal.getcontext().prec = 10 K, T = MAP() a = LIST() ma = max(a) left = K-ma print(max(0, ma-left-1))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 2, 2, 2, 17, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 51, 11 ], [ 42, 13 ], [ 48, 25 ], [ 43, 28 ], [ 49, 37 ], [ 52, 38 ], [ 42, 43 ], [ 51, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "k, t = map(int, input().split())\na = list(map(int, input().split()))\naa = max(a)\nprint(max(2*aa-k-1, 0))", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "aa = max(a)", "aa", "max(a)", "max", "a", "print(max(2*aa-k-1, 0))", "print", "max(2*aa-k-1, 0)", "max", "2*aa-k-1", "2*aa-k", "2*aa", "2", "aa", "k", "1", "0", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "t = map(int, input().split())", "map(int, input().split())", "t", "aa = max(a)", "max(a)", "aa", "k, t = map(int, input().split())", "map(int, input().split())", "k" ]
k, t = map(int, input().split()) a = list(map(int, input().split())) aa = max(a) print(max(2*aa-k-1, 0))
[ 7, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 4, 13, 4, 13, 2, 2, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 58, 2 ], [ 58, 13 ], [ 49, 15 ], [ 55, 27 ], [ 50, 30 ], [ 61, 32 ], [ 50, 36 ], [ 56, 37 ], [ 56, 44 ], [ 62, 45 ], [ 49, 50 ], [ 58, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "K,T = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nm = max(a)\no = sum(a)-m\n\nprint(max(m-o-1, 0))", "K,T = list(map(int, input().split()))", "K", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m = max(a)", "m", "max(a)", "max", "a", "o = sum(a)-m", "o", "sum(a)-m", "sum(a)", "sum", "a", "m", "print(max(m-o-1, 0))", "print", "max(m-o-1, 0)", "max", "m-o-1", "m-o", "m", "o", "1", "0", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "T = list(map(int, input().split()))", "list(map(int, input().split()))", "T", "m = max(a)", "max(a)", "m", "K,T = list(map(int, input().split()))", "list(map(int, input().split()))", "K", "o = sum(a)-m", "sum(a)-m", "o" ]
K,T = list(map(int, input().split())) a = list(map(int, input().split())) m = max(a) o = sum(a)-m print(max(m-o-1, 0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 0, 13, 2, 2, 13, 18, 13, 17, 17, 0, 13, 4, 13, 17, 2, 2, 2, 2, 18, 13, 17, 13, 17, 13, 2, 18, 13, 17, 13, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 75, 2 ], [ 75, 11 ], [ 78, 13 ], [ 76, 26 ], [ 73, 31 ], [ 66, 34 ], [ 73, 37 ], [ 79, 39 ], [ 69, 43 ], [ 79, 52 ], [ 67, 54 ], [ 67, 56 ], [ 79, 59 ], [ 67, 61 ], [ 70, 64 ], [ 66, 67 ], [ 69, 70 ], [ 75, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "k, t = map(int, input().split())\nA = sorted(map(int, input().split()))\nif t == 1:\n print(k - 1)\nelse:\n dev = k - A[-1] + 1\n ans = max(0, (A[-1] // dev - 1) * dev + A[-1] % dev)\n print(ans)", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "A = sorted(map(int, input().split()))", "A", "sorted(map(int, input().split()))", "sorted", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "if t == 1:\n print(k - 1)\nelse:\n dev = k - A[-1] + 1\n ans = max(0, (A[-1] // dev - 1) * dev + A[-1] % dev)\n print(ans)", "t == 1", "t", "1", "print(k - 1)", "print", "k - 1", "k", "1", "dev = k - A[-1] + 1", "dev", "k - A[-1] + 1", "k - A[-1]", "k", "A[-1]", "A", "-1", "1", "ans = max(0, (A[-1] // dev - 1) * dev + A[-1] % dev)", "ans", "max(0, (A[-1] // dev - 1) * dev + A[-1] % dev)", "max", "0", "(A[-1] // dev - 1) * dev + A[-1] % dev", "(A[-1] // dev - 1) * dev", "A[-1] // dev - 1", "A[-1] // dev", "A[-1]", "A", "-1", "dev", "1", "dev", "A[-1] % dev", "A[-1]", "A", "-1", "dev", "print(ans)", "print", "ans", "dev = k - A[-1] + 1", "k - A[-1] + 1", "dev", "ans = max(0, (A[-1] // dev - 1) * dev + A[-1] % dev)", "max(0, (A[-1] // dev - 1) * dev + A[-1] % dev)", "ans", "k, t = map(int, input().split())", "map(int, input().split())", "k", "t = map(int, input().split())", "map(int, input().split())", "t", "A = sorted(map(int, input().split()))", "sorted(map(int, input().split()))", "A" ]
k, t = map(int, input().split()) A = sorted(map(int, input().split())) if t == 1: print(k - 1) else: dev = k - A[-1] + 1 ans = max(0, (A[-1] // dev - 1) * dev + A[-1] % dev) print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 2, 18, 13, 17, 4, 13, 18, 13, 39, 17, 4, 13, 8, 2, 13, 17, 2, 13, 17, 17, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 60, 2 ], [ 60, 11 ], [ 51, 13 ], [ 52, 26 ], [ 54, 29 ], [ 52, 32 ], [ 52, 37 ], [ 55, 44 ], [ 55, 47 ], [ 51, 52 ], [ 54, 55 ], [ 60, 58 ], [ 60, 61 ] ]
[ "k, t = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nans = a[-1] - sum(a[:-1])\nprint(ans - 1 if ans > 0 else 0)", "k, t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort()", "a.sort", "a", "sort", "ans = a[-1] - sum(a[:-1])", "ans", "a[-1] - sum(a[:-1])", "a[-1]", "a", "-1", "sum(a[:-1])", "sum", "a[:-1]", "a", ":-1", "-1", "print(ans - 1 if ans > 0 else 0)", "print", "ans - 1 if ans > 0 else 0", "ans > 0", "ans", "0", "ans - 1", "ans", "1", "0", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans = a[-1] - sum(a[:-1])", "a[-1] - sum(a[:-1])", "ans", "t = map(int,input().split())", "map(int,input().split())", "t", "k, t = map(int,input().split())", "map(int,input().split())", "k" ]
k, t = map(int,input().split()) a = list(map(int,input().split())) a.sort() ans = a[-1] - sum(a[:-1]) print(ans - 1 if ans > 0 else 0)
[ 7, 15, 13, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 12, 13, 23, 13, 13, 12, 13, 23, 13, 13, 12, 13, 23, 13, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 41, 28, 13, 4, 13, 13, 4, 39, 18, 13, 13, 13, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 4, 18, 13, 13, 0, 13, 12, 18, 13, 17, 23, 28, 13, 4, 13, 4, 13, 13, 14, 2, 2, 18, 18, 13, 13, 17, 17, 40, 18, 18, 13, 13, 17, 13, 0, 18, 18, 13, 13, 17, 17, 0, 13, 18, 18, 13, 13, 17, 3, 41, 28, 13, 4, 13, 13, 4, 18, 18, 13, 13, 17, 4, 13, 4, 13, 13, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 145, 4 ], [ 19, 18 ], [ 24, 23 ], [ 29, 28 ], [ 34, 33 ], [ 140, 35 ], [ 34, 36 ], [ 39, 38 ], [ 143, 40 ], [ 44, 43 ], [ 36, 46 ], [ 38, 50 ], [ 43, 51 ], [ 55, 54 ], [ 58, 57 ], [ 61, 60 ], [ 33, 63 ], [ 54, 66 ], [ 70, 69 ], [ 77, 76 ], [ 36, 81 ], [ 54, 87 ], [ 76, 88 ], [ 54, 94 ], [ 76, 95 ], [ 57, 97 ], [ 106, 97 ], [ 104, 99 ], [ 54, 101 ], [ 76, 102 ], [ 107, 106 ], [ 54, 109 ], [ 76, 110 ], [ 116, 115 ], [ 36, 118 ], [ 54, 122 ], [ 115, 123 ], [ 137, 131 ], [ 145, 146 ] ]
[ "#!/usr/bin/env python3\n#%% for atcoder uniittest use\nimport sys\ninput= lambda: sys.stdin.readline().rstrip()\ndef pin(type=int):return map(type,input().split())\ndef tupin(t=int):return tuple(pin(t))\ndef lispin(t=int):return list(pin(t))\n#%%code\ndef resolve():\n K,T=pin()\n A=tupin()\n B=[[A[i],i] for i in range(T)]\n #print(B)\n prev=None\n for k in range(K):\n B.sort(key=lambda x:x[0])\n # print(B,\"#\")\n for i in reversed(range(T)):\n if B[i][0]>0 and B[i][1]!=prev:\n B[i][0]-=1\n \n prev=B[i][1]\n break\n print(sum([B[k][0] for k in range(T)]))\n#%%submit!\nresolve()", "import sys", "sys", "input= lambda: sys.stdin.readline().rstrip()", "input", "lambda: sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "def pin(type=int):return map(type,input().split())", "pin", "type=int", "type", "int", "def tupin(t=int):return tuple(pin(t))", "tupin", "t=int", "t", "int", "def lispin(t=int):return list(pin(t))\n#%%code", "lispin", "t=int", "t", "int", "def resolve():\n K,T=pin()\n A=tupin()\n B=[[A[i],i] for i in range(T)]\n #print(B)\n prev=None\n for k in range(K):\n B.sort(key=lambda x:x[0])\n # print(B,\"#\")\n for i in reversed(range(T)):\n if B[i][0]>0 and B[i][1]!=prev:\n B[i][0]-=1\n \n prev=B[i][1]\n break\n print(sum([B[k][0] for k in range(T)]))\n#%%submit!", "resolve", "K,T=pin()", "K", "pin()", "pin", "T", "A=tupin()", "A", "tupin()", "tupin", "[A[i],i] for i in range(T)", "for i in range(T)", "i", "range(T)", "range", "T", "for i in range(T)", "[A[i],i]", "A[i]", "A", "i", "i", "B=[[A[i],i] for i in range(T)]", "B", "[[A[i],i] for i in range(T)]", "prev=None", "prev", "None", "for k in range(K):\n B.sort(key=lambda x:x[0])\n # print(B,\"#\")\n for i in reversed(range(T)):\n if B[i][0]>0 and B[i][1]!=prev:\n B[i][0]-=1\n \n prev=B[i][1]\n break\n ", "k", "range(K)", "range", "K", "B.sort(key=lambda x:x[0])", "B.sort", "B", "sort", "key=lambda x:x[0]", "key", "lambda x:x[0]", "x[0]", "x", "0", "x", "for i in reversed(range(T)):\n if B[i][0]>0 and B[i][1]!=prev:\n B[i][0]-=1\n \n prev=B[i][1]\n break\n ", "i", "reversed(range(T))", "reversed", "range(T)", "range", "T", "if B[i][0]>0 and B[i][1]!=prev:\n B[i][0]-=1\n \n prev=B[i][1]\n break\n ", "B[i][0]>0 and B[i][1]!=prev", "B[i][0]>0", "B[i][0]", "[i]", "B", "i", "0", "0", "B[i][1]!=prev", "B[i][1]", "[i]", "B", "i", "1", "prev", "B[i][0]-=1", "B[i][0]", "[i]", "B", "i", "0", "1", "prev=B[i][1]", "prev", "B[i][1]", "[i]", "B", "i", "1", "break", "B[k][0] for k in range(T)", "for k in range(T)", "k", "range(T)", "range", "T", "for k in range(T)", "B[k][0]", "[k]", "B", "k", "0", "print(sum([B[k][0] for k in range(T)]))", "print", "sum([B[k][0] for k in range(T)])", "sum", "[B[k][0] for k in range(T)]", "resolve()", "resolve", "def lispin(t=int):return list(pin(t))\n#%%code", "def lispin(t=int):return list(pin(t))\n#%%code", "lispin", "def resolve():\n K,T=pin()\n A=tupin()\n B=[[A[i],i] for i in range(T)]\n #print(B)\n prev=None\n for k in range(K):\n B.sort(key=lambda x:x[0])\n # print(B,\"#\")\n for i in reversed(range(T)):\n if B[i][0]>0 and B[i][1]!=prev:\n B[i][0]-=1\n \n prev=B[i][1]\n break\n print(sum([B[k][0] for k in range(T)]))\n#%%submit!", "def resolve():\n K,T=pin()\n A=tupin()\n B=[[A[i],i] for i in range(T)]\n #print(B)\n prev=None\n for k in range(K):\n B.sort(key=lambda x:x[0])\n # print(B,\"#\")\n for i in reversed(range(T)):\n if B[i][0]>0 and B[i][1]!=prev:\n B[i][0]-=1\n \n prev=B[i][1]\n break\n print(sum([B[k][0] for k in range(T)]))\n#%%submit!", "resolve", "def pin(type=int):return map(type,input().split())", "def pin(type=int):return map(type,input().split())", "pin", "def tupin(t=int):return tuple(pin(t))", "def tupin(t=int):return tuple(pin(t))", "tupin", "input= lambda: sys.stdin.readline().rstrip()", "lambda: sys.stdin.readline().rstrip()", "input" ]
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input= lambda: sys.stdin.readline().rstrip() def pin(type=int):return map(type,input().split()) def tupin(t=int):return tuple(pin(t)) def lispin(t=int):return list(pin(t)) #%%code def resolve(): K,T=pin() A=tupin() B=[[A[i],i] for i in range(T)] #print(B) prev=None for k in range(K): B.sort(key=lambda x:x[0]) # print(B,"#") for i in reversed(range(T)): if B[i][0]>0 and B[i][1]!=prev: B[i][0]-=1 prev=B[i][1] break print(sum([B[k][0] for k in range(T)])) #%%submit! resolve()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 14, 2, 13, 17, 0, 13, 2, 13, 17, 0, 13, 4, 13, 13, 14, 40, 13, 2, 2, 13, 17, 17, 0, 13, 17, 0, 13, 2, 2, 2, 17, 13, 13, 17, 4, 13, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 77, 2 ], [ 77, 11 ], [ 15, 14 ], [ 14, 23 ], [ 68, 25 ], [ 78, 29 ], [ 80, 32 ], [ 72, 34 ], [ 83, 37 ], [ 69, 40 ], [ 84, 43 ], [ 72, 46 ], [ 65, 50 ], [ 74, 53 ], [ 84, 58 ], [ 72, 59 ], [ 75, 63 ], [ 66, 63 ], [ 81, 63 ], [ 65, 66 ], [ 68, 69 ], [ 77, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ] ]
[ "k, t = map(int, input().split())\na = [int(x) for x in input().split()]\n\nif t == 1:\n ans = k-1\nelse:\n key = max(a)\n if key <= (k+1)//2:\n ans = 0\n else:\n ans = 2*key-k-1\n\nprint(ans)", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "a = [int(x) for x in input().split()]", "a", "[int(x) for x in input().split()]", "if t == 1:\n ans = k-1\nelse:\n key = max(a)\n if key <= (k+1)//2:\n ans = 0\n else:\n ans = 2*key-k-1", "t == 1", "t", "1", "ans = k-1", "ans", "k-1", "k", "1", "key = max(a)", "key", "max(a)", "max", "a", "if key <= (k+1)//2:\n ans = 0\n else:\n ans = 2*key-k-1", "key <= (k+1)//2", "key", "(k+1)//2", "k+1", "k", "1", "2", "ans = 0", "ans", "0", "ans = 2*key-k-1", "ans", "2*key-k-1", "2*key-k", "2*key", "2", "key", "k", "1", "print(ans)", "print", "ans", "ans = 0", "0", "ans", "a = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "a", "k, t = map(int, input().split())", "map(int, input().split())", "k", "ans = 2*key-k-1", "2*key-k-1", "ans", "t = map(int, input().split())", "map(int, input().split())", "t", "ans = k-1", "k-1", "ans", "key = max(a)", "max(a)", "key" ]
k, t = map(int, input().split()) a = [int(x) for x in input().split()] if t == 1: ans = k-1 else: key = max(a) if key <= (k+1)//2: ans = 0 else: ans = 2*key-k-1 print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 17, 4, 13, 4, 13, 2, 2, 2, 17, 18, 13, 17, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 52, 2 ], [ 52, 11 ], [ 46, 13 ], [ 47, 26 ], [ 30, 29 ], [ 47, 40 ], [ 50, 42 ], [ 46, 47 ], [ 52, 50 ], [ 52, 53 ] ]
[ "k,t=map(int,input().split())\na=list(map(int,input().split()))\na.sort(reverse=True)\nprint(max(2*a[0]-k-1,0))", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "print(max(2*a[0]-k-1,0))", "print", "max(2*a[0]-k-1,0)", "max", "2*a[0]-k-1", "2*a[0]-k", "2*a[0]", "2", "a[0]", "a", "0", "k", "1", "0", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "k,t=map(int,input().split())", "map(int,input().split())", "k", "t=map(int,input().split())", "map(int,input().split())", "t" ]
k,t=map(int,input().split()) a=list(map(int,input().split())) a.sort(reverse=True) print(max(2*a[0]-k-1,0))
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 18, 18, 13, 13, 13, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 4, 13, 13, 0, 13, 4, 13, 17, 2, 2, 4, 13, 13, 17, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 12, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 91, 11 ], [ 94, 18 ], [ 85, 23 ], [ 33, 32 ], [ 92, 39 ], [ 33, 41 ], [ 44, 43 ], [ 92, 52 ], [ 56, 55 ], [ 43, 59 ], [ 43, 62 ], [ 65, 64 ], [ 43, 72 ], [ 55, 74 ], [ 64, 77 ], [ 89, 83 ], [ 85, 86 ], [ 91, 92 ], [ 94, 95 ] ]
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n k, t = map(int, input().split())\n A = list(map(int, input().split()))\n etc = sum(A) - max(A)\n res = max(0, max(A) - 1 - etc)\n print(res)\n\n\nif __name__ == '__main__':\n resolve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "f_inf = float('inf')", "f_inf", "float('inf')", "float", "'inf'", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "def resolve():\n k, t = map(int, input().split())\n A = list(map(int, input().split()))\n etc = sum(A) - max(A)\n res = max(0, max(A) - 1 - etc)\n print(res)", "resolve", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "etc = sum(A) - max(A)", "etc", "sum(A) - max(A)", "sum(A)", "sum", "A", "max(A)", "max", "A", "res = max(0, max(A) - 1 - etc)", "res", "max(0, max(A) - 1 - etc)", "max", "0", "max(A) - 1 - etc", "max(A) - 1", "max(A)", "max", "A", "1", "etc", "print(res)", "print", "res", "if __name__ == '__main__':\n resolve()", "__name__ == '__main__'", "__name__", "'__main__'", "resolve()", "resolve", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "def resolve():\n k, t = map(int, input().split())\n A = list(map(int, input().split()))\n etc = sum(A) - max(A)\n res = max(0, max(A) - 1 - etc)\n print(res)", "def resolve():\n k, t = map(int, input().split())\n A = list(map(int, input().split()))\n etc = sum(A) - max(A)\n res = max(0, max(A) - 1 - etc)\n print(res)", "resolve", "input = sys.stdin.readline", "sys.stdin.readline", "input", "f_inf = float('inf')", "float('inf')", "f_inf" ]
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): k, t = map(int, input().split()) A = list(map(int, input().split())) etc = sum(A) - max(A) res = max(0, max(A) - 1 - etc) print(res) if __name__ == '__main__': resolve()
[ 7, 15, 13, 13, 13, 13, 13, 13, 13, 13, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 2, 4, 13, 13, 17, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 2, 39, 17, 2, 13, 17, 28, 13, 4, 13, 13, 0, 18, 13, 2, 13, 17, 2, 18, 13, 13, 18, 13, 13, 0, 13, 13, 28, 13, 13, 0, 13, 4, 13, 4, 13, 2, 4, 13, 2, 2, 17, 13, 13, 17, 17, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 163, 11 ], [ 166, 30 ], [ 43, 42 ], [ 164, 46 ], [ 42, 51 ], [ 57, 56 ], [ 164, 60 ], [ 56, 66 ], [ 73, 72 ], [ 164, 76 ], [ 72, 81 ], [ 90, 89 ], [ 185, 91 ], [ 90, 92 ], [ 95, 94 ], [ 185, 96 ], [ 94, 99 ], [ 103, 102 ], [ 106, 105 ], [ 92, 110 ], [ 114, 113 ], [ 92, 116 ], [ 123, 118 ], [ 105, 119 ], [ 113, 121 ], [ 105, 125 ], [ 113, 126 ], [ 94, 128 ], [ 113, 129 ], [ 132, 131 ], [ 167, 132 ], [ 135, 134 ], [ 105, 134 ], [ 138, 137 ], [ 134, 148 ], [ 89, 149 ], [ 131, 152 ], [ 137, 152 ], [ 137, 155 ], [ 131, 155 ], [ 176, 161 ], [ 163, 164 ], [ 166, 167 ] ]
[ "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n K, T = LI()\n a = LI()\n\n # aを2グループに分けて交互に食べれば良い\n # 最も差の少ない2グループの分け方を知りたい\n\n a.sort(reverse=True)\n a_cum = [0] * (T + 1)\n for i in range(T):\n a_cum[i+1] = a_cum[i] + a[i]\n\n ans = INF\n for i in a_cum:\n ans = min(max(abs(2 * i - K) - 1, 0), ans)\n\n print(ans)\n\nif __name__ == '__main__':\n resolve()", "import bisect, collections, copy, heapq, itertools, math, string, sys", "bisect", "collections", "copy", "heapq", "itertools", "math", "string", "sys", "input = lambda: sys.stdin.readline().rstrip()", "input", "lambda: sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "sys.setrecursionlimit(10**7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**7", "10", "7", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "def I(): return int(input())", "I", "def F(): return float(input())", "F", "def SS(): return input()", "SS", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "def LI(): return [int(x) for x in input().split()]", "LI", "int(x)-1 for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)-1", "int(x)", "int", "x", "1", "def LI_(): return [int(x)-1 for x in input().split()]", "LI_", "float(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "float(x)", "float", "x", "def LF(): return [float(x) for x in input().split()]", "LF", "def LSS(): return input().split()", "LSS", "def resolve():\n K, T = LI()\n a = LI()\n\n # aを2グループに分けて交互に食べれば良い\n # 最も差の少ない2グループの分け方を知りたい\n\n a.sort(reverse=True)\n a_cum = [0] * (T + 1)\n for i in range(T):\n a_cum[i+1] = a_cum[i] + a[i]\n\n ans = INF\n for i in a_cum:\n ans = min(max(abs(2 * i - K) - 1, 0), ans)\n\n print(ans)", "resolve", "K, T = LI()", "K", "LI()", "LI", "T", "a = LI()", "a", "LI()", "LI", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "a_cum = [0] * (T + 1)", "a_cum", "[0] * (T + 1)", "[0]", "0", "T + 1", "T", "1", "for i in range(T):\n a_cum[i+1] = a_cum[i] + a[i]\n\n ", "i", "range(T)", "range", "T", "a_cum[i+1] = a_cum[i] + a[i]", "a_cum[i+1]", "a_cum", "i+1", "i", "1", "a_cum[i] + a[i]", "a_cum[i]", "a_cum", "i", "a[i]", "a", "i", "ans = INF", "ans", "INF", "for i in a_cum:\n ans = min(max(abs(2 * i - K) - 1, 0), ans)\n\n ", "i", "a_cum", "ans = min(max(abs(2 * i - K) - 1, 0), ans)", "ans", "min(max(abs(2 * i - K) - 1, 0), ans)", "min", "max(abs(2 * i - K) - 1, 0)", "max", "abs(2 * i - K) - 1", "abs(2 * i - K)", "abs", "2 * i - K", "2 * i", "2", "i", "K", "1", "0", "ans", "print(ans)", "print", "ans", "if __name__ == '__main__':\n resolve()", "__name__ == '__main__'", "__name__", "'__main__'", "resolve()", "resolve", "input = lambda: sys.stdin.readline().rstrip()", "lambda: sys.stdin.readline().rstrip()", "input", "INF = float('inf')", "float('inf')", "INF", "def LSS(): return input().split()", "def LSS(): return input().split()", "LSS", "def F(): return float(input())", "def F(): return float(input())", "F", "def resolve():\n K, T = LI()\n a = LI()\n\n # aを2グループに分けて交互に食べれば良い\n # 最も差の少ない2グループの分け方を知りたい\n\n a.sort(reverse=True)\n a_cum = [0] * (T + 1)\n for i in range(T):\n a_cum[i+1] = a_cum[i] + a[i]\n\n ans = INF\n for i in a_cum:\n ans = min(max(abs(2 * i - K) - 1, 0), ans)\n\n print(ans)", "def resolve():\n K, T = LI()\n a = LI()\n\n # aを2グループに分けて交互に食べれば良い\n # 最も差の少ない2グループの分け方を知りたい\n\n a.sort(reverse=True)\n a_cum = [0] * (T + 1)\n for i in range(T):\n a_cum[i+1] = a_cum[i] + a[i]\n\n ans = INF\n for i in a_cum:\n ans = min(max(abs(2 * i - K) - 1, 0), ans)\n\n print(ans)", "resolve", "def LF(): return [float(x) for x in input().split()]", "def LF(): return [float(x) for x in input().split()]", "LF", "def I(): return int(input())", "def I(): return int(input())", "I", "def LI(): return [int(x) for x in input().split()]", "def LI(): return [int(x) for x in input().split()]", "LI", "def LI_(): return [int(x)-1 for x in input().split()]", "def LI_(): return [int(x)-1 for x in input().split()]", "LI_", "def SS(): return input()", "def SS(): return input()", "SS" ]
import bisect, collections, copy, heapq, itertools, math, string, sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = float('inf') def I(): return int(input()) def F(): return float(input()) def SS(): return input() def LI(): return [int(x) for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] def LF(): return [float(x) for x in input().split()] def LSS(): return input().split() def resolve(): K, T = LI() a = LI() # aを2グループに分けて交互に食べれば良い # 最も差の少ない2グループの分け方を知りたい a.sort(reverse=True) a_cum = [0] * (T + 1) for i in range(T): a_cum[i+1] = a_cum[i] + a[i] ans = INF for i in a_cum: ans = min(max(abs(2 * i - K) - 1, 0), ans) print(ans) if __name__ == '__main__': resolve()
[ 7, 15, 13, 4, 18, 13, 13, 2, 2, 17, 17, 17, 12, 13, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 2, 4, 13, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 17, 13, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 18, 17 ], [ 72, 24 ], [ 18, 26 ], [ 29, 28 ], [ 72, 37 ], [ 41, 40 ], [ 28, 43 ], [ 46, 45 ], [ 28, 48 ], [ 40, 50 ], [ 53, 52 ], [ 28, 56 ], [ 40, 57 ], [ 40, 65 ], [ 52, 67 ], [ 75, 69 ] ]
[ "import sys\nsys.setrecursionlimit(10 ** 5 + 10)\ndef input(): return sys.stdin.readline().strip()\n\ndef resolve():\n \n K,T=map(int,input().split())\n A=list(map(int,input().split()))\n\n mv=max(A)\n mi=A.index(mv)\n\n rem=sum(A)-mv\n print(max(0,mv-1-rem))\n \n\n \n\n \nresolve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 5 + 10)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 5 + 10", "10 ** 5", "10", "5", "10", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n \n K,T=map(int,input().split())\n A=list(map(int,input().split()))\n\n mv=max(A)\n mi=A.index(mv)\n\n rem=sum(A)-mv\n print(max(0,mv-1-rem))\n \n\n \n\n ", "resolve", "K,T=map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A=list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "mv=max(A)", "mv", "max(A)", "max", "A", "mi=A.index(mv)", "mi", "A.index(mv)", "A.index", "A", "index", "mv", "rem=sum(A)-mv", "rem", "sum(A)-mv", "sum(A)", "sum", "A", "mv", "print(max(0,mv-1-rem))", "print", "max(0,mv-1-rem)", "max", "0", "mv-1-rem", "mv-1", "mv", "1", "rem", "resolve()", "resolve", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n \n K,T=map(int,input().split())\n A=list(map(int,input().split()))\n\n mv=max(A)\n mi=A.index(mv)\n\n rem=sum(A)-mv\n print(max(0,mv-1-rem))\n \n\n \n\n ", "def resolve():\n \n K,T=map(int,input().split())\n A=list(map(int,input().split()))\n\n mv=max(A)\n mi=A.index(mv)\n\n rem=sum(A)-mv\n print(max(0,mv-1-rem))\n \n\n \n\n ", "resolve" ]
import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): K,T=map(int,input().split()) A=list(map(int,input().split())) mv=max(A) mi=A.index(mv) rem=sum(A)-mv print(max(0,mv-1-rem)) resolve()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 18, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 0, 13, 2, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 17, 10, 4, 13, 10, 18, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 72, 2 ], [ 72, 11 ], [ 75, 13 ], [ 28, 27 ], [ 63, 30 ], [ 76, 32 ], [ 60, 35 ], [ 76, 39 ], [ 66, 43 ], [ 64, 45 ], [ 61, 46 ], [ 67, 49 ], [ 67, 54 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 72, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "k, t = map(int, input().split())\na = sorted(list(map(int, input().split())), reverse=True)\n\nma = a[0]\nex = sum(a[1:])\ndiff = ma - ex\nif diff > 0:\n print(diff - 1)\nelse:\n print(0)", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = sorted(list(map(int, input().split())), reverse=True)", "a", "sorted(list(map(int, input().split())), reverse=True)", "sorted", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "reverse=True", "reverse", "True", "ma = a[0]", "ma", "a[0]", "a", "0", "ex = sum(a[1:])", "ex", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "diff = ma - ex", "diff", "ma - ex", "ma", "ex", "if diff > 0:\n print(diff - 1)\nelse:\n print(0)", "diff > 0", "diff", "0", "print(diff - 1)", "print", "diff - 1", "diff", "1", "print(0)", "print", "0", "ex = sum(a[1:])", "sum(a[1:])", "ex", "ma = a[0]", "a[0]", "ma", "diff = ma - ex", "ma - ex", "diff", "t = map(int, input().split())", "map(int, input().split())", "t", "k, t = map(int, input().split())", "map(int, input().split())", "k", "a = sorted(list(map(int, input().split())), reverse=True)", "sorted(list(map(int, input().split())), reverse=True)", "a" ]
k, t = map(int, input().split()) a = sorted(list(map(int, input().split())), reverse=True) ma = a[0] ex = sum(a[1:]) diff = ma - ex if diff > 0: print(diff - 1) else: print(0)
[ 7, 0, 13, 2, 2, 17, 17, 17, 0, 13, 2, 17, 17, 15, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 29, 41, 28, 13, 4, 13, 13, 4, 39, 40, 18, 13, 13, 13, 0, 13, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 4, 13, 13, 13, 14, 40, 13, 13, 0, 13, 17, 0, 13, 13, 4, 13, 13, 39, 13, 13, 0, 13, 4, 13, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 13, 4, 13, 13, 39, 13, 13, 4, 13, 13, 39, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 13, 39, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 12, 13, 10, 2, 13 ]
[ [ 157, 2 ], [ 151, 9 ], [ 18, 17 ], [ 18, 26 ], [ 29, 28 ], [ 26, 41 ], [ 17, 46 ], [ 52, 51 ], [ 26, 54 ], [ 28, 59 ], [ 51, 60 ], [ 64, 63 ], [ 63, 67 ], [ 28, 67 ], [ 70, 69 ], [ 73, 72 ], [ 76, 75 ], [ 17, 78 ], [ 81, 80 ], [ 63, 83 ], [ 28, 83 ], [ 81, 84 ], [ 84, 87 ], [ 69, 88 ], [ 115, 88 ], [ 93, 88 ], [ 91, 90 ], [ 94, 93 ], [ 84, 94 ], [ 63, 97 ], [ 28, 97 ], [ 103, 102 ], [ 63, 105 ], [ 28, 105 ], [ 103, 106 ], [ 102, 109 ], [ 112, 109 ], [ 113, 112 ], [ 116, 115 ], [ 106, 116 ], [ 63, 119 ], [ 28, 119 ], [ 63, 125 ], [ 28, 125 ], [ 131, 130 ], [ 134, 133 ], [ 63, 137 ], [ 28, 137 ], [ 133, 143 ], [ 72, 143 ], [ 155, 149 ], [ 151, 152 ], [ 157, 158 ] ]
[ "MOD = 10 **9 + 7\nINF = 10 ** 10\nfrom heapq import heapify,heappop,heappush\n\ndef main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n if t == 1:\n print(k - 1)\n return\n A = [(-A[i],i) for i in range(t)]\n heapify(A)\n \n before = -1\n ans = 0\n for _ in range(k):\n p,i = heappop(A)\n if i != before:\n p += 1\n before = i\n heappush(A,(p,i))\n else:\n q,j = heappop(A)\n if q < 0:\n q += 1\n before = j\n heappush(A,(q,j))\n heappush(A,(p,i))\n else:\n p += 1\n ans += 1\n heappush(A,(p,i))\n print(ans)\nif __name__ == '__main__':\n main()", "MOD = 10 **9 + 7", "MOD", "10 **9 + 7", "10 **9", "10", "9", "7", "INF = 10 ** 10", "INF", "10 ** 10", "10", "10", "from heapq import heapify,heappop,heappush", "def main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n if t == 1:\n print(k - 1)\n return\n A = [(-A[i],i) for i in range(t)]\n heapify(A)\n \n before = -1\n ans = 0\n for _ in range(k):\n p,i = heappop(A)\n if i != before:\n p += 1\n before = i\n heappush(A,(p,i))\n else:\n q,j = heappop(A)\n if q < 0:\n q += 1\n before = j\n heappush(A,(q,j))\n heappush(A,(p,i))\n else:\n p += 1\n ans += 1\n heappush(A,(p,i))\n print(ans)", "main", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "if t == 1:\n print(k - 1)\n return\n ", "t == 1", "t", "1", "print(k - 1)", "print", "k - 1", "k", "1", "return", "(-A[i],i) for i in range(t)", "for i in range(t)", "i", "range(t)", "range", "t", "for i in range(t)", "(-A[i],i)", "-A[i]", "A[i]", "A", "i", "i", "A = [(-A[i],i) for i in range(t)]", "A", "[(-A[i],i) for i in range(t)]", "heapify(A)", "heapify", "A", "before = -1", "before", "-1", "ans = 0", "ans", "0", "for _ in range(k):\n p,i = heappop(A)\n if i != before:\n p += 1\n before = i\n heappush(A,(p,i))\n else:\n q,j = heappop(A)\n if q < 0:\n q += 1\n before = j\n heappush(A,(q,j))\n heappush(A,(p,i))\n else:\n p += 1\n ans += 1\n heappush(A,(p,i))\n ", "_", "range(k)", "range", "k", "p,i = heappop(A)", "p", "heappop(A)", "heappop", "A", "i", "if i != before:\n p += 1\n before = i\n heappush(A,(p,i))\n else:\n q,j = heappop(A)\n if q < 0:\n q += 1\n before = j\n heappush(A,(q,j))\n heappush(A,(p,i))\n else:\n p += 1\n ans += 1\n heappush(A,(p,i))\n ", "i != before", "i", "before", "p += 1", "p", "1", "before = i", "before", "i", "heappush(A,(p,i))", "heappush", "A", "(p,i)", "p", "i", "q,j = heappop(A)", "q", "heappop(A)", "heappop", "A", "j", "if q < 0:\n q += 1\n before = j\n heappush(A,(q,j))\n heappush(A,(p,i))\n else:\n p += 1\n ans += 1\n heappush(A,(p,i))\n ", "q < 0", "q", "0", "q += 1", "q", "1", "before = j", "before", "j", "heappush(A,(q,j))", "heappush", "A", "(q,j)", "q", "j", "heappush(A,(p,i))", "heappush", "A", "(p,i)", "p", "i", "p += 1", "p", "1", "ans += 1", "ans", "1", "heappush(A,(p,i))", "heappush", "A", "(p,i)", "p", "i", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "INF = 10 ** 10", "10 ** 10", "INF", "def main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n if t == 1:\n print(k - 1)\n return\n A = [(-A[i],i) for i in range(t)]\n heapify(A)\n \n before = -1\n ans = 0\n for _ in range(k):\n p,i = heappop(A)\n if i != before:\n p += 1\n before = i\n heappush(A,(p,i))\n else:\n q,j = heappop(A)\n if q < 0:\n q += 1\n before = j\n heappush(A,(q,j))\n heappush(A,(p,i))\n else:\n p += 1\n ans += 1\n heappush(A,(p,i))\n print(ans)", "def main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n if t == 1:\n print(k - 1)\n return\n A = [(-A[i],i) for i in range(t)]\n heapify(A)\n \n before = -1\n ans = 0\n for _ in range(k):\n p,i = heappop(A)\n if i != before:\n p += 1\n before = i\n heappush(A,(p,i))\n else:\n q,j = heappop(A)\n if q < 0:\n q += 1\n before = j\n heappush(A,(q,j))\n heappush(A,(p,i))\n else:\n p += 1\n ans += 1\n heappush(A,(p,i))\n print(ans)", "main", "MOD = 10 **9 + 7", "10 **9 + 7", "MOD" ]
MOD = 10 **9 + 7 INF = 10 ** 10 from heapq import heapify,heappop,heappush def main(): k,t = map(int,input().split()) A = list(map(int,input().split())) if t == 1: print(k - 1) return A = [(-A[i],i) for i in range(t)] heapify(A) before = -1 ans = 0 for _ in range(k): p,i = heappop(A) if i != before: p += 1 before = i heappush(A,(p,i)) else: q,j = heappop(A) if q < 0: q += 1 before = j heappush(A,(q,j)) heappush(A,(p,i)) else: p += 1 ans += 1 heappush(A,(p,i)) print(ans) if __name__ == '__main__': main()
[ 7, 15, 13, 15, 12, 13, 0, 13, 17, 0, 13, 4, 13, 17, 4, 18, 13, 13, 2, 17, 17, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 14, 2, 13, 17, 4, 13, 2, 18, 13, 17, 17, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 40, 2, 13, 17, 13, 4, 13, 17, 4, 13, 2, 2, 13, 17, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 8, 7 ], [ 11, 10 ], [ 39, 38 ], [ 28, 40 ], [ 39, 41 ], [ 44, 43 ], [ 32, 45 ], [ 41, 48 ], [ 43, 54 ], [ 59, 58 ], [ 43, 61 ], [ 64, 63 ], [ 43, 67 ], [ 58, 68 ], [ 58, 72 ], [ 63, 74 ], [ 58, 82 ], [ 63, 84 ], [ 93, 90 ] ]
[ "#!/usr/bin/env python3\n\nimport sys\nfrom typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union\n# import time\n# import math\n# import numpy as np\n# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall\n# import random # random, uniform, randint, randrange, shuffle, sample\n# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits\n# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)\n# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).\n# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()\n# from collections import defaultdict # subclass of dict. defaultdict(facroty)\n# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)\n# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj\n# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj\n# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.\n# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference\n# from functools import reduce # reduce(f, iter[, init])\n# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)\n# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).\n# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).\n# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])\n# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]\n# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]\n# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])\n# from itertools import combinations, combinations_with_replacement\n# from itertools import accumulate # accumulate(iter[, f])\n# from operator import itemgetter # itemgetter(1), itemgetter('key')\n# from fractions import Fraction # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)\n\n\n\ndef main():\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n \n \n k, t = mi()\n cake = lmi()\n if t == 0:\n print(cake[0] - 1)\n else:\n M = max(cake)\n others = sum(cake) - M\n if M - 1 <= others:\n print(0)\n else:\n print(M - 1 - others)\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union", "def main():\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n \n \n k, t = mi()\n cake = lmi()\n if t == 0:\n print(cake[0] - 1)\n else:\n M = max(cake)\n others = sum(cake) - M\n if M - 1 <= others:\n print(0)\n else:\n print(M - 1 - others)", "main", "mod = 1000000007", "mod", "1000000007", "inf = float('inf')", "inf", "float('inf')", "float", "'inf'", "sys.setrecursionlimit(10**6)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**6", "10", "6", "def input(): return sys.stdin.readline().rstrip()\n ", "input", "def ii(): return int(input())\n ", "ii", "def isp(): return input().split()\n ", "isp", "def mi(): return map(int, input().split())\n ", "mi", "def mi_0(): return map(lambda x: int(x)-1, input().split())\n ", "mi_0", "def lmi(): return list(map(int, input().split()))\n ", "lmi", "def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n ", "lmi_0", "def li(): return list(input())\n \n \n ", "li", "k, t = mi()", "k", "mi()", "mi", "t", "cake = lmi()", "cake", "lmi()", "lmi", "if t == 0:\n print(cake[0] - 1)\n else:\n M = max(cake)\n others = sum(cake) - M\n if M - 1 <= others:\n print(0)\n else:\n print(M - 1 - others)", "t == 0", "t", "0", "print(cake[0] - 1)", "print", "cake[0] - 1", "cake[0]", "cake", "0", "1", "M = max(cake)", "M", "max(cake)", "max", "cake", "others = sum(cake) - M", "others", "sum(cake) - M", "sum(cake)", "sum", "cake", "M", "if M - 1 <= others:\n print(0)\n else:\n print(M - 1 - others)", "M - 1 <= others", "M - 1", "M", "1", "others", "print(0)", "print", "0", "print(M - 1 - others)", "print", "M - 1 - others", "M - 1", "M", "1", "others", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n \n \n k, t = mi()\n cake = lmi()\n if t == 0:\n print(cake[0] - 1)\n else:\n M = max(cake)\n others = sum(cake) - M\n if M - 1 <= others:\n print(0)\n else:\n print(M - 1 - others)", "def main():\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79e+308\n # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def isp(): return input().split()\n def mi(): return map(int, input().split())\n def mi_0(): return map(lambda x: int(x)-1, input().split())\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))\n def li(): return list(input())\n \n \n k, t = mi()\n cake = lmi()\n if t == 0:\n print(cake[0] - 1)\n else:\n M = max(cake)\n others = sum(cake) - M\n if M - 1 <= others:\n print(0)\n else:\n print(M - 1 - others)", "main" ]
#!/usr/bin/env python3 import sys from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import Fraction # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10) def main(): mod = 1000000007 # 10^9+7 inf = float('inf') # sys.float_info.max = 1.79e+308 # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def isp(): return input().split() def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x)-1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x)-1, input().split())) def li(): return list(input()) k, t = mi() cake = lmi() if t == 0: print(cake[0] - 1) else: M = max(cake) others = sum(cake) - M if M - 1 <= others: print(0) else: print(M - 1 - others) if __name__ == "__main__": main()
[ 7, 15, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 18, 13, 13, 4, 13, 13, 0, 13, 17, 42, 2, 13, 17, 0, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 3, 0, 13, 39, 0, 13, 18, 13, 39, 14, 2, 13, 17, 0, 18, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 13, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 13, 13, 10, 17, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 137, 4 ], [ 137, 13 ], [ 113, 15 ], [ 107, 27 ], [ 114, 30 ], [ 114, 34 ], [ 116, 36 ], [ 105, 40 ], [ 129, 40 ], [ 46, 43 ], [ 114, 44 ], [ 108, 45 ], [ 126, 45 ], [ 128, 48 ], [ 129, 52 ], [ 105, 52 ], [ 131, 56 ], [ 122, 59 ], [ 114, 61 ], [ 138, 65 ], [ 71, 68 ], [ 123, 69 ], [ 132, 69 ], [ 108, 70 ], [ 126, 70 ], [ 119, 73 ], [ 123, 76 ], [ 132, 76 ], [ 134, 78 ], [ 114, 81 ], [ 120, 83 ], [ 120, 86 ], [ 101, 89 ], [ 125, 92 ], [ 135, 93 ], [ 110, 95 ], [ 111, 99 ], [ 102, 99 ], [ 117, 99 ], [ 101, 102 ], [ 137, 105 ], [ 107, 108 ], [ 110, 111 ], [ 113, 114 ], [ 116, 117 ], [ 119, 120 ], [ 122, 123 ], [ 135, 125 ], [ 125, 126 ], [ 128, 129 ], [ 131, 132 ], [ 134, 135 ], [ 137, 138 ] ]
[ "import heapq\nk,t = map(int,input().split())\na = list(map(int,input().split()))\npre = a.index(max(a))\nres = 0\nwhile k>0:\n a[pre] -=1\n k -=1\n if k==0:\n break\n else:\n Conf=[]\n Conf = a[:]\n if t>1:\n Conf[pre] = -1\n preV = max(Conf)\n prei = a.index(preV)\n if preV==0:\n res+=1\n else:\n pre = prei\n else:\n res+=1\nprint(res)", "import heapq", "heapq", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "pre = a.index(max(a))", "pre", "a.index(max(a))", "a.index", "a", "index", "max(a)", "max", "a", "res = 0", "res", "0", "while k>0:\n a[pre] -=1\n k -=1\n if k==0:\n break\n else:\n Conf=[]\n Conf = a[:]\n if t>1:\n Conf[pre] = -1\n preV = max(Conf)\n prei = a.index(preV)\n if preV==0:\n res+=1\n else:\n pre = prei\n else:\n res+=1", "k>0", "k", "0", "a[pre] -=1", "a[pre]", "a", "pre", "1", "k -=1", "k", "1", "if k==0:\n break\n else:\n Conf=[]\n Conf = a[:]\n if t>1:\n Conf[pre] = -1\n preV = max(Conf)\n prei = a.index(preV)\n if preV==0:\n res+=1\n else:\n pre = prei\n else:\n res+=1", "k==0", "k", "0", "break", "Conf=[]", "Conf", "[]", "Conf = a[:]", "Conf", "a[:]", "a", ":", "if t>1:\n Conf[pre] = -1\n preV = max(Conf)\n prei = a.index(preV)\n if preV==0:\n res+=1\n else:\n pre = prei\n else:\n res+=1", "t>1", "t", "1", "Conf[pre] = -1", "Conf[pre]", "Conf", "pre", "-1", "preV = max(Conf)", "preV", "max(Conf)", "max", "Conf", "prei = a.index(preV)", "prei", "a.index(preV)", "a.index", "a", "index", "preV", "if preV==0:\n res+=1\n else:\n pre = prei\n ", "preV==0", "preV", "0", "res+=1", "res", "1", "pre = prei", "pre", "prei", "res+=1", "res", "1", "print(res)", "print", "res", "res+=1", "1", "res", "k,t = map(int,input().split())", "map(int,input().split())", "k", "pre = a.index(max(a))", "a.index(max(a))", "pre", "res+=1", "1", "res", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "res = 0", "0", "res", "preV = max(Conf)", "max(Conf)", "preV", "Conf = a[:]", "a[:]", "Conf", "pre = prei", "prei", "pre", "k -=1", "1", "k", "Conf=[]", "[]", "Conf", "prei = a.index(preV)", "a.index(preV)", "prei", "t = map(int,input().split())", "map(int,input().split())", "t" ]
import heapq k,t = map(int,input().split()) a = list(map(int,input().split())) pre = a.index(max(a)) res = 0 while k>0: a[pre] -=1 k -=1 if k==0: break else: Conf=[] Conf = a[:] if t>1: Conf[pre] = -1 preV = max(Conf) prei = a.index(preV) if preV==0: res+=1 else: pre = prei else: res+=1 print(res)
[ 7, 15, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 12, 40, 4, 13, 13, 23, 4, 18, 4, 13, 13, 4, 13, 13, 0, 13, 4, 13, 13, 42, 13, 0, 13, 4, 13, 13, 14, 40, 13, 17, 4, 13, 13, 2, 13, 17, 0, 13, 13, 4, 13, 40, 2, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 6, 14 ], [ 17, 16 ], [ 16, 34 ], [ 37, 36 ], [ 16, 39 ], [ 44, 43 ], [ 16, 46 ], [ 36, 49 ], [ 58, 49 ], [ 16, 53 ], [ 36, 55 ], [ 58, 55 ], [ 59, 58 ], [ 43, 59 ], [ 58, 64 ], [ 36, 64 ], [ 74, 71 ] ]
[ "from heapq import heappush, heappop, heapify\ndef main():\n k, t = map(int, input().split())\n A = list(map(lambda x: -int(x), input().split()))\n heapify(A)\n tmp = heappop(A)\n while A:\n now = heappop(A)\n if tmp != -1:\n heappush(A, tmp + 1)\n tmp = now\n print(-(tmp + 1))\n\nif __name__ == '__main__':\n main()", "from heapq import heappush, heappop, heapify", "def main():\n k, t = map(int, input().split())\n A = list(map(lambda x: -int(x), input().split()))\n heapify(A)\n tmp = heappop(A)\n while A:\n now = heappop(A)\n if tmp != -1:\n heappush(A, tmp + 1)\n tmp = now\n print(-(tmp + 1))", "main", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "A = list(map(lambda x: -int(x), input().split()))", "A", "list(map(lambda x: -int(x), input().split()))", "list", "map(lambda x: -int(x), input().split())", "map", "lambda x: -int(x)", "-int(x)", "int(x)", "int", "x", "x", "input().split()", "().split", "()", "input", "split", "heapify(A)", "heapify", "A", "tmp = heappop(A)", "tmp", "heappop(A)", "heappop", "A", "while A:\n now = heappop(A)\n if tmp != -1:\n heappush(A, tmp + 1)\n tmp = now\n ", "A", "now = heappop(A)", "now", "heappop(A)", "heappop", "A", "if tmp != -1:\n heappush(A, tmp + 1)\n ", "tmp != -1", "tmp", "-1", "heappush(A, tmp + 1)", "heappush", "A", "tmp + 1", "tmp", "1", "tmp = now", "tmp", "now", "print(-(tmp + 1))", "print", "-(tmp + 1)", "tmp + 1", "tmp", "1", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n k, t = map(int, input().split())\n A = list(map(lambda x: -int(x), input().split()))\n heapify(A)\n tmp = heappop(A)\n while A:\n now = heappop(A)\n if tmp != -1:\n heappush(A, tmp + 1)\n tmp = now\n print(-(tmp + 1))", "def main():\n k, t = map(int, input().split())\n A = list(map(lambda x: -int(x), input().split()))\n heapify(A)\n tmp = heappop(A)\n while A:\n now = heappop(A)\n if tmp != -1:\n heappush(A, tmp + 1)\n tmp = now\n print(-(tmp + 1))", "main" ]
from heapq import heappush, heappop, heapify def main(): k, t = map(int, input().split()) A = list(map(lambda x: -int(x), input().split())) heapify(A) tmp = heappop(A) while A: now = heappop(A) if tmp != -1: heappush(A, tmp + 1) tmp = now print(-(tmp + 1)) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 2, 17, 13, 4, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 47, 2 ], [ 47, 11 ], [ 50, 13 ], [ 53, 25 ], [ 51, 28 ], [ 54, 38 ], [ 51, 41 ], [ 47, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\nm = max(a)\nprint(max(0,2*m-sum(a)-1))", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m = max(a)", "m", "max(a)", "max", "a", "print(max(0,2*m-sum(a)-1))", "print", "max(0,2*m-sum(a)-1)", "max", "0", "2*m-sum(a)-1", "2*m-sum(a)", "2*m", "2", "m", "sum(a)", "sum", "a", "1", "t = map(int,input().split())", "map(int,input().split())", "t", "k,t = map(int,input().split())", "map(int,input().split())", "k", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "m = max(a)", "max(a)", "m" ]
k,t = map(int,input().split()) a = list(map(int,input().split())) m = max(a) print(max(0,2*m-sum(a)-1))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 2, 2, 18, 13, 17, 17, 2, 13, 18, 13, 17, 4, 13, 4, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 51, 2 ], [ 51, 11 ], [ 54, 13 ], [ 55, 26 ], [ 57, 29 ], [ 55, 33 ], [ 49, 37 ], [ 55, 39 ], [ 58, 45 ], [ 51, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort()\n\nans = (A[-1] - 1) - (K-A[-1])\nprint(max(ans, 0))", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "A.sort()", "A.sort", "A", "sort", "ans = (A[-1] - 1) - (K-A[-1])", "ans", "(A[-1] - 1) - (K-A[-1])", "A[-1] - 1", "A[-1]", "A", "-1", "1", "K-A[-1]", "K", "A[-1]", "A", "-1", "print(max(ans, 0))", "print", "max(ans, 0)", "max", "ans", "0", "K, T = map(int, input().split())", "map(int, input().split())", "K", "T = map(int, input().split())", "map(int, input().split())", "T", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "ans = (A[-1] - 1) - (K-A[-1])", "(A[-1] - 1) - (K-A[-1])", "ans" ]
K, T = map(int, input().split()) A = list(map(int, input().split())) A.sort() ans = (A[-1] - 1) - (K-A[-1]) print(max(ans, 0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 2, 2, 13, 17, 17, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 14, 40, 13, 13, 4, 13, 17, 4, 13, 2, 2, 17, 2, 13, 13, 17, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 62, 2 ], [ 62, 11 ], [ 53, 13 ], [ 63, 16 ], [ 59, 20 ], [ 65, 32 ], [ 60, 35 ], [ 66, 38 ], [ 54, 39 ], [ 66, 49 ], [ 54, 50 ], [ 53, 54 ], [ 62, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "K, T = map(int, input().split())\nN = (K + 1) // 2\nA = list(map(int, input().split()))\na = max(A)\nif a <= N:\n print(0)\nelse:\n print(2 * (a - N) - 1)", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "N = (K + 1) // 2", "N", "(K + 1) // 2", "K + 1", "K", "1", "2", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a = max(A)", "a", "max(A)", "max", "A", "if a <= N:\n print(0)\nelse:\n print(2 * (a - N) - 1)", "a <= N", "a", "N", "print(0)", "print", "0", "print(2 * (a - N) - 1)", "print", "2 * (a - N) - 1", "2 * (a - N)", "2", "a - N", "a", "N", "1", "N = (K + 1) // 2", "(K + 1) // 2", "N", "T = map(int, input().split())", "map(int, input().split())", "T", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "K, T = map(int, input().split())", "map(int, input().split())", "K", "a = max(A)", "max(A)", "a" ]
K, T = map(int, input().split()) N = (K + 1) // 2 A = list(map(int, input().split())) a = max(A) if a <= N: print(0) else: print(2 * (a - N) - 1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 14, 40, 2, 17, 13, 13, 4, 13, 17, 0, 13, 2, 2, 17, 13, 13, 4, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 68, 2 ], [ 68, 11 ], [ 62, 13 ], [ 56, 25 ], [ 63, 28 ], [ 71, 30 ], [ 63, 33 ], [ 57, 38 ], [ 72, 39 ], [ 65, 44 ], [ 57, 48 ], [ 72, 49 ], [ 66, 53 ], [ 56, 57 ], [ 68, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "K,T=map(int,input().split())\na=list(map(int,input().split()))\nM=max(a)\nsm=sum(a)\nif (2*M)<=sm:\n print(0)\nelse:\n ans=2*M-sm\n print(ans-1)", "K,T=map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "M=max(a)", "M", "max(a)", "max", "a", "sm=sum(a)", "sm", "sum(a)", "sum", "a", "if (2*M)<=sm:\n print(0)\nelse:\n ans=2*M-sm\n print(ans-1)", "(2*M)<=sm", "2*M", "2", "M", "sm", "print(0)", "print", "0", "ans=2*M-sm", "ans", "2*M-sm", "2*M", "2", "M", "sm", "print(ans-1)", "print", "ans-1", "ans", "1", "M=max(a)", "max(a)", "M", "T=map(int,input().split())", "map(int,input().split())", "T", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans=2*M-sm", "2*M-sm", "ans", "K,T=map(int,input().split())", "map(int,input().split())", "K", "sm=sum(a)", "sum(a)", "sm" ]
K,T=map(int,input().split()) a=list(map(int,input().split())) M=max(a) sm=sum(a) if (2*M)<=sm: print(0) else: ans=2*M-sm print(ans-1)
[ 7, 15, 13, 15, 13, 15, 15, 15, 13, 15, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 14, 40, 2, 13, 13, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 2, 17, 13, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 68, 11 ], [ 68, 20 ], [ 65, 22 ], [ 59, 34 ], [ 66, 37 ], [ 69, 41 ], [ 60, 42 ], [ 60, 44 ], [ 60, 55 ], [ 69, 57 ], [ 59, 60 ], [ 68, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "#import sys\n#import numpy as np\nimport math\n#from fractions import Fraction\nimport itertools\nfrom collections import deque\nfrom collections import Counter\nimport heapq\nfrom fractions import gcd\n#input=sys.stdin.readline\n#import bisect\n\nk,t=map(int,input().split())\na=list(map(int,input().split()))\nx=max(a)\nif k-x>=x-1:\n print(0)\nelse:\n print(2*x-1-k)", "import math", "math", "import itertools", "itertools", "from collections import deque", "from collections import Counter", "import heapq", "heapq", "from fractions import gcd", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "x=max(a)", "x", "max(a)", "max", "a", "if k-x>=x-1:\n print(0)\nelse:\n print(2*x-1-k)", "k-x>=x-1", "k-x", "k", "x", "x-1", "x", "1", "print(0)", "print", "0", "print(2*x-1-k)", "print", "2*x-1-k", "2*x-1", "2*x", "2", "x", "1", "k", "x=max(a)", "max(a)", "x", "t=map(int,input().split())", "map(int,input().split())", "t", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "k,t=map(int,input().split())", "map(int,input().split())", "k" ]
#import sys #import numpy as np import math #from fractions import Fraction import itertools from collections import deque from collections import Counter import heapq from fractions import gcd #input=sys.stdin.readline #import bisect k,t=map(int,input().split()) a=list(map(int,input().split())) x=max(a) if k-x>=x-1: print(0) else: print(2*x-1-k)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 0, 13, 39, 28, 13, 13, 4, 13, 13, 4, 18, 13, 13, 39, 13, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 28, 13, 4, 13, 13, 14, 40, 18, 18, 13, 13, 17, 13, 0, 18, 18, 13, 13, 17, 17, 0, 13, 18, 18, 13, 13, 17, 4, 18, 13, 13, 0, 13, 17, 3, 14, 40, 18, 18, 13, 2, 13, 17, 17, 17, 9, 0, 13, 17, 3, 14, 2, 13, 17, 3, 14, 2, 13, 17, 4, 13, 17, 4, 13, 18, 18, 13, 17, 17, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 157, 2 ], [ 157, 11 ], [ 148, 13 ], [ 143, 26 ], [ 158, 31 ], [ 160, 36 ], [ 149, 43 ], [ 161, 46 ], [ 161, 53 ], [ 57, 56 ], [ 151, 59 ], [ 139, 62 ], [ 66, 65 ], [ 158, 68 ], [ 71, 70 ], [ 143, 73 ], [ 161, 78 ], [ 70, 79 ], [ 140, 81 ], [ 146, 81 ], [ 88, 83 ], [ 161, 85 ], [ 70, 86 ], [ 145, 90 ], [ 161, 93 ], [ 70, 94 ], [ 161, 98 ], [ 102, 101 ], [ 161, 108 ], [ 70, 110 ], [ 154, 116 ], [ 155, 121 ], [ 152, 121 ], [ 155, 126 ], [ 152, 126 ], [ 161, 135 ], [ 139, 140 ], [ 157, 143 ], [ 145, 146 ], [ 148, 149 ], [ 151, 152 ], [ 154, 155 ], [ 157, 158 ], [ 160, 161 ] ]
[ "k, t = map(int,input().split())\na_l_init = list(map(int,input().split()))\n\nif t == 1:\n print(k-1)\n exit()\n\na_l = []\nfor i, a in enumerate(a_l_init):\n a_l.append([a,i])\na_l.sort(reverse=True)\n\nflag = 0\nyesterday = -1\nfor _ in range(k):\n for j in range(t):\n if a_l[j][1] != yesterday:\n a_l[j][0] -= 1\n yesterday = a_l[j][1]\n a_l.sort(reverse=True)\n break\n elif a_l[j+1][0] != 0:\n continue\n else:\n flag = 1\n break\n if flag == 1:\n break\n\nif flag == 0:\n print(0)\nelse:\n print(a_l[0][0])", "k, t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a_l_init = list(map(int,input().split()))", "a_l_init", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "if t == 1:\n print(k-1)\n exit()", "t == 1", "t", "1", "print(k-1)", "print", "k-1", "k", "1", "exit()", "exit", "a_l = []", "a_l", "[]", "for i, a in enumerate(a_l_init):\n a_l.append([a,i])", "i", "a", "enumerate(a_l_init)", "enumerate", "a_l_init", "a_l.append([a,i])", "a_l.append", "a_l", "append", "[a,i]", "a", "i", "a_l.sort(reverse=True)", "a_l.sort", "a_l", "sort", "reverse=True", "reverse", "True", "flag = 0", "flag", "0", "yesterday = -1", "yesterday", "-1", "for _ in range(k):\n for j in range(t):\n if a_l[j][1] != yesterday:\n a_l[j][0] -= 1\n yesterday = a_l[j][1]\n a_l.sort(reverse=True)\n break\n elif a_l[j+1][0] != 0:\n continue\n else:\n flag = 1\n break\n if flag == 1:\n break", "_", "range(k)", "range", "k", "for j in range(t):\n if a_l[j][1] != yesterday:\n a_l[j][0] -= 1\n yesterday = a_l[j][1]\n a_l.sort(reverse=True)\n break\n elif a_l[j+1][0] != 0:\n continue\n else:\n flag = 1\n break\n ", "j", "range(t)", "range", "t", "if a_l[j][1] != yesterday:\n a_l[j][0] -= 1\n yesterday = a_l[j][1]\n a_l.sort(reverse=True)\n break\n elif a_l[j+1][0] != 0:\n continue\n else:\n flag = 1\n break\n ", "a_l[j][1] != yesterday", "a_l[j][1]", "[j]", "a_l", "j", "1", "yesterday", "a_l[j][0] -= 1", "a_l[j][0]", "[j]", "a_l", "j", "0", "1", "yesterday = a_l[j][1]", "yesterday", "a_l[j][1]", "[j]", "a_l", "j", "1", "a_l.sort(reverse=True)", "a_l.sort", "a_l", "sort", "reverse=True", "reverse", "True", "break", "elif a_l[j+1][0] != 0:\n continue\n ", "a_l[j+1][0] != 0", "a_l[j+1][0]", "[j+1]", "a_l", "j+1", "j", "1", "0", "0", "continue", "flag = 1", "flag", "1", "break", "if flag == 1:\n break", "flag == 1", "flag", "1", "break", "if flag == 0:\n print(0)\nelse:\n print(a_l[0][0])", "flag == 0", "flag", "0", "print(0)", "print", "0", "print(a_l[0][0])", "print", "a_l[0][0]", "[0]", "a_l", "0", "0", "yesterday = -1", "-1", "yesterday", "t = map(int,input().split())", "map(int,input().split())", "t", "yesterday = a_l[j][1]", "a_l[j][1]", "yesterday", "a_l_init = list(map(int,input().split()))", "list(map(int,input().split()))", "a_l_init", "flag = 0", "0", "flag", "flag = 1", "1", "flag", "k, t = map(int,input().split())", "map(int,input().split())", "k", "a_l = []", "[]", "a_l" ]
k, t = map(int,input().split()) a_l_init = list(map(int,input().split())) if t == 1: print(k-1) exit() a_l = [] for i, a in enumerate(a_l_init): a_l.append([a,i]) a_l.sort(reverse=True) flag = 0 yesterday = -1 for _ in range(k): for j in range(t): if a_l[j][1] != yesterday: a_l[j][0] -= 1 yesterday = a_l[j][1] a_l.sort(reverse=True) break elif a_l[j+1][0] != 0: continue else: flag = 1 break if flag == 1: break if flag == 0: print(0) else: print(a_l[0][0])
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 28, 13, 4, 13, 13, 0, 39, 13, 13, 18, 4, 13, 13, 39, 17, 0, 13, 4, 18, 13, 13, 13, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 0, 13, 2, 2, 13, 13, 17, 3, 14, 2, 13, 13, 0, 13, 13, 0, 18, 13, 13, 17, 0, 13, 13, 0, 18, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 13, 13 ]
[ [ 117, 2 ], [ 117, 11 ], [ 120, 13 ], [ 105, 25 ], [ 118, 29 ], [ 112, 34 ], [ 40, 39 ], [ 112, 42 ], [ 47, 44 ], [ 121, 50 ], [ 108, 54 ], [ 121, 57 ], [ 102, 60 ], [ 121, 63 ], [ 114, 71 ], [ 112, 74 ], [ 39, 75 ], [ 106, 80 ], [ 127, 80 ], [ 124, 80 ], [ 109, 81 ], [ 123, 83 ], [ 103, 84 ], [ 89, 86 ], [ 121, 87 ], [ 103, 88 ], [ 126, 91 ], [ 109, 92 ], [ 97, 94 ], [ 121, 95 ], [ 109, 96 ], [ 115, 100 ], [ 102, 103 ], [ 105, 106 ], [ 108, 109 ], [ 117, 112 ], [ 114, 115 ], [ 117, 118 ], [ 120, 121 ], [ 103, 123 ], [ 123, 124 ], [ 109, 126 ], [ 126, 127 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\nlast = None\n\nif t == 1:\n print(k-1)\n exit()\n\nfor i in range(k):# i日目(i=0,1...k-1)\n [nex,ful] = sorted(a)[-2:]\n ful_index,nex_index = a.index(ful),a.index(nex)\n if nex == 0:\n ans = k-i-1\n break\n if last == ful_index:\n last = nex_index\n a[nex_index] -= 1\n else:\n last = ful_index\n a[ful_index] -= 1\n \nprint(ans)", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "last = None", "last", "None", "if t == 1:\n print(k-1)\n exit()", "t == 1", "t", "1", "print(k-1)", "print", "k-1", "k", "1", "exit()", "exit", "for i in range(k):# i日目(i=0,1...k-1)\n [nex,ful] = sorted(a)[-2:]\n ful_index,nex_index = a.index(ful),a.index(nex)\n if nex == 0:\n ans = k-i-1\n break\n if last == ful_index:\n last = nex_index\n a[nex_index] -= 1\n else:\n last = ful_index\n a[ful_index] -= 1\n ", "i", "range(k)", "range", "k", "[nex,ful] = sorted(a)[-2:]", "[nex,ful]", "nex", "ful", "sorted(a)[-2:]", "(a)", "sorted", "a", "-2:", "-2", "ful_index,nex_index = a.index(ful),a.index(nex)", "ful_index", "a.index(ful)", "a.index", "a", "index", "ful", "nex_index", "a.index(nex)", "a.index", "a", "index", "nex", "if nex == 0:\n ans = k-i-1\n break\n ", "nex == 0", "nex", "0", "ans = k-i-1", "ans", "k-i-1", "k-i", "k", "i", "1", "break", "if last == ful_index:\n last = nex_index\n a[nex_index] -= 1\n else:\n last = ful_index\n a[ful_index] -= 1\n ", "last == ful_index", "last", "ful_index", "last = nex_index", "last", "nex_index", "a[nex_index] -= 1", "a[nex_index]", "a", "nex_index", "1", "last = ful_index", "last", "ful_index", "a[ful_index] -= 1", "a[ful_index]", "a", "ful_index", "1", "print(ans)", "print", "ans", "nex_index = a.index(ful),a.index(nex)", "a.index(nex)", "nex_index", "last = None", "None", "last", "ful_index,nex_index = a.index(ful),a.index(nex)", "a.index(ful)", "ful_index", "k,t = map(int,input().split())", "map(int,input().split())", "k", "ans = k-i-1", "k-i-1", "ans", "t = map(int,input().split())", "map(int,input().split())", "t", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "last = nex_index", "nex_index", "last", "last = ful_index", "ful_index", "last" ]
k,t = map(int,input().split()) a = list(map(int,input().split())) last = None if t == 1: print(k-1) exit() for i in range(k):# i日目(i=0,1...k-1) [nex,ful] = sorted(a)[-2:] ful_index,nex_index = a.index(ful),a.index(nex) if nex == 0: ans = k-i-1 break if last == ful_index: last = nex_index a[nex_index] -= 1 else: last = ful_index a[ful_index] -= 1 print(ans)
[ 7, 15, 15, 15, 13, 15, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 2, 4, 13, 13, 17, 12, 13, 41, 28, 13, 4, 13, 4, 2, 4, 13, 13, 17, 12, 13, 12, 13, 23, 13, 12, 13, 12, 13, 14, 13, 4, 13, 31, 13, 0, 13, 13, 23, 13, 17, 23, 0, 13, 21, 22, 17, 17, 22, 17, 17, 0, 13, 21, 22, 17, 17, 22, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 17, 17, 0, 13, 18, 13, 13, 0, 13, 18, 13, 13, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 39, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 13, 17, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 18, 13, 13, 13, 2, 2, 2, 4, 13, 13, 17, 40, 18, 13, 17, 13, 2, 4, 13, 13, 17, 0, 13, 18, 13, 13, 0, 13, 13, 14, 40, 13, 17, 0, 18, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 18, 13, 10, 18, 13, 10, 12, 13, 10, 12, 13, 10, 2, 13, 10, 39, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 21, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 21, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 27, 26 ], [ 26, 35 ], [ 41, 40 ], [ 40, 50 ], [ 57, 56 ], [ 56, 63 ], [ 70, 70 ], [ 83, 82 ], [ 82, 83 ], [ 85, 83 ], [ 86, 85 ], [ 305, 89 ], [ 287, 98 ], [ 266, 107 ], [ 284, 114 ], [ 275, 119 ], [ 254, 124 ], [ 257, 129 ], [ 308, 134 ], [ 269, 147 ], [ 311, 160 ], [ 166, 165 ], [ 297, 167 ], [ 166, 168 ], [ 171, 170 ], [ 300, 172 ], [ 175, 174 ], [ 179, 178 ], [ 165, 181 ], [ 184, 183 ], [ 187, 186 ], [ 190, 189 ], [ 168, 192 ], [ 170, 197 ], [ 189, 198 ], [ 183, 199 ], [ 218, 199 ], [ 174, 205 ], [ 174, 209 ], [ 189, 211 ], [ 174, 215 ], [ 219, 218 ], [ 170, 220 ], [ 189, 221 ], [ 224, 223 ], [ 189, 224 ], [ 223, 227 ], [ 186, 227 ], [ 233, 230 ], [ 170, 231 ], [ 223, 232 ], [ 186, 232 ], [ 174, 236 ], [ 223, 238 ], [ 186, 238 ], [ 170, 243 ], [ 294, 249 ], [ 254, 255 ], [ 257, 258 ], [ 266, 267 ], [ 269, 270 ], [ 275, 276 ], [ 284, 285 ], [ 287, 288 ], [ 305, 306 ], [ 308, 309 ], [ 311, 312 ] ]
[ "from heapq import heappush, heappop, heapify\nfrom collections import deque, defaultdict, Counter\nimport itertools\nfrom itertools import permutations, combinations, accumulate\nimport sys\nimport bisect\nimport string\nimport math\nimport time\n\n\ndef I(): return int(input())\n\n\ndef S(): return input()\n\n\ndef MI(): return map(int, input().split())\n\n\ndef MS(): return map(str, input().split())\n\n\ndef LI(): return [int(i) for i in input().split()]\n\n\ndef LI_(): return [int(i)-1 for i in input().split()]\n\n\ndef StoI(): return [ord(i)-97 for i in input()]\n\n\ndef ItoS(nn): return chr(nn+97)\n\n\ndef input(): return sys.stdin.readline().rstrip()\n\n\ndef show(*inp, end='\\n'):\n if show_flg:\n print(*inp, end=end)\n\n\nYNL = {False: 'No', True: 'Yes'}\nYNU = {False: 'NO', True: 'YES'}\nMOD = 10**9+7\ninf = float('inf')\nIINF = 10**10\nl_alp = string.ascii_lowercase\nu_alp = string.ascii_uppercase\nts = time.time()\nsys.setrecursionlimit(10**6)\nnums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']\n\nshow_flg = False\n# show_flg = True\n\n\ndef main():\n K, T = MI()\n a = LI()\n q = deque()\n\n for i in range(K):\n mx = 0\n mx_i = -1\n for j in range(T):\n if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0):\n mx = a[j]\n mx_i = j\n\n if mx_i != -1:\n a[mx_i] -= 1\n q.append(mx_i)\n\n print(sum(a))\n\n\nif __name__ == '__main__':\n main()", "from heapq import heappush, heappop, heapify", "from collections import deque, defaultdict, Counter", "import itertools", "itertools", "from itertools import permutations, combinations, accumulate", "import sys", "sys", "import bisect", "bisect", "import string", "string", "import math", "math", "import time", "time", "def I(): return int(input())", "I", "def S(): return input()", "S", "def MI(): return map(int, input().split())", "MI", "def MS(): return map(str, input().split())", "MS", "int(i) for i in input().split()", "for i in input().split()", "i", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)", "int", "i", "def LI(): return [int(i) for i in input().split()]", "LI", "int(i)-1 for i in input().split()", "for i in input().split()", "i", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)-1", "int(i)", "int", "i", "1", "def LI_(): return [int(i)-1 for i in input().split()]", "LI_", "ord(i)-97 for i in input()", "for i in input()", "i", "input()", "input", "for i in input()", "ord(i)-97", "ord(i)", "ord", "i", "97", "def StoI(): return [ord(i)-97 for i in input()]", "StoI", "def ItoS(nn): return chr(nn+97)", "ItoS", "nn", "nn", "def input(): return sys.stdin.readline().rstrip()", "input", "def show(*inp, end='\\n'):\n if show_flg:\n print(*inp, end=end)", "show", "if show_flg:\n print(*inp, end=end)", "show_flg", "print(*inp, end=end)", "print", "*inp", "inp", "end=end", "end", "end", "end='\\n'", "end", "'\\n'", "*inp", "YNL = {False: 'No', True: 'Yes'}", "YNL", "{False: 'No', True: 'Yes'}", "False", "False", "'No'", "True", "True", "'Yes'", "YNU = {False: 'NO', True: 'YES'}", "YNU", "{False: 'NO', True: 'YES'}", "False", "False", "'NO'", "True", "True", "'YES'", "MOD = 10**9+7", "MOD", "10**9+7", "10**9", "10", "9", "7", "inf = float('inf')", "inf", "float('inf')", "float", "'inf'", "IINF = 10**10", "IINF", "10**10", "10", "10", "l_alp = string.ascii_lowercase", "l_alp", "string.ascii_lowercase", "string", "ascii_lowercase", "u_alp = string.ascii_uppercase", "u_alp", "string.ascii_uppercase", "string", "ascii_uppercase", "ts = time.time()", "ts", "time.time()", "time.time", "time", "time", "sys.setrecursionlimit(10**6)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**6", "10", "6", "nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']", "nums", "['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'10'", "show_flg = False", "show_flg", "False", "def main():\n K, T = MI()\n a = LI()\n q = deque()\n\n for i in range(K):\n mx = 0\n mx_i = -1\n for j in range(T):\n if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0):\n mx = a[j]\n mx_i = j\n\n if mx_i != -1:\n a[mx_i] -= 1\n q.append(mx_i)\n\n print(sum(a))", "main", "K, T = MI()", "K", "MI()", "MI", "T", "a = LI()", "a", "LI()", "LI", "q = deque()", "q", "deque()", "deque", "for i in range(K):\n mx = 0\n mx_i = -1\n for j in range(T):\n if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0):\n mx = a[j]\n mx_i = j\n\n if mx_i != -1:\n a[mx_i] -= 1\n q.append(mx_i)\n\n ", "i", "range(K)", "range", "K", "mx = 0", "mx", "0", "mx_i = -1", "mx_i", "-1", "for j in range(T):\n if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0):\n mx = a[j]\n mx_i = j\n\n ", "j", "range(T)", "range", "T", "if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0):\n mx = a[j]\n mx_i = j\n\n ", "a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0)", "a[j] > mx", "a[j]", "a", "j", "mx", "(len(q) > 0 and q[-1] != j) or len(q) == 0", "len(q) > 0 and q[-1] != j", "len(q) > 0", "len(q)", "len", "q", "0", "q[-1] != j", "q[-1]", "q", "-1", "j", "len(q) == 0", "len(q)", "len", "q", "0", "mx = a[j]", "mx", "a[j]", "a", "j", "mx_i = j", "mx_i", "j", "if mx_i != -1:\n a[mx_i] -= 1\n q.append(mx_i)\n\n ", "mx_i != -1", "mx_i", "-1", "a[mx_i] -= 1", "a[mx_i]", "a", "mx_i", "1", "q.append(mx_i)", "q.append", "q", "append", "mx_i", "print(sum(a))", "print", "sum(a)", "sum", "a", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def LI_(): return [int(i)-1 for i in input().split()]", "def LI_(): return [int(i)-1 for i in input().split()]", "LI_", "l_alp = string.ascii_lowercase", "string.ascii_lowercase", "l_alp", "u_alp = string.ascii_uppercase", "string.ascii_uppercase", "u_alp", "def input(): return sys.stdin.readline().rstrip()", "def input(): return sys.stdin.readline().rstrip()", "input", "def StoI(): return [ord(i)-97 for i in input()]", "def StoI(): return [ord(i)-97 for i in input()]", "StoI", "MOD = 10**9+7", "10**9+7", "MOD", "nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']", "['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']", "nums", "def I(): return int(input())", "def I(): return int(input())", "I", "IINF = 10**10", "10**10", "IINF", "def MS(): return map(str, input().split())", "def MS(): return map(str, input().split())", "MS", "def show(*inp, end='\\n'):\n if show_flg:\n print(*inp, end=end)", "def show(*inp, end='\\n'):\n if show_flg:\n print(*inp, end=end)", "show", "inf = float('inf')", "float('inf')", "inf", "YNU = {False: 'NO', True: 'YES'}", "{False: 'NO', True: 'YES'}", "YNU", "def S(): return input()", "def S(): return input()", "S", "def main():\n K, T = MI()\n a = LI()\n q = deque()\n\n for i in range(K):\n mx = 0\n mx_i = -1\n for j in range(T):\n if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0):\n mx = a[j]\n mx_i = j\n\n if mx_i != -1:\n a[mx_i] -= 1\n q.append(mx_i)\n\n print(sum(a))", "def main():\n K, T = MI()\n a = LI()\n q = deque()\n\n for i in range(K):\n mx = 0\n mx_i = -1\n for j in range(T):\n if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0):\n mx = a[j]\n mx_i = j\n\n if mx_i != -1:\n a[mx_i] -= 1\n q.append(mx_i)\n\n print(sum(a))", "main", "def MI(): return map(int, input().split())", "def MI(): return map(int, input().split())", "MI", "def LI(): return [int(i) for i in input().split()]", "def LI(): return [int(i) for i in input().split()]", "LI", "def ItoS(nn): return chr(nn+97)", "def ItoS(nn): return chr(nn+97)", "ItoS", "YNL = {False: 'No', True: 'Yes'}", "{False: 'No', True: 'Yes'}", "YNL", "ts = time.time()", "time.time()", "ts", "show_flg = False", "False", "show_flg" ]
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from itertools import permutations, combinations, accumulate import sys import bisect import string import math import time def I(): return int(input()) def S(): return input() def MI(): return map(int, input().split()) def MS(): return map(str, input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def StoI(): return [ord(i)-97 for i in input()] def ItoS(nn): return chr(nn+97) def input(): return sys.stdin.readline().rstrip() def show(*inp, end='\n'): if show_flg: print(*inp, end=end) YNL = {False: 'No', True: 'Yes'} YNU = {False: 'NO', True: 'YES'} MOD = 10**9+7 inf = float('inf') IINF = 10**10 l_alp = string.ascii_lowercase u_alp = string.ascii_uppercase ts = time.time() sys.setrecursionlimit(10**6) nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] show_flg = False # show_flg = True def main(): K, T = MI() a = LI() q = deque() for i in range(K): mx = 0 mx_i = -1 for j in range(T): if a[j] > mx and ((len(q) > 0 and q[-1] != j) or len(q) == 0): mx = a[j] mx_i = j if mx_i != -1: a[mx_i] -= 1 q.append(mx_i) print(sum(a)) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 18, 13, 17, 0, 13, 2, 13, 13, 14, 40, 13, 13, 4, 13, 17, 4, 13, 2, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 18, 13 ]
[ [ 60, 2 ], [ 60, 11 ], [ 51, 13 ], [ 63, 27 ], [ 52, 29 ], [ 57, 32 ], [ 55, 34 ], [ 64, 35 ], [ 64, 38 ], [ 58, 39 ], [ 64, 47 ], [ 58, 48 ], [ 51, 52 ], [ 60, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "K, T = map(int,input().split())\na = sorted(list(map(int,input().split())))\nm = a[-1]\no = K-m\nif m <= o:\n print(0)\nelse:\n print(m-o-1)", "K, T = map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = sorted(list(map(int,input().split())))", "a", "sorted(list(map(int,input().split())))", "sorted", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m = a[-1]", "m", "a[-1]", "a", "-1", "o = K-m", "o", "K-m", "K", "m", "if m <= o:\n print(0)\nelse:\n print(m-o-1)", "m <= o", "m", "o", "print(0)", "print", "0", "print(m-o-1)", "print", "m-o-1", "m-o", "m", "o", "1", "a = sorted(list(map(int,input().split())))", "sorted(list(map(int,input().split())))", "a", "K, T = map(int,input().split())", "map(int,input().split())", "K", "o = K-m", "K-m", "o", "T = map(int,input().split())", "map(int,input().split())", "T", "m = a[-1]", "a[-1]", "m" ]
K, T = map(int,input().split()) a = sorted(list(map(int,input().split()))) m = a[-1] o = K-m if m <= o: print(0) else: print(m-o-1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 4, 13, 13, 13, 0, 13, 13, 4, 13, 4, 13, 17, 2, 2, 2, 17, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 70, 2 ], [ 70, 11 ], [ 58, 13 ], [ 64, 25 ], [ 73, 28 ], [ 32, 31 ], [ 59, 31 ], [ 55, 34 ], [ 65, 37 ], [ 56, 37 ], [ 31, 38 ], [ 67, 40 ], [ 31, 41 ], [ 56, 51 ], [ 65, 51 ], [ 68, 52 ], [ 74, 52 ], [ 55, 56 ], [ 58, 59 ], [ 70, 62 ], [ 64, 65 ], [ 31, 67 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ] ]
[ "K, T = map(int, input().split())\ncakes = list(map(int, input().split()))\nmax_c = 0\nsum_c = 0\nfor cake in cakes:\n max_c = max(max_c, cake)\n sum_c += cake\nprint(max(0, 2*max_c-sum_c-1))", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "cakes = list(map(int, input().split()))", "cakes", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "max_c = 0", "max_c", "0", "sum_c = 0", "sum_c", "0", "for cake in cakes:\n max_c = max(max_c, cake)\n sum_c += cake", "cake", "cakes", "max_c = max(max_c, cake)", "max_c", "max(max_c, cake)", "max", "max_c", "cake", "sum_c += cake", "sum_c", "cake", "print(max(0, 2*max_c-sum_c-1))", "print", "max(0, 2*max_c-sum_c-1)", "max", "0", "2*max_c-sum_c-1", "2*max_c-sum_c", "2*max_c", "2", "max_c", "sum_c", "1", "max_c = max(max_c, cake)", "max(max_c, cake)", "max_c", "cakes = list(map(int, input().split()))", "list(map(int, input().split()))", "cakes", "K, T = map(int, input().split())", "map(int, input().split())", "K", "max_c = 0", "0", "max_c", "sum_c += cake", "cake", "sum_c", "T = map(int, input().split())", "map(int, input().split())", "T", "sum_c = 0", "0", "sum_c" ]
K, T = map(int, input().split()) cakes = list(map(int, input().split())) max_c = 0 sum_c = 0 for cake in cakes: max_c = max(max_c, cake) sum_c += cake print(max(0, 2*max_c-sum_c-1))
[ 7, 0, 13, 12, 4, 13, 13, 0, 13, 17, 23, 0, 13, 12, 4, 13, 4, 13, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 14, 13, 4, 13, 13, 23, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 2, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 17, 2, 17, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13, 10, 2, 13, 10, 4, 13, 10, 12, 13, 10, 17, 13, 10, 2, 13, 10, 2, 13 ]
[ [ 109, 2 ], [ 9, 8 ], [ 121, 12 ], [ 106, 19 ], [ 130, 32 ], [ 103, 43 ], [ 133, 51 ], [ 124, 54 ], [ 136, 59 ], [ 73, 71 ], [ 73, 73 ], [ 118, 75 ], [ 131, 77 ], [ 118, 78 ], [ 127, 80 ], [ 107, 82 ], [ 139, 84 ], [ 116, 86 ], [ 128, 89 ], [ 116, 97 ], [ 140, 101 ], [ 103, 104 ], [ 106, 107 ], [ 109, 110 ], [ 118, 116 ], [ 118, 119 ], [ 121, 122 ], [ 124, 125 ], [ 127, 128 ], [ 130, 131 ], [ 133, 134 ], [ 136, 137 ], [ 139, 140 ] ]
[ "#from collections import deque,defaultdict\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n#R = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\nk,t = inm()\na = inl()\nb = k-max(a)\nprint(max(0,k-1-2*b))", "printn = lambda x: print(x,end='')", "printn", "lambda x: print(x,end='')", "print(x,end='')", "print", "x", "end=''", "end", "''", "x", "inn = lambda : int(input())", "inn", "lambda : int(input())", "int(input())", "int", "input()", "input", "inl = lambda: list(map(int, input().split()))", "inl", "lambda: list(map(int, input().split()))", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "inm = lambda: map(int, input().split())", "inm", "lambda: map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ins = lambda : input().strip()", "ins", "lambda : input().strip()", "input().strip()", "().strip", "()", "input", "strip", "DBG = True", "DBG", "True", "BIG = 10**18", "BIG", "10**18", "10", "18", "R = 10**9 + 7", "R", "10**9 + 7", "10**9", "10", "9", "7", "def ddprint(x):\n if DBG:\n print(x)", "ddprint", "if DBG:\n print(x)", "DBG", "print(x)", "print", "x", "x", "x", "k,t = inm()", "k", "inm()", "inm", "t", "a = inl()", "a", "inl()", "inl", "b = k-max(a)", "b", "k-max(a)", "k", "max(a)", "max", "a", "print(max(0,k-1-2*b))", "print", "max(0,k-1-2*b)", "max", "0", "k-1-2*b", "k-1", "k", "1", "2*b", "2", "b", "ins = lambda : input().strip()", "lambda : input().strip()", "ins", "inl = lambda: list(map(int, input().split()))", "lambda: list(map(int, input().split()))", "inl", "printn = lambda x: print(x,end='')", "lambda x: print(x,end='')", "printn", "def ddprint(x):\n if DBG:\n print(x)", "def ddprint(x):\n if DBG:\n print(x)", "ddprint", "k,t = inm()", "inm()", "k", "t = inm()", "inm()", "t", "inn = lambda : int(input())", "lambda : int(input())", "inn", "BIG = 10**18", "10**18", "BIG", "a = inl()", "inl()", "a", "inm = lambda: map(int, input().split())", "lambda: map(int, input().split())", "inm", "DBG = True", "True", "DBG", "R = 10**9 + 7", "10**9 + 7", "R", "b = k-max(a)", "k-max(a)", "b" ]
#from collections import deque,defaultdict printn = lambda x: print(x,end='') inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda : input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 #R = 998244353 def ddprint(x): if DBG: print(x) k,t = inm() a = inl() b = k-max(a) print(max(0,k-1-2*b))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 4, 13, 18, 13, 39, 17, 4, 13, 4, 13, 17, 2, 2, 4, 13, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 52, 2 ], [ 52, 11 ], [ 55, 13 ], [ 56, 26 ], [ 58, 29 ], [ 56, 33 ], [ 56, 45 ], [ 59, 46 ], [ 52, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "K,T = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\na_sum =sum(a[:-1])\nprint(max(0,max(a)-a_sum-1))", "K,T = map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort()", "a.sort", "a", "sort", "a_sum =sum(a[:-1])", "a_sum", "sum(a[:-1])", "sum", "a[:-1]", "a", ":-1", "-1", "print(max(0,max(a)-a_sum-1))", "print", "max(0,max(a)-a_sum-1)", "max", "0", "max(a)-a_sum-1", "max(a)-a_sum", "max(a)", "max", "a", "a_sum", "1", "K,T = map(int,input().split())", "map(int,input().split())", "K", "T = map(int,input().split())", "map(int,input().split())", "T", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "a_sum =sum(a[:-1])", "sum(a[:-1])", "a_sum" ]
K,T = map(int,input().split()) a = list(map(int,input().split())) a.sort() a_sum =sum(a[:-1]) print(max(0,max(a)-a_sum-1))
[ 7, 15, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 18, 4, 18, 4, 13, 13, 13, 17, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 40, 2, 40, 13, 17, 0, 13, 4, 13, 17, 2, 2, 2, 13, 13, 17, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 18, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 18, 13 ]
[ [ 126, 4 ], [ 141, 13 ], [ 123, 22 ], [ 142, 27 ], [ 120, 29 ], [ 142, 37 ], [ 138, 40 ], [ 142, 50 ], [ 129, 53 ], [ 127, 61 ], [ 132, 64 ], [ 142, 71 ], [ 79, 78 ], [ 121, 80 ], [ 79, 81 ], [ 84, 83 ], [ 139, 85 ], [ 88, 87 ], [ 83, 90 ], [ 93, 92 ], [ 78, 96 ], [ 100, 99 ], [ 87, 106 ], [ 92, 107 ], [ 99, 112 ], [ 136, 118 ], [ 120, 121 ], [ 123, 124 ], [ 126, 127 ], [ 129, 130 ], [ 132, 133 ], [ 138, 139 ], [ 141, 142 ] ]
[ "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\nin_n = lambda: int(readline())\nin_nn = lambda: map(int, readline().split())\nin_nl = lambda: list(map(int, readline().split()))\nin_na = lambda: map(int, read().split())\nin_s = lambda: readline().rstrip().decode('utf-8')\n\n\ndef main():\n K, T = in_nn()\n a = in_nl()\n maxA = max(a)\n mT = -(-K // 2)\n ans = max(0, (maxA - mT) * 2 - 1)\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "read = sys.stdin.buffer.read", "read", "sys.stdin.buffer.read", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "read", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "in_n = lambda: int(readline())", "in_n", "lambda: int(readline())", "int(readline())", "int", "readline()", "readline", "in_nn = lambda: map(int, readline().split())", "in_nn", "lambda: map(int, readline().split())", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "in_nl = lambda: list(map(int, readline().split()))", "in_nl", "lambda: list(map(int, readline().split()))", "list(map(int, readline().split()))", "list", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "in_na = lambda: map(int, read().split())", "in_na", "lambda: map(int, read().split())", "map(int, read().split())", "map", "int", "read().split()", "().split", "()", "read", "split", "in_s = lambda: readline().rstrip().decode('utf-8')", "in_s", "lambda: readline().rstrip().decode('utf-8')", "readline().rstrip().decode('utf-8')", "().rstrip().decode", "().rstrip()", "().rstrip", "()", "readline", "rstrip", "decode", "'utf-8'", "def main():\n K, T = in_nn()\n a = in_nl()\n maxA = max(a)\n mT = -(-K // 2)\n ans = max(0, (maxA - mT) * 2 - 1)\n print(ans)", "main", "K, T = in_nn()", "K", "in_nn()", "in_nn", "T", "a = in_nl()", "a", "in_nl()", "in_nl", "maxA = max(a)", "maxA", "max(a)", "max", "a", "mT = -(-K // 2)", "mT", "-(-K // 2)", "-K // 2", "-K", "K", "2", "ans = max(0, (maxA - mT) * 2 - 1)", "ans", "max(0, (maxA - mT) * 2 - 1)", "max", "0", "(maxA - mT) * 2 - 1", "(maxA - mT) * 2", "maxA - mT", "maxA", "mT", "2", "1", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "in_nn = lambda: map(int, readline().split())", "lambda: map(int, readline().split())", "in_nn", "in_n = lambda: int(readline())", "lambda: int(readline())", "in_n", "read = sys.stdin.buffer.read", "sys.stdin.buffer.read", "read", "in_na = lambda: map(int, read().split())", "lambda: map(int, read().split())", "in_na", "in_s = lambda: readline().rstrip().decode('utf-8')", "lambda: readline().rstrip().decode('utf-8')", "in_s", "def main():\n K, T = in_nn()\n a = in_nl()\n maxA = max(a)\n mT = -(-K // 2)\n ans = max(0, (maxA - mT) * 2 - 1)\n print(ans)", "def main():\n K, T = in_nn()\n a = in_nl()\n maxA = max(a)\n mT = -(-K // 2)\n ans = max(0, (maxA - mT) * 2 - 1)\n print(ans)", "main", "in_nl = lambda: list(map(int, readline().split()))", "lambda: list(map(int, readline().split()))", "in_nl", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline" ]
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: map(int, readline().split()) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: map(int, read().split()) in_s = lambda: readline().rstrip().decode('utf-8') def main(): K, T = in_nn() a = in_nl() maxA = max(a) mT = -(-K // 2) ans = max(0, (maxA - mT) * 2 - 1) print(ans) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 14, 2, 13, 17, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 40, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 50, 2 ], [ 50, 11 ], [ 59, 13 ], [ 51, 26 ], [ 53, 29 ], [ 60, 32 ], [ 56, 34 ], [ 60, 38 ], [ 54, 39 ], [ 57, 42 ], [ 54, 44 ], [ 50, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "k,t=map(int,input().split())\na=list(map(int,input().split()))\nif t==1: print(a[0]-1)\nelse:\n temp=max(a)\n rest=sum(a)-temp\n if rest>=temp-1: print(0)\n else: print(temp-rest-1)", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "if t==1: print(a[0]-1)\nelse:\n temp=max(a)\n rest=sum(a)-temp\n if rest>=temp-1: print(0)\n else: print(temp-rest-1)", "t==1", "t", "1", "temp=max(a)", "temp", "max(a)", "max", "a", "rest=sum(a)-temp", "rest", "sum(a)-temp", "sum(a)", "sum", "a", "temp", "if rest>=temp-1: print(0)\n else: print(temp-rest-1)", "rest>=temp-1", "rest", "temp-1", "temp", "1", "k,t=map(int,input().split())", "map(int,input().split())", "k", "t=map(int,input().split())", "map(int,input().split())", "t", "temp=max(a)", "max(a)", "temp", "rest=sum(a)-temp", "sum(a)-temp", "rest", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
k,t=map(int,input().split()) a=list(map(int,input().split())) if t==1: print(a[0]-1) else: temp=max(a) rest=sum(a)-temp if rest>=temp-1: print(0) else: print(temp-rest-1)
[ 7, 15, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 15, 15, 4, 18, 13, 13, 2, 17, 17, 15, 13, 15, 0, 13, 2, 17, 17, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 31, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 2, 2, 2, 13, 17, 13, 13, 17, 14, 2, 13, 17, 4, 13, 10, 18, 13, 10, 2, 13, 10, 12, 13, 10, 18, 13 ]
[ [ 86, 4 ], [ 77, 13 ], [ 80, 34 ], [ 42, 41 ], [ 78, 48 ], [ 42, 50 ], [ 42, 51 ], [ 55, 54 ], [ 54, 65 ], [ 41, 67 ], [ 54, 68 ], [ 84, 75 ], [ 77, 78 ], [ 80, 81 ], [ 86, 87 ] ]
[ "# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.buffer.readline\nread = sys.stdin.buffer.read\nfrom heapq import heappop, heappush\nfrom collections import defaultdict\nsys.setrecursionlimit(10**7)\nimport math\n#from itertools import product, accumulate, combinations, product\n#import bisect\n#import numpy as np\n#from copy import deepcopy\nfrom collections import deque\n#from decimal import Decimal\n\nINF = 1 << 50\n\ndef run():\n K, T, *A = map(int, read().split())\n max_a = max(A)\n print(max(max_a-1-K+max_a, 0))\n\nif __name__ == \"__main__\":\n run()", "import sys", "sys", "sysread = sys.stdin.buffer.readline", "sysread", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "read = sys.stdin.buffer.read", "read", "sys.stdin.buffer.read", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "read", "from heapq import heappop, heappush", "from collections import defaultdict", "sys.setrecursionlimit(10**7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**7", "10", "7", "import math", "math", "from collections import deque", "INF = 1 << 50", "INF", "1 << 50", "1", "50", "def run():\n K, T, *A = map(int, read().split())\n max_a = max(A)\n print(max(max_a-1-K+max_a, 0))", "run", "K, T, *A = map(int, read().split())", "K", "map(int, read().split())", "map", "int", "read().split()", "().split", "()", "read", "split", "T", "*A", "A", "max_a = max(A)", "max_a", "max(A)", "max", "A", "print(max(max_a-1-K+max_a, 0))", "print", "max(max_a-1-K+max_a, 0)", "max", "max_a-1-K+max_a", "max_a-1-K", "max_a-1", "max_a", "1", "K", "max_a", "0", "if __name__ == \"__main__\":\n run()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "run()", "run", "read = sys.stdin.buffer.read", "sys.stdin.buffer.read", "read", "INF = 1 << 50", "1 << 50", "INF", "def run():\n K, T, *A = map(int, read().split())\n max_a = max(A)\n print(max(max_a-1-K+max_a, 0))", "def run():\n K, T, *A = map(int, read().split())\n max_a = max(A)\n print(max(max_a-1-K+max_a, 0))", "run", "sysread = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "sysread" ]
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10**7) import math #from itertools import product, accumulate, combinations, product #import bisect #import numpy as np #from copy import deepcopy from collections import deque #from decimal import Decimal INF = 1 << 50 def run(): K, T, *A = map(int, read().split()) max_a = max(A) print(max(max_a-1-K+max_a, 0)) if __name__ == "__main__": run()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 40, 2, 13, 17, 13, 4, 13, 17, 4, 13, 2, 2, 13, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 65, 2 ], [ 65, 11 ], [ 59, 13 ], [ 56, 25 ], [ 60, 28 ], [ 62, 30 ], [ 60, 34 ], [ 57, 35 ], [ 63, 39 ], [ 57, 41 ], [ 57, 49 ], [ 63, 51 ], [ 65, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "k,t = map(int,input().split())\nA = list(map(int,input().split()))\nM = max(A)\nOs = sum(A)-M\nif Os+1 >= M:\n print(0)\nelse:\n print(M-1-Os)", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "M = max(A)", "M", "max(A)", "max", "A", "Os = sum(A)-M", "Os", "sum(A)-M", "sum(A)", "sum", "A", "M", "if Os+1 >= M:\n print(0)\nelse:\n print(M-1-Os)", "Os+1 >= M", "Os+1", "Os", "1", "M", "print(0)", "print", "0", "print(M-1-Os)", "print", "M-1-Os", "M-1", "M", "1", "Os", "t = map(int,input().split())", "map(int,input().split())", "t", "M = max(A)", "max(A)", "M", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "Os = sum(A)-M", "sum(A)-M", "Os", "k,t = map(int,input().split())", "map(int,input().split())", "k" ]
k,t = map(int,input().split()) A = list(map(int,input().split())) M = max(A) Os = sum(A)-M if Os+1 >= M: print(0) else: print(M-1-Os)
[ 7, 12, 13, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 4, 18, 13, 13, 0, 13, 2, 2, 18, 13, 17, 4, 13, 18, 13, 39, 17, 17, 4, 13, 8, 2, 13, 17, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 11, 10 ], [ 61, 12 ], [ 11, 13 ], [ 16, 15 ], [ 58, 17 ], [ 15, 20 ], [ 24, 23 ], [ 15, 27 ], [ 15, 32 ], [ 23, 40 ], [ 23, 42 ], [ 52, 49 ] ]
[ "#!/usr/bin/env python3\n\ndef II(): return int(input())\ndef MII(): return map(int, input().split())\ndef LII(): return list(map(int, input().split()))\n\ndef main():\n K, T = MII()\n A = LII()\n\n A.sort()\n cnt = A[-1] - sum(A[:-1]) - 1\n print(cnt if cnt > 0 else 0)\n\nif __name__ == '__main__':\n main()", "def II(): return int(input())", "II", "def MII(): return map(int, input().split())", "MII", "def LII(): return list(map(int, input().split()))", "LII", "def main():\n K, T = MII()\n A = LII()\n\n A.sort()\n cnt = A[-1] - sum(A[:-1]) - 1\n print(cnt if cnt > 0 else 0)", "main", "K, T = MII()", "K", "MII()", "MII", "T", "A = LII()", "A", "LII()", "LII", "A.sort()", "A.sort", "A", "sort", "cnt = A[-1] - sum(A[:-1]) - 1", "cnt", "A[-1] - sum(A[:-1]) - 1", "A[-1] - sum(A[:-1])", "A[-1]", "A", "-1", "sum(A[:-1])", "sum", "A[:-1]", "A", ":-1", "-1", "1", "print(cnt if cnt > 0 else 0)", "print", "cnt if cnt > 0 else 0", "cnt > 0", "cnt", "0", "cnt", "0", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n K, T = MII()\n A = LII()\n\n A.sort()\n cnt = A[-1] - sum(A[:-1]) - 1\n print(cnt if cnt > 0 else 0)", "def main():\n K, T = MII()\n A = LII()\n\n A.sort()\n cnt = A[-1] - sum(A[:-1]) - 1\n print(cnt if cnt > 0 else 0)", "main", "def II(): return int(input())", "def II(): return int(input())", "II", "def LII(): return list(map(int, input().split()))", "def LII(): return list(map(int, input().split()))", "LII", "def MII(): return map(int, input().split())", "def MII(): return map(int, input().split())", "MII" ]
#!/usr/bin/env python3 def II(): return int(input()) def MII(): return map(int, input().split()) def LII(): return list(map(int, input().split())) def main(): K, T = MII() A = LII() A.sort() cnt = A[-1] - sum(A[:-1]) - 1 print(cnt if cnt > 0 else 0) if __name__ == '__main__': main()
[ 7, 15, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 41, 28, 13, 4, 13, 13, 4, 13, 0, 13, 13, 28, 13, 4, 13, 13, 0, 18, 18, 13, 13, 17, 2, 18, 13, 13, 17, 0, 18, 18, 13, 13, 17, 13, 4, 18, 13, 13, 13, 0, 13, 17, 13, 17, 42, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 14, 2, 13, 18, 13, 17, 14, 40, 4, 13, 13, 0, 13, 17, 0, 13, 18, 13, 17, 0, 18, 13, 17, 17, 14, 18, 13, 17, 4, 18, 13, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 18, 13, 17, 0, 18, 13, 17, 17, 4, 18, 13, 13, 13, 13, 14, 18, 13, 17, 4, 18, 13, 13, 13, 13, 0, 13, 18, 13, 17, 0, 18, 13, 17, 17, 14, 18, 13, 17, 4, 18, 13, 13, 13, 13, 4, 13, 13, 10, 13, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13, 10, 4, 13, 10, 18, 13, 10, 18, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 205, 4 ], [ 205, 13 ], [ 17, 16 ], [ 16, 25 ], [ 175, 27 ], [ 32, 31 ], [ 197, 34 ], [ 181, 38 ], [ 42, 41 ], [ 197, 44 ], [ 51, 46 ], [ 182, 48 ], [ 41, 49 ], [ 176, 53 ], [ 41, 54 ], [ 62, 57 ], [ 182, 59 ], [ 41, 60 ], [ 41, 62 ], [ 182, 67 ], [ 190, 69 ], [ 178, 71 ], [ 182, 76 ], [ 184, 78 ], [ 182, 83 ], [ 179, 86 ], [ 194, 86 ], [ 203, 86 ], [ 200, 86 ], [ 185, 88 ], [ 182, 94 ], [ 208, 96 ], [ 193, 99 ], [ 185, 101 ], [ 107, 104 ], [ 185, 105 ], [ 185, 110 ], [ 182, 116 ], [ 185, 117 ], [ 187, 119 ], [ 182, 124 ], [ 202, 126 ], [ 188, 128 ], [ 134, 131 ], [ 188, 132 ], [ 182, 139 ], [ 185, 140 ], [ 188, 143 ], [ 182, 149 ], [ 188, 150 ], [ 199, 152 ], [ 185, 154 ], [ 160, 157 ], [ 185, 158 ], [ 185, 163 ], [ 182, 169 ], [ 185, 170 ], [ 209, 173 ], [ 191, 173 ], [ 175, 176 ], [ 178, 179 ], [ 181, 182 ], [ 184, 185 ], [ 187, 188 ], [ 190, 191 ], [ 193, 194 ], [ 205, 197 ], [ 199, 200 ], [ 202, 203 ], [ 205, 206 ], [ 208, 209 ] ]
[ "import heapq\n\nK, T = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [[0 for j in range(2)] for i in range(T)]\nfor i in range(T):\n\tb[i][0] = a[i] * -1\n\tb[i][1] = i\nheapq.heapify(b)\nans, c = 0, -1\nwhile len(b):\n\td = heapq.heappop(b)\n\tif c == d[1]:\n\t\tif not len(b):\n\t\t\tans += 1\n\t\t\tc = d[1]\n\t\t\td[0] += 1\n\t\t\tif d[0]:\n\t\t\t\theapq.heappush(b, d)\n\t\telse:\n\t\t\te = heapq.heappop(b)\n\t\t\tc = e[1]\n\t\t\te[0] += 1\n\t\t\theapq.heappush(b, d)\n\t\t\tif e[0]:\n\t\t\t\theapq.heappush(b, e)\n\telse:\n\t\tc = d[1]\n\t\td[0] += 1\n\t\tif d[0]:\n\t\t\theapq.heappush(b, d)\nprint(ans)", "import heapq", "heapq", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "int(i) for i in input().split()", "for i in input().split()", "i", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)", "int", "i", "a = [int(i) for i in input().split()]", "a", "[int(i) for i in input().split()]", "[0 for j in range(2)] for i in range(T)", "for i in range(T)", "i", "range(T)", "range", "T", "for i in range(T)", "[0 for j in range(2)]", "b = [[0 for j in range(2)] for i in range(T)]", "b", "[[0 for j in range(2)] for i in range(T)]", "for i in range(T):\n\tb[i][0] = a[i] * -1\n\tb[i][1] = i", "i", "range(T)", "range", "T", "b[i][0] = a[i] * -1", "b[i][0]", "[i]", "b", "i", "0", "a[i] * -1", "a[i]", "a", "i", "-1", "b[i][1] = i", "b[i][1]", "[i]", "b", "i", "1", "i", "heapq.heapify(b)", "heapq.heapify", "heapq", "heapify", "b", "ans, c = 0, -1", "ans", "0", "c", "-1", "while len(b):\n\td = heapq.heappop(b)\n\tif c == d[1]:\n\t\tif not len(b):\n\t\t\tans += 1\n\t\t\tc = d[1]\n\t\t\td[0] += 1\n\t\t\tif d[0]:\n\t\t\t\theapq.heappush(b, d)\n\t\telse:\n\t\t\te = heapq.heappop(b)\n\t\t\tc = e[1]\n\t\t\te[0] += 1\n\t\t\theapq.heappush(b, d)\n\t\t\tif e[0]:\n\t\t\t\theapq.heappush(b, e)\n\telse:\n\t\tc = d[1]\n\t\td[0] += 1\n\t\tif d[0]:\n\t\t\theapq.heappush(b, d)", "len(b)", "len", "b", "d = heapq.heappop(b)", "d", "heapq.heappop(b)", "heapq.heappop", "heapq", "heappop", "b", "if c == d[1]:\n\t\tif not len(b):\n\t\t\tans += 1\n\t\t\tc = d[1]\n\t\t\td[0] += 1\n\t\t\tif d[0]:\n\t\t\t\theapq.heappush(b, d)\n\t\telse:\n\t\t\te = heapq.heappop(b)\n\t\t\tc = e[1]\n\t\t\te[0] += 1\n\t\t\theapq.heappush(b, d)\n\t\t\tif e[0]:\n\t\t\t\theapq.heappush(b, e)\n\telse:\n\t\tc = d[1]\n\t\td[0] += 1\n\t\tif d[0]:\n\t\t\theapq.heappush(b, d)", "c == d[1]", "c", "d[1]", "d", "1", "if not len(b):\n\t\t\tans += 1\n\t\t\tc = d[1]\n\t\t\td[0] += 1\n\t\t\tif d[0]:\n\t\t\t\theapq.heappush(b, d)\n\t\telse:\n\t\t\te = heapq.heappop(b)\n\t\t\tc = e[1]\n\t\t\te[0] += 1\n\t\t\theapq.heappush(b, d)\n\t\t\tif e[0]:\n\t\t\t\theapq.heappush(b, e)\n\t", "not len(b)", "len(b)", "len", "b", "ans += 1", "ans", "1", "c = d[1]", "c", "d[1]", "d", "1", "d[0] += 1", "d[0]", "d", "0", "1", "if d[0]:\n\t\t\t\theapq.heappush(b, d)\n\t\t", "d[0]", "d", "0", "heapq.heappush(b, d)", "heapq.heappush", "heapq", "heappush", "b", "d", "e = heapq.heappop(b)", "e", "heapq.heappop(b)", "heapq.heappop", "heapq", "heappop", "b", "c = e[1]", "c", "e[1]", "e", "1", "e[0] += 1", "e[0]", "e", "0", "1", "heapq.heappush(b, d)", "heapq.heappush", "heapq", "heappush", "b", "d", "if e[0]:\n\t\t\t\theapq.heappush(b, e)\n\t", "e[0]", "e", "0", "heapq.heappush(b, e)", "heapq.heappush", "heapq", "heappush", "b", "e", "c = d[1]", "c", "d[1]", "d", "1", "d[0] += 1", "d[0]", "d", "0", "1", "if d[0]:\n\t\t\theapq.heappush(b, d)", "d[0]", "d", "0", "heapq.heappush(b, d)", "heapq.heappush", "heapq", "heappush", "b", "d", "print(ans)", "print", "ans", "a = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "a", "c = 0, -1", "-1", "c", "b = [[0 for j in range(2)] for i in range(T)]", "[[0 for j in range(2)] for i in range(T)]", "b", "d = heapq.heappop(b)", "heapq.heappop(b)", "d", "e = heapq.heappop(b)", "heapq.heappop(b)", "e", "ans, c = 0, -1", "0", "ans", "c = d[1]", "d[1]", "c", "T = map(int, input().split())", "map(int, input().split())", "T", "c = d[1]", "d[1]", "c", "c = e[1]", "e[1]", "c", "K, T = map(int, input().split())", "map(int, input().split())", "K", "ans += 1", "1", "ans" ]
import heapq K, T = map(int, input().split()) a = [int(i) for i in input().split()] b = [[0 for j in range(2)] for i in range(T)] for i in range(T): b[i][0] = a[i] * -1 b[i][1] = i heapq.heapify(b) ans, c = 0, -1 while len(b): d = heapq.heappop(b) if c == d[1]: if not len(b): ans += 1 c = d[1] d[0] += 1 if d[0]: heapq.heappush(b, d) else: e = heapq.heappop(b) c = e[1] e[0] += 1 heapq.heappush(b, d) if e[0]: heapq.heappush(b, e) else: c = d[1] d[0] += 1 if d[0]: heapq.heappush(b, d) print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 18, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 39, 17, 0, 13, 18, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 14, 40, 2, 13, 17, 13, 4, 13, 17, 4, 13, 2, 2, 13, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 18, 13 ]
[ [ 65, 2 ], [ 65, 11 ], [ 71, 13 ], [ 68, 30 ], [ 72, 32 ], [ 62, 35 ], [ 72, 39 ], [ 69, 45 ], [ 63, 47 ], [ 69, 55 ], [ 63, 57 ], [ 65, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "k,t = map(int,input().split())\na = sorted(list(map(int,input().split())))[::-1]\na1 = a[0]\na2 = sum(a[1:])\nif a1-1<=a2:\n print(0)\nelse:\n print(a1-1-a2)", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = sorted(list(map(int,input().split())))[::-1]", "a", "sorted(list(map(int,input().split())))[::-1]", "(list(map(int,input().split())))", "sorted", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "::-1", "-1", "a1 = a[0]", "a1", "a[0]", "a", "0", "a2 = sum(a[1:])", "a2", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "if a1-1<=a2:\n print(0)\nelse:\n print(a1-1-a2)", "a1-1<=a2", "a1-1", "a1", "1", "a2", "print(0)", "print", "0", "print(a1-1-a2)", "print", "a1-1-a2", "a1-1", "a1", "1", "a2", "k,t = map(int,input().split())", "map(int,input().split())", "k", "a2 = sum(a[1:])", "sum(a[1:])", "a2", "t = map(int,input().split())", "map(int,input().split())", "t", "a1 = a[0]", "a[0]", "a1", "a = sorted(list(map(int,input().split())))[::-1]", "sorted(list(map(int,input().split())))[::-1]", "a" ]
k,t = map(int,input().split()) a = sorted(list(map(int,input().split())))[::-1] a1 = a[0] a2 = sum(a[1:]) if a1-1<=a2: print(0) else: print(a1-1-a2)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 13, 18, 13, 13, 0, 13, 18, 13, 13, 0, 13, 13, 28, 13, 4, 13, 4, 13, 13, 14, 40, 13, 13, 0, 13, 18, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 13, 17, 10, 18, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 95, 2 ], [ 14, 13 ], [ 13, 22 ], [ 101, 24 ], [ 104, 27 ], [ 92, 30 ], [ 86, 33 ], [ 37, 36 ], [ 102, 41 ], [ 93, 44 ], [ 84, 44 ], [ 102, 46 ], [ 36, 47 ], [ 83, 49 ], [ 102, 51 ], [ 36, 52 ], [ 89, 54 ], [ 36, 55 ], [ 58, 57 ], [ 102, 62 ], [ 57, 65 ], [ 90, 66 ], [ 105, 66 ], [ 98, 68 ], [ 102, 70 ], [ 57, 71 ], [ 84, 79 ], [ 93, 79 ], [ 99, 80 ], [ 87, 80 ], [ 83, 84 ], [ 86, 87 ], [ 36, 89 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ] ]
[ "#3問目 CODE FESTIVAL 2016 qual C B問題 -K個のケーキ\nKT = map(int, input().split())\nA = [int(s) for s in input().split()]\nMax_i = 0\nMax = 0\nwithoutMaxSum = 0\n#二回連続で食べる可能性のあるケーキは一番個数の多いケーキのみ\n#一番個数の多いケーキの個数 - その他のケーキの個数の総和 - 1が前日と同じケーキを食べる日数\n#0以下になったら確実に被らずに食べられる\n#1以上になったら確実に被る -> max(0, Max - withoutMaxSum)\nfor i in range(len(A)):\n if(Max < A[i]):\n Max = A[i]\n Max_i = i\nfor i in range(len(A)):\n if(i != Max_i):\n withoutMaxSum += A[i]\nprint(max(0, Max-withoutMaxSum-1))", "KT = map(int, input().split())", "KT", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "int(s) for s in input().split()", "for s in input().split()", "s", "input().split()", "().split", "()", "input", "split", "for s in input().split()", "int(s)", "int", "s", "A = [int(s) for s in input().split()]", "A", "[int(s) for s in input().split()]", "Max_i = 0", "Max_i", "0", "Max = 0", "Max", "0", "withoutMaxSum = 0", "withoutMaxSum", "0", "for i in range(len(A)):\n if(Max < A[i]):\n Max = A[i]\n Max_i = i", "i", "range(len(A))", "range", "len(A)", "len", "A", "if(Max < A[i]):\n Max = A[i]\n Max_i = i", "Max < A[i]", "Max", "A[i]", "A", "i", "Max = A[i]", "Max", "A[i]", "A", "i", "Max_i = i", "Max_i", "i", "for i in range(len(A)):\n if(i != Max_i):\n withoutMaxSum += A[i]", "i", "range(len(A))", "range", "len(A)", "len", "A", "if(i != Max_i):\n withoutMaxSum += A[i]", "i != Max_i", "i", "Max_i", "withoutMaxSum += A[i]", "withoutMaxSum", "A[i]", "A", "i", "print(max(0, Max-withoutMaxSum-1))", "print", "max(0, Max-withoutMaxSum-1)", "max", "0", "Max-withoutMaxSum-1", "Max-withoutMaxSum", "Max", "withoutMaxSum", "1", "Max = A[i]", "A[i]", "Max", "withoutMaxSum = 0", "0", "withoutMaxSum", "Max_i = i", "i", "Max_i", "Max = 0", "0", "Max", "KT = map(int, input().split())", "map(int, input().split())", "KT", "withoutMaxSum += A[i]", "A[i]", "withoutMaxSum", "A = [int(s) for s in input().split()]", "[int(s) for s in input().split()]", "A", "Max_i = 0", "0", "Max_i" ]
#3問目 CODE FESTIVAL 2016 qual C B問題 -K個のケーキ KT = map(int, input().split()) A = [int(s) for s in input().split()] Max_i = 0 Max = 0 withoutMaxSum = 0 #二回連続で食べる可能性のあるケーキは一番個数の多いケーキのみ #一番個数の多いケーキの個数 - その他のケーキの個数の総和 - 1が前日と同じケーキを食べる日数 #0以下になったら確実に被らずに食べられる #1以上になったら確実に被る -> max(0, Max - withoutMaxSum) for i in range(len(A)): if(Max < A[i]): Max = A[i] Max_i = i for i in range(len(A)): if(i != Max_i): withoutMaxSum += A[i] print(max(0, Max-withoutMaxSum-1))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 4, 13, 2, 4, 13, 13, 2, 2, 13, 4, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 47, 2 ], [ 47, 11 ], [ 41, 13 ], [ 42, 31 ], [ 45, 34 ], [ 42, 37 ], [ 41, 42 ], [ 47, 45 ], [ 47, 48 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nprint(max(max(A) - (K - max(A) + 1), 0))", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max(max(A) - (K - max(A) + 1), 0))", "print", "max(max(A) - (K - max(A) + 1), 0)", "max", "max(A) - (K - max(A) + 1)", "max(A)", "max", "A", "K - max(A) + 1", "K - max(A)", "K", "max(A)", "max", "A", "1", "0", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "K, T = map(int, input().split())", "map(int, input().split())", "K", "T = map(int, input().split())", "map(int, input().split())", "T" ]
K, T = map(int, input().split()) A = list(map(int, input().split())) print(max(max(A) - (K - max(A) + 1), 0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 4, 13, 13, 17, 2, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 47, 2 ], [ 47, 11 ], [ 44, 13 ], [ 45, 33 ], [ 48, 36 ], [ 45, 39 ], [ 47, 42 ], [ 44, 45 ], [ 47, 48 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\nprint(max(0,max(a)-1-(k-max(a))))", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max(0,max(a)-1-(k-max(a))))", "print", "max(0,max(a)-1-(k-max(a)))", "max", "0", "max(a)-1-(k-max(a))", "max(a)-1", "max(a)", "max", "a", "1", "k-max(a)", "k", "max(a)", "max", "a", "t = map(int,input().split())", "map(int,input().split())", "t", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "k,t = map(int,input().split())", "map(int,input().split())", "k" ]
k,t = map(int,input().split()) a = list(map(int,input().split())) print(max(0,max(a)-1-(k-max(a))))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 13, 31, 13, 15, 4, 13, 4, 13, 17, 2, 2, 2, 4, 13, 13, 4, 13, 2, 13, 17, 17, 17, 10, 4, 13, 10, 4, 13 ]
[ [ 41, 2 ], [ 41, 15 ], [ 41, 16 ], [ 42, 33 ], [ 41, 39 ], [ 41, 42 ] ]
[ "n,t,*a=map(int,open(0).read().split())\nfrom math import *\nprint(max(0,(max(a)-ceil(n/2))*2-1))", "n,t,*a=map(int,open(0).read().split())", "n", "map(int,open(0).read().split())", "map", "int", "open(0).read().split()", "(0).read().split", "(0).read()", "(0).read", "(0)", "open", "0", "read", "split", "t", "*a", "a", "from math import *", "print(max(0,(max(a)-ceil(n/2))*2-1))", "print", "max(0,(max(a)-ceil(n/2))*2-1)", "max", "0", "(max(a)-ceil(n/2))*2-1", "(max(a)-ceil(n/2))*2", "max(a)-ceil(n/2)", "max(a)", "max", "a", "ceil(n/2)", "ceil", "n/2", "n", "2", "2", "1", "t,*a=map(int,open(0).read().split())", "map(int,open(0).read().split())", "t", "n,t,*a=map(int,open(0).read().split())", "map(int,open(0).read().split())", "n" ]
n,t,*a=map(int,open(0).read().split()) from math import * print(max(0,(max(a)-ceil(n/2))*2-1))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 4, 13, 4, 13, 2, 2, 18, 13, 17, 4, 13, 18, 13, 39, 17, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 53, 2 ], [ 53, 11 ], [ 50, 13 ], [ 28, 27 ], [ 51, 36 ], [ 51, 41 ], [ 53, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "K,T = map(int, input().split())\na = sorted(list(map(int, input().split())), reverse=True)\nprint(max(a[0]-sum(a[1:])-1, 0))", "K,T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "a = sorted(list(map(int, input().split())), reverse=True)", "a", "sorted(list(map(int, input().split())), reverse=True)", "sorted", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "reverse=True", "reverse", "True", "print(max(a[0]-sum(a[1:])-1, 0))", "print", "max(a[0]-sum(a[1:])-1, 0)", "max", "a[0]-sum(a[1:])-1", "a[0]-sum(a[1:])", "a[0]", "a", "0", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "1", "0", "K,T = map(int, input().split())", "map(int, input().split())", "K", "a = sorted(list(map(int, input().split())), reverse=True)", "sorted(list(map(int, input().split())), reverse=True)", "a", "T = map(int, input().split())", "map(int, input().split())", "T" ]
K,T = map(int, input().split()) a = sorted(list(map(int, input().split())), reverse=True) print(max(a[0]-sum(a[1:])-1, 0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 42, 2, 4, 13, 13, 17, 0, 18, 13, 17, 17, 0, 18, 13, 17, 17, 14, 2, 18, 13, 17, 17, 24, 18, 13, 17, 14, 2, 18, 13, 17, 17, 24, 18, 13, 17, 14, 13, 4, 13, 2, 18, 13, 17, 17, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13 ]
[ [ 87, 2 ], [ 87, 11 ], [ 15, 14 ], [ 14, 23 ], [ 90, 25 ], [ 93, 28 ], [ 91, 31 ], [ 34, 33 ], [ 94, 39 ], [ 91, 39 ], [ 45, 42 ], [ 94, 43 ], [ 91, 43 ], [ 50, 47 ], [ 94, 48 ], [ 91, 48 ], [ 94, 54 ], [ 91, 54 ], [ 94, 59 ], [ 91, 59 ], [ 94, 64 ], [ 91, 64 ], [ 94, 69 ], [ 91, 69 ], [ 94, 77 ], [ 91, 77 ], [ 87, 85 ], [ 87, 88 ], [ 90, 91 ], [ 93, 94 ] ]
[ "K, T = map(int, input().split())\nA = [int(i) for i in input().split()]\n\nA = sorted(A, reverse=True)\nwhile len(A) > 1:\n A[0] -= 1\n A[-1] -=1\n if A[0] == 0:\n del A[0]\n if A[-1] == 0:\n del A[-1]\n\nif A:\n print(A[0]-1)\nelse:\n print(0)", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "int(i) for i in input().split()", "for i in input().split()", "i", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)", "int", "i", "A = [int(i) for i in input().split()]", "A", "[int(i) for i in input().split()]", "A = sorted(A, reverse=True)", "A", "sorted(A, reverse=True)", "sorted", "A", "reverse=True", "reverse", "True", "while len(A) > 1:\n A[0] -= 1\n A[-1] -=1\n if A[0] == 0:\n del A[0]\n if A[-1] == 0:\n del A[-1]", "len(A) > 1", "len(A)", "len", "A", "1", "A[0] -= 1", "A[0]", "A", "0", "1", "A[-1] -=1", "A[-1]", "A", "-1", "1", "if A[0] == 0:\n del A[0]\n ", "A[0] == 0", "A[0]", "A", "0", "0", "del A[0]", "A[0]", "A", "0", "if A[-1] == 0:\n del A[-1]", "A[-1] == 0", "A[-1]", "A", "-1", "0", "del A[-1]", "A[-1]", "A", "-1", "if A:\n print(A[0]-1)\nelse:\n print(0)", "A", "print(A[0]-1)", "print", "A[0]-1", "A[0]", "A", "0", "1", "print(0)", "print", "0", "T = map(int, input().split())", "map(int, input().split())", "T", "K, T = map(int, input().split())", "map(int, input().split())", "K", "A = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "A", "A = sorted(A, reverse=True)", "sorted(A, reverse=True)", "A" ]
K, T = map(int, input().split()) A = [int(i) for i in input().split()] A = sorted(A, reverse=True) while len(A) > 1: A[0] -= 1 A[-1] -=1 if A[0] == 0: del A[0] if A[-1] == 0: del A[-1] if A: print(A[0]-1) else: print(0)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 17, 28, 13, 18, 13, 39, 17, 0, 13, 4, 13, 2, 13, 13, 4, 13, 4, 13, 2, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 65, 2 ], [ 65, 11 ], [ 56, 13 ], [ 57, 26 ], [ 62, 29 ], [ 33, 32 ], [ 57, 34 ], [ 59, 38 ], [ 63, 42 ], [ 60, 42 ], [ 32, 43 ], [ 60, 49 ], [ 63, 49 ], [ 65, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "k, t = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\n\nb = 0\nfor i in a[::-1]:\n b = abs(b-i)\nprint(max(b-1, 0))", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort()", "a.sort", "a", "sort", "b = 0", "b", "0", "for i in a[::-1]:\n b = abs(b-i)", "i", "a[::-1]", "a", "::-1", "-1", "b = abs(b-i)", "b", "abs(b-i)", "abs", "b-i", "b", "i", "print(max(b-1, 0))", "print", "max(b-1, 0)", "max", "b-1", "b", "1", "0", "k, t = map(int, input().split())", "map(int, input().split())", "k", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "b = abs(b-i)", "abs(b-i)", "b", "b = 0", "0", "b", "t = map(int, input().split())", "map(int, input().split())", "t" ]
k, t = map(int, input().split()) a = list(map(int, input().split())) a.sort() b = 0 for i in a[::-1]: b = abs(b-i) print(max(b-1, 0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 2, 2, 2, 17, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 48, 2 ], [ 48, 11 ], [ 51, 13 ], [ 42, 25 ], [ 52, 28 ], [ 43, 37 ], [ 49, 38 ], [ 42, 43 ], [ 48, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "n,k=map(int,input().split())\nt=list(map(int,input().split()))\nmt=max(t)\nprint(max(2*mt-n-1,0))", "n,k=map(int,input().split())", "n", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "k", "t=list(map(int,input().split()))", "t", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "mt=max(t)", "mt", "max(t)", "max", "t", "print(max(2*mt-n-1,0))", "print", "max(2*mt-n-1,0)", "max", "2*mt-n-1", "2*mt-n", "2*mt", "2", "mt", "n", "1", "0", "mt=max(t)", "max(t)", "mt", "k=map(int,input().split())", "map(int,input().split())", "k", "n,k=map(int,input().split())", "map(int,input().split())", "n", "t=list(map(int,input().split()))", "list(map(int,input().split()))", "t" ]
n,k=map(int,input().split()) t=list(map(int,input().split())) mt=max(t) print(max(2*mt-n-1,0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 18, 13, 17, 0, 13, 2, 4, 13, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 14, 2, 13, 17, 4, 13, 4, 13, 2, 2, 18, 13, 17, 17, 13, 17, 4, 13, 14, 2, 2, 13, 17, 13, 4, 13, 2, 2, 13, 17, 13, 4, 13, 17, 10, 4, 13, 10, 18, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 102, 2 ], [ 102, 11 ], [ 96, 13 ], [ 99, 25 ], [ 97, 28 ], [ 90, 30 ], [ 100, 32 ], [ 97, 32 ], [ 93, 35 ], [ 100, 39 ], [ 97, 39 ], [ 91, 40 ], [ 88, 43 ], [ 103, 48 ], [ 88, 54 ], [ 100, 63 ], [ 97, 63 ], [ 94, 66 ], [ 91, 73 ], [ 94, 75 ], [ 91, 80 ], [ 94, 82 ], [ 102, 88 ], [ 90, 91 ], [ 93, 94 ], [ 96, 97 ], [ 99, 100 ], [ 102, 103 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nA = sorted(A)\n\nAmax = A[-1]\n\nAtwo = sum(A)-Amax\n\nif T == 1:\n\tprint(K-1)\n\texit()\nif T ==2:\n\tprint(max(A[-1]-1-Atwo, 0))\n\texit()\n\nif Amax-1 > Atwo:\n\tprint(Amax-1-Atwo)\nelse:\n\tprint(0)", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "A = sorted(A)", "A", "sorted(A)", "sorted", "A", "Amax = A[-1]", "Amax", "A[-1]", "A", "-1", "Atwo = sum(A)-Amax", "Atwo", "sum(A)-Amax", "sum(A)", "sum", "A", "Amax", "if T == 1:\n\tprint(K-1)\n\texit()", "T == 1", "T", "1", "print(K-1)", "print", "K-1", "K", "1", "exit()", "exit", "if T ==2:\n\tprint(max(A[-1]-1-Atwo, 0))\n\texit()", "T ==2", "T", "2", "print(max(A[-1]-1-Atwo, 0))", "print", "max(A[-1]-1-Atwo, 0)", "max", "A[-1]-1-Atwo", "A[-1]-1", "A[-1]", "A", "-1", "1", "Atwo", "0", "exit()", "exit", "if Amax-1 > Atwo:\n\tprint(Amax-1-Atwo)\nelse:\n\tprint(0)", "Amax-1 > Atwo", "Amax-1", "Amax", "1", "Atwo", "print(Amax-1-Atwo)", "print", "Amax-1-Atwo", "Amax-1", "Amax", "1", "Atwo", "print(0)", "print", "0", "T = map(int, input().split())", "map(int, input().split())", "T", "Amax = A[-1]", "A[-1]", "Amax", "Atwo = sum(A)-Amax", "sum(A)-Amax", "Atwo", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "A = sorted(A)", "sorted(A)", "A", "K, T = map(int, input().split())", "map(int, input().split())", "K" ]
K, T = map(int, input().split()) A = list(map(int, input().split())) A = sorted(A) Amax = A[-1] Atwo = sum(A)-Amax if T == 1: print(K-1) exit() if T ==2: print(max(A[-1]-1-Atwo, 0)) exit() if Amax-1 > Atwo: print(Amax-1-Atwo) else: print(0)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 28, 13, 4, 13, 2, 13, 17, 28, 13, 4, 13, 2, 13, 17, 13, 14, 2, 18, 13, 13, 17, 3, 0, 13, 4, 13, 18, 13, 13, 18, 13, 13, 0, 18, 13, 13, 13, 0, 18, 13, 13, 13, 4, 13, 4, 13, 2, 4, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 98, 2 ], [ 98, 11 ], [ 86, 13 ], [ 95, 25 ], [ 87, 32 ], [ 35, 34 ], [ 90, 38 ], [ 42, 41 ], [ 34, 45 ], [ 90, 47 ], [ 66, 50 ], [ 96, 51 ], [ 87, 51 ], [ 34, 52 ], [ 92, 56 ], [ 66, 59 ], [ 96, 60 ], [ 87, 60 ], [ 34, 61 ], [ 71, 62 ], [ 96, 63 ], [ 87, 63 ], [ 41, 64 ], [ 69, 66 ], [ 96, 67 ], [ 87, 67 ], [ 34, 68 ], [ 93, 69 ], [ 74, 71 ], [ 96, 72 ], [ 87, 72 ], [ 41, 73 ], [ 93, 74 ], [ 96, 82 ], [ 87, 82 ], [ 86, 87 ], [ 98, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ] ]
[ "k,t = map(int, input().split())\na = list(map(int, input().split()))\na = list(reversed(sorted(a)))\n\nfor i in range(t-1):\n for j in range(i+1,t):\n if a[i] == 0:\n break\n x = min(a[i], a[j])\n a[i] -= x\n a[j] -= x\nprint(max(sum(a)-1, 0))", "k,t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a = list(reversed(sorted(a)))", "a", "list(reversed(sorted(a)))", "list", "reversed(sorted(a))", "reversed", "sorted(a)", "sorted", "a", "for i in range(t-1):\n for j in range(i+1,t):\n if a[i] == 0:\n break\n x = min(a[i], a[j])\n a[i] -= x\n a[j] -= x", "i", "range(t-1)", "range", "t-1", "t", "1", "for j in range(i+1,t):\n if a[i] == 0:\n break\n x = min(a[i], a[j])\n a[i] -= x\n a[j] -= x", "j", "range(i+1,t)", "range", "i+1", "i", "1", "t", "if a[i] == 0:\n break\n ", "a[i] == 0", "a[i]", "a", "i", "0", "break", "x = min(a[i], a[j])", "x", "min(a[i], a[j])", "min", "a[i]", "a", "i", "a[j]", "a", "j", "a[i] -= x", "a[i]", "a", "i", "x", "a[j] -= x", "a[j]", "a", "j", "x", "print(max(sum(a)-1, 0))", "print", "max(sum(a)-1, 0)", "max", "sum(a)-1", "sum(a)", "sum", "a", "1", "0", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "t = map(int, input().split())", "map(int, input().split())", "t", "x = min(a[i], a[j])", "min(a[i], a[j])", "x", "a = list(reversed(sorted(a)))", "list(reversed(sorted(a)))", "a", "k,t = map(int, input().split())", "map(int, input().split())", "k" ]
k,t = map(int, input().split()) a = list(map(int, input().split())) a = list(reversed(sorted(a))) for i in range(t-1): for j in range(i+1,t): if a[i] == 0: break x = min(a[i], a[j]) a[i] -= x a[j] -= x print(max(sum(a)-1, 0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 14, 40, 2, 13, 17, 4, 13, 13, 4, 13, 2, 2, 13, 17, 4, 13, 13, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 76, 2 ], [ 76, 11 ], [ 73, 13 ], [ 70, 25 ], [ 74, 28 ], [ 74, 32 ], [ 74, 36 ], [ 77, 39 ], [ 68, 44 ], [ 71, 49 ], [ 74, 53 ], [ 71, 58 ], [ 74, 62 ], [ 76, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "k,t = map(int,input().split())\na_list = list(map(int,input().split()))\na_max = a_list.pop(a_list.index(max(a_list)))\n\nif t == 1:\n print(k-1)\n \nelse:\n if a_max - 1 >= sum(a_list):\n print(a_max - 1 - sum(a_list))\n else:\n print(0)", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a_list = list(map(int,input().split()))", "a_list", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a_max = a_list.pop(a_list.index(max(a_list)))", "a_max", "a_list.pop(a_list.index(max(a_list)))", "a_list.pop", "a_list", "pop", "a_list.index(max(a_list))", "a_list.index", "a_list", "index", "max(a_list)", "max", "a_list", "if t == 1:\n print(k-1)\n \nelse:\n if a_max - 1 >= sum(a_list):\n print(a_max - 1 - sum(a_list))\n else:\n print(0)", "t == 1", "t", "1", "print(k-1)", "print", "k-1", "k", "1", "if a_max - 1 >= sum(a_list):\n print(a_max - 1 - sum(a_list))\n else:\n print(0)", "a_max - 1 >= sum(a_list)", "a_max - 1", "a_max", "1", "sum(a_list)", "sum", "a_list", "print(a_max - 1 - sum(a_list))", "print", "a_max - 1 - sum(a_list)", "a_max - 1", "a_max", "1", "sum(a_list)", "sum", "a_list", "print(0)", "print", "0", "k,t = map(int,input().split())", "map(int,input().split())", "k", "a_max = a_list.pop(a_list.index(max(a_list)))", "a_list.pop(a_list.index(max(a_list)))", "a_max", "a_list = list(map(int,input().split()))", "list(map(int,input().split()))", "a_list", "t = map(int,input().split())", "map(int,input().split())", "t" ]
k,t = map(int,input().split()) a_list = list(map(int,input().split())) a_max = a_list.pop(a_list.index(max(a_list))) if t == 1: print(k-1) else: if a_max - 1 >= sum(a_list): print(a_max - 1 - sum(a_list)) else: print(0)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 13, 13, 4, 13, 4, 13, 2, 2, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 57, 11 ], [ 48, 13 ], [ 54, 25 ], [ 49, 28 ], [ 51, 30 ], [ 46, 32 ], [ 55, 33 ], [ 55, 40 ], [ 52, 41 ], [ 57, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "k,t=map(int,input().split())\na=list(map(int,input().split()))\nm=max(a)\nn=k-m\nprint(max(m-n-1,0))", "k,t=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m=max(a)", "m", "max(a)", "max", "a", "n=k-m", "n", "k-m", "k", "m", "print(max(m-n-1,0))", "print", "max(m-n-1,0)", "max", "m-n-1", "m-n", "m", "n", "1", "0", "k,t=map(int,input().split())", "map(int,input().split())", "k", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "n=k-m", "k-m", "n", "m=max(a)", "max(a)", "m", "t=map(int,input().split())", "map(int,input().split())", "t" ]
k,t=map(int,input().split()) a=list(map(int,input().split())) m=max(a) n=k-m print(max(m-n-1,0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 2, 2, 2, 17, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 45, 2 ], [ 45, 11 ], [ 48, 13 ], [ 51, 25 ], [ 49, 28 ], [ 52, 37 ], [ 43, 38 ], [ 45, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=max(a)\nprint(max(2*s-n-1,0))", "n,k=map(int,input().split())", "n", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "k", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "s=max(a)", "s", "max(a)", "max", "a", "print(max(2*s-n-1,0))", "print", "max(2*s-n-1,0)", "max", "2*s-n-1", "2*s-n", "2*s", "2", "s", "n", "1", "0", "n,k=map(int,input().split())", "map(int,input().split())", "n", "k=map(int,input().split())", "map(int,input().split())", "k", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "s=max(a)", "max(a)", "s" ]
n,k=map(int,input().split()) a=list(map(int,input().split())) s=max(a) print(max(2*s-n-1,0))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 2, 18, 13, 17, 17, 28, 13, 4, 13, 17, 13, 0, 13, 18, 13, 13, 14, 2, 13, 17, 0, 13, 17, 3, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 68, 2 ], [ 68, 11 ], [ 74, 13 ], [ 77, 25 ], [ 75, 28 ], [ 31, 30 ], [ 80, 33 ], [ 78, 36 ], [ 75, 36 ], [ 41, 40 ], [ 69, 44 ], [ 71, 46 ], [ 78, 48 ], [ 75, 48 ], [ 40, 49 ], [ 72, 52 ], [ 81, 52 ], [ 63, 52 ], [ 62, 55 ], [ 63, 60 ], [ 72, 60 ], [ 81, 60 ], [ 62, 63 ], [ 68, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ] ]
[ "K,T=map(int,input().split())\nA=list(map(int,input().split()))\nA=sorted(A,reverse=True) #大きい順\nans=A[0]-1 #被る日\nfor i in range(1,T): \n ans-=A[i]\n if ans<0:\n ans=0\n break\nprint(ans)", "K,T=map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A=list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "A=sorted(A,reverse=True)", "A", "sorted(A,reverse=True)", "sorted", "A", "reverse=True", "reverse", "True", "ans=A[0]-1", "ans", "A[0]-1", "A[0]", "A", "0", "1", "for i in range(1,T): \n ans-=A[i]\n if ans<0:\n ans=0\n break", "i", "range(1,T)", "range", "1", "T", "ans-=A[i]", "ans", "A[i]", "A", "i", "if ans<0:\n ans=0\n break", "ans<0", "ans", "0", "ans=0", "ans", "0", "break", "print(ans)", "print", "ans", "ans=0", "0", "ans", "K,T=map(int,input().split())", "map(int,input().split())", "K", "T=map(int,input().split())", "map(int,input().split())", "T", "ans-=A[i]", "A[i]", "ans", "A=list(map(int,input().split()))", "list(map(int,input().split()))", "A", "A=sorted(A,reverse=True)", "sorted(A,reverse=True)", "A", "ans=A[0]-1", "A[0]-1", "ans" ]
K,T=map(int,input().split()) A=list(map(int,input().split())) A=sorted(A,reverse=True) #大きい順 ans=A[0]-1 #被る日 for i in range(1,T): ans-=A[i] if ans<0: ans=0 break print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 8, 2, 18, 13, 17, 2, 13, 17, 2, 2, 2, 17, 18, 13, 17, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 53, 2 ], [ 53, 11 ], [ 47, 13 ], [ 48, 31 ], [ 51, 34 ], [ 48, 41 ], [ 51, 43 ], [ 47, 48 ], [ 53, 51 ], [ 53, 54 ] ]
[ "k, t = map(int, input().split())\na = sorted(list(map(int, input().split())))\nprint(2 * a[-1] - k - 1 if a[-1] > k // 2 else 0)", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = sorted(list(map(int, input().split())))", "a", "sorted(list(map(int, input().split())))", "sorted", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(2 * a[-1] - k - 1 if a[-1] > k // 2 else 0)", "print", "2 * a[-1] - k - 1 if a[-1] > k // 2 else 0", "a[-1] > k // 2", "a[-1]", "a", "-1", "k // 2", "k", "2", "2 * a[-1] - k - 1", "2 * a[-1] - k", "2 * a[-1]", "2", "a[-1]", "a", "-1", "k", "1", "0", "a = sorted(list(map(int, input().split())))", "sorted(list(map(int, input().split())))", "a", "k, t = map(int, input().split())", "map(int, input().split())", "k", "t = map(int, input().split())", "map(int, input().split())", "t" ]
k, t = map(int, input().split()) a = sorted(list(map(int, input().split()))) print(2 * a[-1] - k - 1 if a[-1] > k // 2 else 0)
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 12, 13, 29, 4, 18, 4, 18, 18, 13, 13, 13, 13, 14, 2, 13, 17, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 18, 13, 13, 28, 13, 13, 4, 18, 13, 13, 40, 13, 0, 13, 4, 18, 13, 13, 0, 13, 17, 42, 40, 4, 18, 13, 13, 0, 13, 40, 4, 18, 13, 13, 14, 40, 4, 18, 13, 13, 4, 18, 13, 13, 4, 18, 13, 13, 14, 4, 18, 13, 13, 0, 13, 17, 14, 2, 2, 13, 17, 17, 0, 13, 17, 4, 18, 13, 13, 40, 13, 9, 3, 14, 2, 2, 13, 17, 17, 0, 13, 17, 4, 18, 13, 13, 40, 13, 4, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 40, 13, 10, 17, 13 ]
[ [ 163, 26 ], [ 167, 33 ], [ 163, 35 ], [ 145, 37 ], [ 167, 46 ], [ 160, 49 ], [ 56, 55 ], [ 146, 55 ], [ 161, 59 ], [ 55, 62 ], [ 169, 64 ], [ 151, 70 ], [ 161, 76 ], [ 172, 79 ], [ 161, 83 ], [ 170, 89 ], [ 161, 93 ], [ 170, 97 ], [ 161, 102 ], [ 175, 105 ], [ 173, 110 ], [ 158, 110 ], [ 155, 110 ], [ 154, 114 ], [ 161, 118 ], [ 155, 121 ], [ 173, 121 ], [ 158, 121 ], [ 155, 127 ], [ 173, 127 ], [ 158, 127 ], [ 157, 131 ], [ 170, 135 ], [ 158, 138 ], [ 155, 138 ], [ 173, 138 ], [ 176, 142 ], [ 152, 142 ], [ 145, 146 ], [ 163, 149 ], [ 151, 152 ], [ 154, 155 ], [ 157, 158 ], [ 160, 161 ], [ 163, 164 ], [ 169, 170 ], [ 172, 173 ], [ 175, 176 ] ]
[ "import sys\nimport math # noqa\nimport bisect # noqa\nimport queue # noqa\n\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\nif __name__ == '__main__':\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n que = queue.PriorityQueue()\n for a in A:\n que.put(-a)\n\n que2 = queue.Queue()\n\n ans = 0\n while not que.empty():\n n = -que.get()\n if not que2.empty():\n que.put(que2.get())\n if que.empty():\n ans += 1\n if n - 1 > 0:\n n -= 1\n que.put(-n)\n continue\n else:\n break\n if n - 1 > 0:\n n -= 1\n que2.put(-n)\n\n print(ans - 1)", "import sys", "sys", "import math", "math", "import bisect", "bisect", "import queue", "queue", "def input():\n return sys.stdin.readline().rstrip()", "input", "return sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "if __name__ == '__main__':\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n que = queue.PriorityQueue()\n for a in A:\n que.put(-a)\n\n que2 = queue.Queue()\n\n ans = 0\n while not que.empty():\n n = -que.get()\n if not que2.empty():\n que.put(que2.get())\n if que.empty():\n ans += 1\n if n - 1 > 0:\n n -= 1\n que.put(-n)\n continue\n else:\n break\n if n - 1 > 0:\n n -= 1\n que2.put(-n)\n\n print(ans - 1)", "__name__ == '__main__'", "__name__", "'__main__'", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "que = queue.PriorityQueue()", "que", "queue.PriorityQueue()", "queue.PriorityQueue", "queue", "PriorityQueue", "for a in A:\n que.put(-a)\n\n ", "a", "A", "que.put(-a)", "que.put", "que", "put", "-a", "a", "que2 = queue.Queue()", "que2", "queue.Queue()", "queue.Queue", "queue", "Queue", "ans = 0", "ans", "0", "while not que.empty():\n n = -que.get()\n if not que2.empty():\n que.put(que2.get())\n if que.empty():\n ans += 1\n if n - 1 > 0:\n n -= 1\n que.put(-n)\n continue\n else:\n break\n if n - 1 > 0:\n n -= 1\n que2.put(-n)\n\n ", "not que.empty()", "que.empty()", "que.empty", "que", "empty", "n = -que.get()", "n", "-que.get()", "que.get()", "que.get", "que", "get", "if not que2.empty():\n que.put(que2.get())\n ", "not que2.empty()", "que2.empty()", "que2.empty", "que2", "empty", "que.put(que2.get())", "que.put", "que", "put", "que2.get()", "que2.get", "que2", "get", "if que.empty():\n ans += 1\n if n - 1 > 0:\n n -= 1\n que.put(-n)\n continue\n else:\n break\n ", "que.empty()", "que.empty", "que", "empty", "ans += 1", "ans", "1", "if n - 1 > 0:\n n -= 1\n que.put(-n)\n continue\n else:\n break\n ", "n - 1 > 0", "n - 1", "n", "1", "0", "n -= 1", "n", "1", "que.put(-n)", "que.put", "que", "put", "-n", "n", "continue", "break", "if n - 1 > 0:\n n -= 1\n que2.put(-n)\n\n ", "n - 1 > 0", "n - 1", "n", "1", "0", "n -= 1", "n", "1", "que2.put(-n)", "que2.put", "que2", "put", "-n", "n", "print(ans - 1)", "print", "ans - 1", "ans", "1", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "T = map(int, input().split())", "map(int, input().split())", "T", "ans = 0", "0", "ans", "n -= 1", "1", "n", "n -= 1", "1", "n", "que = queue.PriorityQueue()", "queue.PriorityQueue()", "que", "K, T = map(int, input().split())", "map(int, input().split())", "K", "def input():\n return sys.stdin.readline().rstrip()", "def input():\n return sys.stdin.readline().rstrip()", "input", "que2 = queue.Queue()", "queue.Queue()", "que2", "n = -que.get()", "-que.get()", "n", "ans += 1", "1", "ans" ]
import sys import math # noqa import bisect # noqa import queue # noqa def input(): return sys.stdin.readline().rstrip() if __name__ == '__main__': K, T = map(int, input().split()) A = list(map(int, input().split())) que = queue.PriorityQueue() for a in A: que.put(-a) que2 = queue.Queue() ans = 0 while not que.empty(): n = -que.get() if not que2.empty(): que.put(que2.get()) if que.empty(): ans += 1 if n - 1 > 0: n -= 1 que.put(-n) continue else: break if n - 1 > 0: n -= 1 que2.put(-n) print(ans - 1)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 17, 2, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 51, 11 ], [ 48, 13 ], [ 45, 25 ], [ 49, 28 ], [ 46, 36 ], [ 43, 39 ], [ 46, 40 ], [ 51, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "k,t = map(int, input().split())\nA = list(map(int,input().split()))\n\nmaxnum = max(A)\nprint(max(0, maxnum-1-(k-maxnum)))", "k,t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "maxnum = max(A)", "maxnum", "max(A)", "max", "A", "print(max(0, maxnum-1-(k-maxnum)))", "print", "max(0, maxnum-1-(k-maxnum))", "max", "0", "maxnum-1-(k-maxnum)", "maxnum-1", "maxnum", "1", "k-maxnum", "k", "maxnum", "k,t = map(int, input().split())", "map(int, input().split())", "k", "maxnum = max(A)", "max(A)", "maxnum", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "t = map(int, input().split())", "map(int, input().split())", "t" ]
k,t = map(int, input().split()) A = list(map(int,input().split())) maxnum = max(A) print(max(0, maxnum-1-(k-maxnum)))
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 17, 2, 2, 18, 13, 17, 4, 13, 18, 13, 39, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 49, 2 ], [ 49, 11 ], [ 52, 13 ], [ 53, 26 ], [ 53, 36 ], [ 53, 41 ], [ 49, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\n\na.sort()\n\nprint(max(0, a[-1] - sum(a[:-1]) - 1))", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort()", "a.sort", "a", "sort", "print(max(0, a[-1] - sum(a[:-1]) - 1))", "print", "max(0, a[-1] - sum(a[:-1]) - 1)", "max", "0", "a[-1] - sum(a[:-1]) - 1", "a[-1] - sum(a[:-1])", "a[-1]", "a", "-1", "sum(a[:-1])", "sum", "a[:-1]", "a", ":-1", "-1", "1", "k,t = map(int,input().split())", "map(int,input().split())", "k", "t = map(int,input().split())", "map(int,input().split())", "t", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
k,t = map(int,input().split()) a = list(map(int,input().split())) a.sort() print(max(0, a[-1] - sum(a[:-1]) - 1))
[ 7, 12, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 2, 17, 13, 17, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 15 ], [ 18, 17 ], [ 30, 29 ], [ 17, 32 ], [ 29, 42 ], [ 4, 44 ], [ 53, 50 ] ]
[ "def main():\n K, T = list(map(int, input().split()))\n A = list(map(int, input().split()))\n max_a = max(A)\n print(max(0, 2 * max_a - 1 - K))\n\n\nif __name__ == '__main__':\n main()", "def main():\n K, T = list(map(int, input().split()))\n A = list(map(int, input().split()))\n max_a = max(A)\n print(max(0, 2 * max_a - 1 - K))", "main", "K, T = list(map(int, input().split()))", "K", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "max_a = max(A)", "max_a", "max(A)", "max", "A", "print(max(0, 2 * max_a - 1 - K))", "print", "max(0, 2 * max_a - 1 - K)", "max", "0", "2 * max_a - 1 - K", "2 * max_a - 1", "2 * max_a", "2", "max_a", "1", "K", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n K, T = list(map(int, input().split()))\n A = list(map(int, input().split()))\n max_a = max(A)\n print(max(0, 2 * max_a - 1 - K))", "def main():\n K, T = list(map(int, input().split()))\n A = list(map(int, input().split()))\n max_a = max(A)\n print(max(0, 2 * max_a - 1 - K))", "main" ]
def main(): K, T = list(map(int, input().split())) A = list(map(int, input().split())) max_a = max(A) print(max(0, 2 * max_a - 1 - K)) if __name__ == '__main__': main()
[ 7, 15, 13, 0, 13, 39, 17, 17, 17, 0, 13, 17, 0, 13, 18, 13, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 12, 13, 0, 13, 13, 0, 13, 2, 2, 2, 13, 2, 13, 17, 13, 2, 13, 2, 13, 17, 14, 40, 13, 13, 29, 17, 29, 17, 23, 13, 23, 13, 23, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 4, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 4, 13, 13, 0, 13, 18, 13, 17, 0, 13, 2, 13, 13, 0, 13, 4, 13, 17, 2, 2, 13, 2, 13, 17, 17, 4, 13, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 4, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 2, 39, 17, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 28, 13, 4, 13, 13, 0, 18, 13, 13, 13, 0, 13, 17, 14, 40, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 13, 0, 13, 17, 0, 13, 13, 29, 13, 0, 13, 17, 12, 13, 14, 13, 4, 13, 13, 23, 13, 12, 13, 15, 13, 0, 13, 4, 18, 13, 13, 0, 13, 4, 18, 13, 13, 28, 13, 13, 27, 13, 14, 2, 13, 17, 14, 2, 18, 13, 13, 17, 14, 2, 13, 18, 13, 17, 0, 13, 4, 13, 0, 13, 12, 4, 18, 13, 13, 14, 2, 13, 18, 13, 17, 0, 18, 13, 13, 4, 13, 17, 0, 13, 17, 0, 13, 4, 13, 14, 40, 13, 17, 4, 13, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 39, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 303, 4 ], [ 309, 10 ], [ 288, 13 ], [ 304, 15 ], [ 310, 16 ], [ 300, 18 ], [ 312, 29 ], [ 35, 34 ], [ 60, 35 ], [ 38, 37 ], [ 62, 41 ], [ 64, 43 ], [ 64, 45 ], [ 62, 47 ], [ 64, 49 ], [ 34, 53 ], [ 37, 54 ], [ 60, 60 ], [ 62, 62 ], [ 64, 64 ], [ 69, 68 ], [ 301, 70 ], [ 69, 71 ], [ 74, 73 ], [ 301, 77 ], [ 73, 80 ], [ 84, 83 ], [ 87, 86 ], [ 73, 89 ], [ 92, 91 ], [ 73, 93 ], [ 97, 96 ], [ 86, 98 ], [ 91, 99 ], [ 102, 101 ], [ 86, 107 ], [ 96, 109 ], [ 101, 114 ], [ 119, 118 ], [ 301, 120 ], [ 119, 121 ], [ 124, 123 ], [ 301, 127 ], [ 123, 130 ], [ 134, 133 ], [ 137, 136 ], [ 118, 140 ], [ 143, 142 ], [ 123, 149 ], [ 152, 151 ], [ 159, 156 ], [ 136, 157 ], [ 142, 158 ], [ 168, 158 ], [ 161, 158 ], [ 162, 161 ], [ 161, 165 ], [ 142, 165 ], [ 168, 165 ], [ 118, 166 ], [ 169, 168 ], [ 172, 171 ], [ 175, 174 ], [ 178, 177 ], [ 136, 177 ], [ 174, 181 ], [ 187, 181 ], [ 177, 182 ], [ 185, 184 ], [ 188, 187 ], [ 177, 188 ], [ 184, 190 ], [ 171, 190 ], [ 291, 192 ], [ 202, 200 ], [ 202, 202 ], [ 209, 208 ], [ 215, 214 ], [ 208, 217 ], [ 221, 220 ], [ 214, 220 ], [ 220, 223 ], [ 289, 236 ], [ 304, 238 ], [ 315, 241 ], [ 322, 243 ], [ 285, 245 ], [ 316, 249 ], [ 289, 253 ], [ 304, 255 ], [ 261, 258 ], [ 294, 265 ], [ 306, 268 ], [ 280, 270 ], [ 307, 273 ], [ 307, 277 ], [ 285, 286 ], [ 288, 289 ], [ 291, 292 ], [ 294, 295 ], [ 300, 301 ], [ 303, 304 ], [ 306, 307 ], [ 309, 310 ], [ 312, 313 ], [ 315, 316 ] ]
[ "import sys\n\ninput_methods=['clipboard','file','key']\nusing_method=0\ninput_method=input_methods[using_method]\n\nIN=lambda : map(int, input().split())\nmod=1000000007\n\n#+++++\n\ndef can_set(al_max ,k,cc):\n\ta=al_max\n\taa=((k//(cc+1))*cc) + (k%(cc+1))\n\t#pa((a,cc,aa))\n\tif a <= aa:\n\t\treturn True\n\treturn False\n\ndef main():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\t#pa(al)\n\t\n\t#if al[0] <= (k+1)//2:\n\t#\treturn 0\n\t#if al[0] == k:\n\t#\treturn k-1\n\ttt=sum(al)\n\tmm=al[0]\n\tnokori=tt-mm\n\tret = max(0, tt - nokori*2-1)\n\tprint(ret)\n\t\n\t\n\ndef main2():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\tttt=[0]*k\n\tp=0\n\tfor i, v in enumerate(al):\n\t\tfor _ in range(v):\n\t\t\tttt[p]=i\n\t\t\tp+=2\n\t\t\tif p >= k:\n\t\t\t\tp=1\n\t\n\tcc=0\n\tpre=-1\n\tfor v in ttt:\n\t\tif pre == v:\n\t\t\tcc+=1\n\t\telse:\n\t\t\tpre=v\n\t\t\t\n\treturn cc\n\t\n\t\n\t\n\t\n#+++++\nisTest=False\n\ndef pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t\ndef input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l\n\nif __name__ == \"__main__\":\n\tif sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\t#input = sys.stdin.readline\n\t\t\t\n\tret = main()\n\tif ret is not None:\n\t\tprint(ret)", "import sys", "sys", "input_methods=['clipboard','file','key']", "input_methods", "['clipboard','file','key']", "'clipboard'", "'file'", "'key'", "using_method=0", "using_method", "0", "input_method=input_methods[using_method]", "input_method", "input_methods[using_method]", "input_methods", "using_method", "IN=lambda : map(int, input().split())", "IN", "lambda : map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "mod=1000000007", "mod", "1000000007", "def can_set(al_max ,k,cc):\n\ta=al_max\n\taa=((k//(cc+1))*cc) + (k%(cc+1))\n\t#pa((a,cc,aa))\n\tif a <= aa:\n\t\treturn True\n\treturn False", "can_set", "a=al_max", "a", "al_max", "aa=((k//(cc+1))*cc) + (k%(cc+1))", "aa", "((k//(cc+1))*cc) + (k%(cc+1))", "(k//(cc+1))*cc", "k//(cc+1)", "k", "cc+1", "cc", "1", "cc", "k%(cc+1)", "k", "cc+1", "cc", "1", "if a <= aa:\n\t\treturn True\n\t", "a <= aa", "a", "aa", "return True", "True", "return False", "False", "al_max", "al_max", "k", "k", "cc", "cc", "def main():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\t#pa(al)\n\t\n\t#if al[0] <= (k+1)//2:\n\t#\treturn 0\n\t#if al[0] == k:\n\t#\treturn k-1\n\ttt=sum(al)\n\tmm=al[0]\n\tnokori=tt-mm\n\tret = max(0, tt - nokori*2-1)\n\tprint(ret)\n\t\n\t", "main", "k, t = IN()", "k", "IN()", "IN", "t", "al = list(IN())", "al", "list(IN())", "list", "IN()", "IN", "al.sort(reverse=True)", "al.sort", "al", "sort", "reverse=True", "reverse", "True", "tt=sum(al)", "tt", "sum(al)", "sum", "al", "mm=al[0]", "mm", "al[0]", "al", "0", "nokori=tt-mm", "nokori", "tt-mm", "tt", "mm", "ret = max(0, tt - nokori*2-1)", "ret", "max(0, tt - nokori*2-1)", "max", "0", "tt - nokori*2-1", "tt - nokori*2", "tt", "nokori*2", "nokori", "2", "1", "print(ret)", "print", "ret", "def main2():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\tttt=[0]*k\n\tp=0\n\tfor i, v in enumerate(al):\n\t\tfor _ in range(v):\n\t\t\tttt[p]=i\n\t\t\tp+=2\n\t\t\tif p >= k:\n\t\t\t\tp=1\n\t\n\tcc=0\n\tpre=-1\n\tfor v in ttt:\n\t\tif pre == v:\n\t\t\tcc+=1\n\t\telse:\n\t\t\tpre=v\n\t\t\t\n\treturn cc\n\t\n\t\n\t\n\t\n#+++++", "main2", "k, t = IN()", "k", "IN()", "IN", "t", "al = list(IN())", "al", "list(IN())", "list", "IN()", "IN", "al.sort(reverse=True)", "al.sort", "al", "sort", "reverse=True", "reverse", "True", "ttt=[0]*k", "ttt", "[0]*k", "[0]", "0", "k", "p=0", "p", "0", "for i, v in enumerate(al):\n\t\tfor _ in range(v):\n\t\t\tttt[p]=i\n\t\t\tp+=2\n\t\t\tif p >= k:\n\t\t\t\tp=1\n\t\n\t", "i", "v", "enumerate(al)", "enumerate", "al", "for _ in range(v):\n\t\t\tttt[p]=i\n\t\t\tp+=2\n\t\t\tif p >= k:\n\t\t\t\tp=1\n\t\n\t", "_", "range(v)", "range", "v", "ttt[p]=i", "ttt[p]", "ttt", "p", "i", "p+=2", "p", "2", "if p >= k:\n\t\t\t\tp=1\n\t\n\t", "p >= k", "p", "k", "p=1", "p", "1", "cc=0", "cc", "0", "pre=-1", "pre", "-1", "for v in ttt:\n\t\tif pre == v:\n\t\t\tcc+=1\n\t\telse:\n\t\t\tpre=v\n\t\t\t\n\t", "v", "ttt", "if pre == v:\n\t\t\tcc+=1\n\t\telse:\n\t\t\tpre=v\n\t\t\t\n\t", "pre == v", "pre", "v", "cc+=1", "cc", "1", "pre=v", "pre", "v", "return cc", "cc", "isTest=False", "isTest", "False", "def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t", "pa", "if isTest:\n\t\tprint(v)\n\t\t", "isTest", "print(v)", "print", "v", "v", "v", "def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l", "input_clipboard", "import clipboard", "clipboard", "input_text=clipboard.get()", "input_text", "clipboard.get()", "clipboard.get", "clipboard", "get", "input_l=input_text.splitlines()", "input_l", "input_text.splitlines()", "input_text.splitlines", "input_text", "splitlines", "for l in input_l:\n\t\tyield l", "l", "input_l", "yield l", "l", "if __name__ == \"__main__\":\n\tif sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\t#input = sys.stdin.readline\n\t\t\t\n\tret = main()\n\tif ret is not None:\n\t\tprint(ret)", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "if sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\t#input = sys.stdin.readline\n\t\t\t\n\t", "sys.platform =='ios'", "sys.platform", "sys", "platform", "'ios'", "if input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\t", "input_method==input_methods[0]", "input_method", "input_methods[0]", "input_methods", "0", "ic=input_clipboard()", "ic", "input_clipboard()", "input_clipboard", "input = lambda : ic.__next__()", "input", "lambda : ic.__next__()", "ic.__next__()", "ic.__next__", "ic", "__next__", "elif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\t", "input_method==input_methods[1]", "input_method", "input_methods[1]", "input_methods", "1", "sys.stdin=open('inputFile.txt')", "sys.stdin", "sys", "stdin", "open('inputFile.txt')", "open", "'inputFile.txt'", "isTest=True", "isTest", "True", "ret = main()", "ret", "main()", "main", "if ret is not None:\n\t\tprint(ret)", "ret is not None", "ret", "None", "print(ret)", "print", "ret", "def main():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\t#pa(al)\n\t\n\t#if al[0] <= (k+1)//2:\n\t#\treturn 0\n\t#if al[0] == k:\n\t#\treturn k-1\n\ttt=sum(al)\n\tmm=al[0]\n\tnokori=tt-mm\n\tret = max(0, tt - nokori*2-1)\n\tprint(ret)\n\t\n\t", "def main():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\t#pa(al)\n\t\n\t#if al[0] <= (k+1)//2:\n\t#\treturn 0\n\t#if al[0] == k:\n\t#\treturn k-1\n\ttt=sum(al)\n\tmm=al[0]\n\tnokori=tt-mm\n\tret = max(0, tt - nokori*2-1)\n\tprint(ret)\n\t\n\t", "main", "def main2():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\tttt=[0]*k\n\tp=0\n\tfor i, v in enumerate(al):\n\t\tfor _ in range(v):\n\t\t\tttt[p]=i\n\t\t\tp+=2\n\t\t\tif p >= k:\n\t\t\t\tp=1\n\t\n\tcc=0\n\tpre=-1\n\tfor v in ttt:\n\t\tif pre == v:\n\t\t\tcc+=1\n\t\telse:\n\t\t\tpre=v\n\t\t\t\n\treturn cc\n\t\n\t\n\t\n\t\n#+++++", "def main2():\n\tk, t = IN()\n\tal = list(IN())\n\tal.sort(reverse=True)\n\tttt=[0]*k\n\tp=0\n\tfor i, v in enumerate(al):\n\t\tfor _ in range(v):\n\t\t\tttt[p]=i\n\t\t\tp+=2\n\t\t\tif p >= k:\n\t\t\t\tp=1\n\t\n\tcc=0\n\tpre=-1\n\tfor v in ttt:\n\t\tif pre == v:\n\t\t\tcc+=1\n\t\telse:\n\t\t\tpre=v\n\t\t\t\n\treturn cc\n\t\n\t\n\t\n\t\n#+++++", "main2", "input = lambda : ic.__next__()", "lambda : ic.__next__()", "input", "input_method=input_methods[using_method]", "input_methods[using_method]", "input_method", "isTest=False", "False", "isTest", "isTest=True", "True", "isTest", "def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t", "def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t", "pa", "IN=lambda : map(int, input().split())", "lambda : map(int, input().split())", "IN", "input_methods=['clipboard','file','key']", "['clipboard','file','key']", "input_methods", "ret = main()", "main()", "ret", "using_method=0", "0", "using_method", "mod=1000000007", "1000000007", "mod", "ic=input_clipboard()", "input_clipboard()", "ic", "def can_set(al_max ,k,cc):\n\ta=al_max\n\taa=((k//(cc+1))*cc) + (k%(cc+1))\n\t#pa((a,cc,aa))\n\tif a <= aa:\n\t\treturn True\n\treturn False", "def can_set(al_max ,k,cc):\n\ta=al_max\n\taa=((k//(cc+1))*cc) + (k%(cc+1))\n\t#pa((a,cc,aa))\n\tif a <= aa:\n\t\treturn True\n\treturn False", "can_set", "def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l", "def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l", "input_clipboard" ]
import sys input_methods=['clipboard','file','key'] using_method=0 input_method=input_methods[using_method] IN=lambda : map(int, input().split()) mod=1000000007 #+++++ def can_set(al_max ,k,cc): a=al_max aa=((k//(cc+1))*cc) + (k%(cc+1)) #pa((a,cc,aa)) if a <= aa: return True return False def main(): k, t = IN() al = list(IN()) al.sort(reverse=True) #pa(al) #if al[0] <= (k+1)//2: # return 0 #if al[0] == k: # return k-1 tt=sum(al) mm=al[0] nokori=tt-mm ret = max(0, tt - nokori*2-1) print(ret) def main2(): k, t = IN() al = list(IN()) al.sort(reverse=True) ttt=[0]*k p=0 for i, v in enumerate(al): for _ in range(v): ttt[p]=i p+=2 if p >= k: p=1 cc=0 pre=-1 for v in ttt: if pre == v: cc+=1 else: pre=v return cc #+++++ isTest=False def pa(v): if isTest: print(v) def input_clipboard(): import clipboard input_text=clipboard.get() input_l=input_text.splitlines() for l in input_l: yield l if __name__ == "__main__": if sys.platform =='ios': if input_method==input_methods[0]: ic=input_clipboard() input = lambda : ic.__next__() elif input_method==input_methods[1]: sys.stdin=open('inputFile.txt') else: pass isTest=True else: pass #input = sys.stdin.readline ret = main() if ret is not None: print(ret)
[ 7, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 2, 13, 17, 17, 14, 40, 13, 13, 4, 13, 17, 0, 13, 2, 13, 13, 4, 13, 2, 2, 13, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 13 ], [ 16, 15 ], [ 28, 27 ], [ 15, 30 ], [ 33, 32 ], [ 4, 35 ], [ 27, 40 ], [ 32, 41 ], [ 47, 46 ], [ 4, 48 ], [ 27, 49 ], [ 27, 54 ], [ 46, 55 ], [ 65, 62 ] ]
[ "def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n max_a = max(A)\n limit = (K + 1)//2\n if max_a <= limit:\n print(0)\n else:\n remain = K - max_a\n print(max_a - remain - 1)\n\nif __name__ == '__main__':\n main()", "def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n max_a = max(A)\n limit = (K + 1)//2\n if max_a <= limit:\n print(0)\n else:\n remain = K - max_a\n print(max_a - remain - 1)", "main", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "max_a = max(A)", "max_a", "max(A)", "max", "A", "limit = (K + 1)//2", "limit", "(K + 1)//2", "K + 1", "K", "1", "2", "if max_a <= limit:\n print(0)\n else:\n remain = K - max_a\n print(max_a - remain - 1)", "max_a <= limit", "max_a", "limit", "print(0)", "print", "0", "remain = K - max_a", "remain", "K - max_a", "K", "max_a", "print(max_a - remain - 1)", "print", "max_a - remain - 1", "max_a - remain", "max_a", "remain", "1", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n max_a = max(A)\n limit = (K + 1)//2\n if max_a <= limit:\n print(0)\n else:\n remain = K - max_a\n print(max_a - remain - 1)", "def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n max_a = max(A)\n limit = (K + 1)//2\n if max_a <= limit:\n print(0)\n else:\n remain = K - max_a\n print(max_a - remain - 1)", "main" ]
def main(): K, T = map(int, input().split()) A = list(map(int, input().split())) max_a = max(A) limit = (K + 1)//2 if max_a <= limit: print(0) else: remain = K - max_a print(max_a - remain - 1) if __name__ == '__main__': main()
[ 7, 15, 13, 15, 12, 13, 29, 4, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 13, 13, 17, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 41, 28, 13, 4, 13, 13, 4, 39, 40, 18, 13, 13, 13, 0, 13, 13, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 42, 13, 0, 13, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 13, 14, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 18, 13, 17, 0, 18, 13, 17, 17, 14, 40, 18, 13, 17, 17, 4, 18, 13, 13, 13, 13, 0, 13, 17, 0, 13, 18, 13, 17, 0, 18, 13, 17, 17, 0, 18, 13, 17, 17, 0, 13, 18, 13, 17, 14, 40, 18, 13, 17, 17, 4, 18, 13, 13, 13, 13, 29, 13, 14, 2, 13, 17, 4, 13, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 35, 34 ], [ 165, 36 ], [ 35, 37 ], [ 40, 39 ], [ 165, 41 ], [ 45, 44 ], [ 37, 47 ], [ 39, 52 ], [ 44, 53 ], [ 57, 56 ], [ 56, 62 ], [ 65, 64 ], [ 68, 67 ], [ 73, 72 ], [ 56, 77 ], [ 72, 81 ], [ 64, 83 ], [ 134, 83 ], [ 119, 83 ], [ 94, 83 ], [ 88, 87 ], [ 56, 92 ], [ 95, 94 ], [ 87, 96 ], [ 102, 99 ], [ 87, 100 ], [ 87, 106 ], [ 56, 113 ], [ 87, 114 ], [ 117, 116 ], [ 120, 119 ], [ 72, 121 ], [ 127, 124 ], [ 72, 125 ], [ 132, 129 ], [ 72, 130 ], [ 135, 134 ], [ 72, 136 ], [ 72, 141 ], [ 56, 148 ], [ 72, 149 ], [ 116, 151 ], [ 67, 151 ], [ 168, 159 ] ]
[ "import heapq\nfrom typing import List, Any, Tuple\n\n\ndef read_int() -> int:\n return int(input().strip())\n\n\ndef read_ints() -> List[int]:\n return list(map(int, input().strip().split(' ')))\n\n\ndef solve() -> Any:\n K, T = read_ints()\n A = read_ints()\n cakes: List[List[int]] = [[-A[i], i] for i in range(T)]\n heapq.heapify(cakes)\n last_eaten = -1\n count = 0\n while cakes:\n frequent0 = heapq.heappop(cakes)\n if frequent0[1] == last_eaten:\n if cakes:\n frequent1 = heapq.heappop(cakes)\n last_eaten = frequent1[1]\n frequent1[0] += 1\n if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n else:\n count += 1\n last_eaten = frequent0[1]\n frequent0[0] += 1\n else:\n frequent0[0] += 1\n last_eaten = frequent0[1]\n if frequent0[0] != 0:\n heapq.heappush(cakes, frequent0)\n return count\n\n\nif __name__ == '__main__':\n print(solve())", "import heapq", "heapq", "from typing import List, Any, Tuple", "def read_int() -> int:\n return int(input().strip())", "read_int", "return int(input().strip())", "int(input().strip())", "int", "input().strip()", "().strip", "()", "input", "strip", "def read_ints() -> List[int]:\n return list(map(int, input().strip().split(' ')))", "read_ints", "return list(map(int, input().strip().split(' ')))", "list(map(int, input().strip().split(' ')))", "list", "map(int, input().strip().split(' '))", "map", "int", "input().strip().split(' ')", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "' '", "def solve() -> Any:\n K, T = read_ints()\n A = read_ints()\n cakes: List[List[int]] = [[-A[i], i] for i in range(T)]\n heapq.heapify(cakes)\n last_eaten = -1\n count = 0\n while cakes:\n frequent0 = heapq.heappop(cakes)\n if frequent0[1] == last_eaten:\n if cakes:\n frequent1 = heapq.heappop(cakes)\n last_eaten = frequent1[1]\n frequent1[0] += 1\n if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n else:\n count += 1\n last_eaten = frequent0[1]\n frequent0[0] += 1\n else:\n frequent0[0] += 1\n last_eaten = frequent0[1]\n if frequent0[0] != 0:\n heapq.heappush(cakes, frequent0)\n return count", "solve", "K, T = read_ints()", "K", "read_ints()", "read_ints", "T", "A = read_ints()", "A", "read_ints()", "read_ints", "[-A[i], i] for i in range(T)", "for i in range(T)", "i", "range(T)", "range", "T", "for i in range(T)", "[-A[i], i]", "-A[i]", "A[i]", "A", "i", "i", "cakes: List[List[int]] = [[-A[i], i] for i in range(T)]", "cakes", "[[-A[i], i] for i in range(T)]", "heapq.heapify(cakes)", "heapq.heapify", "heapq", "heapify", "cakes", "last_eaten = -1", "last_eaten", "-1", "count = 0", "count", "0", "while cakes:\n frequent0 = heapq.heappop(cakes)\n if frequent0[1] == last_eaten:\n if cakes:\n frequent1 = heapq.heappop(cakes)\n last_eaten = frequent1[1]\n frequent1[0] += 1\n if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n else:\n count += 1\n last_eaten = frequent0[1]\n frequent0[0] += 1\n else:\n frequent0[0] += 1\n last_eaten = frequent0[1]\n if frequent0[0] != 0:\n heapq.heappush(cakes, frequent0)\n ", "cakes", "frequent0 = heapq.heappop(cakes)", "frequent0", "heapq.heappop(cakes)", "heapq.heappop", "heapq", "heappop", "cakes", "if frequent0[1] == last_eaten:\n if cakes:\n frequent1 = heapq.heappop(cakes)\n last_eaten = frequent1[1]\n frequent1[0] += 1\n if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n else:\n count += 1\n last_eaten = frequent0[1]\n frequent0[0] += 1\n else:\n frequent0[0] += 1\n last_eaten = frequent0[1]\n ", "frequent0[1] == last_eaten", "frequent0[1]", "frequent0", "1", "last_eaten", "if cakes:\n frequent1 = heapq.heappop(cakes)\n last_eaten = frequent1[1]\n frequent1[0] += 1\n if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n else:\n count += 1\n last_eaten = frequent0[1]\n frequent0[0] += 1\n ", "cakes", "frequent1 = heapq.heappop(cakes)", "frequent1", "heapq.heappop(cakes)", "heapq.heappop", "heapq", "heappop", "cakes", "last_eaten = frequent1[1]", "last_eaten", "frequent1[1]", "frequent1", "1", "frequent1[0] += 1", "frequent1[0]", "frequent1", "0", "1", "if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n ", "frequent1[0] != 0", "frequent1[0]", "frequent1", "0", "0", "heapq.heappush(cakes, frequent1)", "heapq.heappush", "heapq", "heappush", "cakes", "frequent1", "count += 1", "count", "1", "last_eaten = frequent0[1]", "last_eaten", "frequent0[1]", "frequent0", "1", "frequent0[0] += 1", "frequent0[0]", "frequent0", "0", "1", "frequent0[0] += 1", "frequent0[0]", "frequent0", "0", "1", "last_eaten = frequent0[1]", "last_eaten", "frequent0[1]", "frequent0", "1", "if frequent0[0] != 0:\n heapq.heappush(cakes, frequent0)\n ", "frequent0[0] != 0", "frequent0[0]", "frequent0", "0", "0", "heapq.heappush(cakes, frequent0)", "heapq.heappush", "heapq", "heappush", "cakes", "frequent0", "return count", "count", "if __name__ == '__main__':\n print(solve())", "__name__ == '__main__'", "__name__", "'__main__'", "print(solve())", "print", "solve()", "solve", "def read_int() -> int:\n return int(input().strip())", "def read_int() -> int:\n return int(input().strip())", "read_int", "def read_ints() -> List[int]:\n return list(map(int, input().strip().split(' ')))", "def read_ints() -> List[int]:\n return list(map(int, input().strip().split(' ')))", "read_ints", "def solve() -> Any:\n K, T = read_ints()\n A = read_ints()\n cakes: List[List[int]] = [[-A[i], i] for i in range(T)]\n heapq.heapify(cakes)\n last_eaten = -1\n count = 0\n while cakes:\n frequent0 = heapq.heappop(cakes)\n if frequent0[1] == last_eaten:\n if cakes:\n frequent1 = heapq.heappop(cakes)\n last_eaten = frequent1[1]\n frequent1[0] += 1\n if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n else:\n count += 1\n last_eaten = frequent0[1]\n frequent0[0] += 1\n else:\n frequent0[0] += 1\n last_eaten = frequent0[1]\n if frequent0[0] != 0:\n heapq.heappush(cakes, frequent0)\n return count", "def solve() -> Any:\n K, T = read_ints()\n A = read_ints()\n cakes: List[List[int]] = [[-A[i], i] for i in range(T)]\n heapq.heapify(cakes)\n last_eaten = -1\n count = 0\n while cakes:\n frequent0 = heapq.heappop(cakes)\n if frequent0[1] == last_eaten:\n if cakes:\n frequent1 = heapq.heappop(cakes)\n last_eaten = frequent1[1]\n frequent1[0] += 1\n if frequent1[0] != 0:\n heapq.heappush(cakes, frequent1)\n else:\n count += 1\n last_eaten = frequent0[1]\n frequent0[0] += 1\n else:\n frequent0[0] += 1\n last_eaten = frequent0[1]\n if frequent0[0] != 0:\n heapq.heappush(cakes, frequent0)\n return count", "solve" ]
import heapq from typing import List, Any, Tuple def read_int() -> int: return int(input().strip()) def read_ints() -> List[int]: return list(map(int, input().strip().split(' '))) def solve() -> Any: K, T = read_ints() A = read_ints() cakes: List[List[int]] = [[-A[i], i] for i in range(T)] heapq.heapify(cakes) last_eaten = -1 count = 0 while cakes: frequent0 = heapq.heappop(cakes) if frequent0[1] == last_eaten: if cakes: frequent1 = heapq.heappop(cakes) last_eaten = frequent1[1] frequent1[0] += 1 if frequent1[0] != 0: heapq.heappush(cakes, frequent1) else: count += 1 last_eaten = frequent0[1] frequent0[0] += 1 else: frequent0[0] += 1 last_eaten = frequent0[1] if frequent0[0] != 0: heapq.heappush(cakes, frequent0) return count if __name__ == '__main__': print(solve())
[ 7, 15, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 17, 15, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 14, 40, 2, 17, 13, 2, 13, 17, 4, 13, 17, 0, 13, 2, 2, 13, 13, 17, 4, 13, 2, 13, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 24, 23 ], [ 101, 29 ], [ 33, 33 ], [ 112, 42 ], [ 115, 47 ], [ 118, 51 ], [ 101, 53 ], [ 118, 54 ], [ 91, 56 ], [ 89, 58 ], [ 109, 60 ], [ 92, 63 ], [ 110, 68 ], [ 98, 70 ], [ 121, 76 ], [ 98, 79 ], [ 110, 80 ], [ 110, 85 ], [ 122, 86 ], [ 91, 92 ], [ 118, 98 ], [ 109, 110 ], [ 112, 113 ], [ 115, 116 ], [ 118, 119 ], [ 121, 122 ] ]
[ "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\n#mod = 10 ** 9 + 7 \nmod = 998244353\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\nK, T = MAP()\na = LIST()\nA_max = max(a)\n\nif 2*A_max <= K-1:\n\tprint(0)\nelse:\n\tc = K - A_max + 1\n\tprint(A_max - c)", "import sys, re", "sys", "re", "from collections import deque, defaultdict, Counter", "from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd", "from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby", "from operator import itemgetter, mul", "from copy import deepcopy", "from string import ascii_lowercase, ascii_uppercase, digits", "from bisect import bisect, bisect_left, insort, insort_left", "from heapq import heappush, heappop", "from functools import reduce", "def input(): return sys.stdin.readline().strip()", "input", "def INT(): return int(input())", "INT", "def MAP(): return map(int, input().split())", "MAP", "def LIST(): return list(map(int, input().split()))", "LIST", "MAP() for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "MAP()", "MAP", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "n", "n", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "mod = 998244353", "mod", "998244353", "from decimal import *", "K, T = MAP()", "K", "MAP()", "MAP", "T", "a = LIST()", "a", "LIST()", "LIST", "A_max = max(a)", "A_max", "max(a)", "max", "a", "if 2*A_max <= K-1:\n\tprint(0)\nelse:\n\tc = K - A_max + 1\n\tprint(A_max - c)", "2*A_max <= K-1", "2*A_max", "2", "A_max", "K-1", "K", "1", "print(0)", "print", "0", "c = K - A_max + 1", "c", "K - A_max + 1", "K - A_max", "K", "A_max", "1", "print(A_max - c)", "print", "A_max - c", "A_max", "c", "def LIST(): return list(map(int, input().split()))", "def LIST(): return list(map(int, input().split()))", "LIST", "a = LIST()", "LIST()", "a", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "K, T = MAP()", "MAP()", "K", "def MAP(): return map(int, input().split())", "def MAP(): return map(int, input().split())", "MAP", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "def INT(): return int(input())", "def INT(): return int(input())", "INT", "A_max = max(a)", "max(a)", "A_max", "INF = float('inf')", "float('inf')", "INF", "mod = 998244353", "998244353", "mod", "T = MAP()", "MAP()", "T", "c = K - A_max + 1", "K - A_max + 1", "c" ]
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left, insort, insort_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') #mod = 10 ** 9 + 7 mod = 998244353 from decimal import * #import numpy as np #decimal.getcontext().prec = 10 K, T = MAP() a = LIST() A_max = max(a) if 2*A_max <= K-1: print(0) else: c = K - A_max + 1 print(A_max - c)
[ 7, 12, 13, 17, 15, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 4, 18, 13, 13, 13, 0, 13, 2, 18, 13, 17, 17, 0, 13, 2, 13, 4, 13, 18, 13, 39, 17, 14, 40, 13, 17, 4, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 9, 8 ], [ 8, 17 ], [ 20, 19 ], [ 20, 21 ], [ 25, 24 ], [ 24, 33 ], [ 36, 35 ], [ 35, 39 ], [ 43, 42 ], [ 46, 45 ], [ 35, 50 ], [ 53, 52 ], [ 35, 55 ], [ 60, 59 ], [ 52, 61 ], [ 35, 65 ], [ 59, 70 ], [ 59, 77 ], [ 86, 83 ] ]
[ "def resolve():\n '''\n code here\n '''\n import collections\n K , T = [int(item) for item in input().split()]\n As = [int(item) for item in input().split()]\n As.sort(reverse=True)\n\n cnt = collections.Counter(As)\n interval_num = As[0]-1\n\n res = interval_num - sum(As[1:])\n\n if res <= 0:\n print(0)\n else:\n print(res)\n\nif __name__ == \"__main__\":\n resolve()", "def resolve():\n '''\n code here\n '''\n import collections\n K , T = [int(item) for item in input().split()]\n As = [int(item) for item in input().split()]\n As.sort(reverse=True)\n\n cnt = collections.Counter(As)\n interval_num = As[0]-1\n\n res = interval_num - sum(As[1:])\n\n if res <= 0:\n print(0)\n else:\n print(res)", "resolve", "'''\n code here\n '''", "import collections", "collections", "int(item) for item in input().split()", "for item in input().split()", "item", "input().split()", "().split", "()", "input", "split", "for item in input().split()", "int(item)", "int", "item", "K , T = [int(item) for item in input().split()]", "K", "[int(item) for item in input().split()]", "T", "int(item) for item in input().split()", "for item in input().split()", "item", "input().split()", "().split", "()", "input", "split", "for item in input().split()", "int(item)", "int", "item", "As = [int(item) for item in input().split()]", "As", "[int(item) for item in input().split()]", "As.sort(reverse=True)", "As.sort", "As", "sort", "reverse=True", "reverse", "True", "cnt = collections.Counter(As)", "cnt", "collections.Counter(As)", "collections.Counter", "collections", "Counter", "As", "interval_num = As[0]-1", "interval_num", "As[0]-1", "As[0]", "As", "0", "1", "res = interval_num - sum(As[1:])", "res", "interval_num - sum(As[1:])", "interval_num", "sum(As[1:])", "sum", "As[1:]", "As", "1:", "1", "if res <= 0:\n print(0)\n else:\n print(res)", "res <= 0", "res", "0", "print(0)", "print", "0", "print(res)", "print", "res", "if __name__ == \"__main__\":\n resolve()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "resolve()", "resolve", "def resolve():\n '''\n code here\n '''\n import collections\n K , T = [int(item) for item in input().split()]\n As = [int(item) for item in input().split()]\n As.sort(reverse=True)\n\n cnt = collections.Counter(As)\n interval_num = As[0]-1\n\n res = interval_num - sum(As[1:])\n\n if res <= 0:\n print(0)\n else:\n print(res)", "def resolve():\n '''\n code here\n '''\n import collections\n K , T = [int(item) for item in input().split()]\n As = [int(item) for item in input().split()]\n As.sort(reverse=True)\n\n cnt = collections.Counter(As)\n interval_num = As[0]-1\n\n res = interval_num - sum(As[1:])\n\n if res <= 0:\n print(0)\n else:\n print(res)", "resolve" ]
def resolve(): ''' code here ''' import collections K , T = [int(item) for item in input().split()] As = [int(item) for item in input().split()] As.sort(reverse=True) cnt = collections.Counter(As) interval_num = As[0]-1 res = interval_num - sum(As[1:]) if res <= 0: print(0) else: print(res) if __name__ == "__main__": resolve()