node_ids
listlengths
4
1.4k
edge_index
listlengths
1
2.22k
text
listlengths
4
1.4k
source
stringlengths
14
427k
[ 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, 2, 2, 2, 13, 17, 17, 17, 13, 4, 13, 17, 4, 13, 2, 2, 13, 17, 2, 4, 13, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 63, 2 ], [ 63, 11 ], [ 57, 13 ], [ 54, 25 ], [ 58, 28 ], [ 61, 34 ], [ 55, 38 ], [ 55, 46 ], [ 58, 51 ], [ 55, 52 ], [ 54, 55 ], [ 57, 58 ], [ 63, 61 ], [ 63, 64 ] ]
[ "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nx=max(l)\nif (n+1)//2+1>x:\n print(0)\nelse:\n print(x-1-(sum(l)-x))", "n,k=map(int,input().split())", "n", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "k", "l=list(map(int,input().split()))", "l", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "x=max(l)", "x", "max(l)", "max", "l", "if (n+1)//2+1>x:\n print(0)\nelse:\n print(x-1-(sum(l)-x))", "(n+1)//2+1>x", "(n+1)//2+1", "(n+1)//2", "n+1", "n", "1", "2", "1", "x", "print(0)", "print", "0", "print(x-1-(sum(l)-x))", "print", "x-1-(sum(l)-x)", "x-1", "x", "1", "sum(l)-x", "sum(l)", "sum", "l", "x", "x=max(l)", "max(l)", "x", "l=list(map(int,input().split()))", "list(map(int,input().split()))", "l", "n,k=map(int,input().split())", "map(int,input().split())", "n", "k=map(int,input().split())", "map(int,input().split())", "k" ]
n,k=map(int,input().split()) l=list(map(int,input().split())) x=max(l) if (n+1)//2+1>x: print(0) else: print(x-1-(sum(l)-x))
[ 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, 0, 13, 2, 13, 13, 4, 13, 4, 13, 2, 2, 13, 17, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 59, 2 ], [ 59, 11 ], [ 50, 13 ], [ 62, 25 ], [ 51, 28 ], [ 56, 30 ], [ 51, 33 ], [ 65, 35 ], [ 57, 37 ], [ 63, 38 ], [ 63, 45 ], [ 66, 47 ], [ 50, 51 ], [ 59, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "k,t=map(int,input().split())\na=list(map(int,input().split()))\naa=max(a)\nb=sum(a)\nc=b-aa\nprint(max(aa-1-c,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", "b=sum(a)", "b", "sum(a)", "sum", "a", "c=b-aa", "c", "b-aa", "b", "aa", "print(max(aa-1-c,0))", "print", "max(aa-1-c,0)", "max", "aa-1-c", "aa-1", "aa", "1", "c", "0", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "t=map(int,input().split())", "map(int,input().split())", "t", "b=sum(a)", "sum(a)", "b", "k,t=map(int,input().split())", "map(int,input().split())", "k", "aa=max(a)", "max(a)", "aa", "c=b-aa", "b-aa", "c" ]
k,t=map(int,input().split()) a=list(map(int,input().split())) aa=max(a) b=sum(a) c=b-aa print(max(aa-1-c,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, 13, 13, 14, 2, 2, 2, 13, 13, 17, 17, 4, 13, 2, 2, 13, 13, 17, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 67, 2 ], [ 67, 13 ], [ 55, 15 ], [ 64, 27 ], [ 56, 30 ], [ 61, 32 ], [ 68, 34 ], [ 65, 35 ], [ 65, 40 ], [ 62, 41 ], [ 65, 48 ], [ 62, 49 ], [ 55, 56 ], [ 67, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "k, t = list(map(int, input().split()))\nnums = list(map(int, input().split()))\n\nm = max(nums)\nrest = k - m\nif m - rest - 1 > 0:\n print(m - rest - 1)\nelse:\n print(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", "nums = list(map(int, input().split()))", "nums", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m = max(nums)", "m", "max(nums)", "max", "nums", "rest = k - m", "rest", "k - m", "k", "m", "if m - rest - 1 > 0:\n print(m - rest - 1)\nelse:\n print(0)", "m - rest - 1 > 0", "m - rest - 1", "m - rest", "m", "rest", "1", "0", "print(m - rest - 1)", "print", "m - rest - 1", "m - rest", "m", "rest", "1", "print(0)", "print", "0", "nums = list(map(int, input().split()))", "list(map(int, input().split()))", "nums", "t = list(map(int, input().split()))", "list(map(int, input().split()))", "t", "rest = k - m", "k - m", "rest", "m = max(nums)", "max(nums)", "m", "k, t = list(map(int, input().split()))", "list(map(int, input().split()))", "k" ]
k, t = list(map(int, input().split())) nums = list(map(int, input().split())) m = max(nums) rest = k - m if m - rest - 1 > 0: print(m - rest - 1) else: print(0)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 31, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 2, 17, 2, 40, 13, 17, 28, 13, 13, 14, 2, 13, 13, 0, 13, 2, 2, 2, 17, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 57, 2 ], [ 57, 11 ], [ 15, 13 ], [ 66, 24 ], [ 63, 27 ], [ 55, 32 ], [ 36, 35 ], [ 35, 39 ], [ 64, 40 ], [ 60, 42 ], [ 35, 47 ], [ 55, 48 ], [ 61, 52 ], [ 67, 52 ], [ 57, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "K,T=map(int,input().split())\n*A,=map(int,input().split())\nans=0\nH=0--K//2\nfor a in A:\n if a>H:\n ans+=2*a-K-1\nprint(ans)", "K,T=map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "*A,=map(int,input().split())", "*A", "A", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans=0", "ans", "0", "H=0--K//2", "H", "0--K//2", "0", "-K//2", "-K", "K", "2", "for a in A:\n if a>H:\n ans+=2*a-K-1", "a", "A", "if a>H:\n ans+=2*a-K-1", "a>H", "a", "H", "ans+=2*a-K-1", "ans", "2*a-K-1", "2*a-K", "2*a", "2", "a", "K", "1", "print(ans)", "print", "ans", "K,T=map(int,input().split())", "map(int,input().split())", "K", "T=map(int,input().split())", "map(int,input().split())", "T", "ans+=2*a-K-1", "2*a-K-1", "ans", "H=0--K//2", "0--K//2", "H", "ans=0", "0", "ans" ]
K,T=map(int,input().split()) *A,=map(int,input().split()) ans=0 H=0--K//2 for a in A: if a>H: ans+=2*a-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, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 53, 2 ], [ 53, 11 ], [ 47, 13 ], [ 59, 25 ], [ 48, 28 ], [ 56, 30 ], [ 48, 34 ], [ 60, 35 ], [ 60, 43 ], [ 57, 44 ], [ 47, 48 ], [ 53, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "k, t = map(int, input().split())\na = list(map(int, input().split()))\nx = max(a)\ntotal = sum(a) - x\nprint(max(0, x - total - 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", "x = max(a)", "x", "max(a)", "max", "a", "total = sum(a) - x", "total", "sum(a) - x", "sum(a)", "sum", "a", "x", "print(max(0, x - total - 1))", "print", "max(0, x - total - 1)", "max", "0", "x - total - 1", "x - total", "x", "total", "1", "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", "total = sum(a) - x", "sum(a) - x", "total", "x = max(a)", "max(a)", "x" ]
k, t = map(int, input().split()) a = list(map(int, input().split())) x = max(a) total = sum(a) - x print(max(0, x - total - 1))
[ 7, 12, 13, 15, 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, 4, 18, 13, 13, 0, 13, 17, 0, 13, 4, 13, 2, 2, 18, 13, 17, 17, 4, 13, 18, 13, 39, 17, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 9, 8 ], [ 6, 15 ], [ 9, 17 ], [ 20, 19 ], [ 6, 28 ], [ 19, 32 ], [ 36, 35 ], [ 39, 38 ], [ 19, 44 ], [ 19, 50 ], [ 38, 56 ], [ 65, 62 ] ]
[ "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n k,t = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n ans = max(a[0]-1-sum(a[1:]),0)\n print(ans)\n\n \nif __name__ == '__main__':\n main()", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n k,t = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n ans = max(a[0]-1-sum(a[1:]),0)\n print(ans)\n\n ", "main", "import sys", "sys", "def input(): return sys.stdin.readline().rstrip()\n\n ", "input", "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", "ans = max(a[0]-1-sum(a[1:]),0)", "ans", "max(a[0]-1-sum(a[1:]),0)", "max", "a[0]-1-sum(a[1:])", "a[0]-1", "a[0]", "a", "0", "1", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "0", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n k,t = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n ans = max(a[0]-1-sum(a[1:]),0)\n print(ans)\n\n ", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n k,t = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n ans = max(a[0]-1-sum(a[1:]),0)\n print(ans)\n\n ", "main" ]
def main(): import sys def input(): return sys.stdin.readline().rstrip() k,t = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) ans = max(a[0]-1-sum(a[1:]),0) print(ans) if __name__ == '__main__': main()
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 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, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 2, 13, 13, 4, 13, 4, 13, 17, 2, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 18, 13 ]
[ [ 77, 11 ], [ 21, 20 ], [ 78, 27 ], [ 21, 29 ], [ 32, 31 ], [ 78, 40 ], [ 44, 43 ], [ 31, 46 ], [ 49, 48 ], [ 31, 52 ], [ 43, 53 ], [ 56, 55 ], [ 43, 57 ], [ 48, 58 ], [ 55, 65 ], [ 48, 65 ], [ 75, 72 ], [ 77, 78 ] ]
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\nrl = sys.stdin.readline\n\n\ndef solve():\n _, _ = map(int, rl().split())\n a = list(map(int, rl().split()))\n \n max_a = max(a)\n d = sum(a) - max_a\n d = max_a - d\n print(max(0, d - 1))\n\n\nif __name__ == '__main__':\n solve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "rl = sys.stdin.readline", "rl", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def solve():\n _, _ = map(int, rl().split())\n a = list(map(int, rl().split()))\n \n max_a = max(a)\n d = sum(a) - max_a\n d = max_a - d\n print(max(0, d - 1))", "solve", "_, _ = map(int, rl().split())", "_", "map(int, rl().split())", "map", "int", "rl().split()", "().split", "()", "rl", "split", "_", "a = list(map(int, rl().split()))", "a", "list(map(int, rl().split()))", "list", "map(int, rl().split())", "map", "int", "rl().split()", "().split", "()", "rl", "split", "max_a = max(a)", "max_a", "max(a)", "max", "a", "d = sum(a) - max_a", "d", "sum(a) - max_a", "sum(a)", "sum", "a", "max_a", "d = max_a - d", "d", "max_a - d", "max_a", "d", "print(max(0, d - 1))", "print", "max(0, d - 1)", "max", "0", "d - 1", "d", "1", "if __name__ == '__main__':\n solve()", "__name__ == '__main__'", "__name__", "'__main__'", "solve()", "solve", "def solve():\n _, _ = map(int, rl().split())\n a = list(map(int, rl().split()))\n \n max_a = max(a)\n d = sum(a) - max_a\n d = max_a - d\n print(max(0, d - 1))", "def solve():\n _, _ = map(int, rl().split())\n a = list(map(int, rl().split()))\n \n max_a = max(a)\n d = sum(a) - max_a\n d = max_a - d\n print(max(0, d - 1))", "solve", "rl = sys.stdin.readline", "sys.stdin.readline", "rl" ]
import sys sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): _, _ = map(int, rl().split()) a = list(map(int, rl().split())) max_a = max(a) d = sum(a) - max_a d = max_a - d print(max(0, d - 1)) if __name__ == '__main__': solve()
[ 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, 14, 40, 13, 2, 2, 13, 17, 17, 0, 13, 17, 14, 2, 2, 13, 17, 17, 0, 13, 2, 2, 13, 2, 2, 13, 17, 17, 17, 0, 13, 2, 2, 2, 13, 2, 2, 13, 17, 17, 17, 17, 4, 13, 13, 10, 18, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 97, 2 ], [ 97, 11 ], [ 91, 13 ], [ 28, 27 ], [ 79, 30 ], [ 92, 32 ], [ 80, 36 ], [ 98, 39 ], [ 82, 43 ], [ 98, 48 ], [ 94, 52 ], [ 80, 55 ], [ 98, 58 ], [ 85, 63 ], [ 80, 67 ], [ 98, 70 ], [ 86, 77 ], [ 95, 77 ], [ 83, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 97, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ] ]
[ "K,T = map(int,input().split())\nA = sorted(list(map(int,input().split())),reverse=True)\na = A[0]\nif a<=(K+1)//2:\n ans = 0\nelif K%2==1:\n ans = (a-(K+1)//2)*2\nelse:\n ans = (a-(K+1)//2)*2-1\nprint(ans)", "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", "a = A[0]", "a", "A[0]", "A", "0", "if a<=(K+1)//2:\n ans = 0\nelif K%2==1:\n ans = (a-(K+1)//2)*2\nelse:\n ans = (a-(K+1)//2)*2-1", "a<=(K+1)//2", "a", "(K+1)//2", "K+1", "K", "1", "2", "ans = 0", "ans", "0", "elif K%2==1:\n ans = (a-(K+1)//2)*2", "K%2==1", "K%2", "K", "2", "1", "ans = (a-(K+1)//2)*2", "ans", "(a-(K+1)//2)*2", "a-(K+1)//2", "a", "(K+1)//2", "K+1", "K", "1", "2", "2", "ans = (a-(K+1)//2)*2-1", "ans", "(a-(K+1)//2)*2-1", "(a-(K+1)//2)*2", "a-(K+1)//2", "a", "(K+1)//2", "K+1", "K", "1", "2", "2", "1", "print(ans)", "print", "ans", "a = A[0]", "A[0]", "a", "ans = 0", "0", "ans", "ans = (a-(K+1)//2)*2-1", "(a-(K+1)//2)*2-1", "ans", "T = map(int,input().split())", "map(int,input().split())", "T", "A = sorted(list(map(int,input().split())),reverse=True)", "sorted(list(map(int,input().split())),reverse=True)", "A", "ans = (a-(K+1)//2)*2", "(a-(K+1)//2)*2", "ans", "K,T = map(int,input().split())", "map(int,input().split())", "K" ]
K,T = map(int,input().split()) A = sorted(list(map(int,input().split())),reverse=True) a = A[0] if a<=(K+1)//2: ans = 0 elif K%2==1: ans = (a-(K+1)//2)*2 else: ans = (a-(K+1)//2)*2-1 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, 0, 13, 17, 28, 13, 4, 13, 13, 0, 18, 13, 13, 40, 18, 13, 13, 15, 13, 4, 18, 13, 13, 13, 0, 13, 2, 4, 18, 13, 13, 13, 17, 42, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 14, 40, 13, 17, 4, 18, 13, 13, 13, 13, 0, 13, 2, 13, 17, 4, 13, 40, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 106, 2 ], [ 106, 11 ], [ 100, 13 ], [ 28, 27 ], [ 31, 30 ], [ 107, 33 ], [ 38, 35 ], [ 101, 36 ], [ 30, 37 ], [ 35, 39 ], [ 101, 40 ], [ 30, 41 ], [ 101, 48 ], [ 91, 50 ], [ 101, 56 ], [ 101, 62 ], [ 94, 65 ], [ 101, 70 ], [ 92, 73 ], [ 104, 73 ], [ 101, 79 ], [ 92, 80 ], [ 104, 80 ], [ 103, 82 ], [ 95, 84 ], [ 104, 89 ], [ 92, 89 ], [ 91, 92 ], [ 94, 95 ], [ 106, 98 ], [ 100, 101 ], [ 103, 104 ], [ 106, 107 ] ]
[ "k,t = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=True)\nfor i in range(t):\n a[i] = -a[i]\nimport heapq\nheapq.heapify(a)\nbuf = heapq.heappop(a)+1\nwhile len(a)>0:\n x = heapq.heappop(a)\n if buf!=0:\n heapq.heappush(a,buf)\n buf = x+1\nprint(-buf)", "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", "for i in range(t):\n a[i] = -a[i]", "i", "range(t)", "range", "t", "a[i] = -a[i]", "a[i]", "a", "i", "-a[i]", "a[i]", "a", "i", "import heapq", "heapq", "heapq.heapify(a)", "heapq.heapify", "heapq", "heapify", "a", "buf = heapq.heappop(a)+1", "buf", "heapq.heappop(a)+1", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "1", "while len(a)>0:\n x = heapq.heappop(a)\n if buf!=0:\n heapq.heappush(a,buf)\n buf = x+1", "len(a)>0", "len(a)", "len", "a", "0", "x = heapq.heappop(a)", "x", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "if buf!=0:\n heapq.heappush(a,buf)\n ", "buf!=0", "buf", "0", "heapq.heappush(a,buf)", "heapq.heappush", "heapq", "heappush", "a", "buf", "buf = x+1", "buf", "x+1", "x", "1", "print(-buf)", "print", "-buf", "buf", "buf = heapq.heappop(a)+1", "heapq.heappop(a)+1", "buf", "x = heapq.heappop(a)", "heapq.heappop(a)", "x", "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", "buf = x+1", "x+1", "buf", "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) for i in range(t): a[i] = -a[i] import heapq heapq.heapify(a) buf = heapq.heappop(a)+1 while len(a)>0: x = heapq.heappop(a) if buf!=0: heapq.heappush(a,buf) buf = x+1 print(-buf)
[ 7, 15, 12, 13, 0, 13, 18, 13, 13, 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, 2, 17, 13, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 11, 10 ], [ 5, 17 ], [ 11, 19 ], [ 22, 21 ], [ 5, 30 ], [ 21, 41 ], [ 10, 42 ], [ 48, 45 ] ]
[ "from sys import stdin\n\ndef main():\n input = stdin.readline\n k, _ = map(int, input().split())\n a = max(map(int, input().split()))\n print(max(0, 2 * a - k - 1))\nmain()", "from sys import stdin", "def main():\n input = stdin.readline\n k, _ = map(int, input().split())\n a = max(map(int, input().split()))\n print(max(0, 2 * a - k - 1))", "main", "input = stdin.readline", "input", "stdin.readline", "stdin", "readline", "k, _ = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "_", "a = max(map(int, input().split()))", "a", "max(map(int, input().split()))", "max", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max(0, 2 * a - k - 1))", "print", "max(0, 2 * a - k - 1)", "max", "0", "2 * a - k - 1", "2 * a - k", "2 * a", "2", "a", "k", "1", "main()", "main", "def main():\n input = stdin.readline\n k, _ = map(int, input().split())\n a = max(map(int, input().split()))\n print(max(0, 2 * a - k - 1))", "def main():\n input = stdin.readline\n k, _ = map(int, input().split())\n a = max(map(int, input().split()))\n print(max(0, 2 * a - k - 1))", "main" ]
from sys import stdin def main(): input = stdin.readline k, _ = map(int, input().split()) a = max(map(int, input().split())) print(max(0, 2 * a - k - 1)) main()
[ 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, 4, 13, 4, 13, 2, 2, 4, 13, 13, 17, 2, 13, 4, 13, 13, 17, 10, 4, 13, 10, 13, 13, 10, 4, 13 ]
[ [ 50, 2 ], [ 50, 11 ], [ 15, 14 ], [ 14, 23 ], [ 47, 25 ], [ 48, 35 ], [ 51, 38 ], [ 48, 41 ], [ 50, 45 ], [ 47, 48 ], [ 50, 51 ] ]
[ "K, T = map(int, input().split())\ncake = [int(i) for i in input().split()]\n\nprint(max((max(cake) - 1 - (K - max(cake))), 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", "cake = [int(i) for i in input().split()]", "cake", "[int(i) for i in input().split()]", "print(max((max(cake) - 1 - (K - max(cake))), 0))", "print", "max((max(cake) - 1 - (K - max(cake))), 0)", "max", "max(cake) - 1 - (K - max(cake))", "max(cake) - 1", "max(cake)", "max", "cake", "1", "K - max(cake)", "K", "max(cake)", "max", "cake", "0", "T = map(int, input().split())", "map(int, input().split())", "T", "cake = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "cake", "K, T = map(int, input().split())", "map(int, input().split())", "K" ]
K, T = map(int, input().split()) cake = [int(i) for i in input().split()] print(max((max(cake) - 1 - (K - max(cake))), 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, 0, 13, 2, 4, 13, 13, 4, 13, 13, 14, 2, 2, 4, 13, 13, 17, 13, 0, 13, 2, 2, 4, 13, 13, 17, 13, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 69, 2 ], [ 69, 11 ], [ 60, 13 ], [ 72, 25 ], [ 63, 28 ], [ 61, 32 ], [ 61, 35 ], [ 61, 41 ], [ 64, 43 ], [ 57, 45 ], [ 61, 50 ], [ 64, 52 ], [ 58, 55 ], [ 73, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 69, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\nans = 0\nother = sum(A)-max(A)\nif max(A)-1>other:\n ans = max(A)-1-other\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", "ans = 0", "ans", "0", "other = sum(A)-max(A)", "other", "sum(A)-max(A)", "sum(A)", "sum", "A", "max(A)", "max", "A", "if max(A)-1>other:\n ans = max(A)-1-other", "max(A)-1>other", "max(A)-1", "max(A)", "max", "A", "1", "other", "ans = max(A)-1-other", "ans", "max(A)-1-other", "max(A)-1", "max(A)", "max", "A", "1", "other", "print(ans)", "print", "ans", "ans = max(A)-1-other", "max(A)-1-other", "ans", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "other = sum(A)-max(A)", "sum(A)-max(A)", "other", "T = map(int, input().split())", "map(int, input().split())", "T", "K, T = map(int, input().split())", "map(int, input().split())", "K", "ans = 0", "0", "ans" ]
K, T = map(int, input().split()) A = list(map(int, input().split())) ans = 0 other = sum(A)-max(A) if max(A)-1>other: ans = max(A)-1-other print(ans)
[ 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, 4, 18, 13, 13, 0, 13, 17, 0, 13, 18, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 14, 40, 2, 13, 13, 17, 29, 17, 29, 2, 2, 13, 13, 17, 4, 13, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 13 ], [ 16, 15 ], [ 15, 28 ], [ 32, 31 ], [ 35, 34 ], [ 15, 36 ], [ 40, 39 ], [ 15, 43 ], [ 34, 49 ], [ 39, 50 ], [ 34, 57 ], [ 39, 58 ], [ 66, 63 ] ]
[ "def m():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.sort(reverse=True)\n a = A[0]\n b = sum(A[1:])\n if (a-b) <= 1:\n return 0\n else:\n return (a-b)-1\n\n\nprint(m())", "def m():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.sort(reverse=True)\n a = A[0]\n b = sum(A[1:])\n if (a-b) <= 1:\n return 0\n else:\n return (a-b)-1", "m", "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", "a = A[0]", "a", "A[0]", "A", "0", "b = sum(A[1:])", "b", "sum(A[1:])", "sum", "A[1:]", "A", "1:", "1", "if (a-b) <= 1:\n return 0\n else:\n return (a-b)-1", "(a-b) <= 1", "a-b", "a", "b", "1", "return 0", "0", "return (a-b)-1", "(a-b)-1", "a-b", "a", "b", "1", "print(m())", "print", "m()", "m", "def m():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.sort(reverse=True)\n a = A[0]\n b = sum(A[1:])\n if (a-b) <= 1:\n return 0\n else:\n return (a-b)-1", "def m():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.sort(reverse=True)\n a = A[0]\n b = sum(A[1:])\n if (a-b) <= 1:\n return 0\n else:\n return (a-b)-1", "m" ]
def m(): K, T = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) a = A[0] b = sum(A[1:]) if (a-b) <= 1: return 0 else: return (a-b)-1 print(m())
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 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, 39, 28, 13, 4, 13, 13, 4, 18, 13, 13, 39, 2, 13, 17, 18, 13, 13, 0, 13, 4, 13, 13, 0, 13, 12, 18, 13, 17, 23, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 40, 13, 18, 18, 13, 17, 17, 0, 13, 18, 18, 13, 17, 17, 0, 18, 18, 13, 17, 17, 17, 0, 13, 4, 13, 13, 0, 13, 12, 18, 13, 17, 23, 14, 40, 18, 18, 13, 17, 17, 17, 0, 13, 18, 18, 13, 17, 17, 0, 18, 18, 13, 17, 17, 17, 0, 13, 4, 13, 13, 0, 13, 12, 18, 13, 17, 23, 0, 18, 18, 13, 17, 17, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 194, 11 ], [ 188, 16 ], [ 26, 25 ], [ 26, 34 ], [ 37, 36 ], [ 49, 48 ], [ 52, 51 ], [ 34, 54 ], [ 48, 57 ], [ 51, 61 ], [ 36, 64 ], [ 51, 65 ], [ 68, 67 ], [ 48, 70 ], [ 73, 72 ], [ 34, 80 ], [ 25, 85 ], [ 91, 90 ], [ 94, 93 ], [ 97, 96 ], [ 25, 99 ], [ 93, 102 ], [ 143, 102 ], [ 67, 105 ], [ 48, 105 ], [ 157, 105 ], [ 110, 109 ], [ 67, 112 ], [ 48, 112 ], [ 157, 112 ], [ 121, 116 ], [ 67, 118 ], [ 48, 118 ], [ 157, 118 ], [ 124, 123 ], [ 67, 126 ], [ 48, 126 ], [ 157, 126 ], [ 129, 128 ], [ 67, 138 ], [ 48, 138 ], [ 157, 138 ], [ 144, 143 ], [ 67, 146 ], [ 48, 146 ], [ 157, 146 ], [ 155, 150 ], [ 67, 152 ], [ 48, 152 ], [ 157, 152 ], [ 158, 157 ], [ 67, 160 ], [ 48, 160 ], [ 157, 160 ], [ 163, 162 ], [ 174, 169 ], [ 67, 171 ], [ 48, 171 ], [ 157, 171 ], [ 177, 176 ], [ 176, 180 ], [ 90, 180 ], [ 192, 186 ], [ 188, 189 ], [ 194, 195 ] ]
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\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 B = []\n for i in range(t):\n B.append([i + 1, A[i]])\n B = sorted(B, key=lambda x: x[1])\n\n if t == 1:\n print(k - 1)\n exit()\n\n res = 0\n pre = 0\n for i in range(k):\n if pre != B[-1][0]:\n pre = B[-1][0]\n B[-1][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n if B[-2][1] != 0:\n pre = B[-2][0]\n B[-2][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n B[-1][1] -= 1\n res += 1\n\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", "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 B = []\n for i in range(t):\n B.append([i + 1, A[i]])\n B = sorted(B, key=lambda x: x[1])\n\n if t == 1:\n print(k - 1)\n exit()\n\n res = 0\n pre = 0\n for i in range(k):\n if pre != B[-1][0]:\n pre = B[-1][0]\n B[-1][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n if B[-2][1] != 0:\n pre = B[-2][0]\n B[-2][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n B[-1][1] -= 1\n res += 1\n\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", "B = []", "B", "[]", "for i in range(t):\n B.append([i + 1, A[i]])\n ", "i", "range(t)", "range", "t", "B.append([i + 1, A[i]])", "B.append", "B", "append", "[i + 1, A[i]]", "i + 1", "i", "1", "A[i]", "A", "i", "B = sorted(B, key=lambda x: x[1])", "B", "sorted(B, key=lambda x: x[1])", "sorted", "B", "key=lambda x: x[1]", "key", "lambda x: x[1]", "x[1]", "x", "1", "x", "if t == 1:\n print(k - 1)\n exit()\n\n ", "t == 1", "t", "1", "print(k - 1)", "print", "k - 1", "k", "1", "exit()", "exit", "res = 0", "res", "0", "pre = 0", "pre", "0", "for i in range(k):\n if pre != B[-1][0]:\n pre = B[-1][0]\n B[-1][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n if B[-2][1] != 0:\n pre = B[-2][0]\n B[-2][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n B[-1][1] -= 1\n res += 1\n\n ", "i", "range(k)", "range", "k", "if pre != B[-1][0]:\n pre = B[-1][0]\n B[-1][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n if B[-2][1] != 0:\n pre = B[-2][0]\n B[-2][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n B[-1][1] -= 1\n res += 1\n\n ", "pre != B[-1][0]", "pre", "B[-1][0]", "[-1]", "B", "-1", "0", "pre = B[-1][0]", "pre", "B[-1][0]", "[-1]", "B", "-1", "0", "B[-1][1] -= 1", "B[-1][1]", "[-1]", "B", "-1", "1", "1", "B = sorted(B, key=lambda x: x[1])", "B", "sorted(B, key=lambda x: x[1])", "sorted", "B", "key=lambda x: x[1]", "key", "lambda x: x[1]", "x[1]", "x", "1", "x", "if B[-2][1] != 0:\n pre = B[-2][0]\n B[-2][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n B[-1][1] -= 1\n res += 1\n\n ", "B[-2][1] != 0", "B[-2][1]", "[-2]", "B", "-2", "1", "0", "pre = B[-2][0]", "pre", "B[-2][0]", "[-2]", "B", "-2", "0", "B[-2][1] -= 1", "B[-2][1]", "[-2]", "B", "-2", "1", "1", "B = sorted(B, key=lambda x: x[1])", "B", "sorted(B, key=lambda x: x[1])", "sorted", "B", "key=lambda x: x[1]", "key", "lambda x: x[1]", "x[1]", "x", "1", "x", "B[-1][1] -= 1", "B[-1][1]", "[-1]", "B", "-1", "1", "1", "res += 1", "res", "1", "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 B = []\n for i in range(t):\n B.append([i + 1, A[i]])\n B = sorted(B, key=lambda x: x[1])\n\n if t == 1:\n print(k - 1)\n exit()\n\n res = 0\n pre = 0\n for i in range(k):\n if pre != B[-1][0]:\n pre = B[-1][0]\n B[-1][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n if B[-2][1] != 0:\n pre = B[-2][0]\n B[-2][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n B[-1][1] -= 1\n res += 1\n\n print(res)", "def resolve():\n k, t = map(int, input().split())\n A = list(map(int, input().split()))\n B = []\n for i in range(t):\n B.append([i + 1, A[i]])\n B = sorted(B, key=lambda x: x[1])\n\n if t == 1:\n print(k - 1)\n exit()\n\n res = 0\n pre = 0\n for i in range(k):\n if pre != B[-1][0]:\n pre = B[-1][0]\n B[-1][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n if B[-2][1] != 0:\n pre = B[-2][0]\n B[-2][1] -= 1\n B = sorted(B, key=lambda x: x[1])\n else:\n B[-1][1] -= 1\n res += 1\n\n print(res)", "resolve", "f_inf = float('inf')", "float('inf')", "f_inf" ]
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): k, t = map(int, input().split()) A = list(map(int, input().split())) B = [] for i in range(t): B.append([i + 1, A[i]]) B = sorted(B, key=lambda x: x[1]) if t == 1: print(k - 1) exit() res = 0 pre = 0 for i in range(k): if pre != B[-1][0]: pre = B[-1][0] B[-1][1] -= 1 B = sorted(B, key=lambda x: x[1]) else: if B[-2][1] != 0: pre = B[-2][0] B[-2][1] -= 1 B = sorted(B, key=lambda x: x[1]) else: B[-1][1] -= 1 res += 1 print(res) if __name__ == '__main__': resolve()
[ 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, 18, 13, 17, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 42, 2 ], [ 42, 11 ], [ 45, 13 ], [ 46, 33 ], [ 40, 35 ], [ 42, 40 ], [ 42, 43 ], [ 45, 46 ] ]
[ "K, T = map(int, input().split())\nA = sorted(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(map(int, input().split()))", "A", "sorted(map(int, input().split()))", "sorted", "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] - K", "2 * A[-1]", "2", "A[-1]", "A", "-1", "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 = sorted(map(int, input().split()))", "sorted(map(int, input().split()))", "A" ]
K, T = map(int, input().split()) A = sorted(map(int, input().split())) print(max(2 * A[-1] - K - 1, 0))
[ 7, 17, 15, 12, 13, 0, 13, 12, 18, 4, 18, 13, 13, 39, 17, 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, 39, 0, 13, 39, 0, 13, 2, 2, 13, 17, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 13, 0, 13, 2, 39, 13, 13, 0, 13, 2, 39, 13, 2, 18, 13, 13, 13, 0, 13, 2, 39, 13, 18, 13, 13, 0, 13, 13, 0, 13, 2, 39, 17, 13, 0, 13, 17, 28, 13, 4, 13, 17, 13, 17, 0, 18, 13, 13, 18, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 13, 17, 0, 18, 13, 13, 18, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 17, 13, 0, 13, 2, 18, 13, 2, 13, 17, 18, 13, 13, 4, 13, 13, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 17, 16 ], [ 6, 23 ], [ 17, 25 ], [ 28, 27 ], [ 6, 36 ], [ 27, 40 ], [ 44, 43 ], [ 47, 46 ], [ 50, 49 ], [ 53, 52 ], [ 16, 55 ], [ 60, 59 ], [ 25, 62 ], [ 27, 66 ], [ 59, 67 ], [ 52, 68 ], [ 71, 70 ], [ 52, 74 ], [ 77, 76 ], [ 27, 82 ], [ 59, 83 ], [ 52, 84 ], [ 87, 86 ], [ 27, 91 ], [ 59, 92 ], [ 95, 94 ], [ 76, 95 ], [ 49, 95 ], [ 98, 97 ], [ 16, 101 ], [ 104, 103 ], [ 107, 106 ], [ 16, 110 ], [ 116, 113 ], [ 97, 114 ], [ 106, 115 ], [ 94, 117 ], [ 86, 117 ], [ 70, 117 ], [ 46, 117 ], [ 103, 118 ], [ 120, 118 ], [ 121, 120 ], [ 124, 123 ], [ 16, 127 ], [ 133, 130 ], [ 97, 131 ], [ 123, 132 ], [ 94, 134 ], [ 86, 134 ], [ 70, 134 ], [ 46, 134 ], [ 120, 135 ], [ 103, 135 ], [ 137, 135 ], [ 138, 137 ], [ 141, 140 ], [ 144, 143 ], [ 16, 147 ], [ 150, 149 ], [ 97, 152 ], [ 143, 154 ], [ 130, 156 ], [ 113, 156 ], [ 97, 157 ], [ 143, 158 ], [ 149, 161 ], [ 140, 161 ], [ 166, 163 ] ]
[ "'''\nfrom math import gcd\nfrom itertools import accumulate, combinations, permutations, product\nfrom bisect import bisect, bisect_left\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heappush, heappop\nfrom functools import reduce\nfrom operator import add, mul, sub, truediv, floordiv, mod\n\nfrom decimal import *\ngetcontext().prec = 500\n\nimport string\nascii = string.ascii_lowercase\n'''\nfrom sys import stdin\n\n\ndef main():\n input = lambda: stdin.readline()[:-1]\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n A.sort(reverse=1)\n cake = []\n x = []\n n = (K + 1) // 2\n for i in range(T):\n if A[i] > n:\n cake += [i] * n\n x += [i] * (A[i] - n)\n else:\n cake += [i] * A[i]\n cake += x\n turn = [0] * K\n j = 0\n for i in range(0, K, 2):\n turn[i] = cake[j]\n j += 1\n for i in range(1, K, 2):\n turn[i] = cake[j]\n j += 1\n ans = 0\n for i in range(1, K):\n ans += turn[i-1] == turn[i]\n print(ans)\n\n\nmain()", "'''\nfrom math import gcd\nfrom itertools import accumulate, combinations, permutations, product\nfrom bisect import bisect, bisect_left\nfrom collections import Counter, defaultdict, deque\nfrom heapq import heappush, heappop\nfrom functools import reduce\nfrom operator import add, mul, sub, truediv, floordiv, mod\n\nfrom decimal import *\ngetcontext().prec = 500\n\nimport string\nascii = string.ascii_lowercase\n'''", "from sys import stdin", "def main():\n input = lambda: stdin.readline()[:-1]\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n A.sort(reverse=1)\n cake = []\n x = []\n n = (K + 1) // 2\n for i in range(T):\n if A[i] > n:\n cake += [i] * n\n x += [i] * (A[i] - n)\n else:\n cake += [i] * A[i]\n cake += x\n turn = [0] * K\n j = 0\n for i in range(0, K, 2):\n turn[i] = cake[j]\n j += 1\n for i in range(1, K, 2):\n turn[i] = cake[j]\n j += 1\n ans = 0\n for i in range(1, K):\n ans += turn[i-1] == turn[i]\n print(ans)", "main", "input = lambda: stdin.readline()[:-1]", "input", "lambda: stdin.readline()[:-1]", "stdin.readline()[:-1]", "stdin.readline()", "stdin.readline", "stdin", "readline", ":-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(reverse=1)", "A.sort", "A", "sort", "reverse=1", "reverse", "1", "cake = []", "cake", "[]", "x = []", "x", "[]", "n = (K + 1) // 2", "n", "(K + 1) // 2", "K + 1", "K", "1", "2", "for i in range(T):\n if A[i] > n:\n cake += [i] * n\n x += [i] * (A[i] - n)\n else:\n cake += [i] * A[i]\n ", "i", "range(T)", "range", "T", "if A[i] > n:\n cake += [i] * n\n x += [i] * (A[i] - n)\n else:\n cake += [i] * A[i]\n ", "A[i] > n", "A[i]", "A", "i", "n", "cake += [i] * n", "cake", "[i] * n", "[i]", "i", "n", "x += [i] * (A[i] - n)", "x", "[i] * (A[i] - n)", "[i]", "i", "A[i] - n", "A[i]", "A", "i", "n", "cake += [i] * A[i]", "cake", "[i] * A[i]", "[i]", "i", "A[i]", "A", "i", "cake += x", "cake", "x", "turn = [0] * K", "turn", "[0] * K", "[0]", "0", "K", "j = 0", "j", "0", "for i in range(0, K, 2):\n turn[i] = cake[j]\n j += 1\n ", "i", "range(0, K, 2)", "range", "0", "K", "2", "turn[i] = cake[j]", "turn[i]", "turn", "i", "cake[j]", "cake", "j", "j += 1", "j", "1", "for i in range(1, K, 2):\n turn[i] = cake[j]\n j += 1\n ", "i", "range(1, K, 2)", "range", "1", "K", "2", "turn[i] = cake[j]", "turn[i]", "turn", "i", "cake[j]", "cake", "j", "j += 1", "j", "1", "ans = 0", "ans", "0", "for i in range(1, K):\n ans += turn[i-1] == turn[i]\n ", "i", "range(1, K)", "range", "1", "K", "ans += turn[i-1] == turn[i]", "ans", "turn[i-1] == turn[i]", "turn[i-1]", "turn", "i-1", "i", "1", "turn[i]", "turn", "i", "print(ans)", "print", "ans", "main()", "main", "def main():\n input = lambda: stdin.readline()[:-1]\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n A.sort(reverse=1)\n cake = []\n x = []\n n = (K + 1) // 2\n for i in range(T):\n if A[i] > n:\n cake += [i] * n\n x += [i] * (A[i] - n)\n else:\n cake += [i] * A[i]\n cake += x\n turn = [0] * K\n j = 0\n for i in range(0, K, 2):\n turn[i] = cake[j]\n j += 1\n for i in range(1, K, 2):\n turn[i] = cake[j]\n j += 1\n ans = 0\n for i in range(1, K):\n ans += turn[i-1] == turn[i]\n print(ans)", "def main():\n input = lambda: stdin.readline()[:-1]\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n\n A.sort(reverse=1)\n cake = []\n x = []\n n = (K + 1) // 2\n for i in range(T):\n if A[i] > n:\n cake += [i] * n\n x += [i] * (A[i] - n)\n else:\n cake += [i] * A[i]\n cake += x\n turn = [0] * K\n j = 0\n for i in range(0, K, 2):\n turn[i] = cake[j]\n j += 1\n for i in range(1, K, 2):\n turn[i] = cake[j]\n j += 1\n ans = 0\n for i in range(1, K):\n ans += turn[i-1] == turn[i]\n print(ans)", "main" ]
''' from math import gcd from itertools import accumulate, combinations, permutations, product from bisect import bisect, bisect_left from collections import Counter, defaultdict, deque from heapq import heappush, heappop from functools import reduce from operator import add, mul, sub, truediv, floordiv, mod from decimal import * getcontext().prec = 500 import string ascii = string.ascii_lowercase ''' from sys import stdin def main(): input = lambda: stdin.readline()[:-1] K, T = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=1) cake = [] x = [] n = (K + 1) // 2 for i in range(T): if A[i] > n: cake += [i] * n x += [i] * (A[i] - n) else: cake += [i] * A[i] cake += x turn = [0] * K j = 0 for i in range(0, K, 2): turn[i] = cake[j] j += 1 for i in range(1, K, 2): turn[i] = cake[j] j += 1 ans = 0 for i in range(1, K): ans += turn[i-1] == turn[i] print(ans) 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, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 13, 0, 13, 18, 13, 13, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 13, 13, 9, 0, 13, 18, 13, 13, 14, 2, 2, 13, 17, 13, 4, 13, 2, 2, 13, 13, 17, 4, 13, 17, 10, 13, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13 ]
[ [ 102, 2 ], [ 102, 11 ], [ 99, 13 ], [ 96, 25 ], [ 105, 28 ], [ 32, 31 ], [ 94, 34 ], [ 100, 38 ], [ 31, 39 ], [ 106, 40 ], [ 109, 40 ], [ 108, 42 ], [ 100, 44 ], [ 31, 45 ], [ 84, 47 ], [ 31, 48 ], [ 90, 50 ], [ 54, 53 ], [ 94, 56 ], [ 53, 59 ], [ 85, 60 ], [ 97, 60 ], [ 87, 63 ], [ 100, 65 ], [ 53, 66 ], [ 109, 70 ], [ 106, 70 ], [ 88, 72 ], [ 91, 72 ], [ 109, 77 ], [ 106, 77 ], [ 88, 78 ], [ 91, 78 ], [ 31, 84 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ], [ 102, 94 ], [ 96, 97 ], [ 99, 100 ], [ 102, 103 ], [ 105, 106 ], [ 108, 109 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nmaxix = 0\nmaxv = -1\n\nfor aix in range(T):\n if A[aix] > maxv:\n maxv = A[aix]\n maxix = aix\n\ntotal = 0\nfor aix in range(T):\n if aix == maxix:\n continue\n else:\n total += A[aix]\n\nif maxv - 1 > total:\n print(maxv-total-1)\nelse:\n print(0)\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", "maxix = 0", "maxix", "0", "maxv = -1", "maxv", "-1", "for aix in range(T):\n if A[aix] > maxv:\n maxv = A[aix]\n maxix = aix", "aix", "range(T)", "range", "T", "if A[aix] > maxv:\n maxv = A[aix]\n maxix = aix", "A[aix] > maxv", "A[aix]", "A", "aix", "maxv", "maxv = A[aix]", "maxv", "A[aix]", "A", "aix", "maxix = aix", "maxix", "aix", "total = 0", "total", "0", "for aix in range(T):\n if aix == maxix:\n continue\n else:\n total += A[aix]", "aix", "range(T)", "range", "T", "if aix == maxix:\n continue\n else:\n total += A[aix]", "aix == maxix", "aix", "maxix", "continue", "total += A[aix]", "total", "A[aix]", "A", "aix", "if maxv - 1 > total:\n print(maxv-total-1)\nelse:\n print(0)", "maxv - 1 > total", "maxv - 1", "maxv", "1", "total", "print(maxv-total-1)", "print", "maxv-total-1", "maxv-total", "maxv", "total", "1", "print(0)", "print", "0", "maxix = aix", "aix", "maxix", "total += A[aix]", "A[aix]", "total", "total = 0", "0", "total", "T = map(int, input().split())", "map(int, input().split())", "T", "maxix = 0", "0", "maxix", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "K, T = map(int, input().split())", "map(int, input().split())", "K", "maxv = -1", "-1", "maxv", "maxv = A[aix]", "A[aix]", "maxv" ]
K, T = map(int, input().split()) A = list(map(int, input().split())) maxix = 0 maxv = -1 for aix in range(T): if A[aix] > maxv: maxv = A[aix] maxix = aix total = 0 for aix in range(T): if aix == maxix: continue else: total += A[aix] if maxv - 1 > total: print(maxv-total-1) else: print(0)
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 18, 18, 13, 13, 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, 13, 13, 4, 13, 4, 13, 17, 2, 2, 13, 13, 17, 10, 18, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 61, 11 ], [ 73, 18 ], [ 62, 25 ], [ 73, 27 ], [ 70, 29 ], [ 62, 38 ], [ 76, 41 ], [ 71, 44 ], [ 67, 46 ], [ 74, 48 ], [ 77, 49 ], [ 77, 57 ], [ 68, 58 ], [ 61, 62 ], [ 73, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "import sys\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\n\nk, t = map(int, input().split())\na = list( map(int, input().split()))\n\n\nmost = max(a)\nhasami = k-most\n\nprint(max(0,most-hasami-1))\n", "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", "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", "most = max(a)", "most", "max(a)", "max", "a", "hasami = k-most", "hasami", "k-most", "k", "most", "print(max(0,most-hasami-1))", "print", "max(0,most-hasami-1)", "max", "0", "most-hasami-1", "most-hasami", "most", "hasami", "1", "input = sys.stdin.readline", "sys.stdin.readline", "input", "t = map(int, input().split())", "map(int, input().split())", "t", "hasami = k-most", "k-most", "hasami", "a = list( map(int, input().split()))", "list( map(int, input().split()))", "a", "k, t = map(int, input().split())", "map(int, input().split())", "k", "most = max(a)", "max(a)", "most" ]
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline k, t = map(int, input().split()) a = list( map(int, input().split())) most = max(a) hasami = k-most print(max(0,most-hasami-1))
[ 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, 4, 18, 13, 13, 0, 13, 17, 0, 13, 18, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 14, 40, 2, 13, 13, 17, 4, 13, 17, 29, 4, 13, 2, 2, 13, 13, 17, 29, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 13 ], [ 16, 15 ], [ 15, 28 ], [ 32, 31 ], [ 35, 34 ], [ 15, 36 ], [ 40, 39 ], [ 15, 43 ], [ 34, 49 ], [ 39, 50 ], [ 34, 60 ], [ 39, 61 ], [ 72, 69 ] ]
[ "def main():\n K, T = map(int, input().split())\n a = list(map(int, input().split()))\n\n a.sort(reverse=True)\n greatest = a[0]\n others = sum(a[1:])\n\n if greatest - others <= 1:\n print(0)\n return\n else:\n print(greatest-others-1)\n return\n\nif __name__ == '__main__':\n main()", "def main():\n K, T = map(int, input().split())\n a = list(map(int, input().split()))\n\n a.sort(reverse=True)\n greatest = a[0]\n others = sum(a[1:])\n\n if greatest - others <= 1:\n print(0)\n return\n else:\n print(greatest-others-1)\n return", "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", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "greatest = a[0]", "greatest", "a[0]", "a", "0", "others = sum(a[1:])", "others", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "if greatest - others <= 1:\n print(0)\n return\n else:\n print(greatest-others-1)\n return", "greatest - others <= 1", "greatest - others", "greatest", "others", "1", "print(0)", "print", "0", "return", "print(greatest-others-1)", "print", "greatest-others-1", "greatest-others", "greatest", "others", "1", "return", "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 a.sort(reverse=True)\n greatest = a[0]\n others = sum(a[1:])\n\n if greatest - others <= 1:\n print(0)\n return\n else:\n print(greatest-others-1)\n return", "def main():\n K, T = map(int, input().split())\n a = list(map(int, input().split()))\n\n a.sort(reverse=True)\n greatest = a[0]\n others = sum(a[1:])\n\n if greatest - others <= 1:\n print(0)\n return\n else:\n print(greatest-others-1)\n return", "main" ]
def main(): K, T = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) greatest = a[0] others = sum(a[1:]) if greatest - others <= 1: print(0) return else: print(greatest-others-1) return 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, 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, 28, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 14, 40, 18, 13, 17, 13, 0, 13, 18, 13, 17, 14, 40, 2, 18, 13, 17, 17, 17, 4, 18, 13, 13, 13, 39, 2, 18, 13, 17, 17, 18, 13, 17, 14, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 18, 13, 17, 4, 18, 13, 13, 13, 39, 18, 13, 17, 18, 13, 17, 14, 40, 2, 18, 13, 17, 17, 17, 4, 18, 13, 13, 13, 39, 2, 18, 13, 17, 17, 18, 13, 17, 14, 2, 13, 18, 13, 17, 0, 13, 17, 0, 13, 2, 40, 18, 13, 17, 17, 3, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 17, 13 ]
[ [ 195, 4 ], [ 195, 13 ], [ 183, 15 ], [ 29, 28 ], [ 169, 31 ], [ 184, 36 ], [ 28, 37 ], [ 177, 40 ], [ 178, 46 ], [ 184, 46 ], [ 192, 48 ], [ 201, 51 ], [ 55, 54 ], [ 196, 57 ], [ 171, 59 ], [ 178, 64 ], [ 184, 64 ], [ 172, 68 ], [ 193, 70 ], [ 175, 70 ], [ 199, 70 ], [ 174, 72 ], [ 172, 74 ], [ 172, 80 ], [ 178, 88 ], [ 184, 88 ], [ 172, 92 ], [ 172, 96 ], [ 180, 101 ], [ 178, 106 ], [ 184, 106 ], [ 198, 108 ], [ 181, 110 ], [ 178, 116 ], [ 184, 116 ], [ 172, 119 ], [ 172, 122 ], [ 181, 128 ], [ 178, 136 ], [ 184, 136 ], [ 181, 140 ], [ 181, 144 ], [ 193, 148 ], [ 175, 148 ], [ 199, 148 ], [ 172, 150 ], [ 189, 153 ], [ 186, 156 ], [ 172, 160 ], [ 187, 166 ], [ 190, 166 ], [ 202, 166 ], [ 195, 169 ], [ 171, 172 ], [ 174, 175 ], [ 177, 178 ], [ 180, 181 ], [ 183, 184 ], [ 186, 187 ], [ 189, 190 ], [ 192, 193 ], [ 195, 196 ], [ 198, 199 ], [ 201, 202 ] ]
[ "import heapq\n\nK, T = map(int, input().split())\na = list(map(int, input().split()))\na = [(-a[i], i) for i in range(T)]\n\nheapq.heapify(a)\ncake_yesterday = -1\nans = 0\n\nfor i in range(K):\n cake1 = heapq.heappop(a)\n if cake1[1] != cake_yesterday:\n cake_yesterday = cake1[1]\n if cake1[0]+1 <= -1:\n heapq.heappush(a, (cake1[0]+1, cake1[1]))\n elif a:\n cake2 = heapq.heappop(a)\n cake_yesterday = cake2[1]\n heapq.heappush(a, (cake1[0], cake1[1]))\n if cake2[0]+1 <= -1:\n heapq.heappush(a, (cake2[0]+1, cake2[1]))\n else:\n if cake_yesterday == cake1[1]:\n ans += 1\n ans += -cake1[0] - 1\n break\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", "(-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)]", "heapq.heapify(a)", "heapq.heapify", "heapq", "heapify", "a", "cake_yesterday = -1", "cake_yesterday", "-1", "ans = 0", "ans", "0", "for i in range(K):\n cake1 = heapq.heappop(a)\n if cake1[1] != cake_yesterday:\n cake_yesterday = cake1[1]\n if cake1[0]+1 <= -1:\n heapq.heappush(a, (cake1[0]+1, cake1[1]))\n elif a:\n cake2 = heapq.heappop(a)\n cake_yesterday = cake2[1]\n heapq.heappush(a, (cake1[0], cake1[1]))\n if cake2[0]+1 <= -1:\n heapq.heappush(a, (cake2[0]+1, cake2[1]))\n else:\n if cake_yesterday == cake1[1]:\n ans += 1\n ans += -cake1[0] - 1\n break", "i", "range(K)", "range", "K", "cake1 = heapq.heappop(a)", "cake1", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "if cake1[1] != cake_yesterday:\n cake_yesterday = cake1[1]\n if cake1[0]+1 <= -1:\n heapq.heappush(a, (cake1[0]+1, cake1[1]))\n elif a:\n cake2 = heapq.heappop(a)\n cake_yesterday = cake2[1]\n heapq.heappush(a, (cake1[0], cake1[1]))\n if cake2[0]+1 <= -1:\n heapq.heappush(a, (cake2[0]+1, cake2[1]))\n else:\n if cake_yesterday == cake1[1]:\n ans += 1\n ans += -cake1[0] - 1\n break", "cake1[1] != cake_yesterday", "cake1[1]", "cake1", "1", "cake_yesterday", "cake_yesterday = cake1[1]", "cake_yesterday", "cake1[1]", "cake1", "1", "if cake1[0]+1 <= -1:\n heapq.heappush(a, (cake1[0]+1, cake1[1]))\n ", "cake1[0]+1 <= -1", "cake1[0]+1", "cake1[0]", "cake1", "0", "1", "-1", "heapq.heappush(a, (cake1[0]+1, cake1[1]))", "heapq.heappush", "heapq", "heappush", "a", "(cake1[0]+1, cake1[1])", "cake1[0]+1", "cake1[0]", "cake1", "0", "1", "cake1[1]", "cake1", "1", "elif a:\n cake2 = heapq.heappop(a)\n cake_yesterday = cake2[1]\n heapq.heappush(a, (cake1[0], cake1[1]))\n if cake2[0]+1 <= -1:\n heapq.heappush(a, (cake2[0]+1, cake2[1]))\n ", "a", "cake2 = heapq.heappop(a)", "cake2", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "cake_yesterday = cake2[1]", "cake_yesterday", "cake2[1]", "cake2", "1", "heapq.heappush(a, (cake1[0], cake1[1]))", "heapq.heappush", "heapq", "heappush", "a", "(cake1[0], cake1[1])", "cake1[0]", "cake1", "0", "cake1[1]", "cake1", "1", "if cake2[0]+1 <= -1:\n heapq.heappush(a, (cake2[0]+1, cake2[1]))\n ", "cake2[0]+1 <= -1", "cake2[0]+1", "cake2[0]", "cake2", "0", "1", "-1", "heapq.heappush(a, (cake2[0]+1, cake2[1]))", "heapq.heappush", "heapq", "heappush", "a", "(cake2[0]+1, cake2[1])", "cake2[0]+1", "cake2[0]", "cake2", "0", "1", "cake2[1]", "cake2", "1", "if cake_yesterday == cake1[1]:\n ans += 1\n ", "cake_yesterday == cake1[1]", "cake_yesterday", "cake1[1]", "cake1", "1", "ans += 1", "ans", "1", "ans += -cake1[0] - 1", "ans", "-cake1[0] - 1", "-cake1[0]", "cake1[0]", "cake1", "0", "1", "break", "print(ans)", "print", "ans", "T = map(int, input().split())", "map(int, input().split())", "T", "cake1 = heapq.heappop(a)", "heapq.heappop(a)", "cake1", "cake_yesterday = cake1[1]", "cake1[1]", "cake_yesterday", "a = [(-a[i], i) for i in range(T)]", "[(-a[i], i) for i in range(T)]", "a", "cake2 = heapq.heappop(a)", "heapq.heappop(a)", "cake2", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans += -cake1[0] - 1", "-cake1[0] - 1", "ans", "ans += 1", "1", "ans", "cake_yesterday = -1", "-1", "cake_yesterday", "K, T = map(int, input().split())", "map(int, input().split())", "K", "cake_yesterday = cake2[1]", "cake2[1]", "cake_yesterday", "ans = 0", "0", "ans" ]
import heapq K, T = map(int, input().split()) a = list(map(int, input().split())) a = [(-a[i], i) for i in range(T)] heapq.heapify(a) cake_yesterday = -1 ans = 0 for i in range(K): cake1 = heapq.heappop(a) if cake1[1] != cake_yesterday: cake_yesterday = cake1[1] if cake1[0]+1 <= -1: heapq.heappush(a, (cake1[0]+1, cake1[1])) elif a: cake2 = heapq.heappop(a) cake_yesterday = cake2[1] heapq.heappush(a, (cake1[0], cake1[1])) if cake2[0]+1 <= -1: heapq.heappush(a, (cake2[0]+1, cake2[1])) else: if cake_yesterday == cake1[1]: ans += 1 ans += -cake1[0] - 1 break 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, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 14, 2, 13, 17, 0, 13, 2, 2, 13, 17, 17, 14, 40, 13, 13, 4, 13, 17, 0, 13, 2, 13, 13, 4, 13, 2, 17, 13, 0, 13, 2, 13, 17, 14, 40, 13, 13, 4, 13, 17, 0, 13, 2, 13, 13, 4, 13, 2, 2, 17, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 2, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 99, 2 ], [ 99, 11 ], [ 114, 13 ], [ 93, 25 ], [ 115, 28 ], [ 100, 31 ], [ 97, 36 ], [ 97, 42 ], [ 108, 45 ], [ 97, 48 ], [ 109, 53 ], [ 94, 54 ], [ 102, 59 ], [ 94, 61 ], [ 109, 62 ], [ 103, 67 ], [ 105, 69 ], [ 97, 71 ], [ 106, 75 ], [ 94, 76 ], [ 111, 81 ], [ 94, 83 ], [ 106, 84 ], [ 112, 90 ], [ 93, 94 ], [ 99, 97 ], [ 99, 100 ], [ 102, 103 ], [ 105, 106 ], [ 108, 109 ], [ 111, 112 ], [ 114, 115 ] ]
[ "K,T=map(int,input().split())\nA=list(map(int,input().split()))\n\nB=max(A)\n\nif T==1:\n print(K-1)\n exit()\n\nif K%2:\n X=(K+1)//2\n if X>=B:\n print(0)\n else:\n C=B-X\n print(2*C)\nelse:\n Y=K//2\n if Y>=B:\n print(0)\n else:\n C=B-Y\n print(2*C-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", "B=max(A)", "B", "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:\n X=(K+1)//2\n if X>=B:\n print(0)\n else:\n C=B-X\n print(2*C)\nelse:\n Y=K//2\n if Y>=B:\n print(0)\n else:\n C=B-Y\n print(2*C-1)", "K%2", "K", "2", "X=(K+1)//2", "X", "(K+1)//2", "K+1", "K", "1", "2", "if X>=B:\n print(0)\n else:\n C=B-X\n print(2*C)", "X>=B", "X", "B", "print(0)", "print", "0", "C=B-X", "C", "B-X", "B", "X", "print(2*C)", "print", "2*C", "2", "C", "Y=K//2", "Y", "K//2", "K", "2", "if Y>=B:\n print(0)\n else:\n C=B-Y\n print(2*C-1)", "Y>=B", "Y", "B", "print(0)", "print", "0", "C=B-Y", "C", "B-Y", "B", "Y", "print(2*C-1)", "print", "2*C-1", "2*C", "2", "C", "1", "B=max(A)", "max(A)", "B", "K,T=map(int,input().split())", "map(int,input().split())", "K", "T=map(int,input().split())", "map(int,input().split())", "T", "C=B-X", "B-X", "C", "Y=K//2", "K//2", "Y", "X=(K+1)//2", "(K+1)//2", "X", "C=B-Y", "B-Y", "C", "A=list(map(int,input().split()))", "list(map(int,input().split()))", "A" ]
K,T=map(int,input().split()) A=list(map(int,input().split())) B=max(A) if T==1: print(K-1) exit() if K%2: X=(K+1)//2 if X>=B: print(0) else: C=B-X print(2*C) else: Y=K//2 if Y>=B: print(0) else: C=B-Y print(2*C-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, 2, 39, 17, 13, 28, 13, 4, 13, 13, 0, 18, 13, 13, 39, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 2, 13, 17, 28, 13, 4, 13, 13, 4, 18, 13, 13, 0, 13, 12, 18, 13, 17, 23, 0, 13, 17, 14, 2, 18, 18, 13, 17, 17, 13, 14, 2, 18, 18, 13, 17, 17, 17, 0, 13, 18, 18, 13, 17, 17, 3, 0, 18, 18, 13, 17, 17, 17, 0, 13, 18, 18, 13, 17, 17, 0, 18, 18, 13, 17, 17, 17, 0, 13, 18, 18, 13, 17, 17, 4, 13, 13, 10, 4, 13, 10, 18, 13, 10, 2, 13, 10, 2, 13, 10, 18, 13, 10, 18, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 155, 2 ], [ 155, 11 ], [ 134, 13 ], [ 140, 25 ], [ 156, 29 ], [ 32, 31 ], [ 156, 34 ], [ 39, 36 ], [ 141, 37 ], [ 31, 38 ], [ 135, 41 ], [ 31, 42 ], [ 161, 45 ], [ 158, 48 ], [ 156, 52 ], [ 143, 55 ], [ 153, 57 ], [ 61, 60 ], [ 153, 63 ], [ 141, 66 ], [ 70, 69 ], [ 77, 76 ], [ 141, 82 ], [ 162, 85 ], [ 138, 85 ], [ 150, 85 ], [ 141, 90 ], [ 146, 95 ], [ 141, 98 ], [ 108, 103 ], [ 141, 105 ], [ 149, 110 ], [ 141, 113 ], [ 122, 117 ], [ 141, 119 ], [ 137, 124 ], [ 141, 127 ], [ 147, 132 ], [ 159, 132 ], [ 134, 135 ], [ 137, 138 ], [ 140, 141 ], [ 143, 144 ], [ 146, 147 ], [ 149, 150 ], [ 155, 153 ], [ 155, 156 ], [ 158, 159 ], [ 161, 162 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\nb = [0]*t\nfor i in range(t):\n b[i] = [a[i], i]\ns = -1\nans = 0\nif t == 1:\n ans = k-1\nelse:\n for i in range(k):\n b.sort(key= lambda val : val[0],reverse=True)\n if b[0][1] == s:\n if b[1][0] == 0:\n ans = b[0][0]\n break\n else:\n b[1][0] -= 1\n s = b[1][1]\n else:\n b[0][0] -= 1\n s = b[0][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", "b = [0]*t", "b", "[0]*t", "[0]", "0", "t", "for i in range(t):\n b[i] = [a[i], i]", "i", "range(t)", "range", "t", "b[i] = [a[i], i]", "b[i]", "b", "i", "[a[i], i]", "a[i]", "a", "i", "i", "s = -1", "s", "-1", "ans = 0", "ans", "0", "if t == 1:\n ans = k-1\nelse:\n for i in range(k):\n b.sort(key= lambda val : val[0],reverse=True)\n if b[0][1] == s:\n if b[1][0] == 0:\n ans = b[0][0]\n break\n else:\n b[1][0] -= 1\n s = b[1][1]\n else:\n b[0][0] -= 1\n s = b[0][1]", "t == 1", "t", "1", "ans = k-1", "ans", "k-1", "k", "1", "for i in range(k):\n b.sort(key= lambda val : val[0],reverse=True)\n if b[0][1] == s:\n if b[1][0] == 0:\n ans = b[0][0]\n break\n else:\n b[1][0] -= 1\n s = b[1][1]\n else:\n b[0][0] -= 1\n s = b[0][1]", "i", "range(k)", "range", "k", "b.sort(key= lambda val : val[0],reverse=True)", "b.sort", "b", "sort", "key= lambda val : val[0]", "key", "lambda val : val[0]", "val[0]", "val", "0", "val", "reverse=True", "reverse", "True", "if b[0][1] == s:\n if b[1][0] == 0:\n ans = b[0][0]\n break\n else:\n b[1][0] -= 1\n s = b[1][1]\n else:\n b[0][0] -= 1\n s = b[0][1]", "b[0][1] == s", "b[0][1]", "[0]", "b", "0", "1", "s", "if b[1][0] == 0:\n ans = b[0][0]\n break\n else:\n b[1][0] -= 1\n s = b[1][1]\n ", "b[1][0] == 0", "b[1][0]", "[1]", "b", "1", "0", "0", "ans = b[0][0]", "ans", "b[0][0]", "[0]", "b", "0", "0", "break", "b[1][0] -= 1", "b[1][0]", "[1]", "b", "1", "0", "1", "s = b[1][1]", "s", "b[1][1]", "[1]", "b", "1", "1", "b[0][0] -= 1", "b[0][0]", "[0]", "b", "0", "0", "1", "s = b[0][1]", "s", "b[0][1]", "[0]", "b", "0", "1", "print(ans)", "print", "ans", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "s = b[0][1]", "b[0][1]", "s", "b = [0]*t", "[0]*t", "b", "ans = k-1", "k-1", "ans", "ans = b[0][0]", "b[0][0]", "ans", "s = b[1][1]", "b[1][1]", "s", "k,t = map(int,input().split())", "map(int,input().split())", "k", "t = map(int,input().split())", "map(int,input().split())", "t", "ans = 0", "0", "ans", "s = -1", "-1", "s" ]
k,t = map(int,input().split()) a = list(map(int,input().split())) b = [0]*t for i in range(t): b[i] = [a[i], i] s = -1 ans = 0 if t == 1: ans = k-1 else: for i in range(k): b.sort(key= lambda val : val[0],reverse=True) if b[0][1] == s: if b[1][0] == 0: ans = b[0][0] break else: b[1][0] -= 1 s = b[1][1] else: b[0][0] -= 1 s = b[0][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, 0, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 14, 2, 2, 13, 17, 2, 4, 13, 13, 13, 4, 13, 2, 2, 2, 13, 17, 4, 13, 13, 13, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 72, 2 ], [ 72, 11 ], [ 63, 13 ], [ 69, 25 ], [ 64, 28 ], [ 67, 31 ], [ 73, 36 ], [ 70, 41 ], [ 64, 46 ], [ 70, 47 ], [ 70, 53 ], [ 64, 57 ], [ 70, 58 ], [ 63, 64 ], [ 72, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "k, t = map(int,input().split())\nA = list(map(int,input().split()))\nmax_A = max(A)\n\nif t == 1:\n print(k-1)\nelse:\n if max_A -1 > sum(A) - max_A:\n print((max_A -1) - sum(A) + max_A)\n else:\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", "max_A = max(A)", "max_A", "max(A)", "max", "A", "if t == 1:\n print(k-1)\nelse:\n if max_A -1 > sum(A) - max_A:\n print((max_A -1) - sum(A) + max_A)\n else:\n print(0)\n \n ", "t == 1", "t", "1", "print(k-1)", "print", "k-1", "k", "1", "if max_A -1 > sum(A) - max_A:\n print((max_A -1) - sum(A) + max_A)\n else:\n print(0)\n \n ", "max_A -1 > sum(A) - max_A", "max_A -1", "max_A", "1", "sum(A) - max_A", "sum(A)", "sum", "A", "max_A", "print((max_A -1) - sum(A) + max_A)", "print", "(max_A -1) - sum(A) + max_A", "(max_A -1) - sum(A)", "max_A -1", "max_A", "1", "sum(A)", "sum", "A", "max_A", "print(0)", "print", "0", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "t = map(int,input().split())", "map(int,input().split())", "t", "max_A = max(A)", "max(A)", "max_A", "k, t = map(int,input().split())", "map(int,input().split())", "k" ]
k, t = map(int,input().split()) A = list(map(int,input().split())) max_A = max(A) if t == 1: print(k-1) else: if max_A -1 > sum(A) - max_A: print((max_A -1) - sum(A) + max_A) else: print(0)
[ 7, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 2, 13, 17, 0, 13, 4, 13, 17, 2, 13, 13, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 66, 2 ], [ 66, 14 ], [ 69, 16 ], [ 72, 29 ], [ 70, 32 ], [ 63, 34 ], [ 70, 38 ], [ 73, 39 ], [ 60, 41 ], [ 73, 43 ], [ 75, 46 ], [ 61, 51 ], [ 64, 52 ], [ 76, 55 ], [ 61, 55 ], [ 66, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "K,T = list(map(int,input().split(\" \")))\nnums = list(map(int,input().split(\" \")))\nma = max(nums)\ns = sum(nums) - ma\nans = ma - 1\nans = max(0,ans -s )\nprint(ans)", "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", "nums = list(map(int,input().split(\" \")))", "nums", "list(map(int,input().split(\" \")))", "list", "map(int,input().split(\" \"))", "map", "int", "input().split(\" \")", "().split", "()", "input", "split", "\" \"", "ma = max(nums)", "ma", "max(nums)", "max", "nums", "s = sum(nums) - ma", "s", "sum(nums) - ma", "sum(nums)", "sum", "nums", "ma", "ans = ma - 1", "ans", "ma - 1", "ma", "1", "ans = max(0,ans -s )", "ans", "max(0,ans -s )", "max", "0", "ans -s", "ans", "s", "print(ans)", "print", "ans", "T = list(map(int,input().split(\" \")))", "list(map(int,input().split(\" \")))", "T", "ans = ma - 1", "ma - 1", "ans", "s = sum(nums) - ma", "sum(nums) - ma", "s", "K,T = list(map(int,input().split(\" \")))", "list(map(int,input().split(\" \")))", "K", "nums = list(map(int,input().split(\" \")))", "list(map(int,input().split(\" \")))", "nums", "ma = max(nums)", "max(nums)", "ma", "ans = max(0,ans -s )", "max(0,ans -s )", "ans" ]
K,T = list(map(int,input().split(" "))) nums = list(map(int,input().split(" "))) ma = max(nums) s = sum(nums) - ma ans = ma - 1 ans = max(0,ans -s ) 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, 13, 4, 13, 2, 2, 4, 13, 13, 2, 4, 13, 13, 4, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 49, 2 ], [ 49, 11 ], [ 43, 13 ], [ 44, 32 ], [ 44, 36 ], [ 44, 39 ], [ 43, 44 ], [ 49, 47 ], [ 49, 50 ] ]
[ "N, T = map(int, input().split())\nA = list(map(int,input().split()))\nprint(max(max(A) - (sum(A) - max(A)) - 1, 0))", "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()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max(max(A) - (sum(A) - max(A)) - 1, 0))", "print", "max(max(A) - (sum(A) - max(A)) - 1, 0)", "max", "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", "0", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "T = map(int, input().split())", "map(int, input().split())", "T", "N, T = map(int, input().split())", "map(int, input().split())", "N" ]
N, T = map(int, input().split()) A = list(map(int,input().split())) print(max(max(A) - (sum(A) - max(A)) - 1, 0))
[ 7, 15, 13, 0, 13, 4, 18, 4, 13, 13, 0, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 18, 13, 17, 0, 13, 4, 13, 18, 13, 17, 0, 13, 4, 13, 17, 0, 13, 39, 28, 13, 4, 13, 17, 13, 4, 18, 13, 13, 4, 13, 18, 13, 13, 4, 18, 13, 13, 4, 18, 13, 13, 14, 2, 13, 17, 4, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 14, 2, 13, 17, 4, 13, 2, 2, 18, 13, 17, 18, 13, 17, 17, 4, 18, 13, 13, 28, 13, 4, 13, 17, 13, 0, 13, 18, 13, 17, 14, 2, 2, 13, 17, 18, 13, 17, 14, 2, 18, 13, 17, 17, 0, 13, 17, 14, 40, 18, 13, 17, 17, 0, 13, 17, 0, 13, 4, 13, 18, 13, 17, 4, 18, 13, 13, 13, 0, 13, 4, 13, 17, 0, 13, 4, 13, 17, 0, 13, 4, 13, 2, 13, 17, 42, 40, 13, 13, 0, 13, 4, 13, 2, 13, 2, 2, 13, 13, 17, 14, 40, 18, 13, 13, 2, 13, 17, 0, 13, 2, 13, 17, 0, 13, 4, 13, 13, 2, 13, 17, 0, 13, 2, 13, 17, 4, 18, 13, 13, 13, 2, 13, 17, 0, 18, 13, 17, 17, 14, 2, 2, 13, 17, 18, 13, 17, 0, 18, 13, 17, 17, 14, 2, 13, 18, 13, 17, 0, 13, 4, 13, 17, 0, 13, 4, 13, 17, 0, 13, 4, 13, 2, 13, 17, 42, 40, 13, 13, 0, 13, 4, 13, 2, 13, 2, 2, 13, 13, 17, 14, 2, 18, 13, 13, 13, 0, 13, 2, 13, 17, 0, 13, 4, 13, 13, 2, 13, 17, 0, 13, 2, 13, 17, 4, 18, 13, 13, 13, 2, 13, 17, 4, 18, 13, 13, 13, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 39, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 353, 4 ], [ 320, 11 ], [ 356, 18 ], [ 354, 22 ], [ 377, 25 ], [ 354, 29 ], [ 365, 32 ], [ 368, 37 ], [ 41, 40 ], [ 378, 44 ], [ 369, 47 ], [ 321, 52 ], [ 40, 53 ], [ 369, 56 ], [ 369, 60 ], [ 378, 64 ], [ 369, 70 ], [ 378, 79 ], [ 369, 86 ], [ 369, 89 ], [ 98, 97 ], [ 357, 101 ], [ 371, 103 ], [ 369, 105 ], [ 372, 110 ], [ 369, 113 ], [ 369, 118 ], [ 374, 122 ], [ 369, 127 ], [ 362, 131 ], [ 332, 134 ], [ 369, 138 ], [ 369, 142 ], [ 333, 144 ], [ 311, 146 ], [ 359, 151 ], [ 314, 156 ], [ 378, 160 ], [ 360, 164 ], [ 345, 164 ], [ 309, 164 ], [ 318, 164 ], [ 315, 165 ], [ 330, 165 ], [ 351, 165 ], [ 327, 165 ], [ 338, 167 ], [ 360, 171 ], [ 345, 171 ], [ 309, 171 ], [ 318, 171 ], [ 315, 174 ], [ 330, 174 ], [ 351, 174 ], [ 327, 174 ], [ 360, 175 ], [ 345, 175 ], [ 309, 175 ], [ 318, 175 ], [ 369, 180 ], [ 339, 181 ], [ 342, 181 ], [ 333, 183 ], [ 344, 186 ], [ 339, 188 ], [ 342, 188 ], [ 347, 191 ], [ 312, 194 ], [ 348, 194 ], [ 336, 194 ], [ 324, 194 ], [ 339, 196 ], [ 342, 196 ], [ 329, 199 ], [ 339, 201 ], [ 342, 201 ], [ 369, 205 ], [ 348, 207 ], [ 312, 207 ], [ 336, 207 ], [ 324, 207 ], [ 333, 209 ], [ 215, 212 ], [ 369, 213 ], [ 372, 219 ], [ 369, 222 ], [ 228, 225 ], [ 369, 226 ], [ 372, 231 ], [ 369, 233 ], [ 323, 236 ], [ 317, 241 ], [ 326, 246 ], [ 378, 250 ], [ 318, 254 ], [ 345, 254 ], [ 360, 254 ], [ 309, 254 ], [ 327, 255 ], [ 330, 255 ], [ 315, 255 ], [ 351, 255 ], [ 341, 257 ], [ 318, 261 ], [ 345, 261 ], [ 360, 261 ], [ 309, 261 ], [ 327, 264 ], [ 330, 264 ], [ 315, 264 ], [ 351, 264 ], [ 318, 265 ], [ 345, 265 ], [ 360, 265 ], [ 309, 265 ], [ 369, 270 ], [ 342, 271 ], [ 339, 271 ], [ 372, 272 ], [ 308, 274 ], [ 342, 276 ], [ 339, 276 ], [ 335, 279 ], [ 324, 282 ], [ 348, 282 ], [ 312, 282 ], [ 336, 282 ], [ 342, 284 ], [ 339, 284 ], [ 350, 287 ], [ 342, 289 ], [ 339, 289 ], [ 369, 293 ], [ 336, 295 ], [ 324, 295 ], [ 348, 295 ], [ 312, 295 ], [ 372, 297 ], [ 369, 301 ], [ 372, 303 ], [ 375, 306 ], [ 366, 306 ], [ 308, 309 ], [ 311, 312 ], [ 314, 315 ], [ 317, 318 ], [ 320, 321 ], [ 323, 324 ], [ 326, 327 ], [ 329, 330 ], [ 332, 333 ], [ 335, 336 ], [ 338, 339 ], [ 341, 342 ], [ 344, 345 ], [ 347, 348 ], [ 350, 351 ], [ 353, 354 ], [ 356, 357 ], [ 359, 360 ], [ 362, 363 ], [ 365, 366 ], [ 368, 369 ], [ 371, 372 ], [ 374, 375 ], [ 377, 378 ] ]
[ "import sys\nR1 = input().split()\nR2 = input().split()\nK = int(R1[0])\nT = int(R1[1])\nanswer = int(0)\nA = []\nfor i in range (0, T):\n A.append(int(R2[i]))\nA.sort()\nA.reverse()\nif T == 1:\n print(A[0] - 1)\n sys.exit()\nif T == 2:\n print(A[0] - A[1] - 1)\n sys.exit()\nfor i in range (0, K):\n C = A[0]\n if C - 1 > A[1]:\n if A[1] == 0:\n answer += 1\n if A[1] != 0:\n K -= 1\n D = int(A[1])\n A.remove(D)\n F = int(1)\n left = int(0)\n right = int(T - 2)\n while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] >= D - 1:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n A.insert(F, D - 1)\n A[0] -= 1\n if C - 1 == A[1]:\n A[0] -= 1\n if C == A[1]:\n F = int(0)\n left = int(0)\n right = int(T - 1)\n while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] == C:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n A.insert(F, C - 1)\n A.remove(C)\nprint(answer)", "import sys", "sys", "R1 = input().split()", "R1", "input().split()", "().split", "()", "input", "split", "R2 = input().split()", "R2", "input().split()", "().split", "()", "input", "split", "K = int(R1[0])", "K", "int(R1[0])", "int", "R1[0]", "R1", "0", "T = int(R1[1])", "T", "int(R1[1])", "int", "R1[1]", "R1", "1", "answer = int(0)", "answer", "int(0)", "int", "0", "A = []", "A", "[]", "for i in range (0, T):\n A.append(int(R2[i]))", "i", "range (0, T)", "range", "0", "T", "A.append(int(R2[i]))", "A.append", "A", "append", "int(R2[i])", "int", "R2[i]", "R2", "i", "A.sort()", "A.sort", "A", "sort", "A.reverse()", "A.reverse", "A", "reverse", "if T == 1:\n print(A[0] - 1)\n sys.exit()", "T == 1", "T", "1", "print(A[0] - 1)", "print", "A[0] - 1", "A[0]", "A", "0", "1", "sys.exit()", "sys.exit", "sys", "exit", "if T == 2:\n print(A[0] - A[1] - 1)\n sys.exit()", "T == 2", "T", "2", "print(A[0] - A[1] - 1)", "print", "A[0] - A[1] - 1", "A[0] - A[1]", "A[0]", "A", "0", "A[1]", "A", "1", "1", "sys.exit()", "sys.exit", "sys", "exit", "for i in range (0, K):\n C = A[0]\n if C - 1 > A[1]:\n if A[1] == 0:\n answer += 1\n if A[1] != 0:\n K -= 1\n D = int(A[1])\n A.remove(D)\n F = int(1)\n left = int(0)\n right = int(T - 2)\n while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] >= D - 1:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n A.insert(F, D - 1)\n A[0] -= 1\n if C - 1 == A[1]:\n A[0] -= 1\n if C == A[1]:\n F = int(0)\n left = int(0)\n right = int(T - 1)\n while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] == C:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n A.insert(F, C - 1)\n A.remove(C)", "i", "range (0, K)", "range", "0", "K", "C = A[0]", "C", "A[0]", "A", "0", "if C - 1 > A[1]:\n if A[1] == 0:\n answer += 1\n if A[1] != 0:\n K -= 1\n D = int(A[1])\n A.remove(D)\n F = int(1)\n left = int(0)\n right = int(T - 2)\n while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] >= D - 1:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n A.insert(F, D - 1)\n A[0] -= 1\n ", "C - 1 > A[1]", "C - 1", "C", "1", "A[1]", "A", "1", "if A[1] == 0:\n answer += 1\n ", "A[1] == 0", "A[1]", "A", "1", "0", "answer += 1", "answer", "1", "if A[1] != 0:\n K -= 1\n D = int(A[1])\n A.remove(D)\n F = int(1)\n left = int(0)\n right = int(T - 2)\n while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] >= D - 1:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n A.insert(F, D - 1)\n ", "A[1] != 0", "A[1]", "A", "1", "0", "K -= 1", "K", "1", "D = int(A[1])", "D", "int(A[1])", "int", "A[1]", "A", "1", "A.remove(D)", "A.remove", "A", "remove", "D", "F = int(1)", "F", "int(1)", "int", "1", "left = int(0)", "left", "int(0)", "int", "0", "right = int(T - 2)", "right", "int(T - 2)", "int", "T - 2", "T", "2", "while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] >= D - 1:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n ", "left <= right", "left", "right", "mid = int(left + (right - left) / 2)", "mid", "int(left + (right - left) / 2)", "int", "left + (right - left) / 2", "left", "(right - left) / 2", "right - left", "right", "left", "2", "if A[mid] >= D - 1:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n ", "A[mid] >= D - 1", "A[mid]", "A", "mid", "D - 1", "D", "1", "left = mid + 1", "left", "mid + 1", "mid", "1", "F = max(F, mid + 1)", "F", "max(F, mid + 1)", "max", "F", "mid + 1", "mid", "1", "right = mid - 1", "right", "mid - 1", "mid", "1", "A.insert(F, D - 1)", "A.insert", "A", "insert", "F", "D - 1", "D", "1", "A[0] -= 1", "A[0]", "A", "0", "1", "if C - 1 == A[1]:\n A[0] -= 1\n ", "C - 1 == A[1]", "C - 1", "C", "1", "A[1]", "A", "1", "A[0] -= 1", "A[0]", "A", "0", "1", "if C == A[1]:\n F = int(0)\n left = int(0)\n right = int(T - 1)\n while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] == C:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n A.insert(F, C - 1)\n A.remove(C)", "C == A[1]", "C", "A[1]", "A", "1", "F = int(0)", "F", "int(0)", "int", "0", "left = int(0)", "left", "int(0)", "int", "0", "right = int(T - 1)", "right", "int(T - 1)", "int", "T - 1", "T", "1", "while (left <= right):\n mid = int(left + (right - left) / 2)\n if A[mid] == C:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n ", "left <= right", "left", "right", "mid = int(left + (right - left) / 2)", "mid", "int(left + (right - left) / 2)", "int", "left + (right - left) / 2", "left", "(right - left) / 2", "right - left", "right", "left", "2", "if A[mid] == C:\n left = mid + 1\n F = max(F, mid + 1)\n else:\n right = mid - 1\n ", "A[mid] == C", "A[mid]", "A", "mid", "C", "left = mid + 1", "left", "mid + 1", "mid", "1", "F = max(F, mid + 1)", "F", "max(F, mid + 1)", "max", "F", "mid + 1", "mid", "1", "right = mid - 1", "right", "mid - 1", "mid", "1", "A.insert(F, C - 1)", "A.insert", "A", "insert", "F", "C - 1", "C", "1", "A.remove(C)", "A.remove", "A", "remove", "C", "print(answer)", "print", "answer", "left = mid + 1", "mid + 1", "left", "F = int(1)", "int(1)", "F", "right = int(T - 2)", "int(T - 2)", "right", "left = int(0)", "int(0)", "left", "R2 = input().split()", "input().split()", "R2", "F = int(0)", "int(0)", "F", "right = int(T - 1)", "int(T - 1)", "right", "right = mid - 1", "mid - 1", "right", "D = int(A[1])", "int(A[1])", "D", "F = max(F, mid + 1)", "max(F, mid + 1)", "F", "mid = int(left + (right - left) / 2)", "int(left + (right - left) / 2)", "mid", "mid = int(left + (right - left) / 2)", "int(left + (right - left) / 2)", "mid", "left = mid + 1", "mid + 1", "left", "F = max(F, mid + 1)", "max(F, mid + 1)", "F", "right = mid - 1", "mid - 1", "right", "R1 = input().split()", "input().split()", "R1", "K = int(R1[0])", "int(R1[0])", "K", "left = int(0)", "int(0)", "left", "K -= 1", "1", "K", "answer = int(0)", "int(0)", "answer", "A = []", "[]", "A", "C = A[0]", "A[0]", "C", "answer += 1", "1", "answer", "T = int(R1[1])", "int(R1[1])", "T" ]
import sys R1 = input().split() R2 = input().split() K = int(R1[0]) T = int(R1[1]) answer = int(0) A = [] for i in range (0, T): A.append(int(R2[i])) A.sort() A.reverse() if T == 1: print(A[0] - 1) sys.exit() if T == 2: print(A[0] - A[1] - 1) sys.exit() for i in range (0, K): C = A[0] if C - 1 > A[1]: if A[1] == 0: answer += 1 if A[1] != 0: K -= 1 D = int(A[1]) A.remove(D) F = int(1) left = int(0) right = int(T - 2) while (left <= right): mid = int(left + (right - left) / 2) if A[mid] >= D - 1: left = mid + 1 F = max(F, mid + 1) else: right = mid - 1 A.insert(F, D - 1) A[0] -= 1 if C - 1 == A[1]: A[0] -= 1 if C == A[1]: F = int(0) left = int(0) right = int(T - 1) while (left <= right): mid = int(left + (right - left) / 2) if A[mid] == C: left = mid + 1 F = max(F, mid + 1) else: right = mid - 1 A.insert(F, C - 1) A.remove(C) print(answer)
[ 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, 41, 28, 13, 4, 13, 13, 4, 39, 18, 13, 13, 13, 0, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 4, 18, 13, 13, 0, 13, 17, 14, 40, 18, 18, 13, 17, 17, 13, 0, 18, 18, 13, 17, 17, 17, 0, 13, 18, 18, 13, 17, 17, 14, 2, 18, 18, 13, 17, 17, 17, 0, 18, 18, 13, 17, 17, 17, 0, 13, 18, 18, 13, 17, 17, 0, 13, 18, 18, 13, 17, 17, 3, 4, 13, 13, 10, 13, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 18, 13, 10, 17, 13, 10, 18, 13 ]
[ [ 131, 4 ], [ 131, 13 ], [ 128, 15 ], [ 29, 28 ], [ 132, 31 ], [ 129, 35 ], [ 28, 36 ], [ 119, 39 ], [ 132, 43 ], [ 122, 46 ], [ 140, 49 ], [ 53, 52 ], [ 126, 55 ], [ 120, 58 ], [ 129, 58 ], [ 62, 61 ], [ 120, 67 ], [ 129, 67 ], [ 123, 70 ], [ 135, 70 ], [ 138, 70 ], [ 77, 72 ], [ 120, 74 ], [ 129, 74 ], [ 137, 79 ], [ 120, 82 ], [ 129, 82 ], [ 120, 89 ], [ 129, 89 ], [ 99, 94 ], [ 120, 96 ], [ 129, 96 ], [ 134, 101 ], [ 120, 104 ], [ 129, 104 ], [ 143, 108 ], [ 120, 111 ], [ 129, 111 ], [ 144, 117 ], [ 141, 117 ], [ 119, 120 ], [ 122, 123 ], [ 131, 126 ], [ 128, 129 ], [ 131, 132 ], [ 134, 135 ], [ 137, 138 ], [ 140, 141 ], [ 143, 144 ] ]
[ "import sys\n\nk,n=map(int,input().split())\na=list(map(int,input().split()))\na=[[a[i],i] for i in range(n)]\n\nif n==1: print(a[0][0]-1);sys.exit()\n\npre=-1\nans=0\nfor _ in range(k):\n a.sort(reverse=True)\n if a[0][1]!=pre:\n a[0][0]-=1\n pre=a[0][1]\n elif a[1][0]>0:\n a[1][0]-=1\n pre=a[1][1]\n else:\n ans=a[0][0]\n break\nprint(ans)", "import sys", "sys", "k,n=map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "n", "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[i],i] for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[a[i],i]", "a[i]", "a", "i", "i", "a=[[a[i],i] for i in range(n)]", "a", "[[a[i],i] for i in range(n)]", "if n==1: print(a[0][0]-1);sys.exit()", "n==1", "n", "1", "pre=-1", "pre", "-1", "ans=0", "ans", "0", "for _ in range(k):\n a.sort(reverse=True)\n if a[0][1]!=pre:\n a[0][0]-=1\n pre=a[0][1]\n elif a[1][0]>0:\n a[1][0]-=1\n pre=a[1][1]\n else:\n ans=a[0][0]\n break", "_", "range(k)", "range", "k", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "if a[0][1]!=pre:\n a[0][0]-=1\n pre=a[0][1]\n elif a[1][0]>0:\n a[1][0]-=1\n pre=a[1][1]\n else:\n ans=a[0][0]\n break", "a[0][1]!=pre", "a[0][1]", "[0]", "a", "0", "1", "pre", "a[0][0]-=1", "a[0][0]", "[0]", "a", "0", "0", "1", "pre=a[0][1]", "pre", "a[0][1]", "[0]", "a", "0", "1", "elif a[1][0]>0:\n a[1][0]-=1\n pre=a[1][1]\n ", "a[1][0]>0", "a[1][0]", "[1]", "a", "1", "0", "0", "a[1][0]-=1", "a[1][0]", "[1]", "a", "1", "0", "1", "pre=a[1][1]", "pre", "a[1][1]", "[1]", "a", "1", "1", "ans=a[0][0]", "ans", "a[0][0]", "[0]", "a", "0", "0", "break", "print(ans)", "print", "ans", "a=[[a[i],i] for i in range(n)]", "[[a[i],i] for i in range(n)]", "a", "pre=-1", "-1", "pre", "k,n=map(int,input().split())", "map(int,input().split())", "k", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "n=map(int,input().split())", "map(int,input().split())", "n", "pre=a[1][1]", "a[1][1]", "pre", "pre=a[0][1]", "a[0][1]", "pre", "ans=0", "0", "ans", "ans=a[0][0]", "a[0][0]", "ans" ]
import sys k,n=map(int,input().split()) a=list(map(int,input().split())) a=[[a[i],i] for i in range(n)] if n==1: print(a[0][0]-1);sys.exit() pre=-1 ans=0 for _ in range(k): a.sort(reverse=True) if a[0][1]!=pre: a[0][0]-=1 pre=a[0][1] elif a[1][0]>0: a[1][0]-=1 pre=a[1][1] else: ans=a[0][0] break print(ans)
[ 7, 15, 13, 15, 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, 4, 13, 13, 14, 2, 13, 13, 9, 14, 2, 18, 13, 13, 13, 0, 13, 18, 13, 13, 0, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 13, 0, 18, 13, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 18, 13 ]
[ [ 105, 5 ], [ 15, 14 ], [ 106, 21 ], [ 15, 23 ], [ 26, 25 ], [ 106, 34 ], [ 38, 37 ], [ 41, 40 ], [ 44, 43 ], [ 14, 46 ], [ 49, 48 ], [ 52, 51 ], [ 55, 54 ], [ 23, 57 ], [ 54, 60 ], [ 40, 61 ], [ 85, 61 ], [ 25, 66 ], [ 54, 67 ], [ 51, 68 ], [ 70, 68 ], [ 71, 70 ], [ 25, 72 ], [ 54, 73 ], [ 76, 75 ], [ 54, 76 ], [ 70, 79 ], [ 51, 79 ], [ 83, 82 ], [ 86, 85 ], [ 75, 86 ], [ 48, 86 ], [ 91, 88 ], [ 25, 89 ], [ 75, 90 ], [ 48, 90 ], [ 82, 94 ], [ 37, 94 ], [ 103, 100 ], [ 105, 106 ] ]
[ "import sys\nfrom collections import Counter\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 ans = 0\n prev_j = -1\n for i in range(K):\n j_max = 0\n n_max = 0\n for j in range(T):\n if j == prev_j:\n continue\n if a[j] > n_max:\n n_max = a[j]\n j_max = j\n if n_max == 0:\n ans += 1\n else:\n prev_j = j_max\n a[j_max] -= 1\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "from collections import Counter", "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 ans = 0\n prev_j = -1\n for i in range(K):\n j_max = 0\n n_max = 0\n for j in range(T):\n if j == prev_j:\n continue\n if a[j] > n_max:\n n_max = a[j]\n j_max = j\n if n_max == 0:\n ans += 1\n else:\n prev_j = j_max\n a[j_max] -= 1\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", "ans = 0", "ans", "0", "prev_j = -1", "prev_j", "-1", "for i in range(K):\n j_max = 0\n n_max = 0\n for j in range(T):\n if j == prev_j:\n continue\n if a[j] > n_max:\n n_max = a[j]\n j_max = j\n if n_max == 0:\n ans += 1\n else:\n prev_j = j_max\n a[j_max] -= 1\n ", "i", "range(K)", "range", "K", "j_max = 0", "j_max", "0", "n_max = 0", "n_max", "0", "for j in range(T):\n if j == prev_j:\n continue\n if a[j] > n_max:\n n_max = a[j]\n j_max = j\n ", "j", "range(T)", "range", "T", "if j == prev_j:\n continue\n ", "j == prev_j", "j", "prev_j", "continue", "if a[j] > n_max:\n n_max = a[j]\n j_max = j\n ", "a[j] > n_max", "a[j]", "a", "j", "n_max", "n_max = a[j]", "n_max", "a[j]", "a", "j", "j_max = j", "j_max", "j", "if n_max == 0:\n ans += 1\n else:\n prev_j = j_max\n a[j_max] -= 1\n ", "n_max == 0", "n_max", "0", "ans += 1", "ans", "1", "prev_j = j_max", "prev_j", "j_max", "a[j_max] -= 1", "a[j_max]", "a", "j_max", "1", "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 ans = 0\n prev_j = -1\n for i in range(K):\n j_max = 0\n n_max = 0\n for j in range(T):\n if j == prev_j:\n continue\n if a[j] > n_max:\n n_max = a[j]\n j_max = j\n if n_max == 0:\n ans += 1\n else:\n prev_j = j_max\n a[j_max] -= 1\n print(ans)", "def main():\n K, T = map(int, input().split())\n a = list(map(int, input().split()))\n\n ans = 0\n prev_j = -1\n for i in range(K):\n j_max = 0\n n_max = 0\n for j in range(T):\n if j == prev_j:\n continue\n if a[j] > n_max:\n n_max = a[j]\n j_max = j\n if n_max == 0:\n ans += 1\n else:\n prev_j = j_max\n a[j_max] -= 1\n print(ans)", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input" ]
import sys from collections import Counter input = sys.stdin.readline def main(): K, T = map(int, input().split()) a = list(map(int, input().split())) ans = 0 prev_j = -1 for i in range(K): j_max = 0 n_max = 0 for j in range(T): if j == prev_j: continue if a[j] > n_max: n_max = a[j] j_max = j if n_max == 0: ans += 1 else: prev_j = j_max a[j_max] -= 1 print(ans) if __name__ == "__main__": main()
[ 7, 12, 13, 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, 2, 2, 17, 18, 13, 17, 4, 13, 13, 0, 13, 4, 13, 2, 13, 17, 17, 4, 13, 13, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 13 ], [ 16, 15 ], [ 30, 29 ], [ 15, 34 ], [ 15, 38 ], [ 41, 40 ], [ 29, 44 ], [ 40, 49 ], [ 54, 51 ] ]
[ "def codefes16q_b():\n _, _ = map(int, input().split())\n A = list(sorted(map(int, input().split())))\n x = 2 * A[-1] - sum(A)\n ans = max(x-1, 0)\n print(ans)\n\ncodefes16q_b()", "def codefes16q_b():\n _, _ = map(int, input().split())\n A = list(sorted(map(int, input().split())))\n x = 2 * A[-1] - sum(A)\n ans = max(x-1, 0)\n print(ans)", "codefes16q_b", "_, _ = map(int, input().split())", "_", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "_", "A = list(sorted(map(int, input().split())))", "A", "list(sorted(map(int, input().split())))", "list", "sorted(map(int, input().split()))", "sorted", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "x = 2 * A[-1] - sum(A)", "x", "2 * A[-1] - sum(A)", "2 * A[-1]", "2", "A[-1]", "A", "-1", "sum(A)", "sum", "A", "ans = max(x-1, 0)", "ans", "max(x-1, 0)", "max", "x-1", "x", "1", "0", "print(ans)", "print", "ans", "codefes16q_b()", "codefes16q_b", "def codefes16q_b():\n _, _ = map(int, input().split())\n A = list(sorted(map(int, input().split())))\n x = 2 * A[-1] - sum(A)\n ans = max(x-1, 0)\n print(ans)", "def codefes16q_b():\n _, _ = map(int, input().split())\n A = list(sorted(map(int, input().split())))\n x = 2 * A[-1] - sum(A)\n ans = max(x-1, 0)\n print(ans)", "codefes16q_b" ]
def codefes16q_b(): _, _ = map(int, input().split()) A = list(sorted(map(int, input().split()))) x = 2 * A[-1] - sum(A) ans = max(x-1, 0) print(ans) codefes16q_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, 0, 13, 4, 13, 13, 14, 40, 13, 2, 2, 13, 17, 17, 4, 13, 17, 4, 13, 2, 2, 2, 17, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 59, 2 ], [ 59, 11 ], [ 56, 13 ], [ 50, 25 ], [ 57, 28 ], [ 51, 31 ], [ 54, 34 ], [ 51, 46 ], [ 54, 47 ], [ 50, 51 ], [ 59, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "K,T = map(int,input().split())\nA = list(map(int,input().split()))\na = max(A)\nif a<=(K+1)//2:\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<=(K+1)//2:\n print(0)\nelse:\n print(2*a-K-1)", "a<=(K+1)//2", "a", "(K+1)//2", "K+1", "K", "1", "2", "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", "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 = max(A) if a<=(K+1)//2: print(0) else: print(2*a-K-1)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 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, 14, 2, 2, 2, 4, 13, 13, 4, 13, 13, 17, 4, 13, 13, 4, 13, 2, 2, 2, 4, 13, 13, 17, 4, 13, 13, 17, 4, 13, 17, 14, 2, 13, 17, 4, 13, 10, 18, 13, 10, 18, 13, 10, 4, 13, 10, 12, 13, 10, 2, 13 ]
[ [ 100, 4 ], [ 103, 11 ], [ 106, 27 ], [ 112, 32 ], [ 42, 41 ], [ 104, 48 ], [ 42, 50 ], [ 53, 52 ], [ 104, 61 ], [ 52, 69 ], [ 52, 72 ], [ 52, 76 ], [ 52, 84 ], [ 52, 88 ], [ 110, 98 ], [ 100, 101 ], [ 103, 104 ], [ 106, 107 ], [ 112, 113 ] ]
[ "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n K, T = map(int, readline().split())\n A = list(map(int, readline().split()))\n if sum(A)-max(A)+1 <max(A):\n print(max(A)*2-sum(A)-1)\n else:\n print(0)\n\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "read = sys.stdin.read", "read", "sys.stdin.read", "sys.stdin", "sys", "stdin", "read", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "sys.setrecursionlimit(10 ** 8)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 8", "10", "8", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "MOD = 10 ** 9 + 7", "MOD", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "def main():\n K, T = map(int, readline().split())\n A = list(map(int, readline().split()))\n if sum(A)-max(A)+1 <max(A):\n print(max(A)*2-sum(A)-1)\n else:\n print(0)", "main", "K, T = map(int, readline().split())", "K", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "T", "A = list(map(int, readline().split()))", "A", "list(map(int, readline().split()))", "list", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "if sum(A)-max(A)+1 <max(A):\n print(max(A)*2-sum(A)-1)\n else:\n print(0)", "sum(A)-max(A)+1 <max(A)", "sum(A)-max(A)+1", "sum(A)-max(A)", "sum(A)", "sum", "A", "max(A)", "max", "A", "1", "max(A)", "max", "A", "print(max(A)*2-sum(A)-1)", "print", "max(A)*2-sum(A)-1", "max(A)*2-sum(A)", "max(A)*2", "max(A)", "max", "A", "2", "sum(A)", "sum", "A", "1", "print(0)", "print", "0", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "read = sys.stdin.read", "sys.stdin.read", "read", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline", "INF = float('inf')", "float('inf')", "INF", "def main():\n K, T = map(int, readline().split())\n A = list(map(int, readline().split()))\n if sum(A)-max(A)+1 <max(A):\n print(max(A)*2-sum(A)-1)\n else:\n print(0)", "def main():\n K, T = map(int, readline().split())\n A = list(map(int, readline().split()))\n if sum(A)-max(A)+1 <max(A):\n print(max(A)*2-sum(A)-1)\n else:\n print(0)", "main", "MOD = 10 ** 9 + 7", "10 ** 9 + 7", "MOD" ]
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): K, T = map(int, readline().split()) A = list(map(int, readline().split())) if sum(A)-max(A)+1 <max(A): print(max(A)*2-sum(A)-1) else: print(0) if __name__ == '__main__': main()
[ 7, 17, 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, 4, 13, 2, 4, 13, 13, 17, 0, 13, 18, 13, 13, 14, 40, 18, 13, 2, 4, 13, 13, 17, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 18, 13, 2, 4, 13, 13, 17, 13, 17, 10, 18, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 87, 3 ], [ 87, 12 ], [ 84, 14 ], [ 85, 27 ], [ 81, 30 ], [ 34, 33 ], [ 85, 39 ], [ 75, 42 ], [ 85, 44 ], [ 33, 45 ], [ 85, 49 ], [ 85, 53 ], [ 76, 56 ], [ 82, 56 ], [ 85, 66 ], [ 85, 70 ], [ 76, 72 ], [ 82, 72 ], [ 75, 76 ], [ 87, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ] ]
[ "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jun 19 16:25:46 2020\n\n@author: NEC-PCuser\n\"\"\"\n\n\nK, T = map(int, input().split())\n\na = list(map(int, input().split()))\n\na.sort()\n\nsum_cake = 0\nfor i in range(len(a) - 1):\n sum_cake += a[i]\n\nif a[len(a) - 1] <= sum_cake + 1:\n print(0)\nelse:\n print(a[len(a) - 1] - sum_cake - 1)", "\"\"\"\nCreated on Fri Jun 19 16:25:46 2020\n\n@author: NEC-PCuser\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", "a.sort()", "a.sort", "a", "sort", "sum_cake = 0", "sum_cake", "0", "for i in range(len(a) - 1):\n sum_cake += a[i]", "i", "range(len(a) - 1)", "range", "len(a) - 1", "len(a)", "len", "a", "1", "sum_cake += a[i]", "sum_cake", "a[i]", "a", "i", "if a[len(a) - 1] <= sum_cake + 1:\n print(0)\nelse:\n print(a[len(a) - 1] - sum_cake - 1)", "a[len(a) - 1] <= sum_cake + 1", "a[len(a) - 1]", "a", "len(a) - 1", "len(a)", "len", "a", "1", "sum_cake + 1", "sum_cake", "1", "print(0)", "print", "0", "print(a[len(a) - 1] - sum_cake - 1)", "print", "a[len(a) - 1] - sum_cake - 1", "a[len(a) - 1] - sum_cake", "a[len(a) - 1]", "a", "len(a) - 1", "len(a)", "len", "a", "1", "sum_cake", "1", "sum_cake += a[i]", "a[i]", "sum_cake", "K, T = map(int, input().split())", "map(int, input().split())", "K", "sum_cake = 0", "0", "sum_cake", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "T = map(int, input().split())", "map(int, input().split())", "T" ]
# -*- coding: utf-8 -*- """ Created on Fri Jun 19 16:25:46 2020 @author: NEC-PCuser """ K, T = map(int, input().split()) a = list(map(int, input().split())) a.sort() sum_cake = 0 for i in range(len(a) - 1): sum_cake += a[i] if a[len(a) - 1] <= sum_cake + 1: print(0) else: print(a[len(a) - 1] - sum_cake - 1)
[ 7, 15, 13, 12, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 4, 13, 4, 13, 17, 2, 2, 2, 17, 4, 13, 13, 13, 17, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13 ]
[ [ 40, 8 ], [ 44, 10 ], [ 40, 11 ], [ 34, 13 ], [ 32, 15 ], [ 35, 27 ], [ 41, 28 ], [ 34, 35 ], [ 40, 38 ], [ 40, 41 ] ]
[ "import sys\ndef MI(): return map(int,sys.stdin.readline().rstrip().split())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり\n\n\nK,T = MI()\nA = LI()\nprint(max(0,2*max(A)-K-1))", "import sys", "sys", "def MI(): return map(int,sys.stdin.readline().rstrip().split())", "MI", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり", "LI", "K,T = MI()", "K", "MI()", "MI", "T", "A = LI()", "A", "LI()", "LI", "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", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり", "LI", "A = LI()", "LI()", "A", "T = MI()", "MI()", "T", "K,T = MI()", "MI()", "K", "def MI(): return map(int,sys.stdin.readline().rstrip().split())", "def MI(): return map(int,sys.stdin.readline().rstrip().split())", "MI" ]
import sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり K,T = MI() A = LI() 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, 17, 28, 13, 4, 13, 4, 13, 13, 28, 13, 4, 13, 2, 13, 17, 4, 13, 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, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 40, 18, 13, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 115, 2 ], [ 115, 11 ], [ 103, 13 ], [ 118, 25 ], [ 104, 28 ], [ 31, 30 ], [ 34, 33 ], [ 119, 38 ], [ 104, 38 ], [ 41, 40 ], [ 33, 44 ], [ 119, 48 ], [ 104, 48 ], [ 67, 51 ], [ 119, 52 ], [ 104, 52 ], [ 33, 53 ], [ 106, 57 ], [ 67, 60 ], [ 119, 61 ], [ 104, 61 ], [ 33, 62 ], [ 72, 63 ], [ 119, 64 ], [ 104, 64 ], [ 40, 65 ], [ 70, 67 ], [ 119, 68 ], [ 104, 68 ], [ 33, 69 ], [ 107, 70 ], [ 75, 72 ], [ 119, 73 ], [ 104, 73 ], [ 40, 74 ], [ 107, 75 ], [ 121, 77 ], [ 81, 80 ], [ 119, 85 ], [ 104, 85 ], [ 67, 88 ], [ 119, 89 ], [ 104, 89 ], [ 80, 90 ], [ 112, 93 ], [ 119, 100 ], [ 104, 100 ], [ 113, 101 ], [ 122, 101 ], [ 103, 104 ], [ 106, 107 ], [ 115, 110 ], [ 112, 113 ], [ 115, 116 ], [ 118, 119 ], [ 121, 122 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\nA = sorted(A, reverse=True)\n# print('A', A)\n\nfor i in range(len(A)):\n for j in range(i + 1, len(A)):\n if A[i] == 0:\n break\n v = min(A[i], A[j])\n A[i] -= v\n A[j] -= v\n\ncnt = 0\nfor i in range(len(A)):\n if A[i] >= 1:\n cnt += 1\nprint(max(A) - cnt)", "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", "for i in range(len(A)):\n for j in range(i + 1, len(A)):\n if A[i] == 0:\n break\n v = min(A[i], A[j])\n A[i] -= v\n A[j] -= v", "i", "range(len(A))", "range", "len(A)", "len", "A", "for j in range(i + 1, len(A)):\n if A[i] == 0:\n break\n v = min(A[i], A[j])\n A[i] -= v\n A[j] -= v", "j", "range(i + 1, len(A))", "range", "i + 1", "i", "1", "len(A)", "len", "A", "if A[i] == 0:\n break\n ", "A[i] == 0", "A[i]", "A", "i", "0", "break", "v = min(A[i], A[j])", "v", "min(A[i], A[j])", "min", "A[i]", "A", "i", "A[j]", "A", "j", "A[i] -= v", "A[i]", "A", "i", "v", "A[j] -= v", "A[j]", "A", "j", "v", "cnt = 0", "cnt", "0", "for i in range(len(A)):\n if A[i] >= 1:\n cnt += 1", "i", "range(len(A))", "range", "len(A)", "len", "A", "if A[i] >= 1:\n cnt += 1", "A[i] >= 1", "A[i]", "A", "i", "1", "cnt += 1", "cnt", "1", "print(max(A) - cnt)", "print", "max(A) - cnt", "max(A)", "max", "A", "cnt", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "v = min(A[i], A[j])", "min(A[i], A[j])", "v", "T = map(int, input().split())", "map(int, input().split())", "T", "cnt += 1", "1", "cnt", "K, T = map(int, input().split())", "map(int, input().split())", "K", "A = sorted(A, reverse=True)", "sorted(A, reverse=True)", "A", "cnt = 0", "0", "cnt" ]
K, T = map(int, input().split()) A = list(map(int, input().split())) A = sorted(A, reverse=True) # print('A', A) for i in range(len(A)): for j in range(i + 1, len(A)): if A[i] == 0: break v = min(A[i], A[j]) A[i] -= v A[j] -= v cnt = 0 for i in range(len(A)): if A[i] >= 1: cnt += 1 print(max(A) - cnt)
[ 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, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 50, 2 ], [ 50, 11 ], [ 53, 13 ], [ 44, 25 ], [ 54, 28 ], [ 45, 38 ], [ 54, 42 ], [ 44, 45 ], [ 50, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "k,t = map(int,input().split())\nls = list(map(int,input().split()))\nmx = max(ls)\nprint(max(0,2*mx-1-sum(ls)))", "k,t = map(int,input().split())", "k", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "ls = list(map(int,input().split()))", "ls", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "mx = max(ls)", "mx", "max(ls)", "max", "ls", "print(max(0,2*mx-1-sum(ls)))", "print", "max(0,2*mx-1-sum(ls))", "max", "0", "2*mx-1-sum(ls)", "2*mx-1", "2*mx", "2", "mx", "1", "sum(ls)", "sum", "ls", "mx = max(ls)", "max(ls)", "mx", "k,t = map(int,input().split())", "map(int,input().split())", "k", "t = map(int,input().split())", "map(int,input().split())", "t", "ls = list(map(int,input().split()))", "list(map(int,input().split()))", "ls" ]
k,t = map(int,input().split()) ls = list(map(int,input().split())) mx = max(ls) print(max(0,2*mx-1-sum(ls)))
[ 7, 15, 13, 13, 13, 13, 13, 13, 15, 13, 12, 13, 12, 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, 4, 13, 2, 2, 18, 13, 17, 17, 4, 13, 18, 13, 39, 17, 17, 4, 13, 13, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 22, 21 ], [ 66, 23 ], [ 22, 24 ], [ 27, 26 ], [ 66, 28 ], [ 26, 31 ], [ 35, 34 ], [ 38, 37 ], [ 26, 43 ], [ 26, 49 ], [ 37, 55 ], [ 60, 57 ] ]
[ "import bisect,collections,copy,itertools,math,string\nimport sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S(): return sys.stdin.readline().rstrip()\ndef LS(): return list(sys.stdin.readline().rstrip().split())\ndef main():\n\n k, t = LI()\n a = LI()\n a.sort(reverse=True)\n\n ans = max(a[0]-1-sum(a[1:]), 0)\n print(ans)\n\n\nmain()", "import bisect,collections,copy,itertools,math,string", "bisect", "collections", "copy", "itertools", "math", "string", "import sys", "sys", "def I(): return int(sys.stdin.readline().rstrip())", "I", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))", "LI", "def S(): return sys.stdin.readline().rstrip()", "S", "def LS(): return list(sys.stdin.readline().rstrip().split())", "LS", "def main():\n\n k, t = LI()\n a = LI()\n a.sort(reverse=True)\n\n ans = max(a[0]-1-sum(a[1:]), 0)\n print(ans)", "main", "k, t = LI()", "k", "LI()", "LI", "t", "a = LI()", "a", "LI()", "LI", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "ans = max(a[0]-1-sum(a[1:]), 0)", "ans", "max(a[0]-1-sum(a[1:]), 0)", "max", "a[0]-1-sum(a[1:])", "a[0]-1", "a[0]", "a", "0", "1", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "0", "print(ans)", "print", "ans", "main()", "main", "def main():\n\n k, t = LI()\n a = LI()\n a.sort(reverse=True)\n\n ans = max(a[0]-1-sum(a[1:]), 0)\n print(ans)", "def main():\n\n k, t = LI()\n a = LI()\n a.sort(reverse=True)\n\n ans = max(a[0]-1-sum(a[1:]), 0)\n print(ans)", "main", "def I(): return int(sys.stdin.readline().rstrip())", "def I(): return int(sys.stdin.readline().rstrip())", "I", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))", "LI", "def LS(): return list(sys.stdin.readline().rstrip().split())", "def LS(): return list(sys.stdin.readline().rstrip().split())", "LS", "def S(): return sys.stdin.readline().rstrip()", "def S(): return sys.stdin.readline().rstrip()", "S" ]
import bisect,collections,copy,itertools,math,string import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def main(): k, t = LI() a = LI() a.sort(reverse=True) ans = max(a[0]-1-sum(a[1:]), 0) print(ans) 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, 2, 4, 13, 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, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 62, 2 ], [ 62, 11 ], [ 65, 13 ], [ 66, 28 ], [ 63, 29 ], [ 59, 31 ], [ 66, 34 ], [ 53, 36 ], [ 66, 40 ], [ 60, 41 ], [ 60, 48 ], [ 54, 49 ], [ 53, 54 ], [ 62, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "K, T = map(int, input().split())\nA = list(map(int, input().split()))\nassert len(A) == T\namax = max(A)\nrest = sum(A) - amax\nprint(max(amax - rest - 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", "assert len(A) == T", "len(A) == T", "len(A)", "len", "A", "T", "amax = max(A)", "amax", "max(A)", "max", "A", "rest = sum(A) - amax", "rest", "sum(A) - amax", "sum(A)", "sum", "A", "amax", "print(max(amax - rest - 1, 0))", "print", "max(amax - rest - 1, 0)", "max", "amax - rest - 1", "amax - rest", "amax", "rest", "1", "0", "rest = sum(A) - amax", "sum(A) - amax", "rest", "K, T = map(int, input().split())", "map(int, input().split())", "K", "amax = max(A)", "max(A)", "amax", "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())) assert len(A) == T amax = max(A) rest = sum(A) - amax print(max(amax - rest - 1, 0))
[ 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, 14, 2, 13, 17, 4, 13, 2, 18, 13, 17, 17, 4, 13, 0, 13, 4, 13, 18, 13, 39, 17, 14, 40, 2, 18, 13, 17, 13, 17, 4, 13, 2, 2, 18, 13, 17, 13, 17, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 80, 2 ], [ 80, 11 ], [ 77, 13 ], [ 28, 27 ], [ 75, 31 ], [ 78, 37 ], [ 71, 43 ], [ 78, 47 ], [ 78, 54 ], [ 72, 56 ], [ 78, 63 ], [ 72, 65 ], [ 71, 72 ], [ 80, 75 ], [ 77, 78 ], [ 80, 81 ] ]
[ "K,T = map(int,input().split())\nA = sorted(list(map(int,input().split())),reverse=True)\n\nif T == 1:\n print(A[0]-1)\n exit()\nsu = sum(A[1:])\nif A[0] - su >= 2:\n print(A[0] - su - 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", "if T == 1:\n print(A[0]-1)\n exit()", "T == 1", "T", "1", "print(A[0]-1)", "print", "A[0]-1", "A[0]", "A", "0", "1", "exit()", "exit", "su = sum(A[1:])", "su", "sum(A[1:])", "sum", "A[1:]", "A", "1:", "1", "if A[0] - su >= 2:\n print(A[0] - su - 1)\nelse:\n print(0)", "A[0] - su >= 2", "A[0] - su", "A[0]", "A", "0", "su", "2", "print(A[0] - su - 1)", "print", "A[0] - su - 1", "A[0] - su", "A[0]", "A", "0", "su", "1", "print(0)", "print", "0", "su = sum(A[1:])", "sum(A[1:])", "su", "T = map(int,input().split())", "map(int,input().split())", "T", "A = sorted(list(map(int,input().split())),reverse=True)", "sorted(list(map(int,input().split())),reverse=True)", "A", "K,T = map(int,input().split())", "map(int,input().split())", "K" ]
K,T = map(int,input().split()) A = sorted(list(map(int,input().split())),reverse=True) if T == 1: print(A[0]-1) exit() su = sum(A[1:]) if A[0] - su >= 2: print(A[0] - su - 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, 13, 4, 13, 2, 2, 13, 17, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 40, 2 ], [ 40, 11 ], [ 43, 13 ], [ 44, 30 ], [ 38, 33 ], [ 44, 34 ], [ 40, 38 ], [ 40, 41 ], [ 43, 44 ] ]
[ "k, t = map(int, input().split())\na = max(map(int, input().split()))\nprint(max(a - 1 - (k - a), 0))", "k, t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "a = max(map(int, input().split()))", "a", "max(map(int, input().split()))", "max", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max(a - 1 - (k - a), 0))", "print", "max(a - 1 - (k - a), 0)", "max", "a - 1 - (k - a)", "a - 1", "a", "1", "k - a", "k", "a", "0", "k, t = map(int, input().split())", "map(int, input().split())", "k", "t = map(int, input().split())", "map(int, input().split())", "t", "a = max(map(int, input().split()))", "max(map(int, input().split()))", "a" ]
k, t = map(int, input().split()) a = max(map(int, input().split())) print(max(a - 1 - (k - a), 0))
[ 7, 15, 15, 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, 4, 13, 4, 13, 17, 2, 2, 2, 17, 4, 13, 13, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 8, 7 ], [ 8, 16 ], [ 19, 18 ], [ 18, 40 ], [ 7, 41 ], [ 51, 48 ] ]
[ "#!/usr/bin/env python3\nfrom collections import deque, Counter\nfrom heapq import heappop, heappush\nfrom bisect import bisect_right\n\ndef main():\n K, T = map(int, input().split())\n a = list(map(int, input().split()))\n print(max(0,2*max(a) - K - 1)) \n\nif __name__ == \"__main__\":\n main()", "from collections import deque, Counter", "from heapq import heappop, heappush", "from bisect import bisect_right", "def main():\n K, T = map(int, input().split())\n a = list(map(int, input().split()))\n print(max(0,2*max(a) - K - 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", "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", "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 print(max(0,2*max(a) - K - 1)) ", "def main():\n K, T = map(int, input().split())\n a = list(map(int, input().split()))\n print(max(0,2*max(a) - K - 1)) ", "main" ]
#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right def main(): K, T = map(int, input().split()) a = list(map(int, input().split())) print(max(0,2*max(a) - K - 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, 13, 4, 13, 17, 2, 2, 13, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 43, 2 ], [ 43, 11 ], [ 37, 13 ], [ 38, 31 ], [ 41, 33 ], [ 38, 34 ], [ 37, 38 ], [ 43, 41 ], [ 43, 44 ] ]
[ "K,T=map(int,input().split())\nM=max(map(int,input().split()))\nprint(max(0,M-(K-M)-1))", "K,T=map(int,input().split())", "K", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "M=max(map(int,input().split()))", "M", "max(map(int,input().split()))", "max", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(max(0,M-(K-M)-1))", "print", "max(0,M-(K-M)-1)", "max", "0", "M-(K-M)-1", "M-(K-M)", "M", "K-M", "K", "M", "1", "M=max(map(int,input().split()))", "max(map(int,input().split()))", "M", "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()) M=max(map(int,input().split())) print(max(0,M-(K-M)-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, 4, 13, 4, 13, 17, 2, 2, 18, 13, 17, 17, 4, 13, 18, 13, 39, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 59, 2 ], [ 59, 11 ], [ 50, 13 ], [ 56, 25 ], [ 51, 28 ], [ 31, 30 ], [ 57, 40 ], [ 51, 40 ], [ 57, 46 ], [ 51, 46 ], [ 50, 51 ], [ 59, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "\nK, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nA = sorted(A, reverse=True)\n\nprint(max(0, A[0] - 1 - 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", "A = sorted(A, reverse=True)", "A", "sorted(A, reverse=True)", "sorted", "A", "reverse=True", "reverse", "True", "print(max(0, A[0] - 1 - sum(A[1:])))", "print", "max(0, A[0] - 1 - sum(A[1:]))", "max", "0", "A[0] - 1 - sum(A[1:])", "A[0] - 1", "A[0]", "A", "0", "1", "sum(A[1:])", "sum", "A[1:]", "A", "1:", "1", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "K, T = map(int, input().split())", "map(int, input().split())", "K", "A = sorted(A, reverse=True)", "sorted(A, reverse=True)", "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) print(max(0, A[0] - 1 - 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, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 40, 13, 13, 4, 13, 17, 4, 13, 2, 2, 13, 13, 17, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 60, 2 ], [ 60, 11 ], [ 63, 13 ], [ 51, 25 ], [ 64, 28 ], [ 54, 30 ], [ 64, 34 ], [ 52, 35 ], [ 52, 38 ], [ 55, 39 ], [ 52, 47 ], [ 55, 48 ], [ 51, 52 ], [ 54, 55 ], [ 60, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "K,T=map(int,input().split())\na=list(map(int,input().split()))\n\nmaxi=max(a)\nother = sum(a)-maxi\n#print(maxi,other)\n\nif maxi<=other:\n print(0)\nelse:\n print(maxi-other-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", "maxi=max(a)", "maxi", "max(a)", "max", "a", "other = sum(a)-maxi", "other", "sum(a)-maxi", "sum(a)", "sum", "a", "maxi", "if maxi<=other:\n print(0)\nelse:\n print(maxi-other-1)", "maxi<=other", "maxi", "other", "print(0)", "print", "0", "print(maxi-other-1)", "print", "maxi-other-1", "maxi-other", "maxi", "other", "1", "maxi=max(a)", "max(a)", "maxi", "other = sum(a)-maxi", "sum(a)-maxi", "other", "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())) maxi=max(a) other = sum(a)-maxi #print(maxi,other) if maxi<=other: print(0) else: print(maxi-other-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, 17, 0, 13, 2, 18, 13, 17, 17, 28, 13, 18, 13, 39, 17, 0, 13, 13, 14, 2, 13, 17, 0, 13, 17, 3, 4, 13, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 65, 2 ], [ 65, 11 ], [ 71, 13 ], [ 72, 26 ], [ 30, 29 ], [ 74, 32 ], [ 72, 35 ], [ 40, 39 ], [ 72, 41 ], [ 62, 45 ], [ 39, 46 ], [ 63, 49 ], [ 75, 49 ], [ 69, 49 ], [ 68, 52 ], [ 69, 57 ], [ 63, 57 ], [ 75, 57 ], [ 65, 60 ], [ 39, 62 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "k,t = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\nans = A[0]-1\nfor a in A[1:]:\n ans -= a\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.sort(reverse=True)", "A.sort", "A", "sort", "reverse=True", "reverse", "True", "ans = A[0]-1", "ans", "A[0]-1", "A[0]", "A", "0", "1", "for a in A[1:]:\n ans -= a\n if ans < 0:\n ans = 0\n break", "a", "A[1:]", "A", "1:", "1", "ans -= a", "ans", "a", "if ans < 0:\n ans = 0\n break", "ans < 0", "ans", "0", "ans = 0", "ans", "0", "break", "print(ans)", "print", "ans", "k,t = map(int, input().split())", "map(int, input().split())", "k", "ans -= a", "a", "ans", "t = map(int, input().split())", "map(int, input().split())", "t", "ans = 0", "0", "ans", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "ans = A[0]-1", "A[0]-1", "ans" ]
k,t = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) ans = A[0]-1 for a in A[1:]: ans -= a if ans < 0: ans = 0 break 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, 2, 18, 13, 17, 17, 28, 13, 4, 13, 17, 13, 0, 13, 18, 13, 13, 14, 2, 13, 17, 4, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 2, 13, 10, 18, 13 ]
[ [ 63, 2 ], [ 63, 11 ], [ 66, 13 ], [ 69, 30 ], [ 67, 33 ], [ 38, 37 ], [ 61, 41 ], [ 72, 43 ], [ 67, 45 ], [ 37, 46 ], [ 73, 49 ], [ 70, 49 ], [ 73, 58 ], [ 70, 58 ], [ 63, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "K, T = map(int, input().split())\na = sorted(list(map(int, input().split())))[::-1]\nans = a[0]-1\n\nfor i in range(1, T):\n ans -= a[i]\n if ans < 0:\n print(0)\n exit()\nprint(ans)", "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", "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 print(0)\n exit()", "i", "range(1, T)", "range", "1", "T", "ans -= a[i]", "ans", "a[i]", "a", "i", "if ans < 0:\n print(0)\n exit()", "ans < 0", "ans", "0", "print(0)", "print", "0", "exit()", "exit", "print(ans)", "print", "ans", "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())))[::-1]", "sorted(list(map(int, input().split())))[::-1]", "a", "ans = a[0]-1", "a[0]-1", "ans", "ans -= a[i]", "a[i]", "ans" ]
K, T = map(int, input().split()) a = sorted(list(map(int, input().split())))[::-1] ans = a[0]-1 for i in range(1, T): ans -= a[i] if ans < 0: print(0) exit() 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, 0, 13, 4, 13, 13, 0, 13, 2, 2, 2, 13, 17, 13, 17, 4, 13, 4, 13, 17, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 57, 2 ], [ 57, 11 ], [ 15, 14 ], [ 14, 23 ], [ 51, 25 ], [ 54, 28 ], [ 52, 31 ], [ 60, 33 ], [ 55, 37 ], [ 58, 39 ], [ 61, 46 ], [ 57, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "k, t = map(int, input().split())\narr = [int(x) for x in input().split()]\n\nm = max(arr)\nans = m*2 - k - 1\n\nprint(max(0, 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", "arr = [int(x) for x in input().split()]", "arr", "[int(x) for x in input().split()]", "m = max(arr)", "m", "max(arr)", "max", "arr", "ans = m*2 - k - 1", "ans", "m*2 - k - 1", "m*2 - k", "m*2", "m", "2", "k", "1", "print(max(0, ans))", "print", "max(0, ans)", "max", "0", "ans", "t = map(int, input().split())", "map(int, input().split())", "t", "arr = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "arr", "m = max(arr)", "max(arr)", "m", "k, t = map(int, input().split())", "map(int, input().split())", "k", "ans = m*2 - k - 1", "m*2 - k - 1", "ans" ]
k, t = map(int, input().split()) arr = [int(x) for x in input().split()] m = max(arr) ans = m*2 - k - 1 print(max(0, 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, 4, 13, 13, 14, 40, 13, 40, 2, 40, 13, 17, 4, 13, 17, 14, 2, 2, 13, 17, 17, 4, 13, 2, 2, 2, 13, 2, 13, 17, 17, 17, 4, 13, 2, 2, 2, 13, 17, 2, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 78, 2 ], [ 78, 11 ], [ 75, 13 ], [ 69, 25 ], [ 76, 28 ], [ 70, 31 ], [ 73, 35 ], [ 73, 43 ], [ 70, 51 ], [ 73, 53 ], [ 70, 62 ], [ 73, 65 ], [ 69, 70 ], [ 78, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\nM = max(a)\nif M <= -(-k//2):\n print(0)\nelse:\n if k % 2 == 0:\n print((M-k//2)*2-1)\n else:\n print((M+1-k//2)*2)", "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", "if M <= -(-k//2):\n print(0)\nelse:\n if k % 2 == 0:\n print((M-k//2)*2-1)\n else:\n print((M+1-k//2)*2)", "M <= -(-k//2)", "M", "-(-k//2)", "-k//2", "-k", "k", "2", "print(0)", "print", "0", "if k % 2 == 0:\n print((M-k//2)*2-1)\n else:\n print((M+1-k//2)*2)", "k % 2 == 0", "k % 2", "k", "2", "0", "print((M-k//2)*2-1)", "print", "(M-k//2)*2-1", "(M-k//2)*2", "M-k//2", "M", "k//2", "k", "2", "2", "1", "print((M+1-k//2)*2)", "print", "(M+1-k//2)*2", "M+1-k//2", "M+1", "M", "1", "k//2", "k", "2", "2", "M = max(a)", "max(a)", "M", "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())) M = max(a) if M <= -(-k//2): print(0) else: if k % 2 == 0: print((M-k//2)*2-1) else: print((M+1-k//2)*2)
[ 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, 17, 2, 2, 13, 17, 2, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 57, 11 ], [ 51, 13 ], [ 54, 25 ], [ 52, 28 ], [ 48, 30 ], [ 55, 36 ], [ 46, 39 ], [ 55, 40 ], [ 49, 43 ], [ 57, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "k, t = map(int, input().split())\nA = list(map(int, input().split()))\n_max = max(A)\nans = max(0, _max - 1 - (k-_max))\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", "_max = max(A)", "_max", "max(A)", "max", "A", "ans = max(0, _max - 1 - (k-_max))", "ans", "max(0, _max - 1 - (k-_max))", "max", "0", "_max - 1 - (k-_max)", "_max - 1", "_max", "1", "k-_max", "k", "_max", "print(ans)", "print", "ans", "k, t = map(int, input().split())", "map(int, input().split())", "k", "ans = max(0, _max - 1 - (k-_max))", "max(0, _max - 1 - (k-_max))", "ans", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "_max = max(A)", "max(A)", "_max", "t = map(int, input().split())", "map(int, input().split())", "t" ]
k, t = map(int, input().split()) A = list(map(int, input().split())) _max = max(A) ans = max(0, _max - 1 - (k-_max)) print(ans)
[ 7, 15, 15, 15, 15, 15, 15, 13, 15, 13, 4, 18, 13, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 14, 40, 18, 13, 17, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 13, 2, 2, 13, 18, 13, 17, 17, 17, 10, 4, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 99, 16 ], [ 96, 43 ], [ 88, 45 ], [ 96, 46 ], [ 81, 48 ], [ 88, 50 ], [ 84, 52 ], [ 82, 55 ], [ 85, 59 ], [ 82, 59 ], [ 94, 62 ], [ 94, 71 ], [ 94, 74 ], [ 85, 76 ], [ 82, 76 ], [ 81, 82 ], [ 84, 85 ], [ 96, 94 ], [ 96, 97 ], [ 99, 100 ] ]
[ "from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations # (string,3) 3回\nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# pythonで無理なときは、pypyでやると正解するかも!!\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\nk,t = readInts()\ncake = readInts()\ncake = sorted(cake)\nif cake[-1] <= k/2:\n print(0)\nelse:\n print(k - (k- cake[-1]) * 2 - 1)", "from statistics import median", "from fractions import gcd", "from itertools import combinations", "from collections import deque", "from collections import defaultdict", "import bisect", "bisect", "import sys", "sys", "sys.setrecursionlimit(10000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10000000", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "def readInts():\n return list(map(int,input().split()))", "readInts", "return list(map(int,input().split()))", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def I():\n return int(input())", "I", "return int(input())", "int(input())", "int", "input()", "input", "k,t = readInts()", "k", "readInts()", "readInts", "t", "cake = readInts()", "cake", "readInts()", "readInts", "cake = sorted(cake)", "cake", "sorted(cake)", "sorted", "cake", "if cake[-1] <= k/2:\n print(0)\nelse:\n print(k - (k- cake[-1]) * 2 - 1)", "cake[-1] <= k/2", "cake[-1]", "cake", "-1", "k/2", "k", "2", "print(0)", "print", "0", "print(k - (k- cake[-1]) * 2 - 1)", "print", "k - (k- cake[-1]) * 2 - 1", "k - (k- cake[-1]) * 2", "k", "(k- cake[-1]) * 2", "k- cake[-1]", "k", "cake[-1]", "cake", "-1", "2", "1", "cake = readInts()", "readInts()", "cake", "cake = sorted(cake)", "sorted(cake)", "cake", "def readInts():\n return list(map(int,input().split()))", "def readInts():\n return list(map(int,input().split()))", "readInts", "def I():\n return int(input())", "def I():\n return int(input())", "I", "k,t = readInts()", "readInts()", "k", "t = readInts()", "readInts()", "t", "mod = 10**9 + 7", "10**9 + 7", "mod" ]
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 #mod = 9982443453 def readInts(): return list(map(int,input().split())) def I(): return int(input()) k,t = readInts() cake = readInts() cake = sorted(cake) if cake[-1] <= k/2: print(0) else: print(k - (k- cake[-1]) * 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, 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 ], [ 51, 13 ], [ 48, 25 ], [ 52, 28 ], [ 49, 37 ], [ 46, 38 ], [ 45, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "K, T = map(int, input().split())\n\nAs = list(map(int, input().split()))\n\na = max(As)\n\nprint(max(2*a-K-1,0))", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "As = list(map(int, input().split()))", "As", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a = max(As)", "a", "max(As)", "max", "As", "print(max(2*a-K-1,0))", "print", "max(2*a-K-1,0)", "max", "2*a-K-1", "2*a-K", "2*a", "2", "a", "K", "1", "0", "T = map(int, input().split())", "map(int, input().split())", "T", "K, T = map(int, input().split())", "map(int, input().split())", "K", "a = max(As)", "max(As)", "a", "As = list(map(int, input().split()))", "list(map(int, input().split()))", "As" ]
K, T = map(int, input().split()) As = list(map(int, input().split())) a = max(As) print(max(2*a-K-1,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, 4, 13, 13, 0, 13, 2, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 14, 40, 13, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 13, 13, 17, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 73, 4 ], [ 73, 13 ], [ 76, 15 ], [ 70, 27 ], [ 77, 30 ], [ 64, 32 ], [ 68, 34 ], [ 71, 35 ], [ 74, 38 ], [ 68, 43 ], [ 65, 49 ], [ 71, 51 ], [ 71, 60 ], [ 65, 61 ], [ 64, 65 ], [ 73, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "import heapq\nk,t = map(int,input().split())\na = list(map(int,input().split()))\nmx = max(a)\nothers = k - mx\nif t == 1:\n print(k - 1)\n exit()\n\nif others >= mx - 1:\n print(0)\nelse:\n print(mx - others - 1)", "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", "mx = max(a)", "mx", "max(a)", "max", "a", "others = k - mx", "others", "k - mx", "k", "mx", "if t == 1:\n print(k - 1)\n exit()", "t == 1", "t", "1", "print(k - 1)", "print", "k - 1", "k", "1", "exit()", "exit", "if others >= mx - 1:\n print(0)\nelse:\n print(mx - others - 1)", "others >= mx - 1", "others", "mx - 1", "mx", "1", "print(0)", "print", "0", "print(mx - others - 1)", "print", "mx - others - 1", "mx - others", "mx", "others", "1", "others = k - mx", "k - mx", "others", "k,t = map(int,input().split())", "map(int,input().split())", "k", "mx = max(a)", "max(a)", "mx", "t = map(int,input().split())", "map(int,input().split())", "t", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
import heapq k,t = map(int,input().split()) a = list(map(int,input().split())) mx = max(a) others = k - mx if t == 1: print(k - 1) exit() if others >= mx - 1: print(0) else: print(mx - others - 1)
[ 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, 4, 18, 13, 13, 0, 13, 17, 4, 13, 4, 13, 17, 2, 2, 18, 13, 17, 2, 4, 13, 13, 18, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 56, 2 ], [ 56, 11 ], [ 15, 14 ], [ 14, 23 ], [ 59, 25 ], [ 60, 29 ], [ 33, 32 ], [ 60, 42 ], [ 60, 47 ], [ 60, 49 ], [ 56, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "k,t = map(int,input().split())\nai = [int(i) for i in input().split()]\n\nai.sort(reverse=True)\n\nprint(max(0,ai[0]-(sum(ai)-ai[0])-1))", "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", "ai = [int(i) for i in input().split()]", "ai", "[int(i) for i in input().split()]", "ai.sort(reverse=True)", "ai.sort", "ai", "sort", "reverse=True", "reverse", "True", "print(max(0,ai[0]-(sum(ai)-ai[0])-1))", "print", "max(0,ai[0]-(sum(ai)-ai[0])-1)", "max", "0", "ai[0]-(sum(ai)-ai[0])-1", "ai[0]-(sum(ai)-ai[0])", "ai[0]", "ai", "0", "sum(ai)-ai[0]", "sum(ai)", "sum", "ai", "ai[0]", "ai", "0", "1", "k,t = map(int,input().split())", "map(int,input().split())", "k", "t = map(int,input().split())", "map(int,input().split())", "t", "ai = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "ai" ]
k,t = map(int,input().split()) ai = [int(i) for i in input().split()] ai.sort(reverse=True) print(max(0,ai[0]-(sum(ai)-ai[0])-1))
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 15, 15, 13, 15, 13, 0, 13, 12, 4, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 17, 12, 13, 0, 13, 39, 0, 13, 13, 14, 2, 13, 17, 29, 13, 28, 13, 4, 13, 17, 2, 4, 13, 40, 2, 40, 2, 13, 17, 17, 17, 14, 2, 2, 13, 13, 17, 0, 13, 17, 42, 2, 2, 13, 13, 17, 0, 13, 17, 0, 13, 13, 4, 18, 13, 13, 39, 13, 13, 14, 40, 13, 17, 4, 18, 13, 13, 39, 13, 17, 14, 2, 13, 39, 4, 18, 13, 13, 39, 13, 17, 29, 13, 23, 13, 12, 13, 0, 13, 17, 42, 13, 14, 2, 13, 17, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 2, 13, 13, 29, 2, 13, 13, 23, 13, 23, 13, 23, 13, 12, 13, 14, 2, 13, 17, 29, 17, 0, 13, 13, 0, 13, 2, 13, 17, 42, 40, 13, 13, 0, 13, 2, 2, 13, 13, 13, 0, 13, 17, 29, 13, 23, 13, 23, 13, 23, 13, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 14, 2, 13, 2, 2, 13, 17, 17, 4, 13, 2, 2, 2, 13, 2, 2, 13, 17, 17, 17, 17, 4, 13, 17, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 2, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 262, 20 ], [ 256, 25 ], [ 263, 30 ], [ 265, 32 ], [ 263, 42 ], [ 50, 49 ], [ 53, 52 ], [ 129, 53 ], [ 129, 56 ], [ 49, 59 ], [ 62, 61 ], [ 129, 72 ], [ 52, 79 ], [ 95, 79 ], [ 61, 80 ], [ 84, 83 ], [ 52, 88 ], [ 95, 88 ], [ 61, 89 ], [ 93, 92 ], [ 96, 95 ], [ 61, 96 ], [ 49, 99 ], [ 95, 106 ], [ 52, 106 ], [ 49, 110 ], [ 49, 117 ], [ 49, 121 ], [ 49, 127 ], [ 129, 129 ], [ 134, 133 ], [ 161, 139 ], [ 147, 139 ], [ 143, 142 ], [ 159, 144 ], [ 150, 144 ], [ 163, 145 ], [ 148, 147 ], [ 151, 150 ], [ 159, 152 ], [ 150, 152 ], [ 163, 153 ], [ 142, 156 ], [ 133, 156 ], [ 163, 157 ], [ 159, 159 ], [ 161, 161 ], [ 163, 163 ], [ 197, 168 ], [ 174, 173 ], [ 197, 174 ], [ 177, 176 ], [ 197, 178 ], [ 176, 182 ], [ 192, 182 ], [ 199, 183 ], [ 186, 185 ], [ 173, 188 ], [ 185, 188 ], [ 176, 189 ], [ 192, 189 ], [ 201, 190 ], [ 193, 192 ], [ 185, 195 ], [ 173, 195 ], [ 197, 197 ], [ 199, 199 ], [ 201, 201 ], [ 253, 203 ], [ 274, 208 ], [ 286, 215 ], [ 266, 217 ], [ 286, 218 ], [ 268, 220 ], [ 266, 222 ], [ 283, 224 ], [ 269, 227 ], [ 284, 230 ], [ 278, 233 ], [ 284, 241 ], [ 278, 244 ], [ 253, 254 ], [ 256, 257 ], [ 262, 263 ], [ 265, 266 ], [ 268, 269 ], [ 274, 275 ], [ 286, 278 ], [ 283, 284 ], [ 286, 287 ] ]
[ "# input()\n# int(input())\n# map(int, input().split())\n# list(map(int, input().split()))\n# list(map(int, list(input()))) # スペースがない数字リストを読み込み\nimport math\nimport fractions\nimport sys\nimport bisect\nimport heapq # 優先度付きキュー(最小値取り出し)\nimport collections\nfrom collections import Counter\nfrom collections import deque\nimport pprint\nimport itertools\n\nsr = lambda: input()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\n\"\"\"nを素因数分解\"\"\"\n\"\"\"2以上の整数n => [[素因数, 指数], ...]の2次元リスト\"\"\"\n\n\ndef factorization(n):\n arr = []\n temp = n\n if n == 1:\n return arr\n\n for i in range(2, int(-(-n ** 0.5 // 1)) + 1):\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr.append([i, cnt])\n\n if temp != 1:\n arr.append([temp, 1])\n\n if arr == []:\n arr.append([n, 1])\n\n return arr\n\n\n# a^n\ndef power(a, n, mod):\n x = 1\n while n:\n if n & 1:\n x *= a % mod\n n >>= 1\n a *= a % mod\n return x % mod\n\n\n# n*(n-1)*...*(l+1)*l\ndef kaijo(n, l, mod):\n if n == 0:\n return 1\n a = n\n tmp = n - 1\n while (tmp >= l):\n a = a * tmp % mod\n tmp -= 1\n return a\n\n\ninf = 10 ** 18\nmod = 10 ** 9 + 7\n\nk,t = lr()\na = lr()\nmaxa = max(a)\nif maxa > (k+1)//2:\n print((maxa-((k+1)//2))*2-1)\nelse:\n print(0)", "import math", "math", "import fractions", "fractions", "import sys", "sys", "import bisect", "bisect", "import heapq", "heapq", "import collections", "collections", "from collections import Counter", "from collections import deque", "import pprint", "pprint", "import itertools", "itertools", "sr = lambda: input()", "sr", "lambda: input()", "input()", "input", "ir = lambda: int(sr())", "ir", "lambda: int(sr())", "int(sr())", "int", "sr()", "sr", "lr = lambda: list(map(int, sr().split()))", "lr", "lambda: list(map(int, sr().split()))", "list(map(int, sr().split()))", "list", "map(int, sr().split())", "map", "int", "sr().split()", "().split", "()", "sr", "split", "\"\"\"nを素因数分解\"\"\"", "\"\"\"2以上の整数n => [[素因数, 指数], ...]の2次元リスト\"\"\"", "def factorization(n):\n arr = []\n temp = n\n if n == 1:\n return arr\n\n for i in range(2, int(-(-n ** 0.5 // 1)) + 1):\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr.append([i, cnt])\n\n if temp != 1:\n arr.append([temp, 1])\n\n if arr == []:\n arr.append([n, 1])\n\n return arr\n\n\n# a^n", "factorization", "arr = []", "arr", "[]", "temp = n", "temp", "n", "if n == 1:\n return arr\n\n ", "n == 1", "n", "1", "return arr", "arr", "for i in range(2, int(-(-n ** 0.5 // 1)) + 1):\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr.append([i, cnt])\n\n ", "i", "range(2, int(-(-n ** 0.5 // 1)) + 1)", "range", "2", "int(-(-n ** 0.5 // 1)) + 1", "int(-(-n ** 0.5 // 1))", "int", "-(-n ** 0.5 // 1)", "-n ** 0.5 // 1", "-n ** 0.5", "n ** 0.5", "n", "0.5", "1", "1", "if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr.append([i, cnt])\n\n ", "temp % i == 0", "temp % i", "temp", "i", "0", "cnt = 0", "cnt", "0", "while temp % i == 0:\n cnt += 1\n temp //= i\n ", "temp % i == 0", "temp % i", "temp", "i", "0", "cnt += 1", "cnt", "1", "temp //= i", "temp", "i", "arr.append([i, cnt])", "arr.append", "arr", "append", "[i, cnt]", "i", "cnt", "if temp != 1:\n arr.append([temp, 1])\n\n ", "temp != 1", "temp", "1", "arr.append([temp, 1])", "arr.append", "arr", "append", "[temp, 1]", "temp", "1", "if arr == []:\n arr.append([n, 1])\n\n ", "arr == []", "arr", "[]", "arr.append([n, 1])", "arr.append", "arr", "append", "[n, 1]", "n", "1", "return arr", "arr", "n", "n", "def power(a, n, mod):\n x = 1\n while n:\n if n & 1:\n x *= a % mod\n n >>= 1\n a *= a % mod\n return x % mod\n\n\n# n*(n-1)*...*(l+1)*l", "power", "x = 1", "x", "1", "while n:\n if n & 1:\n x *= a % mod\n n >>= 1\n a *= a % mod\n ", "n", "if n & 1:\n x *= a % mod\n ", "n & 1", "n", "1", "x *= a % mod", "x", "a % mod", "a", "mod", "n >>= 1", "n", "1", "a *= a % mod", "a", "a % mod", "a", "mod", "return x % mod", "x % mod", "x", "mod", "a", "a", "n", "n", "mod", "mod", "def kaijo(n, l, mod):\n if n == 0:\n return 1\n a = n\n tmp = n - 1\n while (tmp >= l):\n a = a * tmp % mod\n tmp -= 1\n return a", "kaijo", "if n == 0:\n return 1\n ", "n == 0", "n", "0", "return 1", "1", "a = n", "a", "n", "tmp = n - 1", "tmp", "n - 1", "n", "1", "while (tmp >= l):\n a = a * tmp % mod\n tmp -= 1\n ", "tmp >= l", "tmp", "l", "a = a * tmp % mod", "a", "a * tmp % mod", "a * tmp", "a", "tmp", "mod", "tmp -= 1", "tmp", "1", "return a", "a", "n", "n", "l", "l", "mod", "mod", "inf = 10 ** 18", "inf", "10 ** 18", "10", "18", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "k,t = lr()", "k", "lr()", "lr", "t", "a = lr()", "a", "lr()", "lr", "maxa = max(a)", "maxa", "max(a)", "max", "a", "if maxa > (k+1)//2:\n print((maxa-((k+1)//2))*2-1)\nelse:\n print(0)", "maxa > (k+1)//2", "maxa", "(k+1)//2", "k+1", "k", "1", "2", "print((maxa-((k+1)//2))*2-1)", "print", "(maxa-((k+1)//2))*2-1", "(maxa-((k+1)//2))*2", "maxa-((k+1)//2)", "maxa", "(k+1)//2", "k+1", "k", "1", "2", "2", "1", "print(0)", "print", "0", "inf = 10 ** 18", "10 ** 18", "inf", "ir = lambda: int(sr())", "lambda: int(sr())", "ir", "def factorization(n):\n arr = []\n temp = n\n if n == 1:\n return arr\n\n for i in range(2, int(-(-n ** 0.5 // 1)) + 1):\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr.append([i, cnt])\n\n if temp != 1:\n arr.append([temp, 1])\n\n if arr == []:\n arr.append([n, 1])\n\n return arr\n\n\n# a^n", "def factorization(n):\n arr = []\n temp = n\n if n == 1:\n return arr\n\n for i in range(2, int(-(-n ** 0.5 // 1)) + 1):\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr.append([i, cnt])\n\n if temp != 1:\n arr.append([temp, 1])\n\n if arr == []:\n arr.append([n, 1])\n\n return arr\n\n\n# a^n", "factorization", "sr = lambda: input()", "lambda: input()", "sr", "lr = lambda: list(map(int, sr().split()))", "lambda: list(map(int, sr().split()))", "lr", "a = lr()", "lr()", "a", "def power(a, n, mod):\n x = 1\n while n:\n if n & 1:\n x *= a % mod\n n >>= 1\n a *= a % mod\n return x % mod\n\n\n# n*(n-1)*...*(l+1)*l", "def power(a, n, mod):\n x = 1\n while n:\n if n & 1:\n x *= a % mod\n n >>= 1\n a *= a % mod\n return x % mod\n\n\n# n*(n-1)*...*(l+1)*l", "power", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "k,t = lr()", "lr()", "k", "def kaijo(n, l, mod):\n if n == 0:\n return 1\n a = n\n tmp = n - 1\n while (tmp >= l):\n a = a * tmp % mod\n tmp -= 1\n return a", "def kaijo(n, l, mod):\n if n == 0:\n return 1\n a = n\n tmp = n - 1\n while (tmp >= l):\n a = a * tmp % mod\n tmp -= 1\n return a", "kaijo", "maxa = max(a)", "max(a)", "maxa", "t = lr()", "lr()", "t" ]
# input() # int(input()) # map(int, input().split()) # list(map(int, input().split())) # list(map(int, list(input()))) # スペースがない数字リストを読み込み import math import fractions import sys import bisect import heapq # 優先度付きキュー(最小値取り出し) import collections from collections import Counter from collections import deque import pprint import itertools sr = lambda: input() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) """nを素因数分解""" """2以上の整数n => [[素因数, 指数], ...]の2次元リスト""" def factorization(n): arr = [] temp = n if n == 1: return arr for i in range(2, int(-(-n ** 0.5 // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr # a^n def power(a, n, mod): x = 1 while n: if n & 1: x *= a % mod n >>= 1 a *= a % mod return x % mod # n*(n-1)*...*(l+1)*l def kaijo(n, l, mod): if n == 0: return 1 a = n tmp = n - 1 while (tmp >= l): a = a * tmp % mod tmp -= 1 return a inf = 10 ** 18 mod = 10 ** 9 + 7 k,t = lr() a = lr() maxa = max(a) if maxa > (k+1)//2: print((maxa-((k+1)//2))*2-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, 14, 2, 4, 13, 13, 2, 2, 13, 17, 17, 4, 13, 17, 4, 13, 2, 2, 4, 13, 13, 2, 4, 13, 13, 4, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 56, 2 ], [ 56, 11 ], [ 59, 13 ], [ 60, 28 ], [ 57, 31 ], [ 60, 43 ], [ 60, 47 ], [ 60, 50 ], [ 56, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "k, t = map(int, input().split())\nA = list(map(int, input().split()))\nif max(A) < k//2+1:\n print(0)\nelse:\n print(max(A)-(sum(A)-max(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", "if max(A) < k//2+1:\n print(0)\nelse:\n print(max(A)-(sum(A)-max(A))-1)", "max(A) < k//2+1", "max(A)", "max", "A", "k//2+1", "k//2", "k", "2", "1", "print(0)", "print", "0", "print(max(A)-(sum(A)-max(A))-1)", "print", "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", "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())) if max(A) < k//2+1: print(0) else: print(max(A)-(sum(A)-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, 17, 2, 2, 4, 13, 13, 2, 13, 4, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 50, 2 ], [ 50, 11 ], [ 53, 13 ], [ 44, 25 ], [ 54, 33 ], [ 51, 35 ], [ 54, 38 ], [ 45, 42 ], [ 44, 45 ], [ 50, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "K,T=map(int,input().split())\nA=list(map(int,input().split()))\n\nans=max(0,max(A)-(K-max(A))-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", "ans=max(0,max(A)-(K-max(A))-1)", "ans", "max(0,max(A)-(K-max(A))-1)", "max", "0", "max(A)-(K-max(A))-1", "max(A)-(K-max(A))", "max(A)", "max", "A", "K-max(A)", "K", "max(A)", "max", "A", "1", "print(ans)", "print", "ans", "ans=max(0,max(A)-(K-max(A))-1)", "max(0,max(A)-(K-max(A))-1)", "ans", "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())) ans=max(0,max(A)-(K-max(A))-1) print(ans)
[ 7, 15, 13, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 18, 18, 13, 13, 13, 12, 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, 0, 13, 39, 28, 13, 4, 13, 13, 4, 18, 13, 13, 13, 39, 40, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 42, 13, 0, 13, 4, 18, 13, 13, 13, 14, 2, 13, 18, 13, 17, 14, 13, 0, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 13, 0, 13, 18, 13, 17, 0, 13, 18, 13, 17, 0, 13, 13, 0, 13, 17, 14, 40, 13, 17, 4, 18, 13, 13, 13, 39, 13, 13, 0, 13, 18, 13, 17, 3, 0, 13, 18, 13, 17, 0, 13, 18, 13, 17, 0, 13, 17, 0, 13, 13, 14, 40, 13, 17, 4, 18, 13, 13, 13, 39, 13, 13, 4, 13, 40, 13, 14, 2, 13, 17, 4, 13, 10, 18, 13, 10, 12, 13 ]
[ [ 180, 13 ], [ 24, 23 ], [ 181, 27 ], [ 23, 32 ], [ 35, 34 ], [ 35, 36 ], [ 40, 39 ], [ 181, 43 ], [ 39, 48 ], [ 51, 50 ], [ 54, 53 ], [ 57, 56 ], [ 36, 59 ], [ 53, 64 ], [ 50, 68 ], [ 56, 69 ], [ 73, 72 ], [ 76, 75 ], [ 81, 80 ], [ 53, 85 ], [ 75, 88 ], [ 118, 88 ], [ 155, 88 ], [ 80, 90 ], [ 96, 95 ], [ 53, 100 ], [ 53, 105 ], [ 80, 106 ], [ 109, 108 ], [ 95, 110 ], [ 114, 113 ], [ 95, 115 ], [ 119, 118 ], [ 113, 119 ], [ 147, 119 ], [ 122, 121 ], [ 121, 125 ], [ 108, 125 ], [ 152, 125 ], [ 142, 125 ], [ 53, 131 ], [ 137, 136 ], [ 80, 138 ], [ 143, 142 ], [ 80, 144 ], [ 148, 147 ], [ 80, 149 ], [ 153, 152 ], [ 156, 155 ], [ 147, 156 ], [ 113, 156 ], [ 152, 159 ], [ 142, 159 ], [ 121, 159 ], [ 108, 159 ], [ 53, 165 ], [ 136, 172 ], [ 72, 172 ], [ 184, 178 ], [ 180, 181 ] ]
[ "import sys\nimport heapq\n\nsys.setrecursionlimit(10 ** 8)\n\ninput = sys.stdin.readline\n\n\ndef main():\n K, T = [int(x) for x in input().split()]\n A = [int(x) for x in input().split()]\n\n h = []\n for i in range(T):\n heapq.heappush(h, (-A[i], i))\n\n ans = 0\n p = -1\n\n while h:\n c = heapq.heappop(h)\n if p == c[1]:\n if h:\n c2 = heapq.heappop(h)\n heapq.heappush(h, c)\n x = c2[0]\n y = c2[1]\n p = y\n x += 1\n if x != 0:\n heapq.heappush(h, (x, y))\n else:\n ans = c[0]\n break\n else:\n x = c[0]\n y = c[1]\n x += 1\n p = y\n if x != 0:\n heapq.heappush(h, (x, y))\n\n print(-ans)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "import heapq", "heapq", "sys.setrecursionlimit(10 ** 8)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 8", "10", "8", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def main():\n K, T = [int(x) for x in input().split()]\n A = [int(x) for x in input().split()]\n\n h = []\n for i in range(T):\n heapq.heappush(h, (-A[i], i))\n\n ans = 0\n p = -1\n\n while h:\n c = heapq.heappop(h)\n if p == c[1]:\n if h:\n c2 = heapq.heappop(h)\n heapq.heappush(h, c)\n x = c2[0]\n y = c2[1]\n p = y\n x += 1\n if x != 0:\n heapq.heappush(h, (x, y))\n else:\n ans = c[0]\n break\n else:\n x = c[0]\n y = c[1]\n x += 1\n p = y\n if x != 0:\n heapq.heappush(h, (x, y))\n\n print(-ans)", "main", "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", "K, T = [int(x) for x in input().split()]", "K", "[int(x) for x in 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()]", "h = []", "h", "[]", "for i in range(T):\n heapq.heappush(h, (-A[i], i))\n\n ", "i", "range(T)", "range", "T", "heapq.heappush(h, (-A[i], i))", "heapq.heappush", "heapq", "heappush", "h", "(-A[i], i)", "-A[i]", "A[i]", "A", "i", "i", "ans = 0", "ans", "0", "p = -1", "p", "-1", "while h:\n c = heapq.heappop(h)\n if p == c[1]:\n if h:\n c2 = heapq.heappop(h)\n heapq.heappush(h, c)\n x = c2[0]\n y = c2[1]\n p = y\n x += 1\n if x != 0:\n heapq.heappush(h, (x, y))\n else:\n ans = c[0]\n break\n else:\n x = c[0]\n y = c[1]\n x += 1\n p = y\n if x != 0:\n heapq.heappush(h, (x, y))\n\n ", "h", "c = heapq.heappop(h)", "c", "heapq.heappop(h)", "heapq.heappop", "heapq", "heappop", "h", "if p == c[1]:\n if h:\n c2 = heapq.heappop(h)\n heapq.heappush(h, c)\n x = c2[0]\n y = c2[1]\n p = y\n x += 1\n if x != 0:\n heapq.heappush(h, (x, y))\n else:\n ans = c[0]\n break\n else:\n x = c[0]\n y = c[1]\n x += 1\n p = y\n if x != 0:\n heapq.heappush(h, (x, y))\n\n ", "p == c[1]", "p", "c[1]", "c", "1", "if h:\n c2 = heapq.heappop(h)\n heapq.heappush(h, c)\n x = c2[0]\n y = c2[1]\n p = y\n x += 1\n if x != 0:\n heapq.heappush(h, (x, y))\n else:\n ans = c[0]\n break\n ", "h", "c2 = heapq.heappop(h)", "c2", "heapq.heappop(h)", "heapq.heappop", "heapq", "heappop", "h", "heapq.heappush(h, c)", "heapq.heappush", "heapq", "heappush", "h", "c", "x = c2[0]", "x", "c2[0]", "c2", "0", "y = c2[1]", "y", "c2[1]", "c2", "1", "p = y", "p", "y", "x += 1", "x", "1", "if x != 0:\n heapq.heappush(h, (x, y))\n ", "x != 0", "x", "0", "heapq.heappush(h, (x, y))", "heapq.heappush", "heapq", "heappush", "h", "(x, y)", "x", "y", "ans = c[0]", "ans", "c[0]", "c", "0", "break", "x = c[0]", "x", "c[0]", "c", "0", "y = c[1]", "y", "c[1]", "c", "1", "x += 1", "x", "1", "p = y", "p", "y", "if x != 0:\n heapq.heappush(h, (x, y))\n\n ", "x != 0", "x", "0", "heapq.heappush(h, (x, y))", "heapq.heappush", "heapq", "heappush", "h", "(x, y)", "x", "y", "print(-ans)", "print", "-ans", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def main():\n K, T = [int(x) for x in input().split()]\n A = [int(x) for x in input().split()]\n\n h = []\n for i in range(T):\n heapq.heappush(h, (-A[i], i))\n\n ans = 0\n p = -1\n\n while h:\n c = heapq.heappop(h)\n if p == c[1]:\n if h:\n c2 = heapq.heappop(h)\n heapq.heappush(h, c)\n x = c2[0]\n y = c2[1]\n p = y\n x += 1\n if x != 0:\n heapq.heappush(h, (x, y))\n else:\n ans = c[0]\n break\n else:\n x = c[0]\n y = c[1]\n x += 1\n p = y\n if x != 0:\n heapq.heappush(h, (x, y))\n\n print(-ans)", "def main():\n K, T = [int(x) for x in input().split()]\n A = [int(x) for x in input().split()]\n\n h = []\n for i in range(T):\n heapq.heappush(h, (-A[i], i))\n\n ans = 0\n p = -1\n\n while h:\n c = heapq.heappop(h)\n if p == c[1]:\n if h:\n c2 = heapq.heappop(h)\n heapq.heappush(h, c)\n x = c2[0]\n y = c2[1]\n p = y\n x += 1\n if x != 0:\n heapq.heappush(h, (x, y))\n else:\n ans = c[0]\n break\n else:\n x = c[0]\n y = c[1]\n x += 1\n p = y\n if x != 0:\n heapq.heappush(h, (x, y))\n\n print(-ans)", "main" ]
import sys import heapq sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): K, T = [int(x) for x in input().split()] A = [int(x) for x in input().split()] h = [] for i in range(T): heapq.heappush(h, (-A[i], i)) ans = 0 p = -1 while h: c = heapq.heappop(h) if p == c[1]: if h: c2 = heapq.heappop(h) heapq.heappush(h, c) x = c2[0] y = c2[1] p = y x += 1 if x != 0: heapq.heappush(h, (x, y)) else: ans = c[0] break else: x = c[0] y = c[1] x += 1 p = y if x != 0: heapq.heappush(h, (x, y)) print(-ans) if __name__ == '__main__': main()
[ 7, 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, 14, 2, 13, 17, 4, 13, 2, 13, 17, 0, 13, 4, 13, 13, 4, 13, 4, 13, 2, 2, 13, 17, 2, 13, 13, 17, 10, 4, 13, 10, 13, 13, 10, 13, 13, 10, 13, 13 ]
[ [ 4, 3 ], [ 3, 12 ], [ 68, 14 ], [ 68, 16 ], [ 20, 19 ], [ 19, 28 ], [ 65, 30 ], [ 69, 34 ], [ 63, 39 ], [ 59, 42 ], [ 66, 45 ], [ 60, 52 ], [ 63, 55 ], [ 60, 56 ], [ 59, 60 ], [ 68, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "k,t = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nif t == 1:\n print(k-1)\nelse:\n m = max(a)\n print(max(m-1-(k-m), 0))", "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", "k,t = [int(x) for x in input().split()]", "k", "[int(x) for x in 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 print(k-1)\nelse:\n m = max(a)\n print(max(m-1-(k-m), 0))", "t == 1", "t", "1", "print(k-1)", "print", "k-1", "k", "1", "m = max(a)", "m", "max(a)", "max", "a", "print(max(m-1-(k-m), 0))", "print", "max(m-1-(k-m), 0)", "max", "m-1-(k-m)", "m-1", "m", "1", "k-m", "k", "m", "0", "m = max(a)", "max(a)", "m", "k,t = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "k", "a = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "a", "t = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "t" ]
k,t = [int(x) for x in input().split()] a = [int(x) for x in input().split()] if t == 1: print(k-1) else: m = max(a) print(max(m-1-(k-m), 0))
[ 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, 4, 18, 13, 13, 0, 13, 17, 14, 40, 18, 13, 17, 2, 2, 13, 17, 17, 4, 13, 17, 4, 13, 2, 2, 2, 18, 13, 17, 2, 2, 13, 17, 17, 17, 2, 2, 13, 17, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 13 ], [ 16, 15 ], [ 15, 28 ], [ 32, 31 ], [ 15, 36 ], [ 4, 40 ], [ 15, 52 ], [ 4, 56 ], [ 4, 62 ], [ 73, 70 ] ]
[ "def main():\n K, T = map( int, input().split())\n A = list( map( int, input().split()))\n A.sort(reverse=True)\n if A[0] <= (K+1)//2:\n print(0)\n else:\n print((A[0] - (K+1)//2)*2 - (K+1)%2)\nif __name__ == '__main__':\n main()", "def main():\n K, T = map( int, input().split())\n A = list( map( int, input().split()))\n A.sort(reverse=True)\n if A[0] <= (K+1)//2:\n print(0)\n else:\n print((A[0] - (K+1)//2)*2 - (K+1)%2)", "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", "A.sort(reverse=True)", "A.sort", "A", "sort", "reverse=True", "reverse", "True", "if A[0] <= (K+1)//2:\n print(0)\n else:\n print((A[0] - (K+1)//2)*2 - (K+1)%2)", "A[0] <= (K+1)//2", "A[0]", "A", "0", "(K+1)//2", "K+1", "K", "1", "2", "print(0)", "print", "0", "print((A[0] - (K+1)//2)*2 - (K+1)%2)", "print", "(A[0] - (K+1)//2)*2 - (K+1)%2", "(A[0] - (K+1)//2)*2", "A[0] - (K+1)//2", "A[0]", "A", "0", "(K+1)//2", "K+1", "K", "1", "2", "2", "(K+1)%2", "K+1", "K", "1", "2", "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 A.sort(reverse=True)\n if A[0] <= (K+1)//2:\n print(0)\n else:\n print((A[0] - (K+1)//2)*2 - (K+1)%2)", "def main():\n K, T = map( int, input().split())\n A = list( map( int, input().split()))\n A.sort(reverse=True)\n if A[0] <= (K+1)//2:\n print(0)\n else:\n print((A[0] - (K+1)//2)*2 - (K+1)%2)", "main" ]
def main(): K, T = map( int, input().split()) A = list( map( int, input().split())) A.sort(reverse=True) if A[0] <= (K+1)//2: print(0) else: print((A[0] - (K+1)//2)*2 - (K+1)%2) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 13, 31, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 2, 4, 13, 18, 13, 17, 2, 4, 13, 18, 13, 39, 17, 17, 4, 13, 18, 13, 39, 17, 4, 13, 2, 13, 4, 13, 13, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 62, 2 ], [ 62, 15 ], [ 62, 16 ], [ 24, 23 ], [ 56, 26 ], [ 60, 50 ], [ 60, 53 ], [ 57, 54 ], [ 56, 57 ], [ 62, 60 ], [ 62, 63 ] ]
[ "k,t,*aa = map(int, open(0).read().split())\naa.sort(reverse=True)\n\neligible = min(aa[0], sum(aa[1:]) + 1) + sum(aa[1:])\n\nprint(k-min(k,eligible))", "k,t,*aa = 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", "*aa", "aa", "aa.sort(reverse=True)", "aa.sort", "aa", "sort", "reverse=True", "reverse", "True", "eligible = min(aa[0], sum(aa[1:]) + 1) + sum(aa[1:])", "eligible", "min(aa[0], sum(aa[1:]) + 1) + sum(aa[1:])", "min(aa[0], sum(aa[1:]) + 1)", "min", "aa[0]", "aa", "0", "sum(aa[1:]) + 1", "sum(aa[1:])", "sum", "aa[1:]", "aa", "1:", "1", "1", "sum(aa[1:])", "sum", "aa[1:]", "aa", "1:", "1", "print(k-min(k,eligible))", "print", "k-min(k,eligible)", "k", "min(k,eligible)", "min", "k", "eligible", "eligible = min(aa[0], sum(aa[1:]) + 1) + sum(aa[1:])", "min(aa[0], sum(aa[1:]) + 1) + sum(aa[1:])", "eligible", "k,t,*aa = map(int, open(0).read().split())", "map(int, open(0).read().split())", "k", "t,*aa = map(int, open(0).read().split())", "map(int, open(0).read().split())", "t" ]
k,t,*aa = map(int, open(0).read().split()) aa.sort(reverse=True) eligible = min(aa[0], sum(aa[1:]) + 1) + sum(aa[1:]) print(k-min(k,eligible))
[ 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, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 13, 0, 13, 13, 0, 13, 13, 14, 2, 4, 13, 2, 13, 13, 39, 17, 17, 4, 13, 17, 0, 13, 2, 4, 13, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 90, 2 ], [ 90, 11 ], [ 87, 13 ], [ 96, 25 ], [ 88, 32 ], [ 84, 34 ], [ 102, 37 ], [ 41, 40 ], [ 97, 40 ], [ 88, 40 ], [ 85, 44 ], [ 94, 44 ], [ 103, 45 ], [ 100, 45 ], [ 93, 47 ], [ 40, 48 ], [ 99, 50 ], [ 40, 51 ], [ 94, 57 ], [ 85, 57 ], [ 100, 58 ], [ 103, 58 ], [ 81, 66 ], [ 94, 71 ], [ 85, 71 ], [ 100, 72 ], [ 103, 72 ], [ 82, 76 ], [ 90, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ], [ 40, 93 ], [ 93, 94 ], [ 96, 97 ], [ 40, 99 ], [ 99, 100 ], [ 102, 103 ] ]
[ "k, t = map(int, input().split())\n\nA = list(map(int, input().split()))\n\nA = list(reversed(sorted(A)))\n\nleft_sum = 0\nright_sum = 0\nfor i in A:\n if left_sum < right_sum :\n left_sum += i\n else:\n right_sum += i\n\nif abs(left_sum - right_sum) in [0, 1]:\n print(0)\nelse:\n a = abs(left_sum - right_sum) - 1\n print(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", "A = list(reversed(sorted(A)))", "A", "list(reversed(sorted(A)))", "list", "reversed(sorted(A))", "reversed", "sorted(A)", "sorted", "A", "left_sum = 0", "left_sum", "0", "right_sum = 0", "right_sum", "0", "for i in A:\n if left_sum < right_sum :\n left_sum += i\n else:\n right_sum += i", "i", "A", "if left_sum < right_sum :\n left_sum += i\n else:\n right_sum += i", "left_sum < right_sum", "left_sum", "right_sum", "left_sum += i", "left_sum", "i", "right_sum += i", "right_sum", "i", "if abs(left_sum - right_sum) in [0, 1]:\n print(0)\nelse:\n a = abs(left_sum - right_sum) - 1\n print(a)", "abs(left_sum - right_sum) in [0, 1]", "abs(left_sum - right_sum)", "abs", "left_sum - right_sum", "left_sum", "right_sum", "[0, 1]", "0", "1", "print(0)", "print", "0", "a = abs(left_sum - right_sum) - 1", "a", "abs(left_sum - right_sum) - 1", "abs(left_sum - right_sum)", "abs", "left_sum - right_sum", "left_sum", "right_sum", "1", "print(a)", "print", "a", "t = map(int, input().split())", "map(int, input().split())", "t", "a = abs(left_sum - right_sum) - 1", "abs(left_sum - right_sum) - 1", "a", "left_sum = 0", "0", "left_sum", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "k, t = map(int, input().split())", "map(int, input().split())", "k", "left_sum += i", "i", "left_sum", "A = list(reversed(sorted(A)))", "list(reversed(sorted(A)))", "A", "right_sum += i", "i", "right_sum", "right_sum = 0", "0", "right_sum" ]
k, t = map(int, input().split()) A = list(map(int, input().split())) A = list(reversed(sorted(A))) left_sum = 0 right_sum = 0 for i in A: if left_sum < right_sum : left_sum += i else: right_sum += i if abs(left_sum - right_sum) in [0, 1]: print(0) else: a = abs(left_sum - right_sum) - 1 print(a)
[ 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, 2, 2, 13, 17, 17, 0, 13, 4, 13, 17, 2, 17, 2, 17, 2, 2, 13, 13, 17, 0, 13, 4, 13, 17, 2, 17, 2, 13, 13, 4, 13, 13, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 13 ], [ 16, 15 ], [ 28, 27 ], [ 15, 30 ], [ 33, 32 ], [ 4, 35 ], [ 4, 41 ], [ 46, 45 ], [ 27, 55 ], [ 32, 56 ], [ 60, 59 ], [ 27, 66 ], [ 32, 67 ], [ 59, 70 ], [ 45, 70 ], [ 75, 72 ] ]
[ "def main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n\n a = max(A)\n\n limit = (k+1) //2\n\n if k % 2 == 0:\n ans = max(0,1 + 2*(a - limit -1))\n else:\n ans = max(0,2*(a-limit))\n\n print(ans)\n\nmain()", "def main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n\n a = max(A)\n\n limit = (k+1) //2\n\n if k % 2 == 0:\n ans = max(0,1 + 2*(a - limit -1))\n else:\n ans = max(0,2*(a-limit))\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", "a = max(A)", "a", "max(A)", "max", "A", "limit = (k+1) //2", "limit", "(k+1) //2", "k+1", "k", "1", "2", "if k % 2 == 0:\n ans = max(0,1 + 2*(a - limit -1))\n else:\n ans = max(0,2*(a-limit))\n\n ", "k % 2 == 0", "k % 2", "k", "2", "0", "ans = max(0,1 + 2*(a - limit -1))", "ans", "max(0,1 + 2*(a - limit -1))", "max", "0", "1 + 2*(a - limit -1)", "1", "2*(a - limit -1)", "2", "a - limit -1", "a - limit", "a", "limit", "1", "ans = max(0,2*(a-limit))", "ans", "max(0,2*(a-limit))", "max", "0", "2*(a-limit)", "2", "a-limit", "a", "limit", "print(ans)", "print", "ans", "main()", "main", "def main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n\n a = max(A)\n\n limit = (k+1) //2\n\n if k % 2 == 0:\n ans = max(0,1 + 2*(a - limit -1))\n else:\n ans = max(0,2*(a-limit))\n\n print(ans)", "def main():\n k,t = map(int,input().split())\n A = list(map(int,input().split()))\n\n a = max(A)\n\n limit = (k+1) //2\n\n if k % 2 == 0:\n ans = max(0,1 + 2*(a - limit -1))\n else:\n ans = max(0,2*(a-limit))\n\n print(ans)", "main" ]
def main(): k,t = map(int,input().split()) A = list(map(int,input().split())) a = max(A) limit = (k+1) //2 if k % 2 == 0: ans = max(0,1 + 2*(a - limit -1)) else: ans = max(0,2*(a-limit)) print(ans) main()
[ 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, 4, 18, 13, 13, 4, 13, 4, 13, 17, 2, 2, 18, 13, 17, 17, 4, 13, 18, 13, 39, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 5, 15 ], [ 18, 17 ], [ 17, 30 ], [ 17, 40 ], [ 17, 46 ], [ 57, 54 ] ]
[ "def main():\n k, t = list(map(int, input().split()))\n A = list(map(int, input().split()))\n A.sort()\n print(max(0, A[-1] - 1 - sum(A[:-1])))\n\nif __name__ == '__main__':\n main()", "def main():\n k, t = list(map(int, input().split()))\n A = list(map(int, input().split()))\n A.sort()\n print(max(0, A[-1] - 1 - sum(A[:-1])))", "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", "A.sort()", "A.sort", "A", "sort", "print(max(0, A[-1] - 1 - sum(A[:-1])))", "print", "max(0, A[-1] - 1 - sum(A[:-1]))", "max", "0", "A[-1] - 1 - sum(A[:-1])", "A[-1] - 1", "A[-1]", "A", "-1", "1", "sum(A[:-1])", "sum", "A[:-1]", "A", ":-1", "-1", "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 A.sort()\n print(max(0, A[-1] - 1 - sum(A[:-1])))", "def main():\n k, t = list(map(int, input().split()))\n A = list(map(int, input().split()))\n A.sort()\n print(max(0, A[-1] - 1 - sum(A[:-1])))", "main" ]
def main(): k, t = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() print(max(0, A[-1] - 1 - sum(A[:-1]))) if __name__ == '__main__': main()
[ 7, 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, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 2, 4, 13, 13, 17, 4, 13, 42, 2, 13, 17, 0, 13, 4, 18, 13, 13, 0, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 17, 14, 40, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 14, 40, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 4, 13, 4, 13, 2, 4, 13, 13, 17, 17, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 143, 3 ], [ 143, 12 ], [ 131, 14 ], [ 116, 26 ], [ 132, 29 ], [ 119, 31 ], [ 117, 34 ], [ 132, 34 ], [ 110, 36 ], [ 120, 39 ], [ 117, 39 ], [ 132, 39 ], [ 111, 42 ], [ 120, 49 ], [ 117, 49 ], [ 132, 49 ], [ 111, 55 ], [ 114, 55 ], [ 123, 55 ], [ 134, 58 ], [ 120, 61 ], [ 117, 61 ], [ 132, 61 ], [ 128, 64 ], [ 120, 67 ], [ 117, 67 ], [ 132, 67 ], [ 137, 70 ], [ 140, 73 ], [ 138, 77 ], [ 135, 77 ], [ 120, 81 ], [ 117, 81 ], [ 132, 81 ], [ 138, 83 ], [ 135, 83 ], [ 122, 85 ], [ 141, 89 ], [ 129, 89 ], [ 120, 93 ], [ 117, 93 ], [ 132, 93 ], [ 141, 95 ], [ 129, 95 ], [ 113, 97 ], [ 120, 106 ], [ 117, 106 ], [ 132, 106 ], [ 110, 111 ], [ 113, 114 ], [ 116, 117 ], [ 119, 120 ], [ 122, 123 ], [ 143, 126 ], [ 128, 129 ], [ 131, 132 ], [ 134, 135 ], [ 137, 138 ], [ 140, 141 ], [ 143, 144 ] ]
[ "from collections import deque\nk,t = map(int, input().split())\na = list(map(int, input().split()))\na = sorted(a)\na = deque(a)\nlength = len(a)\nif length ==1:\n print(sum(a)-1)\n exit()\nwhile length > 1:\n mx = a.pop()\n mn = a.popleft()\n mx -= 1\n mn -= 1\n if mx != 0:\n a.append(mx)\n else:\n length -=1\n if mn != 0:\n a.appendleft(mn)\n else:\n length-=1 \nprint(max(sum(a)-1,0)) ", "from collections import deque", "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", "a = deque(a)", "a", "deque(a)", "deque", "a", "length = len(a)", "length", "len(a)", "len", "a", "if length ==1:\n print(sum(a)-1)\n exit()", "length ==1", "length", "1", "print(sum(a)-1)", "print", "sum(a)-1", "sum(a)", "sum", "a", "1", "exit()", "exit", "while length > 1:\n mx = a.pop()\n mn = a.popleft()\n mx -= 1\n mn -= 1\n if mx != 0:\n a.append(mx)\n else:\n length -=1\n if mn != 0:\n a.appendleft(mn)\n else:\n length-=1 ", "length > 1", "length", "1", "mx = a.pop()", "mx", "a.pop()", "a.pop", "a", "pop", "mn = a.popleft()", "mn", "a.popleft()", "a.popleft", "a", "popleft", "mx -= 1", "mx", "1", "mn -= 1", "mn", "1", "if mx != 0:\n a.append(mx)\n else:\n length -=1\n ", "mx != 0", "mx", "0", "a.append(mx)", "a.append", "a", "append", "mx", "length -=1", "length", "1", "if mn != 0:\n a.appendleft(mn)\n else:\n length-=1 ", "mn != 0", "mn", "0", "a.appendleft(mn)", "a.appendleft", "a", "appendleft", "mn", "length-=1", "length", "1", "print(max(sum(a)-1,0))", "print", "max(sum(a)-1,0)", "max", "sum(a)-1", "sum(a)", "sum", "a", "1", "0", "length = len(a)", "len(a)", "length", "length-=1", "1", "length", "a = sorted(a)", "sorted(a)", "a", "a = deque(a)", "deque(a)", "a", "length -=1", "1", "length", "t = map(int, input().split())", "map(int, input().split())", "t", "mn = a.popleft()", "a.popleft()", "mn", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "mx = a.pop()", "a.pop()", "mx", "mx -= 1", "1", "mx", "mn -= 1", "1", "mn", "k,t = map(int, input().split())", "map(int, input().split())", "k" ]
from collections import deque k,t = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) a = deque(a) length = len(a) if length ==1: print(sum(a)-1) exit() while length > 1: mx = a.pop() mn = a.popleft() mx -= 1 mn -= 1 if mx != 0: a.append(mx) else: length -=1 if mn != 0: a.appendleft(mn) else: length-=1 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, 14, 2, 13, 17, 0, 13, 2, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13, 2, 2, 18, 13, 17, 4, 13, 18, 13, 39, 17, 17, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 68, 2 ], [ 68, 11 ], [ 71, 13 ], [ 69, 26 ], [ 65, 29 ], [ 63, 31 ], [ 59, 34 ], [ 72, 37 ], [ 74, 39 ], [ 60, 45 ], [ 60, 50 ], [ 75, 57 ], [ 66, 57 ], [ 59, 60 ], [ 68, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "#!/usr/bin/env python\n# coding: utf-8\n\n# In[9]:\n\n\nK,T = map(int, input().split())\na = list(map(int, input().split()))\n\n\n# In[10]:\n\n\nif T == 1:\n ans = K-1\nelse:\n mylist = sorted(a)\n ans = max(mylist[-1]-sum(mylist[:-1])-1,0)\nprint(ans)\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", "if T == 1:\n ans = K-1\nelse:\n mylist = sorted(a)\n ans = max(mylist[-1]-sum(mylist[:-1])-1,0)", "T == 1", "T", "1", "ans = K-1", "ans", "K-1", "K", "1", "mylist = sorted(a)", "mylist", "sorted(a)", "sorted", "a", "ans = max(mylist[-1]-sum(mylist[:-1])-1,0)", "ans", "max(mylist[-1]-sum(mylist[:-1])-1,0)", "max", "mylist[-1]-sum(mylist[:-1])-1", "mylist[-1]-sum(mylist[:-1])", "mylist[-1]", "mylist", "-1", "sum(mylist[:-1])", "sum", "mylist[:-1]", "mylist", ":-1", "-1", "1", "0", "print(ans)", "print", "ans", "mylist = sorted(a)", "sorted(a)", "mylist", "K,T = map(int, input().split())", "map(int, input().split())", "K", "ans = K-1", "K-1", "ans", "T = map(int, input().split())", "map(int, input().split())", "T", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans = max(mylist[-1]-sum(mylist[:-1])-1,0)", "max(mylist[-1]-sum(mylist[:-1])-1,0)", "ans" ]
#!/usr/bin/env python # coding: utf-8 # In[9]: K,T = map(int, input().split()) a = list(map(int, input().split())) # In[10]: if T == 1: ans = K-1 else: mylist = sorted(a) ans = max(mylist[-1]-sum(mylist[:-1])-1,0) 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, 42, 2, 4, 13, 13, 17, 4, 18, 13, 13, 0, 13, 17, 0, 18, 13, 17, 4, 18, 13, 13, 4, 13, 4, 13, 17, 2, 18, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 62, 2 ], [ 62, 11 ], [ 59, 13 ], [ 60, 28 ], [ 60, 32 ], [ 36, 35 ], [ 41, 38 ], [ 60, 39 ], [ 60, 43 ], [ 60, 52 ], [ 62, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "K,T=map(int,input().split())\na=list(map(int,input().split()))\nwhile len(a)>1:\n a.sort(reverse=True)\n a[0]-=a.pop()\nprint(max(0,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", "while len(a)>1:\n a.sort(reverse=True)\n a[0]-=a.pop()", "len(a)>1", "len(a)", "len", "a", "1", "a.sort(reverse=True)", "a.sort", "a", "sort", "reverse=True", "reverse", "True", "a[0]-=a.pop()", "a[0]", "a", "0", "a.pop()", "a.pop", "a", "pop", "print(max(0,a[0]-1))", "print", "max(0,a[0]-1)", "max", "0", "a[0]-1", "a[0]", "a", "0", "1", "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())) while len(a)>1: a.sort(reverse=True) a[0]-=a.pop() print(max(0,a[0]-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, 14, 2, 13, 17, 4, 13, 2, 13, 17, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 40, 13, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 68, 2 ], [ 68, 11 ], [ 74, 13 ], [ 63, 26 ], [ 69, 31 ], [ 65, 34 ], [ 75, 37 ], [ 71, 39 ], [ 75, 43 ], [ 66, 44 ], [ 72, 47 ], [ 66, 49 ], [ 66, 58 ], [ 72, 59 ], [ 68, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "K, T = map(int, input().split())\na = list(map(int, input().split()))\n\nif T == 1:\n print(K - 1)\nelse:\n M = max(a)\n rest = sum(a) - M\n\n if rest >= M - 1:\n print(0)\n else:\n print(M - 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:\n print(K - 1)\nelse:\n M = max(a)\n rest = sum(a) - M\n\n if rest >= M - 1:\n print(0)\n else:\n print(M - rest - 1)", "T == 1", "T", "1", "print(K - 1)", "print", "K - 1", "K", "1", "M = max(a)", "M", "max(a)", "max", "a", "rest = sum(a) - M", "rest", "sum(a) - M", "sum(a)", "sum", "a", "M", "if rest >= M - 1:\n print(0)\n else:\n print(M - rest - 1)", "rest >= M - 1", "rest", "M - 1", "M", "1", "print(0)", "print", "0", "print(M - rest - 1)", "print", "M - rest - 1", "M - rest", "M", "rest", "1", "T = map(int, input().split())", "map(int, input().split())", "T", "M = max(a)", "max(a)", "M", "K, T = map(int, input().split())", "map(int, input().split())", "K", "rest = sum(a) - M", "sum(a) - M", "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(K - 1) else: M = max(a) rest = sum(a) - M if rest >= M - 1: print(0) else: print(M - rest - 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, 14, 2, 4, 13, 13, 17, 4, 13, 2, 18, 13, 17, 17, 4, 13, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 2, 2, 13, 17, 13, 4, 13, 2, 2, 13, 13, 17, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 71, 2 ], [ 71, 11 ], [ 74, 13 ], [ 75, 28 ], [ 75, 34 ], [ 80, 40 ], [ 75, 43 ], [ 77, 45 ], [ 75, 49 ], [ 81, 50 ], [ 81, 54 ], [ 78, 56 ], [ 81, 61 ], [ 78, 62 ], [ 71, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ] ]
[ "k,t = map(int,input().split())\nl = list(map(int,input().split()))\n\nif len(l) == 0:\n print(l[0]-1)\n exit()\n\nm = max(l)\ns = sum(l)-m\n\nif m-1 > s:\n print(m-s-1)\nelse:\n print(0)", "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", "if len(l) == 0:\n print(l[0]-1)\n exit()", "len(l) == 0", "len(l)", "len", "l", "0", "print(l[0]-1)", "print", "l[0]-1", "l[0]", "l", "0", "1", "exit()", "exit", "m = max(l)", "m", "max(l)", "max", "l", "s = sum(l)-m", "s", "sum(l)-m", "sum(l)", "sum", "l", "m", "if m-1 > s:\n print(m-s-1)\nelse:\n print(0)", "m-1 > s", "m-1", "m", "1", "s", "print(m-s-1)", "print", "m-s-1", "m-s", "m", "s", "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", "l = list(map(int,input().split()))", "list(map(int,input().split()))", "l", "s = sum(l)-m", "sum(l)-m", "s", "m = max(l)", "max(l)", "m" ]
k,t = map(int,input().split()) l = list(map(int,input().split())) if len(l) == 0: print(l[0]-1) exit() m = max(l) s = sum(l)-m if m-1 > s: print(m-s-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, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 2, 17, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 51, 11 ], [ 45, 13 ], [ 42, 25 ], [ 46, 28 ], [ 43, 38 ], [ 52, 39 ], [ 42, 43 ], [ 45, 46 ], [ 51, 49 ], [ 51, 52 ] ]
[ "n, m = map(int, input().split())\ndata = list(map(int, input().split()))\nans = max(data)\nprint(max(0, 2*ans-n-1))", "n, m = map(int, input().split())", "n", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m", "data = list(map(int, input().split()))", "data", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = max(data)", "ans", "max(data)", "max", "data", "print(max(0, 2*ans-n-1))", "print", "max(0, 2*ans-n-1)", "max", "0", "2*ans-n-1", "2*ans-n", "2*ans", "2", "ans", "n", "1", "ans = max(data)", "max(data)", "ans", "data = list(map(int, input().split()))", "list(map(int, input().split()))", "data", "m = map(int, input().split())", "map(int, input().split())", "m", "n, m = map(int, input().split())", "map(int, input().split())", "n" ]
n, m = map(int, input().split()) data = list(map(int, input().split())) ans = max(data) print(max(0, 2*ans-n-1))
[ 7, 15, 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, 14, 2, 13, 17, 4, 13, 2, 13, 17, 29, 41, 28, 13, 13, 4, 40, 13, 0, 13, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 28, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 3, 4, 18, 13, 13, 13, 2, 13, 17, 0, 13, 13, 4, 13, 2, 2, 13, 17, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 7, 15 ], [ 18, 17 ], [ 15, 30 ], [ 6, 35 ], [ 41, 40 ], [ 17, 40 ], [ 40, 44 ], [ 47, 46 ], [ 46, 52 ], [ 55, 54 ], [ 46, 59 ], [ 62, 61 ], [ 6, 64 ], [ 67, 66 ], [ 46, 71 ], [ 66, 74 ], [ 46, 81 ], [ 54, 83 ], [ 86, 83 ], [ 87, 86 ], [ 66, 87 ], [ 6, 92 ], [ 103, 100 ] ]
[ "import heapq\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 b = [-x for x in a]\n heapq.heapify(b)\n tmp = heapq.heappop(b)\n for i in range(K):\n tmp2 = heapq.heappop(b)\n if tmp2 == 0:\n break\n heapq.heappush(b, tmp+1)\n tmp = tmp2\n print(K-1-i)\n \nif __name__ == \"__main__\":\n main()", "import heapq", "heapq", "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 b = [-x for x in a]\n heapq.heapify(b)\n tmp = heapq.heappop(b)\n for i in range(K):\n tmp2 = heapq.heappop(b)\n if tmp2 == 0:\n break\n heapq.heappush(b, tmp+1)\n tmp = tmp2\n print(K-1-i)\n ", "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", "-x for x in a", "for x in a", "x", "a", "for x in a", "-x", "x", "b = [-x for x in a]", "b", "[-x for x in a]", "heapq.heapify(b)", "heapq.heapify", "heapq", "heapify", "b", "tmp = heapq.heappop(b)", "tmp", "heapq.heappop(b)", "heapq.heappop", "heapq", "heappop", "b", "for i in range(K):\n tmp2 = heapq.heappop(b)\n if tmp2 == 0:\n break\n heapq.heappush(b, tmp+1)\n tmp = tmp2\n ", "i", "range(K)", "range", "K", "tmp2 = heapq.heappop(b)", "tmp2", "heapq.heappop(b)", "heapq.heappop", "heapq", "heappop", "b", "if tmp2 == 0:\n break\n ", "tmp2 == 0", "tmp2", "0", "break", "heapq.heappush(b, tmp+1)", "heapq.heappush", "heapq", "heappush", "b", "tmp+1", "tmp", "1", "tmp = tmp2", "tmp", "tmp2", "print(K-1-i)", "print", "K-1-i", "K-1", "K", "1", "i", "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 if T == 1:\n print(K-1)\n return\n b = [-x for x in a]\n heapq.heapify(b)\n tmp = heapq.heappop(b)\n for i in range(K):\n tmp2 = heapq.heappop(b)\n if tmp2 == 0:\n break\n heapq.heappush(b, tmp+1)\n tmp = tmp2\n print(K-1-i)\n ", "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 b = [-x for x in a]\n heapq.heapify(b)\n tmp = heapq.heappop(b)\n for i in range(K):\n tmp2 = heapq.heappop(b)\n if tmp2 == 0:\n break\n heapq.heappush(b, tmp+1)\n tmp = tmp2\n print(K-1-i)\n ", "main" ]
import heapq def main(): K, T = map(int, input().split()) a = list(map(int, input().split())) if T == 1: print(K-1) return b = [-x for x in a] heapq.heapify(b) tmp = heapq.heappop(b) for i in range(K): tmp2 = heapq.heappop(b) if tmp2 == 0: break heapq.heappush(b, tmp+1) tmp = tmp2 print(K-1-i) if __name__ == "__main__": main()
[ 7, 12, 13, 14, 2, 13, 17, 29, 2, 13, 17, 0, 13, 4, 13, 13, 14, 40, 13, 2, 13, 13, 29, 17, 29, 2, 2, 13, 2, 17, 2, 13, 13, 17, 23, 13, 23, 13, 23, 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, 4, 13, 4, 13, 13, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 39, 5 ], [ 37, 9 ], [ 13, 12 ], [ 35, 15 ], [ 12, 18 ], [ 37, 20 ], [ 12, 21 ], [ 37, 27 ], [ 37, 31 ], [ 12, 32 ], [ 35, 35 ], [ 37, 37 ], [ 39, 39 ], [ 44, 43 ], [ 44, 52 ], [ 55, 54 ], [ 80, 68 ], [ 54, 69 ], [ 43, 70 ], [ 52, 71 ], [ 83, 77 ] ]
[ "def min_day(A,K,T):\n if T == 1:\n return K-1\n else:\n A_max = max(A)\n if A_max <= K - A_max:\n return 0\n else:\n return K-2*(K-A_max)-1\n\ndef main():\n K,T = map(int,input().split())\n A = list(map(int,input().split()))\n\n print(min_day(A,K,T))\n\nif __name__ == \"__main__\":\n main()", "def min_day(A,K,T):\n if T == 1:\n return K-1\n else:\n A_max = max(A)\n if A_max <= K - A_max:\n return 0\n else:\n return K-2*(K-A_max)-1", "min_day", "if T == 1:\n return K-1\n else:\n A_max = max(A)\n if A_max <= K - A_max:\n return 0\n else:\n return K-2*(K-A_max)-1", "T == 1", "T", "1", "return K-1", "K-1", "K", "1", "A_max = max(A)", "A_max", "max(A)", "max", "A", "if A_max <= K - A_max:\n return 0\n else:\n return K-2*(K-A_max)-1", "A_max <= K - A_max", "A_max", "K - A_max", "K", "A_max", "return 0", "0", "return K-2*(K-A_max)-1", "K-2*(K-A_max)-1", "K-2*(K-A_max)", "K", "2*(K-A_max)", "2", "K-A_max", "K", "A_max", "1", "A", "A", "K", "K", "T", "T", "def main():\n K,T = map(int,input().split())\n A = list(map(int,input().split()))\n\n print(min_day(A,K,T))", "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", "print(min_day(A,K,T))", "print", "min_day(A,K,T)", "min_day", "A", "K", "T", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def min_day(A,K,T):\n if T == 1:\n return K-1\n else:\n A_max = max(A)\n if A_max <= K - A_max:\n return 0\n else:\n return K-2*(K-A_max)-1", "def min_day(A,K,T):\n if T == 1:\n return K-1\n else:\n A_max = max(A)\n if A_max <= K - A_max:\n return 0\n else:\n return K-2*(K-A_max)-1", "min_day", "def main():\n K,T = map(int,input().split())\n A = list(map(int,input().split()))\n\n print(min_day(A,K,T))", "def main():\n K,T = map(int,input().split())\n A = list(map(int,input().split()))\n\n print(min_day(A,K,T))", "main" ]
def min_day(A,K,T): if T == 1: return K-1 else: A_max = max(A) if A_max <= K - A_max: return 0 else: return K-2*(K-A_max)-1 def main(): K,T = map(int,input().split()) A = list(map(int,input().split())) print(min_day(A,K,T)) if __name__ == "__main__": main()
[ 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, 4, 18, 13, 13, 0, 13, 17, 0, 13, 2, 18, 13, 17, 17, 28, 13, 18, 13, 39, 17, 0, 13, 13, 4, 13, 4, 13, 17, 13, 10, 13, 13, 10, 13, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 69, 2 ], [ 69, 11 ], [ 15, 14 ], [ 14, 23 ], [ 57, 25 ], [ 58, 29 ], [ 33, 32 ], [ 63, 35 ], [ 58, 38 ], [ 43, 42 ], [ 58, 44 ], [ 60, 48 ], [ 42, 49 ], [ 61, 55 ], [ 64, 55 ], [ 57, 58 ], [ 42, 60 ], [ 60, 61 ], [ 63, 64 ], [ 69, 67 ], [ 69, 70 ] ]
[ "K, T = map(int, input().split())\nA = [int(i) for i in input().split()]\nA.sort(reverse=True)\n\n# スペース\nspace = A[0] - 1\nfor x in A[1:]:\n space -= x\n\nprint(max(0, space))", "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.sort(reverse=True)", "A.sort", "A", "sort", "reverse=True", "reverse", "True", "space = A[0] - 1", "space", "A[0] - 1", "A[0]", "A", "0", "1", "for x in A[1:]:\n space -= x", "x", "A[1:]", "A", "1:", "1", "space -= x", "space", "x", "print(max(0, space))", "print", "max(0, space)", "max", "0", "space", "A = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "A", "space -= x", "x", "space", "space = A[0] - 1", "A[0] - 1", "space", "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 = [int(i) for i in input().split()] A.sort(reverse=True) # スペース space = A[0] - 1 for x in A[1:]: space -= x print(max(0, space))
[ 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, 39, 17, 13, 0, 13, 17, 0, 13, 13, 28, 13, 4, 13, 13, 14, 2, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 13, 0, 18, 13, 13, 13, 0, 13, 39, 17, 17, 28, 13, 4, 13, 13, 14, 2, 13, 13, 9, 14, 2, 18, 13, 13, 18, 13, 17, 0, 13, 39, 18, 13, 13, 13, 0, 18, 13, 18, 13, 17, 17, 14, 2, 18, 13, 18, 13, 17, 17, 0, 13, 17, 0, 18, 13, 13, 18, 13, 17, 0, 13, 18, 13, 17, 0, 13, 17, 28, 13, 4, 13, 17, 13, 14, 2, 18, 13, 13, 18, 13, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 39, 13, 10, 17, 13, 10, 2, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13, 10, 18, 13, 10, 39, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 168, 2 ], [ 168, 11 ], [ 165, 13 ], [ 156, 25 ], [ 169, 29 ], [ 174, 31 ], [ 171, 34 ], [ 163, 35 ], [ 38, 37 ], [ 169, 40 ], [ 172, 43 ], [ 184, 43 ], [ 47, 46 ], [ 163, 49 ], [ 166, 53 ], [ 46, 54 ], [ 159, 57 ], [ 46, 58 ], [ 63, 60 ], [ 157, 61 ], [ 37, 62 ], [ 160, 63 ], [ 181, 63 ], [ 151, 63 ], [ 150, 65 ], [ 71, 70 ], [ 163, 73 ], [ 70, 76 ], [ 175, 77 ], [ 178, 77 ], [ 166, 82 ], [ 70, 83 ], [ 160, 85 ], [ 151, 85 ], [ 181, 85 ], [ 180, 88 ], [ 166, 91 ], [ 70, 92 ], [ 100, 95 ], [ 166, 96 ], [ 181, 98 ], [ 160, 98 ], [ 151, 98 ], [ 166, 104 ], [ 181, 106 ], [ 160, 106 ], [ 151, 106 ], [ 183, 110 ], [ 116, 113 ], [ 157, 114 ], [ 37, 115 ], [ 181, 117 ], [ 160, 117 ], [ 151, 117 ], [ 177, 120 ], [ 181, 122 ], [ 160, 122 ], [ 151, 122 ], [ 186, 125 ], [ 129, 128 ], [ 169, 132 ], [ 113, 135 ], [ 60, 135 ], [ 157, 136 ], [ 128, 137 ], [ 157, 139 ], [ 128, 141 ], [ 153, 144 ], [ 154, 148 ], [ 187, 148 ], [ 150, 151 ], [ 153, 154 ], [ 156, 157 ], [ 46, 159 ], [ 159, 160 ], [ 168, 163 ], [ 165, 166 ], [ 168, 169 ], [ 163, 171 ], [ 171, 172 ], [ 174, 175 ], [ 177, 178 ], [ 180, 181 ], [ 183, 184 ], [ 186, 187 ] ]
[ "K,T = map(int, input().split())\na = list(map(int, input().split()))\nlis = [0] * K\nd = -1\nT2 = T\nfor i in range(K):\n if T2 == 1:\n for j in range(T):\n if a[j] > 0:\n val = j\n lis[i] = val\n else:\n val = [0,0]\n for j in range(T):\n if j == d:\n continue\n if a[j] > val[0]:\n val = [a[j],j]\n a[val[1]] -= 1\n if a[val[1]] == 0:\n T2 -= 1\n\n lis[i] = val[1]\n d = val[1]\n\n#print(lis)\nans = 0\nfor i in range(1,K):\n if lis[i] == lis[i-1]:\n ans += 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", "lis = [0] * K", "lis", "[0] * K", "[0]", "0", "K", "d = -1", "d", "-1", "T2 = T", "T2", "T", "for i in range(K):\n if T2 == 1:\n for j in range(T):\n if a[j] > 0:\n val = j\n lis[i] = val\n else:\n val = [0,0]\n for j in range(T):\n if j == d:\n continue\n if a[j] > val[0]:\n val = [a[j],j]\n a[val[1]] -= 1\n if a[val[1]] == 0:\n T2 -= 1\n\n lis[i] = val[1]\n d = val[1]\n\n#print(lis)", "i", "range(K)", "range", "K", "if T2 == 1:\n for j in range(T):\n if a[j] > 0:\n val = j\n lis[i] = val\n else:\n val = [0,0]\n for j in range(T):\n if j == d:\n continue\n if a[j] > val[0]:\n val = [a[j],j]\n a[val[1]] -= 1\n if a[val[1]] == 0:\n T2 -= 1\n\n lis[i] = val[1]\n d = val[1]\n\n#print(lis)", "T2 == 1", "T2", "1", "for j in range(T):\n if a[j] > 0:\n val = j\n ", "j", "range(T)", "range", "T", "if a[j] > 0:\n val = j\n ", "a[j] > 0", "a[j]", "a", "j", "0", "val = j", "val", "j", "lis[i] = val", "lis[i]", "lis", "i", "val", "val = [0,0]", "val", "[0,0]", "0", "0", "for j in range(T):\n if j == d:\n continue\n if a[j] > val[0]:\n val = [a[j],j]\n ", "j", "range(T)", "range", "T", "if j == d:\n continue\n ", "j == d", "j", "d", "continue", "if a[j] > val[0]:\n val = [a[j],j]\n ", "a[j] > val[0]", "a[j]", "a", "j", "val[0]", "val", "0", "val = [a[j],j]", "val", "[a[j],j]", "a[j]", "a", "j", "j", "a[val[1]] -= 1", "a[val[1]]", "a", "val[1]", "val", "1", "1", "if a[val[1]] == 0:\n T2 -= 1\n\n ", "a[val[1]] == 0", "a[val[1]]", "a", "val[1]", "val", "1", "0", "T2 -= 1", "T2", "1", "lis[i] = val[1]", "lis[i]", "lis", "i", "val[1]", "val", "1", "d = val[1]", "d", "val[1]", "val", "1", "ans = 0", "ans", "0", "for i in range(1,K):\n if lis[i] == lis[i-1]:\n ans += 1", "i", "range(1,K)", "range", "1", "K", "if lis[i] == lis[i-1]:\n ans += 1", "lis[i] == lis[i-1]", "lis[i]", "lis", "i", "lis[i-1]", "lis", "i-1", "i", "1", "ans += 1", "ans", "1", "print(ans)", "print", "ans", "val = [0,0]", "[0,0]", "val", "ans += 1", "1", "ans", "lis = [0] * K", "[0] * K", "lis", "val = j", "j", "val", "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", "T2 = T", "T", "T2", "d = -1", "-1", "d", "d = val[1]", "val[1]", "d", "val = [a[j],j]", "[a[j],j]", "val", "T2 -= 1", "1", "T2", "ans = 0", "0", "ans" ]
K,T = map(int, input().split()) a = list(map(int, input().split())) lis = [0] * K d = -1 T2 = T for i in range(K): if T2 == 1: for j in range(T): if a[j] > 0: val = j lis[i] = val else: val = [0,0] for j in range(T): if j == d: continue if a[j] > val[0]: val = [a[j],j] a[val[1]] -= 1 if a[val[1]] == 0: T2 -= 1 lis[i] = val[1] d = val[1] #print(lis) ans = 0 for i in range(1,K): if lis[i] == lis[i-1]: ans += 1 print(ans)
[ 7, 15, 13, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 13, 31, 13, 4, 18, 13, 13, 0, 13, 2, 4, 13, 13, 18, 13, 17, 0, 13, 18, 13, 17, 0, 13, 4, 13, 17, 2, 13, 2, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 7, 19 ], [ 7, 20 ], [ 28, 27 ], [ 37, 36 ], [ 42, 41 ], [ 36, 46 ], [ 27, 48 ], [ 41, 52 ], [ 61, 58 ] ]
[ "import sys\n\ndef main():\n n, t, *a = map(int, sys.stdin.read().split())\n a.sort()\n b = sum(a) - a[-1]\n a = a[-1]\n ans = max(0, a-(b+1))\n print(ans)\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "def main():\n n, t, *a = map(int, sys.stdin.read().split())\n a.sort()\n b = sum(a) - a[-1]\n a = a[-1]\n ans = max(0, a-(b+1))\n print(ans)", "main", "n, t, *a = map(int, sys.stdin.read().split())", "n", "map(int, sys.stdin.read().split())", "map", "int", "sys.stdin.read().split()", "sys.stdin.read().split", "sys.stdin.read()", "sys.stdin.read", "sys.stdin", "sys", "stdin", "read", "split", "t", "*a", "a", "a.sort()", "a.sort", "a", "sort", "b = sum(a) - a[-1]", "b", "sum(a) - a[-1]", "sum(a)", "sum", "a", "a[-1]", "a", "-1", "a = a[-1]", "a", "a[-1]", "a", "-1", "ans = max(0, a-(b+1))", "ans", "max(0, a-(b+1))", "max", "0", "a-(b+1)", "a", "b+1", "b", "1", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n n, t, *a = map(int, sys.stdin.read().split())\n a.sort()\n b = sum(a) - a[-1]\n a = a[-1]\n ans = max(0, a-(b+1))\n print(ans)", "def main():\n n, t, *a = map(int, sys.stdin.read().split())\n a.sort()\n b = sum(a) - a[-1]\n a = a[-1]\n ans = max(0, a-(b+1))\n print(ans)", "main" ]
import sys def main(): n, t, *a = map(int, sys.stdin.read().split()) a.sort() b = sum(a) - a[-1] a = a[-1] ans = max(0, a-(b+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, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 13, 13, 4, 13, 4, 13, 2, 13, 2, 13, 17, 17, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 56, 2 ], [ 56, 11 ], [ 65, 13 ], [ 59, 25 ], [ 66, 28 ], [ 62, 30 ], [ 66, 33 ], [ 50, 35 ], [ 63, 37 ], [ 60, 38 ], [ 60, 44 ], [ 51, 46 ], [ 50, 51 ], [ 56, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "n,t = map(int,input().split())\na = list(map(int,input().split()))\n\nma = max(a)\nsa = sum(a)\nd = sa - ma\n\nprint(max(ma-(d+1),0))", "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()))", "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", "sa = sum(a)", "sa", "sum(a)", "sum", "a", "d = sa - ma", "d", "sa - ma", "sa", "ma", "print(max(ma-(d+1),0))", "print", "max(ma-(d+1),0)", "max", "ma-(d+1)", "ma", "d+1", "d", "1", "0", "d = sa - ma", "sa - ma", "d", "t = map(int,input().split())", "map(int,input().split())", "t", "n,t = map(int,input().split())", "map(int,input().split())", "n", "ma = max(a)", "max(a)", "ma", "sa = sum(a)", "sum(a)", "sa", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
n,t = map(int,input().split()) a = list(map(int,input().split())) ma = max(a) sa = sum(a) d = sa - ma print(max(ma-(d+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, 2, 17, 4, 13, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 45, 2 ], [ 45, 11 ], [ 39, 13 ], [ 40, 35 ], [ 43, 36 ], [ 39, 40 ], [ 45, 43 ], [ 45, 46 ] ]
[ "k, t = map(int, input().split())\na = list(map(int, input().split()))\nprint(max(0, 2 * max(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", "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", "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(0, 2 * max(a) - k - 1))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 13, 4, 13, 31, 13, 0, 13, 18, 13, 13, 23, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 4, 13, 4, 13, 17, 2, 2, 18, 13, 17, 2, 4, 13, 13, 18, 13, 17, 17, 10, 4, 13, 10, 18, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 73, 4 ], [ 18, 17 ], [ 82, 23 ], [ 74, 30 ], [ 82, 32 ], [ 85, 34 ], [ 74, 41 ], [ 70, 44 ], [ 86, 47 ], [ 50, 49 ], [ 71, 59 ], [ 86, 59 ], [ 71, 64 ], [ 86, 64 ], [ 71, 66 ], [ 86, 66 ], [ 70, 71 ], [ 73, 74 ], [ 82, 80 ], [ 82, 83 ], [ 85, 86 ] ]
[ "import sys\ninput = sys.stdin.readline\n\n\ndef log(*args):\n print(*args, file=sys.stderr)\n\n\nK, T = map(int, input().split())\ncounts = map(int, input().split())\ncounts = sorted(counts, reverse=True)\nprint(max(0, counts[0] - (sum(counts) - counts[0]) - 1))", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def log(*args):\n print(*args, file=sys.stderr)", "log", "print(*args, file=sys.stderr)", "print", "*args", "args", "file=sys.stderr", "file", "sys.stderr", "sys", "stderr", "*args", "K, T = map(int, input().split())", "K", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "T", "counts = map(int, input().split())", "counts", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "counts = sorted(counts, reverse=True)", "counts", "sorted(counts, reverse=True)", "sorted", "counts", "reverse=True", "reverse", "True", "print(max(0, counts[0] - (sum(counts) - counts[0]) - 1))", "print", "max(0, counts[0] - (sum(counts) - counts[0]) - 1)", "max", "0", "counts[0] - (sum(counts) - counts[0]) - 1", "counts[0] - (sum(counts) - counts[0])", "counts[0]", "counts", "0", "sum(counts) - counts[0]", "sum(counts)", "sum", "counts", "counts[0]", "counts", "0", "1", "counts = sorted(counts, reverse=True)", "sorted(counts, reverse=True)", "counts", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def log(*args):\n print(*args, file=sys.stderr)", "def log(*args):\n print(*args, file=sys.stderr)", "log", "T = map(int, input().split())", "map(int, input().split())", "T", "K, T = map(int, input().split())", "map(int, input().split())", "K", "counts = map(int, input().split())", "map(int, input().split())", "counts" ]
import sys input = sys.stdin.readline def log(*args): print(*args, file=sys.stderr) K, T = map(int, input().split()) counts = map(int, input().split()) counts = sorted(counts, reverse=True) print(max(0, counts[0] - (sum(counts) - counts[0]) - 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, 17, 0, 13, 4, 13, 18, 13, 39, 17, 0, 13, 18, 13, 17, 4, 13, 4, 13, 17, 2, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13 ]
[ [ 64, 2 ], [ 64, 11 ], [ 58, 13 ], [ 59, 26 ], [ 30, 29 ], [ 61, 32 ], [ 59, 36 ], [ 67, 40 ], [ 59, 42 ], [ 68, 51 ], [ 62, 52 ], [ 64, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "k,t = map(int,input().split())\na = list(map(int,input().split()))\na.sort(reverse = True)\nx = sum(a[1:])\ny = a[0]\n\nprint(max(0,y-x-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(reverse = True)", "a.sort", "a", "sort", "reverse = True", "reverse", "True", "x = sum(a[1:])", "x", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "y = a[0]", "y", "a[0]", "a", "0", "print(max(0,y-x-1))", "print", "max(0,y-x-1)", "max", "0", "y-x-1", "y-x", "y", "x", "1", "k,t = map(int,input().split())", "map(int,input().split())", "k", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "x = sum(a[1:])", "sum(a[1:])", "x", "t = map(int,input().split())", "map(int,input().split())", "t", "y = a[0]", "a[0]", "y" ]
k,t = map(int,input().split()) a = list(map(int,input().split())) a.sort(reverse = True) x = sum(a[1:]) y = a[0] print(max(0,y-x-1))
[ 7, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 29, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 5, 14 ], [ 21, 20 ], [ 49, 22 ], [ 21, 23 ], [ 26, 25 ], [ 49, 27 ], [ 30, 29 ], [ 33, 32 ], [ 25, 32 ], [ 29, 36 ], [ 52, 43 ] ]
[ "def Z(): return int(input())\ndef ZZ(): return [int(_) for _ in input().split()]\n\ndef main():\n K, T = ZZ()\n A = ZZ()\n output = 0\n for a in A: output += max(0, a - (K - a + 2) + 1)\n print(output)\n\n return\n\nif __name__ == '__main__':\n main()", "def Z(): return int(input())", "Z", "int(_) for _ in input().split()", "for _ in input().split()", "_", "input().split()", "().split", "()", "input", "split", "for _ in input().split()", "int(_)", "int", "_", "def ZZ(): return [int(_) for _ in input().split()]", "ZZ", "def main():\n K, T = ZZ()\n A = ZZ()\n output = 0\n for a in A: output += max(0, a - (K - a + 2) + 1)\n print(output)\n\n return", "main", "K, T = ZZ()", "K", "ZZ()", "ZZ", "T", "A = ZZ()", "A", "ZZ()", "ZZ", "output = 0", "output", "0", "for a in A: output += max(0, a - (K - a + 2) + 1)\n ", "a", "A", "print(output)", "print", "output", "return", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def Z(): return int(input())", "def Z(): return int(input())", "Z", "def ZZ(): return [int(_) for _ in input().split()]", "def ZZ(): return [int(_) for _ in input().split()]", "ZZ", "def main():\n K, T = ZZ()\n A = ZZ()\n output = 0\n for a in A: output += max(0, a - (K - a + 2) + 1)\n print(output)\n\n return", "def main():\n K, T = ZZ()\n A = ZZ()\n output = 0\n for a in A: output += max(0, a - (K - a + 2) + 1)\n print(output)\n\n return", "main" ]
def Z(): return int(input()) def ZZ(): return [int(_) for _ in input().split()] def main(): K, T = ZZ() A = ZZ() output = 0 for a in A: output += max(0, a - (K - a + 2) + 1) print(output) return 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, 18, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 4, 13, 4, 13, 2, 2, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 61, 2 ], [ 61, 11 ], [ 58, 13 ], [ 59, 26 ], [ 30, 29 ], [ 64, 32 ], [ 59, 34 ], [ 67, 37 ], [ 59, 41 ], [ 65, 50 ], [ 68, 51 ], [ 61, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "k, t = map(int, input().split())\na = list(map(int, input().split()))\na.sort(reverse=True)\nmx = a[0]\nsa = sum(a[1:])\nprint(max(mx-sa-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", "mx = a[0]", "mx", "a[0]", "a", "0", "sa = sum(a[1:])", "sa", "sum(a[1:])", "sum", "a[1:]", "a", "1:", "1", "print(max(mx-sa-1, 0))", "print", "max(mx-sa-1, 0)", "max", "mx-sa-1", "mx-sa", "mx", "sa", "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", "t = map(int, input().split())", "map(int, input().split())", "t", "mx = a[0]", "a[0]", "mx", "sa = sum(a[1:])", "sum(a[1:])", "sa" ]
k, t = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) mx = a[0] sa = sum(a[1:]) print(max(mx-sa-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, 4, 13, 13, 17, 13, 4, 13, 13, 14, 2, 13, 13, 4, 13, 2, 2, 13, 13, 17, 4, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 62, 2 ], [ 62, 11 ], [ 50, 13 ], [ 59, 25 ], [ 51, 29 ], [ 56, 31 ], [ 51, 34 ], [ 60, 37 ], [ 57, 38 ], [ 60, 43 ], [ 57, 44 ], [ 50, 51 ], [ 62, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "K, T = map(int, input().split())\na = list(map(int, input().split()))\ns, t = max(a)<<1, sum(a)\nif s > t:\n print(s-t-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 = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "s, t = max(a)<<1, sum(a)", "s", "max(a)<<1", "max(a)", "max", "a", "1", "t", "sum(a)", "sum", "a", "if s > t:\n print(s-t-1)\nelse:\n print(0)", "s > t", "s", "t", "print(s-t-1)", "print", "s-t-1", "s-t", "s", "t", "1", "print(0)", "print", "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 = max(a)<<1, sum(a)", "sum(a)", "t", "s, t = max(a)<<1, sum(a)", "max(a)<<1", "s", "T = map(int, input().split())", "map(int, input().split())", "T" ]
K, T = map(int, input().split()) a = list(map(int, input().split())) s, t = max(a)<<1, sum(a) if s > t: print(s-t-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, 31, 13, 4, 13, 4, 13, 2, 2, 13, 4, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 42, 2 ], [ 42, 11 ], [ 45, 13 ], [ 45, 24 ], [ 46, 32 ], [ 42, 40 ], [ 42, 43 ], [ 45, 46 ] ]
[ "k, t = map(int, input().split())\n*A, MAX = sorted(map(int, input().split()))\nprint(max(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, MAX = sorted(map(int, input().split()))", "MAX", "sorted(map(int, input().split()))", "sorted", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "*A", "A", "print(max(MAX-sum(A)-1, 0))", "print", "max(MAX-sum(A)-1, 0)", "max", "MAX-sum(A)-1", "MAX-sum(A)", "MAX", "sum(A)", "sum", "A", "1", "0", "k, t = map(int, input().split())", "map(int, input().split())", "k", "t = map(int, input().split())", "map(int, input().split())", "t", "MAX = sorted(map(int, input().split()))", "sorted(map(int, input().split()))", "MAX" ]
k, t = map(int, input().split()) *A, MAX = sorted(map(int, input().split())) print(max(MAX-sum(A)-1, 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, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 4, 13, 4, 13, 2, 2, 13, 17, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 55, 4 ], [ 55, 13 ], [ 58, 15 ], [ 52, 27 ], [ 59, 30 ], [ 61, 32 ], [ 59, 36 ], [ 53, 37 ], [ 53, 44 ], [ 62, 46 ], [ 55, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "import math\nk, t = map(int, input().split())\na = list(map(int, input().split()))\nmax_a = max(a)\nrest_a = sum(a) - max_a\nprint(max(max_a - 1 - rest_a, 0))", "import math", "math", "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", "rest_a = sum(a) - max_a", "rest_a", "sum(a) - max_a", "sum(a)", "sum", "a", "max_a", "print(max(max_a - 1 - rest_a, 0))", "print", "max(max_a - 1 - rest_a, 0)", "max", "max_a - 1 - rest_a", "max_a - 1", "max_a", "1", "rest_a", "0", "k, t = map(int, input().split())", "map(int, input().split())", "k", "max_a = max(a)", "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", "rest_a = sum(a) - max_a", "sum(a) - max_a", "rest_a" ]
import math k, t = map(int, input().split()) a = list(map(int, input().split())) max_a = max(a) rest_a = sum(a) - max_a print(max(max_a - 1 - rest_a, 0))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 13, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 14, 40, 13, 2, 2, 13, 17, 17, 4, 13, 17, 0, 13, 2, 4, 13, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 4, 13, 10, 18, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 63, 4 ], [ 20, 19 ], [ 73, 21 ], [ 20, 22 ], [ 25, 24 ], [ 67, 26 ], [ 29, 28 ], [ 24, 31 ], [ 28, 34 ], [ 19, 37 ], [ 45, 44 ], [ 24, 48 ], [ 28, 49 ], [ 52, 51 ], [ 28, 54 ], [ 44, 55 ], [ 51, 59 ], [ 76, 61 ], [ 63, 64 ] ]
[ "import sys\ninput = sys.stdin.readline\n\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\ndef main():\n K,T=MI()\n a=LI()\n M=max(a)\n if M<=(K+1)//2:\n print(0)\n else:\n temp=sum(a)-M\n ans=M-temp-1\n print(ans)\n \n\nmain()", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def I(): return int(input())", "I", "def MI(): return map(int, input().split())", "MI", "def LI(): return list(map(int, input().split()))", "LI", "def main():\n K,T=MI()\n a=LI()\n M=max(a)\n if M<=(K+1)//2:\n print(0)\n else:\n temp=sum(a)-M\n ans=M-temp-1\n print(ans)\n ", "main", "K,T=MI()", "K", "MI()", "MI", "T", "a=LI()", "a", "LI()", "LI", "M=max(a)", "M", "max(a)", "max", "a", "if M<=(K+1)//2:\n print(0)\n else:\n temp=sum(a)-M\n ans=M-temp-1\n print(ans)\n ", "M<=(K+1)//2", "M", "(K+1)//2", "K+1", "K", "1", "2", "print(0)", "print", "0", "temp=sum(a)-M", "temp", "sum(a)-M", "sum(a)", "sum", "a", "M", "ans=M-temp-1", "ans", "M-temp-1", "M-temp", "M", "temp", "1", "print(ans)", "print", "ans", "main()", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def LI(): return list(map(int, input().split()))", "def LI(): return list(map(int, input().split()))", "LI", "def I(): return int(input())", "def I(): return int(input())", "I", "def MI(): return map(int, input().split())", "def MI(): return map(int, input().split())", "MI", "def main():\n K,T=MI()\n a=LI()\n M=max(a)\n if M<=(K+1)//2:\n print(0)\n else:\n temp=sum(a)-M\n ans=M-temp-1\n print(ans)\n ", "def main():\n K,T=MI()\n a=LI()\n M=max(a)\n if M<=(K+1)//2:\n print(0)\n else:\n temp=sum(a)-M\n ans=M-temp-1\n print(ans)\n ", "main" ]
import sys input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): K,T=MI() a=LI() M=max(a) if M<=(K+1)//2: print(0) else: temp=sum(a)-M ans=M-temp-1 print(ans) 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, 13, 0, 13, 4, 13, 13, 14, 2, 4, 13, 13, 17, 0, 13, 2, 18, 13, 17, 17, 0, 13, 4, 13, 17, 2, 2, 13, 17, 2, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 86, 2 ], [ 86, 11 ], [ 74, 13 ], [ 68, 25 ], [ 75, 28 ], [ 77, 30 ], [ 75, 33 ], [ 71, 35 ], [ 75, 38 ], [ 75, 43 ], [ 83, 46 ], [ 75, 49 ], [ 89, 53 ], [ 78, 59 ], [ 72, 62 ], [ 78, 63 ], [ 90, 66 ], [ 84, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 86, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ] ]
[ "K,T = map(int,input().split())\nA = list(map(int,input().split()))\nminA = min(A)\nmaxA = max(A)\nsumA = sum(A)\n\nif len(A) == 1:\n ans = A[0]-1\nelse:\n ans = max(0,maxA-1-(sumA-maxA))\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", "minA = min(A)", "minA", "min(A)", "min", "A", "maxA = max(A)", "maxA", "max(A)", "max", "A", "sumA = sum(A)", "sumA", "sum(A)", "sum", "A", "if len(A) == 1:\n ans = A[0]-1\nelse:\n ans = max(0,maxA-1-(sumA-maxA))", "len(A) == 1", "len(A)", "len", "A", "1", "ans = A[0]-1", "ans", "A[0]-1", "A[0]", "A", "0", "1", "ans = max(0,maxA-1-(sumA-maxA))", "ans", "max(0,maxA-1-(sumA-maxA))", "max", "0", "maxA-1-(sumA-maxA)", "maxA-1", "maxA", "1", "sumA-maxA", "sumA", "maxA", "print(ans)", "print", "ans", "minA = min(A)", "min(A)", "minA", "sumA = sum(A)", "sum(A)", "sumA", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "maxA = max(A)", "max(A)", "maxA", "T = map(int,input().split())", "map(int,input().split())", "T", "ans = A[0]-1", "A[0]-1", "ans", "K,T = map(int,input().split())", "map(int,input().split())", "K", "ans = max(0,maxA-1-(sumA-maxA))", "max(0,maxA-1-(sumA-maxA))", "ans" ]
K,T = map(int,input().split()) A = list(map(int,input().split())) minA = min(A) maxA = max(A) sumA = sum(A) if len(A) == 1: ans = A[0]-1 else: ans = max(0,maxA-1-(sumA-maxA)) 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, 0, 13, 4, 13, 13, 4, 13, 4, 13, 17, 2, 2, 4, 13, 13, 2, 13, 4, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 52, 2 ], [ 52, 11 ], [ 15, 14 ], [ 14, 23 ], [ 58, 25 ], [ 55, 28 ], [ 59, 31 ], [ 59, 41 ], [ 56, 43 ], [ 59, 46 ], [ 52, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "k, t = map(int, input().split())\na = [int(i) for i in input().split()]\ns = sum(a)\nprint(max(0, max(a) - (s-max(a)) - 1))", "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()]", "s = sum(a)", "s", "sum(a)", "sum", "a", "print(max(0, max(a) - (s-max(a)) - 1))", "print", "max(0, max(a) - (s-max(a)) - 1)", "max", "0", "max(a) - (s-max(a)) - 1", "max(a) - (s-max(a))", "max(a)", "max", "a", "s-max(a)", "s", "max(a)", "max", "a", "1", "k, t = map(int, input().split())", "map(int, input().split())", "k", "t = map(int, input().split())", "map(int, input().split())", "t", "s = sum(a)", "sum(a)", "s", "a = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "a" ]
k, t = map(int, input().split()) a = [int(i) for i in input().split()] s = sum(a) print(max(0, max(a) - (s-max(a)) - 1))
[ 7, 15, 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, 18, 13, 13, 15, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 17, 42, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 13, 0, 13, 2, 13, 17, 4, 13, 40, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 88, 4 ], [ 88, 13 ], [ 91, 15 ], [ 92, 33 ], [ 92, 41 ], [ 100, 43 ], [ 92, 48 ], [ 94, 50 ], [ 92, 56 ], [ 97, 59 ], [ 92, 64 ], [ 95, 67 ], [ 101, 67 ], [ 104, 67 ], [ 92, 73 ], [ 95, 74 ], [ 101, 74 ], [ 104, 74 ], [ 103, 76 ], [ 98, 78 ], [ 104, 83 ], [ 95, 83 ], [ 101, 83 ], [ 88, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ], [ 100, 101 ], [ 103, 104 ] ]
[ "import numpy as np\nk,t=map(int,input().split())\na=list(map(lambda x:-int(x),input().split()))\na.sort()\nimport heapq\nheapq.heapify(a)\nb=heapq.heappop(a)\nb+=1\nwhile len(a)>0:\n c=heapq.heappop(a)\n if b<0:\n heapq.heappush(a,b)\n b=c+1\nprint(-b)", "import numpy as np", "numpy", "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", "a.sort()", "a.sort", "a", "sort", "import heapq", "heapq", "heapq.heapify(a)", "heapq.heapify", "heapq", "heapify", "a", "b=heapq.heappop(a)", "b", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "b+=1", "b", "1", "while len(a)>0:\n c=heapq.heappop(a)\n if b<0:\n heapq.heappush(a,b)\n b=c+1", "len(a)>0", "len(a)", "len", "a", "0", "c=heapq.heappop(a)", "c", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "if b<0:\n heapq.heappush(a,b)\n ", "b<0", "b", "0", "heapq.heappush(a,b)", "heapq.heappush", "heapq", "heappush", "a", "b", "b=c+1", "b", "c+1", "c", "1", "print(-b)", "print", "-b", "b", "k,t=map(int,input().split())", "map(int,input().split())", "k", "t=map(int,input().split())", "map(int,input().split())", "t", "a=list(map(lambda x:-int(x),input().split()))", "list(map(lambda x:-int(x),input().split()))", "a", "b+=1", "1", "b", "c=heapq.heappop(a)", "heapq.heappop(a)", "c", "b=heapq.heappop(a)", "heapq.heappop(a)", "b", "b=c+1", "c+1", "b" ]
import numpy as np k,t=map(int,input().split()) a=list(map(lambda x:-int(x),input().split())) a.sort() import heapq heapq.heapify(a) b=heapq.heappop(a) b+=1 while len(a)>0: c=heapq.heappop(a) if b<0: heapq.heappush(a,b) b=c+1 print(-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, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 14, 18, 13, 39, 17, 14, 40, 4, 13, 18, 13, 39, 17, 13, 4, 13, 17, 4, 13, 2, 2, 13, 17, 4, 13, 18, 13, 39, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 76, 2 ], [ 76, 11 ], [ 67, 13 ], [ 70, 25 ], [ 68, 28 ], [ 73, 30 ], [ 68, 33 ], [ 74, 36 ], [ 68, 36 ], [ 74, 44 ], [ 68, 44 ], [ 71, 47 ], [ 71, 55 ], [ 74, 60 ], [ 68, 60 ], [ 76, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "k,t = map(int, input().split())\nlis = list(map(int, input().split()))\n\nm = max(lis)\nlis = sorted(lis)\n\nif lis[-1:]:\n pass\n\nif sum(lis[:-1]) >= m:\n print(0)\nelse:\n print(m-1-sum(lis[:-1]))", "k,t = map(int, input().split())", "k", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "t", "lis = list(map(int, input().split()))", "lis", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m = max(lis)", "m", "max(lis)", "max", "lis", "lis = sorted(lis)", "lis", "sorted(lis)", "sorted", "lis", "if lis[-1:]:\n pass", "lis[-1:]", "lis", "-1:", "-1", "if sum(lis[:-1]) >= m:\n print(0)\nelse:\n print(m-1-sum(lis[:-1]))", "sum(lis[:-1]) >= m", "sum(lis[:-1])", "sum", "lis[:-1]", "lis", ":-1", "-1", "m", "print(0)", "print", "0", "print(m-1-sum(lis[:-1]))", "print", "m-1-sum(lis[:-1])", "m-1", "m", "1", "sum(lis[:-1])", "sum", "lis[:-1]", "lis", ":-1", "-1", "t = map(int, input().split())", "map(int, input().split())", "t", "lis = list(map(int, input().split()))", "list(map(int, input().split()))", "lis", "m = max(lis)", "max(lis)", "m", "lis = sorted(lis)", "sorted(lis)", "lis", "k,t = map(int, input().split())", "map(int, input().split())", "k" ]
k,t = map(int, input().split()) lis = list(map(int, input().split())) m = max(lis) lis = sorted(lis) if lis[-1:]: pass if sum(lis[:-1]) >= m: print(0) else: print(m-1-sum(lis[:-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, 17, 0, 13, 18, 13, 17, 0, 13, 4, 13, 13, 0, 13, 2, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 13, 4, 13, 2, 2, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 2, 13 ]
[ [ 75, 2 ], [ 75, 11 ], [ 72, 13 ], [ 73, 26 ], [ 30, 29 ], [ 78, 32 ], [ 73, 34 ], [ 69, 37 ], [ 73, 40 ], [ 81, 42 ], [ 70, 44 ], [ 79, 45 ], [ 76, 48 ], [ 70, 53 ], [ 79, 61 ], [ 82, 62 ], [ 75, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ] ]
[ "K,T=map(int,input().split())\na=list(map(int,input().split()))\na.sort(reverse=True)\nma=a[0]\nsu=sum(a)\nres=su-ma\nif T==1:\n print(su-1)\nelse:\n print(max(ma-res-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", "ma=a[0]", "ma", "a[0]", "a", "0", "su=sum(a)", "su", "sum(a)", "sum", "a", "res=su-ma", "res", "su-ma", "su", "ma", "if T==1:\n print(su-1)\nelse:\n print(max(ma-res-1,0))", "T==1", "T", "1", "print(su-1)", "print", "su-1", "su", "1", "print(max(ma-res-1,0))", "print", "max(ma-res-1,0)", "max", "ma-res-1", "ma-res", "ma", "res", "1", "0", "K,T=map(int,input().split())", "map(int,input().split())", "K", "su=sum(a)", "sum(a)", "su", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "T=map(int,input().split())", "map(int,input().split())", "T", "ma=a[0]", "a[0]", "ma", "res=su-ma", "su-ma", "res" ]
K,T=map(int,input().split()) a=list(map(int,input().split())) a.sort(reverse=True) ma=a[0] su=sum(a) res=su-ma if T==1: print(su-1) else: print(max(ma-res-1,0))
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 23, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 12, 13, 23, 13, 23, 13, 17, 0, 13, 4, 13, 17, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 14, 2, 13, 17, 4, 13, 2, 18, 13, 17, 17, 29, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 18, 13, 17, 13, 18, 13, 17, 14, 2, 13, 13, 4, 13, 17, 29, 0, 13, 4, 13, 17, 2, 2, 13, 17, 4, 13, 18, 13, 39, 17, 4, 13, 13, 29, 14, 2, 13, 17, 4, 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, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 13, 13 ], [ 27, 26 ], [ 171, 32 ], [ 36, 36 ], [ 44, 43 ], [ 150, 49 ], [ 53, 53 ], [ 57, 57 ], [ 60, 59 ], [ 146, 62 ], [ 70, 69 ], [ 174, 71 ], [ 70, 72 ], [ 75, 74 ], [ 171, 76 ], [ 72, 79 ], [ 74, 85 ], [ 91, 90 ], [ 74, 93 ], [ 96, 95 ], [ 99, 98 ], [ 90, 100 ], [ 74, 100 ], [ 103, 102 ], [ 90, 104 ], [ 74, 104 ], [ 98, 108 ], [ 102, 109 ], [ 116, 115 ], [ 98, 121 ], [ 90, 126 ], [ 74, 126 ], [ 115, 131 ], [ 162, 138 ], [ 146, 147 ] ]
[ "import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef MS(): return input().split()\ndef LS(): return list(input())\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\ndef printlist(lst, k=' '): print(k.join(list(map(str, lst))))\nINF = float('inf')\n# from math import ceil, floor, log2\n# from collections import deque\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\n# from heapq import heapify, heappop, heappush\n# import numpy as np # cumsum\n# from bisect import bisect_left, bisect_right\n\ndef solve():\n K, T = MI()\n A = LI()\n\n if T == 1:\n print(A[0] - 1)\n return\n\n A = sorted(A, reverse=True)\n mx1, mx2 = A[0], A[1]\n if mx1 == mx2:\n print(0)\n return\n else:\n ans = max(0, mx1 - 1 - sum(A[1:]))\n print(ans)\n return\n\nif __name__ == '__main__':\n solve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "def int1(x): return int(x) - 1", "int1", "x", "x", "def II(): return int(input())", "II", "def MI(): return map(int, input().split())", "MI", "def MI1(): return map(int1, input().split())", "MI1", "def LI(): return list(map(int, input().split()))", "LI", "def LI1(): return list(map(int1, input().split()))", "LI1", "LI() for _ in range(rows_number)", "for _ in range(rows_number)", "_", "range(rows_number)", "range", "rows_number", "for _ in range(rows_number)", "LI()", "LI", "def LLI(rows_number): return [LI() for _ in range(rows_number)]", "LLI", "rows_number", "rows_number", "def MS(): return input().split()", "MS", "def LS(): return list(input())", "LS", "LS() for _ in range(rows_number)", "for _ in range(rows_number)", "_", "range(rows_number)", "range", "rows_number", "for _ in range(rows_number)", "LS()", "LS", "def LLS(rows_number): return [LS() for _ in range(rows_number)]", "LLS", "rows_number", "rows_number", "def printlist(lst, k=' '): print(k.join(list(map(str, lst))))", "printlist", "lst", "lst", "k=' '", "k", "' '", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "def solve():\n K, T = MI()\n A = LI()\n\n if T == 1:\n print(A[0] - 1)\n return\n\n A = sorted(A, reverse=True)\n mx1, mx2 = A[0], A[1]\n if mx1 == mx2:\n print(0)\n return\n else:\n ans = max(0, mx1 - 1 - sum(A[1:]))\n print(ans)\n return", "solve", "K, T = MI()", "K", "MI()", "MI", "T", "A = LI()", "A", "LI()", "LI", "if T == 1:\n print(A[0] - 1)\n return\n\n ", "T == 1", "T", "1", "print(A[0] - 1)", "print", "A[0] - 1", "A[0]", "A", "0", "1", "return", "A = sorted(A, reverse=True)", "A", "sorted(A, reverse=True)", "sorted", "A", "reverse=True", "reverse", "True", "mx1, mx2 = A[0], A[1]", "mx1", "A[0]", "A", "0", "mx2", "A[1]", "A", "1", "if mx1 == mx2:\n print(0)\n return\n else:\n ans = max(0, mx1 - 1 - sum(A[1:]))\n print(ans)\n return", "mx1 == mx2", "mx1", "mx2", "print(0)", "print", "0", "return", "ans = max(0, mx1 - 1 - sum(A[1:]))", "ans", "max(0, mx1 - 1 - sum(A[1:]))", "max", "0", "mx1 - 1 - sum(A[1:])", "mx1 - 1", "mx1", "1", "sum(A[1:])", "sum", "A[1:]", "A", "1:", "1", "print(ans)", "print", "ans", "return", "if __name__ == '__main__':\n solve()", "__name__ == '__main__'", "__name__", "'__main__'", "solve()", "solve", "def II(): return int(input())", "def II(): return int(input())", "II", "def int1(x): return int(x) - 1", "def int1(x): return int(x) - 1", "int1", "INF = float('inf')", "float('inf')", "INF", "def LS(): return list(input())", "def LS(): return list(input())", "LS", "def MI1(): return map(int1, input().split())", "def MI1(): return map(int1, input().split())", "MI1", "def LLI(rows_number): return [LI() for _ in range(rows_number)]", "def LLI(rows_number): return [LI() for _ in range(rows_number)]", "LLI", "def LI1(): return list(map(int1, input().split()))", "def LI1(): return list(map(int1, input().split()))", "LI1", "def solve():\n K, T = MI()\n A = LI()\n\n if T == 1:\n print(A[0] - 1)\n return\n\n A = sorted(A, reverse=True)\n mx1, mx2 = A[0], A[1]\n if mx1 == mx2:\n print(0)\n return\n else:\n ans = max(0, mx1 - 1 - sum(A[1:]))\n print(ans)\n return", "def solve():\n K, T = MI()\n A = LI()\n\n if T == 1:\n print(A[0] - 1)\n return\n\n A = sorted(A, reverse=True)\n mx1, mx2 = A[0], A[1]\n if mx1 == mx2:\n print(0)\n return\n else:\n ans = max(0, mx1 - 1 - sum(A[1:]))\n print(ans)\n return", "solve", "def printlist(lst, k=' '): print(k.join(list(map(str, lst))))", "def printlist(lst, k=' '): print(k.join(list(map(str, lst))))", "printlist", "def MS(): return input().split()", "def MS(): return input().split()", "MS", "def LI(): return list(map(int, input().split()))", "def LI(): return list(map(int, input().split()))", "LI", "def MI(): return map(int, input().split())", "def MI(): return map(int, input().split())", "MI", "def LLS(rows_number): return [LS() for _ in range(rows_number)]", "def LLS(rows_number): return [LS() for _ in range(rows_number)]", "LLS" ]
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(input()) def MI(): return map(int, input().split()) def MI1(): return map(int1, input().split()) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def MS(): return input().split() def LS(): return list(input()) def LLS(rows_number): return [LS() for _ in range(rows_number)] def printlist(lst, k=' '): print(k.join(list(map(str, lst)))) INF = float('inf') # from math import ceil, floor, log2 # from collections import deque # from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations # from heapq import heapify, heappop, heappush # import numpy as np # cumsum # from bisect import bisect_left, bisect_right def solve(): K, T = MI() A = LI() if T == 1: print(A[0] - 1) return A = sorted(A, reverse=True) mx1, mx2 = A[0], A[1] if mx1 == mx2: print(0) return else: ans = max(0, mx1 - 1 - sum(A[1:])) print(ans) return if __name__ == '__main__': solve()
[ 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, 14, 40, 4, 13, 18, 13, 39, 2, 13, 17, 18, 13, 17, 4, 13, 17, 4, 13, 2, 2, 18, 13, 17, 4, 13, 18, 13, 39, 2, 13, 17, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 67, 2 ], [ 67, 11 ], [ 64, 13 ], [ 65, 26 ], [ 65, 33 ], [ 62, 36 ], [ 65, 39 ], [ 65, 49 ], [ 65, 54 ], [ 62, 57 ], [ 67, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "k, t = map(int,input().split())\nA = list(map(int,input().split()))\n\nA.sort()\nif sum(A[:t-1]) >= A[-1]:\n print(0)\nelse:\n print(A[-1]-sum(A[:t-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", "if sum(A[:t-1]) >= A[-1]:\n print(0)\nelse:\n print(A[-1]-sum(A[:t-1])-1)", "sum(A[:t-1]) >= A[-1]", "sum(A[:t-1])", "sum", "A[:t-1]", "A", ":t-1", "t-1", "t", "1", "A[-1]", "A", "-1", "print(0)", "print", "0", "print(A[-1]-sum(A[:t-1])-1)", "print", "A[-1]-sum(A[:t-1])-1", "A[-1]-sum(A[:t-1])", "A[-1]", "A", "-1", "sum(A[:t-1])", "sum", "A[:t-1]", "A", ":t-1", "t-1", "t", "1", "1", "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())) A.sort() if sum(A[:t-1]) >= A[-1]: print(0) else: print(A[-1]-sum(A[:t-1])-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, 4, 18, 13, 13, 0, 13, 2, 2, 2, 17, 18, 13, 17, 4, 13, 13, 17, 14, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 65, 2 ], [ 65, 11 ], [ 59, 13 ], [ 60, 26 ], [ 60, 30 ], [ 68, 33 ], [ 60, 39 ], [ 60, 43 ], [ 69, 47 ], [ 62, 50 ], [ 63, 54 ], [ 69, 54 ], [ 65, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "K,T=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\na.reverse()\nans=2*a[0]-sum(a)-1\nif ans<0:\n ans=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", "a.sort()", "a.sort", "a", "sort", "a.reverse()", "a.reverse", "a", "reverse", "ans=2*a[0]-sum(a)-1", "ans", "2*a[0]-sum(a)-1", "2*a[0]-sum(a)", "2*a[0]", "2", "a[0]", "a", "0", "sum(a)", "sum", "a", "1", "if ans<0:\n ans=0", "ans<0", "ans", "0", "ans=0", "ans", "0", "print(ans)", "print", "ans", "T=map(int,input().split())", "map(int,input().split())", "T", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans=0", "0", "ans", "K,T=map(int,input().split())", "map(int,input().split())", "K", "ans=2*a[0]-sum(a)-1", "2*a[0]-sum(a)-1", "ans" ]
K,T=map(int,input().split()) a=list(map(int,input().split())) a.sort() a.reverse() ans=2*a[0]-sum(a)-1 if ans<0: ans=0 print(ans)
[ 7, 15, 13, 15, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 40, 4, 13, 13, 0, 13, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 4, 13, 2, 13, 17, 4, 18, 13, 13, 42, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 14, 40, 2, 13, 17, 17, 4, 18, 13, 13, 13, 2, 13, 17, 4, 18, 13, 13, 13, 2, 13, 17, 14, 40, 2, 13, 17, 17, 4, 18, 13, 13, 13, 2, 13, 17, 14, 2, 4, 13, 13, 17, 4, 13, 17, 4, 13, 2, 40, 18, 13, 17, 17, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 136, 6 ], [ 136, 15 ], [ 19, 18 ], [ 18, 28 ], [ 124, 30 ], [ 125, 36 ], [ 137, 39 ], [ 128, 44 ], [ 125, 54 ], [ 133, 57 ], [ 125, 62 ], [ 130, 64 ], [ 125, 69 ], [ 131, 73 ], [ 125, 80 ], [ 134, 82 ], [ 125, 88 ], [ 131, 90 ], [ 134, 95 ], [ 125, 102 ], [ 134, 104 ], [ 125, 110 ], [ 125, 120 ], [ 124, 125 ], [ 136, 128 ], [ 130, 131 ], [ 133, 134 ], [ 136, 137 ] ]
[ "import sys\nimport heapq\nK, T = map(int, input().split())\nm = [-int(i) for i in input().split()]\nheapq.heapify(m)\n\nif T == 1:\n print(K-1)\n sys.exit()\n\nwhile len(m) > 1:\n l = heapq.heappop(m)\n r = heapq.heappop(m)\n if r+1 != 0:\n heapq.heappush(m, l+1)\n heapq.heappush(m, r+1)\n else:\n if l+1 != 0:\n heapq.heappush(m, l+1)\nif len(m) == 0:\n print(0)\nelse:\n print(-m[0]-1)", "import sys", "sys", "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)", "int", "i", "m = [-int(i) for i in input().split()]", "m", "[-int(i) for i in input().split()]", "heapq.heapify(m)", "heapq.heapify", "heapq", "heapify", "m", "if T == 1:\n print(K-1)\n sys.exit()", "T == 1", "T", "1", "print(K-1)", "print", "K-1", "K", "1", "sys.exit()", "sys.exit", "sys", "exit", "while len(m) > 1:\n l = heapq.heappop(m)\n r = heapq.heappop(m)\n if r+1 != 0:\n heapq.heappush(m, l+1)\n heapq.heappush(m, r+1)\n else:\n if l+1 != 0:\n heapq.heappush(m, l+1)", "len(m) > 1", "len(m)", "len", "m", "1", "l = heapq.heappop(m)", "l", "heapq.heappop(m)", "heapq.heappop", "heapq", "heappop", "m", "r = heapq.heappop(m)", "r", "heapq.heappop(m)", "heapq.heappop", "heapq", "heappop", "m", "if r+1 != 0:\n heapq.heappush(m, l+1)\n heapq.heappush(m, r+1)\n else:\n if l+1 != 0:\n heapq.heappush(m, l+1)", "r+1 != 0", "r+1", "r", "1", "0", "heapq.heappush(m, l+1)", "heapq.heappush", "heapq", "heappush", "m", "l+1", "l", "1", "heapq.heappush(m, r+1)", "heapq.heappush", "heapq", "heappush", "m", "r+1", "r", "1", "if l+1 != 0:\n heapq.heappush(m, l+1)", "l+1 != 0", "l+1", "l", "1", "0", "heapq.heappush(m, l+1)", "heapq.heappush", "heapq", "heappush", "m", "l+1", "l", "1", "if len(m) == 0:\n print(0)\nelse:\n print(-m[0]-1)", "len(m) == 0", "len(m)", "len", "m", "0", "print(0)", "print", "0", "print(-m[0]-1)", "print", "-m[0]-1", "-m[0]", "m[0]", "m", "0", "1", "m = [-int(i) for i in input().split()]", "[-int(i) for i in input().split()]", "m", "K, T = map(int, input().split())", "map(int, input().split())", "K", "r = heapq.heappop(m)", "heapq.heappop(m)", "r", "l = heapq.heappop(m)", "heapq.heappop(m)", "l", "T = map(int, input().split())", "map(int, input().split())", "T" ]
import sys import heapq K, T = map(int, input().split()) m = [-int(i) for i in input().split()] heapq.heapify(m) if T == 1: print(K-1) sys.exit() while len(m) > 1: l = heapq.heappop(m) r = heapq.heappop(m) if r+1 != 0: heapq.heappush(m, l+1) heapq.heappush(m, r+1) else: if l+1 != 0: heapq.heappush(m, l+1) if len(m) == 0: print(0) else: print(-m[0]-1)
[ 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, 4, 13, 2, 2, 13, 17, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 51, 11 ], [ 15, 14 ], [ 14, 23 ], [ 54, 25 ], [ 60, 28 ], [ 55, 31 ], [ 57, 33 ], [ 61, 38 ], [ 49, 41 ], [ 61, 42 ], [ 58, 46 ], [ 51, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "# https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b\n\nk, t = map(int, input().split())\nnums = [int(i) for i in input().split()]\nMAX = max(nums)\n\nans = max(MAX - 1 - (k - MAX), 0)\nprint(ans)", "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", "nums = [int(i) for i in input().split()]", "nums", "[int(i) for i in input().split()]", "MAX = max(nums)", "MAX", "max(nums)", "max", "nums", "ans = max(MAX - 1 - (k - MAX), 0)", "ans", "max(MAX - 1 - (k - MAX), 0)", "max", "MAX - 1 - (k - MAX)", "MAX - 1", "MAX", "1", "k - MAX", "k", "MAX", "0", "print(ans)", "print", "ans", "k, t = map(int, input().split())", "map(int, input().split())", "k", "t = map(int, input().split())", "map(int, input().split())", "t", "nums = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "nums", "ans = max(MAX - 1 - (k - MAX), 0)", "max(MAX - 1 - (k - MAX), 0)", "ans", "MAX = max(nums)", "max(nums)", "MAX" ]
# https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b k, t = map(int, input().split()) nums = [int(i) for i in input().split()] MAX = max(nums) ans = max(MAX - 1 - (k - MAX), 0) print(ans)
[ 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 13, 15, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 17, 2, 2, 2, 4, 13, 13, 2, 2, 13, 17, 17, 17, 17, 4, 13, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 78, 30 ], [ 64, 32 ], [ 78, 33 ], [ 81, 35 ], [ 67, 37 ], [ 60, 39 ], [ 82, 48 ], [ 79, 51 ], [ 61, 58 ], [ 60, 61 ], [ 78, 70 ], [ 78, 79 ], [ 81, 82 ] ]
[ "from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf\nfrom itertools import accumulate,permutations,combinations,product,combinations_with_replacement\nfrom collections import deque,defaultdict,Counter\nfrom bisect import bisect_left,bisect_right\nfrom operator import itemgetter\nfrom heapq import heapify,heappop,heappush\nfrom queue import Queue,LifoQueue,PriorityQueue\nfrom copy import deepcopy\nfrom time import time\nimport string\nimport sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nk, t = MAP()\na = LIST()\n\nans = max(0, ( max(a) - (k+1)//2 ) * 2 - 1)\nprint(ans)", "from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf", "from itertools import accumulate,permutations,combinations,product,combinations_with_replacement", "from collections import deque,defaultdict,Counter", "from bisect import bisect_left,bisect_right", "from operator import itemgetter", "from heapq import heapify,heappop,heappush", "from queue import Queue,LifoQueue,PriorityQueue", "from copy import deepcopy", "from time import time", "import string", "string", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "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())", "LIST", "k, t = MAP()", "k", "MAP()", "MAP", "t", "a = LIST()", "a", "LIST()", "LIST", "ans = max(0, ( max(a) - (k+1)//2 ) * 2 - 1)", "ans", "max(0, ( max(a) - (k+1)//2 ) * 2 - 1)", "max", "0", "( max(a) - (k+1)//2 ) * 2 - 1", "( max(a) - (k+1)//2 ) * 2", "max(a) - (k+1)//2", "max(a)", "max", "a", "(k+1)//2", "k+1", "k", "1", "2", "2", "1", "print(ans)", "print", "ans", "ans = max(0, ( max(a) - (k+1)//2 ) * 2 - 1)", "max(0, ( max(a) - (k+1)//2 ) * 2 - 1)", "ans", "def MAP() : return map(int,input().split())", "def MAP() : return map(int,input().split())", "MAP", "def LIST() : return list(MAP())", "def LIST() : return list(MAP())", "LIST", "t = MAP()", "MAP()", "t", "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", "k, t = MAP()", "MAP()", "k", "a = LIST()", "LIST()", "a" ]
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heapify,heappop,heappush from queue import Queue,LifoQueue,PriorityQueue from copy import deepcopy from time import time import string import sys sys.setrecursionlimit(10 ** 7) def input() : return sys.stdin.readline().strip() def INT() : return int(input()) def MAP() : return map(int,input().split()) def LIST() : return list(MAP()) k, t = MAP() a = LIST() ans = max(0, ( max(a) - (k+1)//2 ) * 2 - 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, 0, 13, 4, 13, 13, 14, 40, 2, 13, 13, 2, 13, 17, 4, 13, 17, 4, 13, 2, 2, 2, 17, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 59, 2 ], [ 59, 11 ], [ 56, 13 ], [ 50, 25 ], [ 57, 28 ], [ 54, 32 ], [ 51, 33 ], [ 51, 35 ], [ 51, 46 ], [ 54, 47 ], [ 50, 51 ], [ 59, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "\nk,t = map(int,input().split())\na = list(map(int,input().split()))\n\nmx = max(a)\n\nif k -mx >= mx -1:\n print(0)\nelse:\n print(2*mx-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", "mx = max(a)", "mx", "max(a)", "max", "a", "if k -mx >= mx -1:\n print(0)\nelse:\n print(2*mx-k-1)", "k -mx >= mx -1", "k -mx", "k", "mx", "mx -1", "mx", "1", "print(0)", "print", "0", "print(2*mx-k-1)", "print", "2*mx-k-1", "2*mx-k", "2*mx", "2", "mx", "k", "1", "mx = max(a)", "max(a)", "mx", "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())) mx = max(a) if k -mx >= mx -1: print(0) else: print(2*mx-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, 4, 18, 13, 13, 0, 13, 18, 13, 17, 0, 13, 4, 13, 18, 13, 39, 17, 4, 13, 4, 13, 17, 2, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 55, 2 ], [ 55, 11 ], [ 58, 13 ], [ 59, 26 ], [ 61, 29 ], [ 59, 31 ], [ 64, 34 ], [ 59, 38 ], [ 62, 48 ], [ 65, 49 ], [ 55, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "k, t = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort()\nmax_value = A[-1]\nothers = sum(A[:-1])\nprint(max(0, max_value - others - 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", "max_value = A[-1]", "max_value", "A[-1]", "A", "-1", "others = sum(A[:-1])", "others", "sum(A[:-1])", "sum", "A[:-1]", "A", ":-1", "-1", "print(max(0, max_value - others - 1))", "print", "max(0, max_value - others - 1)", "max", "0", "max_value - others - 1", "max_value - others", "max_value", "others", "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", "max_value = A[-1]", "A[-1]", "max_value", "others = sum(A[:-1])", "sum(A[:-1])", "others" ]
k, t = map(int, input().split()) A = list(map(int, input().split())) A.sort() max_value = A[-1] others = sum(A[:-1]) print(max(0, max_value - others - 1))
[ 7, 15, 13, 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, 39, 28, 13, 4, 13, 4, 13, 13, 14, 40, 18, 13, 13, 17, 4, 18, 13, 13, 13, 39, 40, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 13, 0, 13, 17, 0, 13, 39, 13, 13, 42, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 13, 0, 13, 17, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 13, 0, 13, 39, 13, 13, 4, 13, 40, 18, 13, 17, 29, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 7, 17 ], [ 20, 19 ], [ 32, 31 ], [ 35, 34 ], [ 19, 39 ], [ 19, 43 ], [ 34, 44 ], [ 31, 50 ], [ 19, 54 ], [ 34, 55 ], [ 59, 58 ], [ 31, 63 ], [ 59, 64 ], [ 67, 66 ], [ 70, 69 ], [ 31, 77 ], [ 81, 80 ], [ 31, 85 ], [ 81, 86 ], [ 89, 88 ], [ 69, 93 ], [ 103, 93 ], [ 31, 100 ], [ 69, 101 ], [ 103, 101 ], [ 104, 103 ], [ 103, 111 ], [ 69, 111 ], [ 122, 119 ] ]
[ "import heapq\n\ndef solve():\n k, t = list(map(int, input().split()))\n a = list(map(int, input().split()))\n \n q = []\n \n for i in range(len(a)):\n if a[i] != 0:\n heapq.heappush(q, (-a[i], i))\n \n count, i = heapq.heappop(q)\n count += 1\n keep = (count, i)\n\n while len(q) > 0:\n count, i = heapq.heappop(q)\n count += 1\n \n if keep[0] < 0:\n heapq.heappush(q, keep)\n keep = (count, i)\n \n print(- keep[0])\n return\n\nif __name__ == \"__main__\":\n solve()", "import heapq", "heapq", "def solve():\n k, t = list(map(int, input().split()))\n a = list(map(int, input().split()))\n \n q = []\n \n for i in range(len(a)):\n if a[i] != 0:\n heapq.heappush(q, (-a[i], i))\n \n count, i = heapq.heappop(q)\n count += 1\n keep = (count, i)\n\n while len(q) > 0:\n count, i = heapq.heappop(q)\n count += 1\n \n if keep[0] < 0:\n heapq.heappush(q, keep)\n keep = (count, i)\n \n print(- keep[0])\n return", "solve", "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", "q = []", "q", "[]", "for i in range(len(a)):\n if a[i] != 0:\n heapq.heappush(q, (-a[i], i))\n \n ", "i", "range(len(a))", "range", "len(a)", "len", "a", "if a[i] != 0:\n heapq.heappush(q, (-a[i], i))\n \n ", "a[i] != 0", "a[i]", "a", "i", "0", "heapq.heappush(q, (-a[i], i))", "heapq.heappush", "heapq", "heappush", "q", "(-a[i], i)", "-a[i]", "a[i]", "a", "i", "i", "count, i = heapq.heappop(q)", "count", "heapq.heappop(q)", "heapq.heappop", "heapq", "heappop", "q", "i", "count += 1", "count", "1", "keep = (count, i)", "keep", "(count, i)", "count", "i", "while len(q) > 0:\n count, i = heapq.heappop(q)\n count += 1\n \n if keep[0] < 0:\n heapq.heappush(q, keep)\n keep = (count, i)\n \n ", "len(q) > 0", "len(q)", "len", "q", "0", "count, i = heapq.heappop(q)", "count", "heapq.heappop(q)", "heapq.heappop", "heapq", "heappop", "q", "i", "count += 1", "count", "1", "if keep[0] < 0:\n heapq.heappush(q, keep)\n ", "keep[0] < 0", "keep[0]", "keep", "0", "0", "heapq.heappush(q, keep)", "heapq.heappush", "heapq", "heappush", "q", "keep", "keep = (count, i)", "keep", "(count, i)", "count", "i", "print(- keep[0])", "print", "- keep[0]", "keep[0]", "keep", "0", "return", "if __name__ == \"__main__\":\n solve()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "solve()", "solve", "def solve():\n k, t = list(map(int, input().split()))\n a = list(map(int, input().split()))\n \n q = []\n \n for i in range(len(a)):\n if a[i] != 0:\n heapq.heappush(q, (-a[i], i))\n \n count, i = heapq.heappop(q)\n count += 1\n keep = (count, i)\n\n while len(q) > 0:\n count, i = heapq.heappop(q)\n count += 1\n \n if keep[0] < 0:\n heapq.heappush(q, keep)\n keep = (count, i)\n \n print(- keep[0])\n return", "def solve():\n k, t = list(map(int, input().split()))\n a = list(map(int, input().split()))\n \n q = []\n \n for i in range(len(a)):\n if a[i] != 0:\n heapq.heappush(q, (-a[i], i))\n \n count, i = heapq.heappop(q)\n count += 1\n keep = (count, i)\n\n while len(q) > 0:\n count, i = heapq.heappop(q)\n count += 1\n \n if keep[0] < 0:\n heapq.heappush(q, keep)\n keep = (count, i)\n \n print(- keep[0])\n return", "solve" ]
import heapq def solve(): k, t = list(map(int, input().split())) a = list(map(int, input().split())) q = [] for i in range(len(a)): if a[i] != 0: heapq.heappush(q, (-a[i], i)) count, i = heapq.heappop(q) count += 1 keep = (count, i) while len(q) > 0: count, i = heapq.heappop(q) count += 1 if keep[0] < 0: heapq.heappush(q, keep) keep = (count, i) print(- keep[0]) return if __name__ == "__main__": solve()
[ 7, 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, 0, 13, 17, 0, 13, 17, 4, 18, 13, 13, 28, 13, 4, 13, 13, 0, 13, 4, 13, 13, 18, 13, 2, 13, 17, 14, 2, 13, 13, 14, 2, 2, 13, 17, 2, 18, 13, 2, 13, 17, 17, 0, 13, 4, 13, 13, 18, 13, 2, 13, 17, 0, 13, 17, 0, 18, 13, 13, 17, 0, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 6, 14 ], [ 17, 16 ], [ 29, 28 ], [ 32, 31 ], [ 16, 35 ], [ 39, 38 ], [ 5, 41 ], [ 44, 43 ], [ 16, 46 ], [ 16, 48 ], [ 14, 50 ], [ 43, 54 ], [ 69, 54 ], [ 31, 55 ], [ 87, 55 ], [ 14, 59 ], [ 16, 63 ], [ 43, 65 ], [ 69, 65 ], [ 70, 69 ], [ 16, 72 ], [ 16, 74 ], [ 43, 76 ], [ 69, 76 ], [ 80, 79 ], [ 85, 82 ], [ 16, 83 ], [ 69, 84 ], [ 43, 84 ], [ 88, 87 ], [ 69, 88 ], [ 43, 88 ], [ 79, 91 ], [ 28, 91 ], [ 100, 97 ] ]
[ "from bisect import bisect_left\ndef main():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n ans = 0\n pre = -1\n a.sort()\n for _ in range(k):\n x = bisect_left(a, a[t-1])\n if x == pre:\n if t > 1 and a[x-1] > 0:\n x = bisect_left(a, a[x-1])\n else:\n ans += 1\n a[x] -= 1\n pre = x\n print(ans)\n\nif __name__ == \"__main__\":\n main()", "from bisect import bisect_left", "def main():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n ans = 0\n pre = -1\n a.sort()\n for _ in range(k):\n x = bisect_left(a, a[t-1])\n if x == pre:\n if t > 1 and a[x-1] > 0:\n x = bisect_left(a, a[x-1])\n else:\n ans += 1\n a[x] -= 1\n pre = x\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", "ans = 0", "ans", "0", "pre = -1", "pre", "-1", "a.sort()", "a.sort", "a", "sort", "for _ in range(k):\n x = bisect_left(a, a[t-1])\n if x == pre:\n if t > 1 and a[x-1] > 0:\n x = bisect_left(a, a[x-1])\n else:\n ans += 1\n a[x] -= 1\n pre = x\n ", "_", "range(k)", "range", "k", "x = bisect_left(a, a[t-1])", "x", "bisect_left(a, a[t-1])", "bisect_left", "a", "a[t-1]", "a", "t-1", "t", "1", "if x == pre:\n if t > 1 and a[x-1] > 0:\n x = bisect_left(a, a[x-1])\n else:\n ans += 1\n ", "x == pre", "x", "pre", "if t > 1 and a[x-1] > 0:\n x = bisect_left(a, a[x-1])\n else:\n ans += 1\n ", "t > 1 and a[x-1] > 0", "t > 1", "t", "1", "a[x-1] > 0", "a[x-1]", "a", "x-1", "x", "1", "0", "x = bisect_left(a, a[x-1])", "x", "bisect_left(a, a[x-1])", "bisect_left", "a", "a[x-1]", "a", "x-1", "x", "1", "ans += 1", "ans", "1", "a[x] -= 1", "a[x]", "a", "x", "1", "pre = x", "pre", "x", "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 ans = 0\n pre = -1\n a.sort()\n for _ in range(k):\n x = bisect_left(a, a[t-1])\n if x == pre:\n if t > 1 and a[x-1] > 0:\n x = bisect_left(a, a[x-1])\n else:\n ans += 1\n a[x] -= 1\n pre = x\n print(ans)", "def main():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n ans = 0\n pre = -1\n a.sort()\n for _ in range(k):\n x = bisect_left(a, a[t-1])\n if x == pre:\n if t > 1 and a[x-1] > 0:\n x = bisect_left(a, a[x-1])\n else:\n ans += 1\n a[x] -= 1\n pre = x\n print(ans)", "main" ]
from bisect import bisect_left def main(): k, t = map(int, input().split()) a = list(map(int, input().split())) ans = 0 pre = -1 a.sort() for _ in range(k): x = bisect_left(a, a[t-1]) if x == pre: if t > 1 and a[x-1] > 0: x = bisect_left(a, a[x-1]) else: ans += 1 a[x] -= 1 pre = x print(ans) 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, 41, 28, 13, 13, 4, 40, 13, 0, 13, 13, 4, 18, 13, 13, 13, 42, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 42, 2, 2, 13, 17, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 14, 40, 13, 13, 4, 18, 13, 13, 13, 2, 13, 13, 0, 13, 17, 0, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 2, 40, 13, 17, 17, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 134, 4 ], [ 134, 13 ], [ 131, 15 ], [ 29, 28 ], [ 132, 28 ], [ 28, 32 ], [ 122, 34 ], [ 123, 40 ], [ 132, 40 ], [ 123, 45 ], [ 132, 45 ], [ 125, 48 ], [ 123, 53 ], [ 132, 53 ], [ 126, 57 ], [ 141, 57 ], [ 120, 57 ], [ 123, 62 ], [ 132, 62 ], [ 137, 65 ], [ 123, 70 ], [ 132, 70 ], [ 138, 73 ], [ 126, 74 ], [ 141, 74 ], [ 120, 74 ], [ 123, 79 ], [ 132, 79 ], [ 138, 81 ], [ 126, 82 ], [ 141, 82 ], [ 120, 82 ], [ 119, 84 ], [ 140, 87 ], [ 138, 88 ], [ 141, 91 ], [ 120, 91 ], [ 126, 91 ], [ 123, 97 ], [ 132, 97 ], [ 141, 98 ], [ 120, 98 ], [ 126, 98 ], [ 116, 100 ], [ 123, 105 ], [ 132, 105 ], [ 117, 112 ], [ 116, 117 ], [ 119, 120 ], [ 122, 123 ], [ 125, 126 ], [ 134, 129 ], [ 131, 132 ], [ 134, 135 ], [ 137, 138 ], [ 138, 140 ], [ 140, 141 ] ]
[ "import heapq\nk, t = map(int, input().split())\na = list(map(int, input().split()))\na = [-i for i in a]\nheapq.heapify(a)\nwhile len(a) > 1:\n m = heapq.heappop(a)\n while m < 0 and len(a) > 0:\n n = heapq.heappop(a)\n if n <= m:\n heapq.heappush(a, n-m)\n m = 0\n else:\n m -= n\n if m < 0:\n heapq.heappush(a, m)\nres = heapq.heappop(a)\n\nprint(max(-res-1, 0))\n", "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", "-i for i in a", "for i in a", "i", "a", "for i in a", "-i", "i", "a = [-i for i in a]", "a", "[-i for i in a]", "heapq.heapify(a)", "heapq.heapify", "heapq", "heapify", "a", "while len(a) > 1:\n m = heapq.heappop(a)\n while m < 0 and len(a) > 0:\n n = heapq.heappop(a)\n if n <= m:\n heapq.heappush(a, n-m)\n m = 0\n else:\n m -= n\n if m < 0:\n heapq.heappush(a, m)", "len(a) > 1", "len(a)", "len", "a", "1", "m = heapq.heappop(a)", "m", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "while m < 0 and len(a) > 0:\n n = heapq.heappop(a)\n if n <= m:\n heapq.heappush(a, n-m)\n m = 0\n else:\n m -= n\n ", "m < 0 and len(a) > 0", "m < 0", "m", "0", "len(a) > 0", "len(a)", "len", "a", "0", "n = heapq.heappop(a)", "n", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "if n <= m:\n heapq.heappush(a, n-m)\n m = 0\n else:\n m -= n\n ", "n <= m", "n", "m", "heapq.heappush(a, n-m)", "heapq.heappush", "heapq", "heappush", "a", "n-m", "n", "m", "m = 0", "m", "0", "m -= n", "m", "n", "if m < 0:\n heapq.heappush(a, m)", "m < 0", "m", "0", "heapq.heappush(a, m)", "heapq.heappush", "heapq", "heappush", "a", "m", "res = heapq.heappop(a)", "res", "heapq.heappop(a)", "heapq.heappop", "heapq", "heappop", "a", "print(max(-res-1, 0))", "print", "max(-res-1, 0)", "max", "-res-1", "-res", "res", "1", "0", "res = heapq.heappop(a)", "heapq.heappop(a)", "res", "m = 0", "0", "m", "a = [-i for i in a]", "[-i for i in a]", "a", "m = heapq.heappop(a)", "heapq.heappop(a)", "m", "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", "n = heapq.heappop(a)", "heapq.heappop(a)", "n", "m -= n", "n", "m" ]
import heapq k, t = map(int, input().split()) a = list(map(int, input().split())) a = [-i for i in a] heapq.heapify(a) while len(a) > 1: m = heapq.heappop(a) while m < 0 and len(a) > 0: n = heapq.heappop(a) if n <= m: heapq.heappush(a, n-m) m = 0 else: m -= n if m < 0: heapq.heappush(a, m) res = heapq.heappop(a) print(max(-res-1, 0))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 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, 39, 4, 13, 13, 0, 13, 2, 39, 17, 13, 28, 13, 4, 13, 13, 4, 13, 13, 39, 40, 18, 13, 13, 13, 0, 13, 4, 13, 13, 0, 18, 13, 17, 18, 13, 17, 0, 18, 13, 17, 17, 14, 2, 18, 13, 17, 17, 4, 13, 13, 13, 28, 13, 4, 13, 17, 13, 0, 13, 4, 13, 13, 14, 2, 2, 18, 13, 2, 13, 17, 18, 13, 17, 13, 0, 13, 4, 13, 13, 0, 18, 13, 13, 18, 13, 17, 0, 18, 13, 17, 17, 14, 2, 18, 13, 17, 17, 4, 13, 13, 13, 4, 13, 13, 13, 0, 18, 13, 13, 18, 13, 17, 0, 18, 13, 17, 17, 14, 2, 18, 13, 17, 17, 4, 13, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 13, 14, 2, 18, 13, 13, 18, 13, 2, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 39, 13, 10, 4, 13, 10, 18, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 207, 4 ], [ 195, 12 ], [ 208, 19 ], [ 195, 21 ], [ 216, 23 ], [ 208, 32 ], [ 201, 35 ], [ 202, 39 ], [ 210, 41 ], [ 196, 45 ], [ 48, 47 ], [ 190, 50 ], [ 202, 53 ], [ 217, 57 ], [ 47, 58 ], [ 192, 61 ], [ 202, 64 ], [ 69, 66 ], [ 211, 67 ], [ 193, 70 ], [ 76, 73 ], [ 193, 74 ], [ 193, 80 ], [ 202, 85 ], [ 193, 86 ], [ 89, 88 ], [ 196, 92 ], [ 204, 94 ], [ 202, 97 ], [ 211, 102 ], [ 88, 104 ], [ 205, 107 ], [ 193, 107 ], [ 202, 109 ], [ 198, 111 ], [ 202, 114 ], [ 119, 116 ], [ 211, 117 ], [ 88, 118 ], [ 199, 120 ], [ 126, 123 ], [ 199, 124 ], [ 199, 130 ], [ 202, 135 ], [ 199, 136 ], [ 202, 139 ], [ 205, 140 ], [ 193, 140 ], [ 145, 142 ], [ 211, 143 ], [ 88, 144 ], [ 205, 146 ], [ 193, 146 ], [ 152, 149 ], [ 205, 150 ], [ 193, 150 ], [ 205, 156 ], [ 193, 156 ], [ 202, 161 ], [ 205, 162 ], [ 193, 162 ], [ 213, 164 ], [ 168, 167 ], [ 196, 171 ], [ 116, 174 ], [ 142, 174 ], [ 211, 175 ], [ 167, 176 ], [ 211, 178 ], [ 167, 180 ], [ 219, 183 ], [ 220, 187 ], [ 214, 187 ], [ 195, 190 ], [ 192, 193 ], [ 195, 196 ], [ 198, 199 ], [ 201, 202 ], [ 204, 205 ], [ 207, 208 ], [ 210, 211 ], [ 213, 214 ], [ 216, 217 ], [ 219, 220 ] ]
[ "import sys\ninput = sys.stdin.readline\nfrom heapq import heappush,heapify,heappop\nk,t=map(int,input().split())\na=list(map(int,input().split()))\nb=[]\nheapify(b)\nans=[-1]*k\nfor i in range(t):\n heappush(b,[-a[i],i])\nx=heappop(b)\nans[0]=x[1]\nx[0]+=1\nif x[0]<0:\n heappush(b,x)\nfor i in range(1,k):\n x=heappop(b)\n if ans[i-1]==x[1] and b:\n y=heappop(b)\n ans[i]=y[1]\n y[0]+=1\n if y[0]<0:\n heappush(b,y)\n heappush(b,x)\n else:\n ans[i]=x[1]\n x[0]+=1\n if x[0]<0:\n heappush(b,x)\ncnt=0\nfor i in range(1,k):\n if ans[i]==ans[i-1]:\n cnt+=1\nprint(cnt)", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "from heapq import heappush,heapify,heappop", "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=[]", "b", "[]", "heapify(b)", "heapify", "b", "ans=[-1]*k", "ans", "[-1]*k", "[-1]", "-1", "k", "for i in range(t):\n heappush(b,[-a[i],i])", "i", "range(t)", "range", "t", "heappush(b,[-a[i],i])", "heappush", "b", "[-a[i],i]", "-a[i]", "a[i]", "a", "i", "i", "x=heappop(b)", "x", "heappop(b)", "heappop", "b", "ans[0]=x[1]", "ans[0]", "ans", "0", "x[1]", "x", "1", "x[0]+=1", "x[0]", "x", "0", "1", "if x[0]<0:\n heappush(b,x)", "x[0]<0", "x[0]", "x", "0", "0", "heappush(b,x)", "heappush", "b", "x", "for i in range(1,k):\n x=heappop(b)\n if ans[i-1]==x[1] and b:\n y=heappop(b)\n ans[i]=y[1]\n y[0]+=1\n if y[0]<0:\n heappush(b,y)\n heappush(b,x)\n else:\n ans[i]=x[1]\n x[0]+=1\n if x[0]<0:\n heappush(b,x)", "i", "range(1,k)", "range", "1", "k", "x=heappop(b)", "x", "heappop(b)", "heappop", "b", "if ans[i-1]==x[1] and b:\n y=heappop(b)\n ans[i]=y[1]\n y[0]+=1\n if y[0]<0:\n heappush(b,y)\n heappush(b,x)\n else:\n ans[i]=x[1]\n x[0]+=1\n if x[0]<0:\n heappush(b,x)", "ans[i-1]==x[1] and b", "ans[i-1]==x[1]", "ans[i-1]", "ans", "i-1", "i", "1", "x[1]", "x", "1", "b", "y=heappop(b)", "y", "heappop(b)", "heappop", "b", "ans[i]=y[1]", "ans[i]", "ans", "i", "y[1]", "y", "1", "y[0]+=1", "y[0]", "y", "0", "1", "if y[0]<0:\n heappush(b,y)\n ", "y[0]<0", "y[0]", "y", "0", "0", "heappush(b,y)", "heappush", "b", "y", "heappush(b,x)", "heappush", "b", "x", "ans[i]=x[1]", "ans[i]", "ans", "i", "x[1]", "x", "1", "x[0]+=1", "x[0]", "x", "0", "1", "if x[0]<0:\n heappush(b,x)", "x[0]<0", "x[0]", "x", "0", "0", "heappush(b,x)", "heappush", "b", "x", "cnt=0", "cnt", "0", "for i in range(1,k):\n if ans[i]==ans[i-1]:\n cnt+=1", "i", "range(1,k)", "range", "1", "k", "if ans[i]==ans[i-1]:\n cnt+=1", "ans[i]==ans[i-1]", "ans[i]", "ans", "i", "ans[i-1]", "ans", "i-1", "i", "1", "cnt+=1", "cnt", "1", "print(cnt)", "print", "cnt", "t=map(int,input().split())", "map(int,input().split())", "t", "x=heappop(b)", "heappop(b)", "x", "k,t=map(int,input().split())", "map(int,input().split())", "k", "y=heappop(b)", "heappop(b)", "y", "b=[]", "[]", "b", "x=heappop(b)", "heappop(b)", "x", "input = sys.stdin.readline", "sys.stdin.readline", "input", "ans=[-1]*k", "[-1]*k", "ans", "cnt=0", "0", "cnt", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "cnt+=1", "1", "cnt" ]
import sys input = sys.stdin.readline from heapq import heappush,heapify,heappop k,t=map(int,input().split()) a=list(map(int,input().split())) b=[] heapify(b) ans=[-1]*k for i in range(t): heappush(b,[-a[i],i]) x=heappop(b) ans[0]=x[1] x[0]+=1 if x[0]<0: heappush(b,x) for i in range(1,k): x=heappop(b) if ans[i-1]==x[1] and b: y=heappop(b) ans[i]=y[1] y[0]+=1 if y[0]<0: heappush(b,y) heappush(b,x) else: ans[i]=x[1] x[0]+=1 if x[0]<0: heappush(b,x) cnt=0 for i in range(1,k): if ans[i]==ans[i-1]: cnt+=1 print(cnt)