node_ids
listlengths 4
1.4k
| edge_index
listlengths 1
2.22k
| text
listlengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
0,
13,
17,
0,
13,
17,
0,
13,
4,
13,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
2,
13,
17,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
2,
13,
17,
2,
13,
17,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
55,
2
],
[
64,
5
],
[
58,
8
],
[
13,
12
],
[
59,
17
],
[
59,
21
],
[
12,
22
],
[
67,
25
],
[
68,
30
],
[
56,
30
],
[
59,
34
],
[
12,
35
],
[
61,
38
],
[
68,
43
],
[
56,
43
],
[
62,
46
],
[
65,
46
],
[
55,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
]
] |
[
"c_f = False\nf_f = False\nS = input()\nfor i in range(len(S)):\n\tif S[i] == \"C\":\n\t\tc_f = True\n\tif c_f == True and S[i] == \"F\":\n\t\tf_f = True\nif c_f == True and f_f == True:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")",
"c_f = False",
"c_f",
"False",
"f_f = False",
"f_f",
"False",
"S = input()",
"S",
"input()",
"input",
"for i in range(len(S)):\n\tif S[i] == \"C\":\n\t\tc_f = True\n\tif c_f == True and S[i] == \"F\":\n\t\tf_f = True",
"i",
"range(len(S))",
"range",
"len(S)",
"len",
"S",
"if S[i] == \"C\":\n\t\tc_f = True\n\t",
"S[i] == \"C\"",
"S[i]",
"S",
"i",
"\"C\"",
"c_f = True",
"c_f",
"True",
"if c_f == True and S[i] == \"F\":\n\t\tf_f = True",
"c_f == True and S[i] == \"F\"",
"c_f == True",
"c_f",
"True",
"S[i] == \"F\"",
"S[i]",
"S",
"i",
"\"F\"",
"f_f = True",
"f_f",
"True",
"if c_f == True and f_f == True:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")",
"c_f == True and f_f == True",
"c_f == True",
"c_f",
"True",
"f_f == True",
"f_f",
"True",
"print(\"Yes\")",
"print",
"\"Yes\"",
"print(\"No\")",
"print",
"\"No\"",
"c_f = False",
"False",
"c_f",
"S = input()",
"input()",
"S",
"f_f = True",
"True",
"f_f",
"f_f = False",
"False",
"f_f",
"c_f = True",
"True",
"c_f"
] |
c_f = False
f_f = False
S = input()
for i in range(len(S)):
if S[i] == "C":
c_f = True
if c_f == True and S[i] == "F":
f_f = True
if c_f == True and f_f == True:
print("Yes")
else:
print("No")
|
[
7,
15,
13,
0,
13,
4,
13,
0,
13,
39,
28,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
4,
18,
13,
13,
13,
0,
13,
4,
18,
17,
13,
13,
14,
2,
17,
13,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
39,
13
] |
[
[
47,
4
],
[
50,
8
],
[
12,
11
],
[
48,
11
],
[
11,
16
],
[
11,
19
],
[
51,
23
],
[
11,
25
],
[
44,
27
],
[
51,
32
],
[
45,
36
],
[
51,
36
],
[
44,
45
],
[
47,
48
],
[
50,
51
]
] |
[
"import re\ns = input()\nt = []\nfor ch in s:\n if ch == 'C' or ch == 'F':\n t.append(ch)\nt = \"\".join(t)\nif \"CF\" in t:\n print(\"Yes\")\nelse:\n print(\"No\")",
"import re",
"re",
"s = input()",
"s",
"input()",
"input",
"t = []",
"t",
"[]",
"for ch in s:\n if ch == 'C' or ch == 'F':\n t.append(ch)",
"ch",
"s",
"if ch == 'C' or ch == 'F':\n t.append(ch)",
"ch == 'C' or ch == 'F'",
"ch == 'C'",
"ch",
"'C'",
"ch == 'F'",
"ch",
"'F'",
"t.append(ch)",
"t.append",
"t",
"append",
"ch",
"t = \"\".join(t)",
"t",
"\"\".join(t)",
"\"\".join",
"\"\"",
"join",
"t",
"if \"CF\" in t:\n print(\"Yes\")\nelse:\n print(\"No\")",
"\"CF\" in t",
"\"CF\"",
"t",
"print(\"Yes\")",
"print",
"\"Yes\"",
"print(\"No\")",
"print",
"\"No\"",
"t = \"\".join(t)",
"\"\".join(t)",
"t",
"s = input()",
"input()",
"s",
"t = []",
"[]",
"t"
] |
import re
s = input()
t = []
for ch in s:
if ch == 'C' or ch == 'F':
t.append(ch)
t = "".join(t)
if "CF" in t:
print("Yes")
else:
print("No")
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
54,
2
],
[
63,
8
],
[
57,
11
],
[
15,
14
],
[
55,
19
],
[
55,
23
],
[
14,
24
],
[
51,
27
],
[
52,
31
],
[
64,
31
],
[
55,
34
],
[
14,
35
],
[
60,
38
],
[
52,
42
],
[
64,
42
],
[
61,
43
],
[
58,
43
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] |
[
"s = list(input())\n\nc = False\nf = False\nfor i in range(len(s)):\n if s[i]==\"C\":\n c = True\n if c and s[i]==\"F\":\n f = True\n\nif c and f:\n print(\"Yes\")\nelse:\n print(\"No\")",
"s = list(input())",
"s",
"list(input())",
"list",
"input()",
"input",
"c = False",
"c",
"False",
"f = False",
"f",
"False",
"for i in range(len(s)):\n if s[i]==\"C\":\n c = True\n if c and s[i]==\"F\":\n f = True",
"i",
"range(len(s))",
"range",
"len(s)",
"len",
"s",
"if s[i]==\"C\":\n c = True\n ",
"s[i]==\"C\"",
"s[i]",
"s",
"i",
"\"C\"",
"c = True",
"c",
"True",
"if c and s[i]==\"F\":\n f = True",
"c and s[i]==\"F\"",
"c",
"s[i]==\"F\"",
"s[i]",
"s",
"i",
"\"F\"",
"f = True",
"f",
"True",
"if c and f:\n print(\"Yes\")\nelse:\n print(\"No\")",
"c and f",
"c",
"f",
"print(\"Yes\")",
"print",
"\"Yes\"",
"print(\"No\")",
"print",
"\"No\"",
"c = True",
"True",
"c",
"s = list(input())",
"list(input())",
"s",
"f = False",
"False",
"f",
"f = True",
"True",
"f",
"c = False",
"False",
"c"
] |
s = list(input())
c = False
f = False
for i in range(len(s)):
if s[i]=="C":
c = True
if c and s[i]=="F":
f = True
if c and f:
print("Yes")
else:
print("No")
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
54,
2
],
[
63,
8
],
[
51,
11
],
[
15,
14
],
[
55,
19
],
[
55,
23
],
[
14,
24
],
[
57,
27
],
[
58,
31
],
[
64,
31
],
[
55,
34
],
[
14,
35
],
[
60,
38
],
[
58,
42
],
[
64,
42
],
[
61,
43
],
[
52,
43
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] |
[
"#%%\ns = list(input())\n\nf1 = False\nf2 = False\n\nfor i in range(len(s)):\n if s[i] == 'C':\n f1 = True\n if f1 and s[i] == 'F':\n f2 = True\nif f1 and f2:\n print('Yes')\nelse:\n print('No')",
"s = list(input())",
"s",
"list(input())",
"list",
"input()",
"input",
"f1 = False",
"f1",
"False",
"f2 = False",
"f2",
"False",
"for i in range(len(s)):\n if s[i] == 'C':\n f1 = True\n if f1 and s[i] == 'F':\n f2 = True",
"i",
"range(len(s))",
"range",
"len(s)",
"len",
"s",
"if s[i] == 'C':\n f1 = True\n ",
"s[i] == 'C'",
"s[i]",
"s",
"i",
"'C'",
"f1 = True",
"f1",
"True",
"if f1 and s[i] == 'F':\n f2 = True",
"f1 and s[i] == 'F'",
"f1",
"s[i] == 'F'",
"s[i]",
"s",
"i",
"'F'",
"f2 = True",
"f2",
"True",
"if f1 and f2:\n print('Yes')\nelse:\n print('No')",
"f1 and f2",
"f1",
"f2",
"print('Yes')",
"print",
"'Yes'",
"print('No')",
"print",
"'No'",
"f2 = False",
"False",
"f2",
"s = list(input())",
"list(input())",
"s",
"f1 = True",
"True",
"f1",
"f2 = True",
"True",
"f2",
"f1 = False",
"False",
"f1"
] |
#%%
s = list(input())
f1 = False
f2 = False
for i in range(len(s)):
if s[i] == 'C':
f1 = True
if f1 and s[i] == 'F':
f2 = True
if f1 and f2:
print('Yes')
else:
print('No')
|
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
28,
13,
4,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
4,
13,
13,
14,
2,
2,
18,
13,
13,
17,
2,
18,
13,
13,
17,
4,
13,
17,
4,
13,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
11,
10
],
[
4,
15
],
[
18,
17
],
[
10,
21
],
[
4,
25
],
[
4,
30
],
[
10,
31
],
[
4,
35
],
[
17,
36
],
[
54,
51
]
] |
[
"def main():\n s = list(input())\n for i in range(len(s)):\n for j in range(i+1,len(s)):\n if s[i]==\"C\" and s[j]==\"F\":\n print(\"Yes\")\n exit()\n print(\"No\")\n\nif __name__ == '__main__':\n main()",
"def main():\n s = list(input())\n for i in range(len(s)):\n for j in range(i+1,len(s)):\n if s[i]==\"C\" and s[j]==\"F\":\n print(\"Yes\")\n exit()\n print(\"No\")",
"main",
"s = list(input())",
"s",
"list(input())",
"list",
"input()",
"input",
"for i in range(len(s)):\n for j in range(i+1,len(s)):\n if s[i]==\"C\" and s[j]==\"F\":\n print(\"Yes\")\n exit()\n ",
"i",
"range(len(s))",
"range",
"len(s)",
"len",
"s",
"for j in range(i+1,len(s)):\n if s[i]==\"C\" and s[j]==\"F\":\n print(\"Yes\")\n exit()\n ",
"j",
"range(i+1,len(s))",
"range",
"i+1",
"i",
"1",
"len(s)",
"len",
"s",
"if s[i]==\"C\" and s[j]==\"F\":\n print(\"Yes\")\n exit()\n ",
"s[i]==\"C\" and s[j]==\"F\"",
"s[i]==\"C\"",
"s[i]",
"s",
"i",
"\"C\"",
"s[j]==\"F\"",
"s[j]",
"s",
"j",
"\"F\"",
"print(\"Yes\")",
"print",
"\"Yes\"",
"exit()",
"exit",
"print(\"No\")",
"print",
"\"No\"",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n s = list(input())\n for i in range(len(s)):\n for j in range(i+1,len(s)):\n if s[i]==\"C\" and s[j]==\"F\":\n print(\"Yes\")\n exit()\n print(\"No\")",
"def main():\n s = list(input())\n for i in range(len(s)):\n for j in range(i+1,len(s)):\n if s[i]==\"C\" and s[j]==\"F\":\n print(\"Yes\")\n exit()\n print(\"No\")",
"main"
] |
def main():
s = list(input())
for i in range(len(s)):
for j in range(i+1,len(s)):
if s[i]=="C" and s[j]=="F":
print("Yes")
exit()
print("No")
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
0,
13,
17,
13,
17,
28,
13,
13,
4,
13,
13,
14,
2,
13,
17,
0,
13,
13,
3,
28,
13,
13,
4,
13,
18,
13,
39,
17,
14,
2,
13,
17,
0,
13,
2,
2,
4,
13,
13,
13,
17,
3,
14,
2,
2,
40,
13,
17,
40,
13,
17,
2,
13,
13,
4,
13,
17,
4,
13,
17,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13
] |
[
[
72,
2
],
[
78,
6
],
[
69,
8
],
[
73,
15
],
[
75,
21
],
[
73,
30
],
[
66,
38
],
[
73,
43
],
[
76,
51
],
[
79,
51
],
[
67,
54
],
[
70,
54
],
[
76,
57
],
[
79,
57
],
[
67,
58
],
[
70,
58
],
[
66,
67
],
[
69,
70
],
[
72,
73
],
[
75,
76
],
[
78,
79
]
] |
[
"S = input()\nc, f = -1, -1\nfor i, s in enumerate(S):\n if s == 'C':\n c = i\n break\nfor i, s in enumerate(S[::-1]):\n if s == 'F':\n f = len(S)-i-1\n break\nif c >= 0 and f >= 0 and c < f:\n print('Yes')\nelse:\n print('No')",
"S = input()",
"S",
"input()",
"input",
"c, f = -1, -1",
"c",
"-1",
"f",
"-1",
"for i, s in enumerate(S):\n if s == 'C':\n c = i\n break",
"i",
"s",
"enumerate(S)",
"enumerate",
"S",
"if s == 'C':\n c = i\n break",
"s == 'C'",
"s",
"'C'",
"c = i",
"c",
"i",
"break",
"for i, s in enumerate(S[::-1]):\n if s == 'F':\n f = len(S)-i-1\n break",
"i",
"s",
"enumerate(S[::-1])",
"enumerate",
"S[::-1]",
"S",
"::-1",
"-1",
"if s == 'F':\n f = len(S)-i-1\n break",
"s == 'F'",
"s",
"'F'",
"f = len(S)-i-1",
"f",
"len(S)-i-1",
"len(S)-i",
"len(S)",
"len",
"S",
"i",
"1",
"break",
"if c >= 0 and f >= 0 and c < f:\n print('Yes')\nelse:\n print('No')",
"c >= 0 and f >= 0 and c < f",
"c >= 0 and f >= 0",
"c >= 0",
"c",
"0",
"f >= 0",
"f",
"0",
"c < f",
"c",
"f",
"print('Yes')",
"print",
"'Yes'",
"print('No')",
"print",
"'No'",
"f = len(S)-i-1",
"len(S)-i-1",
"f",
"f = -1, -1",
"-1",
"f",
"S = input()",
"input()",
"S",
"c = i",
"i",
"c",
"c, f = -1, -1",
"-1",
"c"
] |
S = input()
c, f = -1, -1
for i, s in enumerate(S):
if s == 'C':
c = i
break
for i, s in enumerate(S[::-1]):
if s == 'F':
f = len(S)-i-1
break
if c >= 0 and f >= 0 and c < f:
print('Yes')
else:
print('No')
|
[
7,
15,
15,
13,
4,
18,
13,
13,
2,
2,
17,
17,
17,
15,
15,
13,
13,
15,
13,
15,
13,
15,
13,
15,
12,
13,
0,
13,
4,
13,
0,
13,
17,
28,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
0,
13,
17,
14,
2,
2,
13,
17,
2,
13,
17,
0,
13,
17,
14,
2,
13,
17,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
28,
27
],
[
32,
31
],
[
35,
34
],
[
27,
34
],
[
31,
39
],
[
56,
39
],
[
45,
39
],
[
34,
42
],
[
46,
45
],
[
45,
50
],
[
31,
50
],
[
56,
50
],
[
34,
53
],
[
57,
56
],
[
56,
60
],
[
45,
60
],
[
31,
60
],
[
76,
73
]
] |
[
"from collections import Counter, defaultdict\nimport sys\nsys.setrecursionlimit(10 ** 5 + 10)\n# input = sys.stdin.readline\nfrom math import factorial\nimport heapq, bisect\nimport math\nimport itertools\n\n\nimport queue\nfrom collections import deque\n\n\n\n\ndef main():\n a = input()\n flg = 0\n for ele in a:\n if flg == 0 and ele == 'C':\n flg += 1\n if flg == 1 and ele == 'F':\n flg += 1\n if flg == 2:\n print('Yes')\n\n else:\n print('No')\n\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n",
"from collections import Counter, defaultdict",
"import sys",
"sys",
"sys.setrecursionlimit(10 ** 5 + 10)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 5 + 10",
"10 ** 5",
"10",
"5",
"10",
"from math import factorial",
"import heapq, bisect",
"heapq",
"bisect",
"import math",
"math",
"import itertools",
"itertools",
"import queue",
"queue",
"from collections import deque",
"def main():\n a = input()\n flg = 0\n for ele in a:\n if flg == 0 and ele == 'C':\n flg += 1\n if flg == 1 and ele == 'F':\n flg += 1\n if flg == 2:\n print('Yes')\n\n else:\n print('No')",
"main",
"a = input()",
"a",
"input()",
"input",
"flg = 0",
"flg",
"0",
"for ele in a:\n if flg == 0 and ele == 'C':\n flg += 1\n if flg == 1 and ele == 'F':\n flg += 1\n ",
"ele",
"a",
"if flg == 0 and ele == 'C':\n flg += 1\n ",
"flg == 0 and ele == 'C'",
"flg == 0",
"flg",
"0",
"ele == 'C'",
"ele",
"'C'",
"flg += 1",
"flg",
"1",
"if flg == 1 and ele == 'F':\n flg += 1\n ",
"flg == 1 and ele == 'F'",
"flg == 1",
"flg",
"1",
"ele == 'F'",
"ele",
"'F'",
"flg += 1",
"flg",
"1",
"if flg == 2:\n print('Yes')\n\n else:\n print('No')",
"flg == 2",
"flg",
"2",
"print('Yes')",
"print",
"'Yes'",
"print('No')",
"print",
"'No'",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n a = input()\n flg = 0\n for ele in a:\n if flg == 0 and ele == 'C':\n flg += 1\n if flg == 1 and ele == 'F':\n flg += 1\n if flg == 2:\n print('Yes')\n\n else:\n print('No')",
"def main():\n a = input()\n flg = 0\n for ele in a:\n if flg == 0 and ele == 'C':\n flg += 1\n if flg == 1 and ele == 'F':\n flg += 1\n if flg == 2:\n print('Yes')\n\n else:\n print('No')",
"main"
] |
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
def main():
a = input()
flg = 0
for ele in a:
if flg == 0 and ele == 'C':
flg += 1
if flg == 1 and ele == 'F':
flg += 1
if flg == 2:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
4,
13,
0,
13,
2,
4,
13,
13,
17,
0,
13,
4,
13,
13,
0,
13,
40,
4,
13,
13,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
2,
2,
13,
17,
13,
17,
0,
13,
2,
2,
13,
17,
13,
3,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
13,
3,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
40,
13
] |
[
[
79,
2
],
[
88,
8
],
[
80,
12
],
[
82,
15
],
[
80,
18
],
[
91,
20
],
[
80,
24
],
[
27,
26
],
[
80,
31
],
[
80,
35
],
[
83,
38
],
[
26,
40
],
[
76,
43
],
[
83,
46
],
[
26,
48
],
[
52,
51
],
[
83,
54
],
[
80,
58
],
[
51,
59
],
[
85,
62
],
[
51,
63
],
[
86,
67
],
[
89,
67
],
[
77,
68
],
[
92,
68
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
51,
85
],
[
85,
86
],
[
88,
89
],
[
91,
92
]
] |
[
"s=list(input())\nc=len(s)+10\nn=len(s)\nf=-len(s)\nfor i in range(len(s)):\n if s[n-1-i]=='F':\n f=n-1-i\n break\nfor i in range(n):\n if s[i]==\"C\":\n c=i\n break\nif c<f:\n print('Yes')\nelse:\n print('No')",
"s=list(input())",
"s",
"list(input())",
"list",
"input()",
"input",
"c=len(s)+10",
"c",
"len(s)+10",
"len(s)",
"len",
"s",
"10",
"n=len(s)",
"n",
"len(s)",
"len",
"s",
"f=-len(s)",
"f",
"-len(s)",
"len(s)",
"len",
"s",
"for i in range(len(s)):\n if s[n-1-i]=='F':\n f=n-1-i\n break",
"i",
"range(len(s))",
"range",
"len(s)",
"len",
"s",
"if s[n-1-i]=='F':\n f=n-1-i\n break",
"s[n-1-i]=='F'",
"s[n-1-i]",
"s",
"n-1-i",
"n-1",
"n",
"1",
"i",
"'F'",
"f=n-1-i",
"f",
"n-1-i",
"n-1",
"n",
"1",
"i",
"break",
"for i in range(n):\n if s[i]==\"C\":\n c=i\n break",
"i",
"range(n)",
"range",
"n",
"if s[i]==\"C\":\n c=i\n break",
"s[i]==\"C\"",
"s[i]",
"s",
"i",
"\"C\"",
"c=i",
"c",
"i",
"break",
"if c<f:\n print('Yes')\nelse:\n print('No')",
"c<f",
"c",
"f",
"print('Yes')",
"print",
"'Yes'",
"print('No')",
"print",
"'No'",
"f=n-1-i",
"n-1-i",
"f",
"s=list(input())",
"list(input())",
"s",
"n=len(s)",
"len(s)",
"n",
"c=i",
"i",
"c",
"c=len(s)+10",
"len(s)+10",
"c",
"f=-len(s)",
"-len(s)",
"f"
] |
s=list(input())
c=len(s)+10
n=len(s)
f=-len(s)
for i in range(len(s)):
if s[n-1-i]=='F':
f=n-1-i
break
for i in range(n):
if s[i]=="C":
c=i
break
if c<f:
print('Yes')
else:
print('No')
|
[
7,
0,
13,
4,
13,
38,
5,
4,
13,
17,
4,
13,
0,
13,
4,
18,
13,
13,
17,
38,
5,
4,
13,
17,
4,
13,
0,
13,
4,
18,
18,
13,
39,
13,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
43,
2
],
[
40,
13
],
[
44,
16
],
[
46,
27
],
[
44,
31
],
[
40,
41
],
[
43,
44
],
[
46,
47
]
] |
[
"s=input()\ntry:\n A = s.index(\"C\")\nexcept ValueError:\n print(\"No\")\n exit()\ntry:\n B = s[A:].index(\"F\")\n print(\"Yes\")\nexcept ValueError:\n print(\"No\")\n exit()",
"s=input()",
"s",
"input()",
"input",
"try:\n A = s.index(\"C\")\nexcept ValueError:\n print(\"No\")\n exit()",
"except ValueError:\n print(\"No\")\n exit()",
"print(\"No\")",
"print",
"\"No\"",
"exit()",
"exit",
"A = s.index(\"C\")",
"A",
"s.index(\"C\")",
"s.index",
"s",
"index",
"\"C\"",
"try:\n B = s[A:].index(\"F\")\n print(\"Yes\")\nexcept ValueError:\n print(\"No\")\n exit()",
"except ValueError:\n print(\"No\")\n exit()",
"print(\"No\")",
"print",
"\"No\"",
"exit()",
"exit",
"B = s[A:].index(\"F\")",
"B",
"s[A:].index(\"F\")",
"[A:].index",
"[A:]",
"s",
"A:",
"A",
"index",
"\"F\"",
"print(\"Yes\")",
"print",
"\"Yes\"",
"A = s.index(\"C\")",
"s.index(\"C\")",
"A",
"s=input()",
"input()",
"s",
"B = s[A:].index(\"F\")",
"s[A:].index(\"F\")",
"B"
] |
s=input()
try:
A = s.index("C")
except ValueError:
print("No")
exit()
try:
B = s[A:].index("F")
print("Yes")
except ValueError:
print("No")
exit()
|
[
7,
0,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
18,
13,
13,
17,
4,
13,
17,
4,
13,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13
] |
[
[
44,
2
],
[
47,
6
],
[
10,
9
],
[
45,
14
],
[
45,
18
],
[
9,
19
],
[
41,
22
],
[
42,
26
],
[
48,
26
],
[
45,
29
],
[
9,
30
],
[
41,
42
],
[
44,
45
],
[
47,
48
]
] |
[
"s = input()\nflag = False\nfor i in range(len(s)):\n if s[i] == 'C':\n flag = True\n if flag and s[i] == 'F':\n print('Yes')\n exit()\nprint('No')",
"s = input()",
"s",
"input()",
"input",
"flag = False",
"flag",
"False",
"for i in range(len(s)):\n if s[i] == 'C':\n flag = True\n if flag and s[i] == 'F':\n print('Yes')\n exit()",
"i",
"range(len(s))",
"range",
"len(s)",
"len",
"s",
"if s[i] == 'C':\n flag = True\n ",
"s[i] == 'C'",
"s[i]",
"s",
"i",
"'C'",
"flag = True",
"flag",
"True",
"if flag and s[i] == 'F':\n print('Yes')\n exit()",
"flag and s[i] == 'F'",
"flag",
"s[i] == 'F'",
"s[i]",
"s",
"i",
"'F'",
"print('Yes')",
"print",
"'Yes'",
"exit()",
"exit",
"print('No')",
"print",
"'No'",
"flag = True",
"True",
"flag",
"s = input()",
"input()",
"s",
"flag = False",
"False",
"flag"
] |
s = input()
flag = False
for i in range(len(s)):
if s[i] == 'C':
flag = True
if flag and s[i] == 'F':
print('Yes')
exit()
print('No')
|
[
7,
0,
13,
4,
13,
0,
13,
17,
14,
2,
2,
4,
18,
13,
13,
17,
4,
18,
13,
13,
17,
17,
4,
13,
17,
4,
13,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
14,
2,
2,
13,
17,
2,
18,
13,
13,
17,
4,
13,
17,
4,
13,
4,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13
] |
[
[
62,
2
],
[
65,
6
],
[
63,
13
],
[
63,
18
],
[
29,
28
],
[
63,
33
],
[
63,
37
],
[
28,
38
],
[
68,
41
],
[
69,
46
],
[
66,
46
],
[
63,
50
],
[
28,
51
],
[
62,
63
],
[
65,
66
],
[
68,
69
]
] |
[
"s = input()\n\nflag = 0\n\nif s.count('C')*s.count('F')==0:\n\tprint('No')\n\texit()\n\t\nfor i in range(len(s)):\n\tif s[i]=='C':\n\t\tflag = 1\n\tif flag == 1 and s[i]=='F':\n\t\tprint('Yes')\n\t\texit()\n\nprint('No')",
"s = input()",
"s",
"input()",
"input",
"flag = 0",
"flag",
"0",
"if s.count('C')*s.count('F')==0:\n\tprint('No')\n\texit()\n\t",
"s.count('C')*s.count('F')==0",
"s.count('C')*s.count('F')",
"s.count('C')",
"s.count",
"s",
"count",
"'C'",
"s.count('F')",
"s.count",
"s",
"count",
"'F'",
"0",
"print('No')",
"print",
"'No'",
"exit()",
"exit",
"for i in range(len(s)):\n\tif s[i]=='C':\n\t\tflag = 1\n\tif flag == 1 and s[i]=='F':\n\t\tprint('Yes')\n\t\texit()",
"i",
"range(len(s))",
"range",
"len(s)",
"len",
"s",
"if s[i]=='C':\n\t\tflag = 1\n\t",
"s[i]=='C'",
"s[i]",
"s",
"i",
"'C'",
"flag = 1",
"flag",
"1",
"if flag == 1 and s[i]=='F':\n\t\tprint('Yes')\n\t\texit()",
"flag == 1 and s[i]=='F'",
"flag == 1",
"flag",
"1",
"s[i]=='F'",
"s[i]",
"s",
"i",
"'F'",
"print('Yes')",
"print",
"'Yes'",
"exit()",
"exit",
"print('No')",
"print",
"'No'",
"s = input()",
"input()",
"s",
"flag = 0",
"0",
"flag",
"flag = 1",
"1",
"flag"
] |
s = input()
flag = 0
if s.count('C')*s.count('F')==0:
print('No')
exit()
for i in range(len(s)):
if s[i]=='C':
flag = 1
if flag == 1 and s[i]=='F':
print('Yes')
exit()
print('No')
|
[
7,
0,
13,
4,
13,
0,
13,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
2,
13,
17,
2,
18,
13,
13,
17,
4,
13,
17,
4,
13,
14,
2,
2,
13,
17,
2,
18,
13,
13,
17,
0,
13,
17,
4,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
56,
2
],
[
59,
6
],
[
57,
9
],
[
50,
11
],
[
15,
14
],
[
60,
17
],
[
51,
21
],
[
54,
21
],
[
57,
25
],
[
14,
26
],
[
51,
36
],
[
54,
36
],
[
57,
40
],
[
14,
41
],
[
53,
44
],
[
50,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] |
[
"s=input()\nn=len(s)\nc=0\nfor i in range(n):\n if c==1 and s[i]==\"F\":\n print(\"Yes\")\n exit()\n if c==0 and s[i]==\"C\":\n c+=1\nprint(\"No\")",
"s=input()",
"s",
"input()",
"input",
"n=len(s)",
"n",
"len(s)",
"len",
"s",
"c=0",
"c",
"0",
"for i in range(n):\n if c==1 and s[i]==\"F\":\n print(\"Yes\")\n exit()\n if c==0 and s[i]==\"C\":\n c+=1",
"i",
"range(n)",
"range",
"n",
"if c==1 and s[i]==\"F\":\n print(\"Yes\")\n exit()\n ",
"c==1 and s[i]==\"F\"",
"c==1",
"c",
"1",
"s[i]==\"F\"",
"s[i]",
"s",
"i",
"\"F\"",
"print(\"Yes\")",
"print",
"\"Yes\"",
"exit()",
"exit",
"if c==0 and s[i]==\"C\":\n c+=1",
"c==0 and s[i]==\"C\"",
"c==0",
"c",
"0",
"s[i]==\"C\"",
"s[i]",
"s",
"i",
"\"C\"",
"c+=1",
"c",
"1",
"print(\"No\")",
"print",
"\"No\"",
"c=0",
"0",
"c",
"c+=1",
"1",
"c",
"s=input()",
"input()",
"s",
"n=len(s)",
"len(s)",
"n"
] |
s=input()
n=len(s)
c=0
for i in range(n):
if c==1 and s[i]=="F":
print("Yes")
exit()
if c==0 and s[i]=="C":
c+=1
print("No")
|
[
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,
39,
4,
13,
13,
28,
13,
4,
13,
13,
4,
13,
13,
39,
40,
18,
13,
13,
13,
0,
13,
39,
17,
42,
2,
4,
13,
13,
17,
14,
2,
4,
13,
13,
17,
0,
13,
4,
13,
13,
13,
28,
13,
4,
13,
40,
13,
4,
18,
13,
13,
13,
3,
0,
13,
4,
13,
13,
13,
14,
2,
18,
13,
17,
13,
0,
13,
4,
13,
13,
13,
4,
18,
13,
13,
13,
4,
13,
13,
39,
13,
13,
0,
13,
17,
14,
2,
13,
17,
4,
13,
13,
39,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
14,
2,
13,
17,
4,
13,
13,
39,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
4,
13,
13,
17,
14,
2,
18,
13,
13,
18,
13,
2,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
17,
13
] |
[
[
204,
3
],
[
204,
12
],
[
201,
14
],
[
195,
26
],
[
196,
30
],
[
33,
32
],
[
205,
35
],
[
196,
38
],
[
202,
42
],
[
32,
43
],
[
207,
46
],
[
196,
53
],
[
196,
59
],
[
189,
62
],
[
196,
65
],
[
189,
66
],
[
69,
68
],
[
190,
72
],
[
184,
72
],
[
193,
72
],
[
208,
75
],
[
169,
77
],
[
192,
80
],
[
196,
83
],
[
192,
84
],
[
208,
88
],
[
178,
90
],
[
198,
92
],
[
196,
95
],
[
198,
96
],
[
208,
99
],
[
199,
101
],
[
196,
104
],
[
174,
109
],
[
175,
113
],
[
172,
113
],
[
196,
117
],
[
208,
123
],
[
178,
125
],
[
183,
127
],
[
184,
131
],
[
193,
131
],
[
190,
131
],
[
196,
135
],
[
210,
140
],
[
144,
143
],
[
208,
149
],
[
208,
154
],
[
143,
155
],
[
208,
157
],
[
143,
159
],
[
180,
162
],
[
181,
166
],
[
211,
166
],
[
189,
169
],
[
198,
172
],
[
174,
175
],
[
192,
178
],
[
180,
181
],
[
183,
184
],
[
204,
187
],
[
189,
190
],
[
192,
193
],
[
195,
196
],
[
198,
199
],
[
201,
202
],
[
204,
205
],
[
207,
208
],
[
210,
211
]
] |
[
"from heapq import heapify, heappop, heappush\nk, t = map(int, input().split())\na = list(map(int, input().split()))\n\nque = []\nheapify(que)\n\nfor i in range(t):\n heappush(que, (-a[i], i))\n\ns = [-1]\nwhile len(que) > 0:\n if len(que) == 1:\n a_i, idx = heappop(que)\n for _ in range(-a_i):\n s.append(idx)\n break\n else:\n a_i, idx_i = heappop(que)\n if s[-1] == idx_i:\n a_j, idx_j = heappop(que)\n s.append(idx_j)\n heappush(que, (a_i, idx_i))\n a_j += 1\n if a_j < 0:\n heappush(que, (a_j, idx_j))\n else:\n s.append(idx_i)\n a_i += 1\n if a_i < 0:\n heappush(que, (a_i, idx_i))\n\ncnt = 0\nfor i in range(len(s)-1):\n if s[i] == s[i+1]:\n cnt += 1\nprint(cnt)",
"from heapq import heapify, heappop, heappush",
"k, t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"que = []",
"que",
"[]",
"heapify(que)",
"heapify",
"que",
"for i in range(t):\n heappush(que, (-a[i], i))",
"i",
"range(t)",
"range",
"t",
"heappush(que, (-a[i], i))",
"heappush",
"que",
"(-a[i], i)",
"-a[i]",
"a[i]",
"a",
"i",
"i",
"s = [-1]",
"s",
"[-1]",
"-1",
"while len(que) > 0:\n if len(que) == 1:\n a_i, idx = heappop(que)\n for _ in range(-a_i):\n s.append(idx)\n break\n else:\n a_i, idx_i = heappop(que)\n if s[-1] == idx_i:\n a_j, idx_j = heappop(que)\n s.append(idx_j)\n heappush(que, (a_i, idx_i))\n a_j += 1\n if a_j < 0:\n heappush(que, (a_j, idx_j))\n else:\n s.append(idx_i)\n a_i += 1\n if a_i < 0:\n heappush(que, (a_i, idx_i))",
"len(que) > 0",
"len(que)",
"len",
"que",
"0",
"if len(que) == 1:\n a_i, idx = heappop(que)\n for _ in range(-a_i):\n s.append(idx)\n break\n else:\n a_i, idx_i = heappop(que)\n if s[-1] == idx_i:\n a_j, idx_j = heappop(que)\n s.append(idx_j)\n heappush(que, (a_i, idx_i))\n a_j += 1\n if a_j < 0:\n heappush(que, (a_j, idx_j))\n else:\n s.append(idx_i)\n a_i += 1\n if a_i < 0:\n heappush(que, (a_i, idx_i))",
"len(que) == 1",
"len(que)",
"len",
"que",
"1",
"a_i, idx = heappop(que)",
"a_i",
"heappop(que)",
"heappop",
"que",
"idx",
"for _ in range(-a_i):\n s.append(idx)\n ",
"_",
"range(-a_i)",
"range",
"-a_i",
"a_i",
"s.append(idx)",
"s.append",
"s",
"append",
"idx",
"break",
"a_i, idx_i = heappop(que)",
"a_i",
"heappop(que)",
"heappop",
"que",
"idx_i",
"if s[-1] == idx_i:\n a_j, idx_j = heappop(que)\n s.append(idx_j)\n heappush(que, (a_i, idx_i))\n a_j += 1\n if a_j < 0:\n heappush(que, (a_j, idx_j))\n else:\n s.append(idx_i)\n a_i += 1\n if a_i < 0:\n heappush(que, (a_i, idx_i))",
"s[-1] == idx_i",
"s[-1]",
"s",
"-1",
"idx_i",
"a_j, idx_j = heappop(que)",
"a_j",
"heappop(que)",
"heappop",
"que",
"idx_j",
"s.append(idx_j)",
"s.append",
"s",
"append",
"idx_j",
"heappush(que, (a_i, idx_i))",
"heappush",
"que",
"(a_i, idx_i)",
"a_i",
"idx_i",
"a_j += 1",
"a_j",
"1",
"if a_j < 0:\n heappush(que, (a_j, idx_j))\n ",
"a_j < 0",
"a_j",
"0",
"heappush(que, (a_j, idx_j))",
"heappush",
"que",
"(a_j, idx_j)",
"a_j",
"idx_j",
"s.append(idx_i)",
"s.append",
"s",
"append",
"idx_i",
"a_i += 1",
"a_i",
"1",
"if a_i < 0:\n heappush(que, (a_i, idx_i))",
"a_i < 0",
"a_i",
"0",
"heappush(que, (a_i, idx_i))",
"heappush",
"que",
"(a_i, idx_i)",
"a_i",
"idx_i",
"cnt = 0",
"cnt",
"0",
"for i in range(len(s)-1):\n if s[i] == s[i+1]:\n cnt += 1",
"i",
"range(len(s)-1)",
"range",
"len(s)-1",
"len(s)",
"len",
"s",
"1",
"if s[i] == s[i+1]:\n cnt += 1",
"s[i] == s[i+1]",
"s[i]",
"s",
"i",
"s[i+1]",
"s",
"i+1",
"i",
"1",
"cnt += 1",
"cnt",
"1",
"print(cnt)",
"print",
"cnt",
"idx = heappop(que)",
"heappop(que)",
"idx",
"a_j, idx_j = heappop(que)",
"heappop(que)",
"a_j",
"a_j += 1",
"1",
"a_j",
"idx_i = heappop(que)",
"heappop(que)",
"idx_i",
"cnt += 1",
"1",
"cnt",
"a_i += 1",
"1",
"a_i",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"a_i, idx = heappop(que)",
"heappop(que)",
"a_i",
"a_i, idx_i = heappop(que)",
"heappop(que)",
"a_i",
"que = []",
"[]",
"que",
"idx_j = heappop(que)",
"heappop(que)",
"idx_j",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"s = [-1]",
"[-1]",
"s",
"cnt = 0",
"0",
"cnt"
] |
from heapq import heapify, heappop, heappush
k, t = map(int, input().split())
a = list(map(int, input().split()))
que = []
heapify(que)
for i in range(t):
heappush(que, (-a[i], i))
s = [-1]
while len(que) > 0:
if len(que) == 1:
a_i, idx = heappop(que)
for _ in range(-a_i):
s.append(idx)
break
else:
a_i, idx_i = heappop(que)
if s[-1] == idx_i:
a_j, idx_j = heappop(que)
s.append(idx_j)
heappush(que, (a_i, idx_i))
a_j += 1
if a_j < 0:
heappush(que, (a_j, idx_j))
else:
s.append(idx_i)
a_i += 1
if a_i < 0:
heappush(que, (a_i, idx_i))
cnt = 0
for i in range(len(s)-1):
if s[i] == s[i+1]:
cnt += 1
print(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,
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
] |
[
[
56,
2
],
[
56,
11
],
[
53,
13
],
[
59,
25
],
[
54,
28
],
[
51,
32
],
[
60,
33
],
[
60,
35
],
[
60,
46
],
[
51,
47
],
[
56,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] |
[
"K,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",
"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 = max(A)",
"max(A)",
"MX"
] |
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,
0,
13,
4,
13,
13,
0,
13,
2,
4,
13,
13,
4,
13,
13,
4,
13,
4,
13,
2,
2,
13,
13,
17,
17,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
58,
2
],
[
58,
11
],
[
61,
13
],
[
55,
25
],
[
62,
28
],
[
52,
30
],
[
62,
34
],
[
62,
37
],
[
56,
44
],
[
53,
45
],
[
58,
50
],
[
52,
53
],
[
55,
56
],
[
58,
59
],
[
61,
62
]
] |
[
"k, t = map(int, input().split())\na = list(map(int, input().split()))\nr = max(a)\nl = sum(a) - max(a)\nprint(max((r-l)-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",
"r = max(a)",
"r",
"max(a)",
"max",
"a",
"l = sum(a) - max(a)",
"l",
"sum(a) - max(a)",
"sum(a)",
"sum",
"a",
"max(a)",
"max",
"a",
"print(max((r-l)-1, 0))",
"print",
"max((r-l)-1, 0)",
"max",
"(r-l)-1",
"r-l",
"r",
"l",
"1",
"0",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"l = sum(a) - max(a)",
"sum(a) - max(a)",
"l",
"r = max(a)",
"max(a)",
"r",
"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()))
r = max(a)
l = sum(a) - max(a)
print(max((r-l)-1, 0))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
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,
2,
13
] |
[
[
51,
2
],
[
51,
11
],
[
48,
13
],
[
54,
25
],
[
49,
28
],
[
57,
30
],
[
46,
32
],
[
55,
33
],
[
55,
40
],
[
58,
42
],
[
51,
46
],
[
48,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
]
] |
[
"# coding: utf-8\nk, t = map(int,input().split())\nA=list(map(int,input().split()))\nm=max(A)\ns=k-m\nprint(max(m-1-s, 0))",
"k, t = map(int,input().split())",
"k",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"A=list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m=max(A)",
"m",
"max(A)",
"max",
"A",
"s=k-m",
"s",
"k-m",
"k",
"m",
"print(max(m-1-s, 0))",
"print",
"max(m-1-s, 0)",
"max",
"m-1-s",
"m-1",
"m",
"1",
"s",
"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",
"m=max(A)",
"max(A)",
"m",
"s=k-m",
"k-m",
"s"
] |
# coding: utf-8
k, t = map(int,input().split())
A=list(map(int,input().split()))
m=max(A)
s=k-m
print(max(m-1-s, 0))
|
[
7,
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,
2,
13,
13,
0,
13,
2,
2,
13,
13,
17,
4,
13,
4,
13,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] |
[
[
55,
2
],
[
55,
11
],
[
46,
13
],
[
49,
23
],
[
47,
26
],
[
58,
28
],
[
56,
30
],
[
50,
31
],
[
61,
33
],
[
50,
36
],
[
59,
37
],
[
62,
44
],
[
46,
47
],
[
49,
50
],
[
55,
53
],
[
55,
56
],
[
58,
59
],
[
61,
62
]
] |
[
"k, t = map(int, input().split())\na = map(int, input().split())\n\nx = max(a)\ny = (k - x)\n\nr = x - y - 1\nprint(max(0, r))",
"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",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"x = max(a)",
"x",
"max(a)",
"max",
"a",
"y = (k - x)",
"y",
"k - x",
"k",
"x",
"r = x - y - 1",
"r",
"x - y - 1",
"x - y",
"x",
"y",
"1",
"print(max(0, r))",
"print",
"max(0, r)",
"max",
"0",
"r",
"a = map(int, input().split())",
"map(int, input().split())",
"a",
"x = max(a)",
"max(a)",
"x",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"y = (k - x)",
"k - x",
"y",
"r = x - y - 1",
"x - y - 1",
"r"
] |
k, t = map(int, input().split())
a = map(int, input().split())
x = max(a)
y = (k - x)
r = x - y - 1
print(max(0, r))
|
[
7,
15,
15,
15,
15,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
13,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
0,
13,
17,
0,
13,
17,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
17,
0,
13,
17,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
4,
13,
13,
2,
13,
17,
17,
0,
18,
13,
13,
18,
13,
2,
13,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
18,
13,
13,
0,
13,
4,
13,
13,
4,
13,
2,
2,
13,
13,
13,
2,
13,
2,
13,
13,
14,
13,
4,
13,
2,
13,
17,
4,
13,
17,
29,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] |
[
[
275,
17
],
[
245,
24
],
[
45,
44
],
[
282,
50
],
[
54,
54
],
[
58,
57
],
[
240,
63
],
[
67,
67
],
[
71,
70
],
[
255,
76
],
[
80,
80
],
[
84,
83
],
[
240,
89
],
[
93,
93
],
[
97,
96
],
[
261,
102
],
[
106,
106
],
[
110,
109
],
[
270,
115
],
[
119,
119
],
[
123,
122
],
[
294,
128
],
[
132,
132
],
[
251,
134
],
[
284,
137
],
[
143,
142
],
[
240,
144
],
[
143,
145
],
[
148,
147
],
[
240,
149
],
[
152,
151
],
[
142,
156
],
[
163,
159
],
[
163,
162
],
[
168,
165
],
[
151,
166
],
[
171,
170
],
[
147,
170
],
[
174,
173
],
[
142,
176
],
[
170,
178
],
[
185,
182
],
[
151,
183
],
[
173,
184
],
[
151,
186
],
[
173,
188
],
[
170,
189
],
[
192,
191
],
[
285,
192
],
[
195,
194
],
[
142,
198
],
[
151,
202
],
[
194,
203
],
[
206,
205
],
[
191,
208
],
[
205,
208
],
[
142,
213
],
[
194,
214
],
[
194,
215
],
[
194,
217
],
[
142,
219
],
[
194,
220
],
[
205,
226
],
[
191,
226
],
[
243,
237
],
[
245,
246
],
[
251,
252
],
[
275,
276
],
[
284,
285
]
] |
[
"#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n k, t = LI()\n a = LI()\n dp = [0] * (k + 1)\n l = r = 0\n dp[0] = 1\n for ai in a:\n for i in range(k, ai - 1, -1):\n dp[i] |= dp[i - ai]\n ans = inf\n for i in range(k + 1):\n if dp[i]:\n ans = min(ans, max(k - i - i, i - (k - i)))\n if ans:\n print(ans - 1)\n else:\n print(0)\n\n return\n\n\n#main\nif __name__ == '__main__':\n solve()",
"from collections import defaultdict,deque",
"from heapq import heappush, heappop",
"from bisect import bisect_left, bisect_right",
"import sys, random, itertools, math",
"sys",
"random",
"itertools",
"math",
"sys.setrecursionlimit(10**5)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10**5",
"10",
"5",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"sqrt = math.sqrt",
"sqrt",
"math.sqrt",
"math",
"sqrt",
"def LI(): return list(map(int, input().split()))",
"LI",
"def LF(): return list(map(float, input().split()))",
"LF",
"def LI_(): return list(map(lambda x: int(x)-1, input().split()))",
"LI_",
"def II(): return int(input())",
"II",
"def IF(): return float(input())",
"IF",
"def S(): return input().rstrip()",
"S",
"def LS(): return S().split()",
"LS",
"II() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"II()",
"II",
"def IR(n): return [II() for _ in range(n)]",
"IR",
"n",
"n",
"LI() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LI()",
"LI",
"def LIR(n): return [LI() for _ in range(n)]",
"LIR",
"n",
"n",
"IF() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"IF()",
"IF",
"def FR(n): return [IF() for _ in range(n)]",
"FR",
"n",
"n",
"LI() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LI()",
"LI",
"def LFR(n): return [LI() for _ in range(n)]",
"LFR",
"n",
"n",
"LI_() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LI_()",
"LI_",
"def LIR_(n): return [LI_() for _ in range(n)]",
"LIR_",
"n",
"n",
"S() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"S()",
"S",
"def SR(n): return [S() for _ in range(n)]",
"SR",
"n",
"n",
"LS() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"LS()",
"LS",
"def LSR(n): return [LS() for _ in range(n)]",
"LSR",
"n",
"n",
"mod = 1000000007",
"mod",
"1000000007",
"inf = 1e10",
"inf",
"1e10",
"def solve():\n k, t = LI()\n a = LI()\n dp = [0] * (k + 1)\n l = r = 0\n dp[0] = 1\n for ai in a:\n for i in range(k, ai - 1, -1):\n dp[i] |= dp[i - ai]\n ans = inf\n for i in range(k + 1):\n if dp[i]:\n ans = min(ans, max(k - i - i, i - (k - i)))\n if ans:\n print(ans - 1)\n else:\n print(0)\n\n return\n\n\n#main",
"solve",
"k, t = LI()",
"k",
"LI()",
"LI",
"t",
"a = LI()",
"a",
"LI()",
"LI",
"dp = [0] * (k + 1)",
"dp",
"[0] * (k + 1)",
"[0]",
"0",
"k + 1",
"k",
"1",
"l = r = 0",
"l",
"0",
"= r = 0",
"r",
"0",
"dp[0] = 1",
"dp[0]",
"dp",
"0",
"1",
"for ai in a:\n for i in range(k, ai - 1, -1):\n dp[i] |= dp[i - ai]\n ",
"ai",
"a",
"for i in range(k, ai - 1, -1):\n dp[i] |= dp[i - ai]\n ",
"i",
"range(k, ai - 1, -1)",
"range",
"k",
"ai - 1",
"ai",
"1",
"-1",
"dp[i] |= dp[i - ai]",
"dp[i]",
"dp",
"i",
"dp[i - ai]",
"dp",
"i - ai",
"i",
"ai",
"ans = inf",
"ans",
"inf",
"for i in range(k + 1):\n if dp[i]:\n ans = min(ans, max(k - i - i, i - (k - i)))\n ",
"i",
"range(k + 1)",
"range",
"k + 1",
"k",
"1",
"if dp[i]:\n ans = min(ans, max(k - i - i, i - (k - i)))\n ",
"dp[i]",
"dp",
"i",
"ans = min(ans, max(k - i - i, i - (k - i)))",
"ans",
"min(ans, max(k - i - i, i - (k - i)))",
"min",
"ans",
"max(k - i - i, i - (k - i))",
"max",
"k - i - i",
"k - i",
"k",
"i",
"i",
"i - (k - i)",
"i",
"k - i",
"k",
"i",
"if ans:\n print(ans - 1)\n else:\n print(0)\n\n ",
"ans",
"print(ans - 1)",
"print",
"ans - 1",
"ans",
"1",
"print(0)",
"print",
"0",
"return",
"if __name__ == '__main__':\n solve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"solve()",
"solve",
"def LI(): return list(map(int, input().split()))",
"def LI(): return list(map(int, input().split()))",
"LI",
"def solve():\n k, t = LI()\n a = LI()\n dp = [0] * (k + 1)\n l = r = 0\n dp[0] = 1\n for ai in a:\n for i in range(k, ai - 1, -1):\n dp[i] |= dp[i - ai]\n ans = inf\n for i in range(k + 1):\n if dp[i]:\n ans = min(ans, max(k - i - i, i - (k - i)))\n if ans:\n print(ans - 1)\n else:\n print(0)\n\n return\n\n\n#main",
"def solve():\n k, t = LI()\n a = LI()\n dp = [0] * (k + 1)\n l = r = 0\n dp[0] = 1\n for ai in a:\n for i in range(k, ai - 1, -1):\n dp[i] |= dp[i - ai]\n ans = inf\n for i in range(k + 1):\n if dp[i]:\n ans = min(ans, max(k - i - i, i - (k - i)))\n if ans:\n print(ans - 1)\n else:\n print(0)\n\n return\n\n\n#main",
"solve",
"sqrt = math.sqrt",
"math.sqrt",
"sqrt",
"def FR(n): return [IF() for _ in range(n)]",
"def FR(n): return [IF() for _ in range(n)]",
"FR",
"mod = 1000000007",
"1000000007",
"mod",
"def IF(): return float(input())",
"def IF(): return float(input())",
"IF",
"def LIR(n): return [LI() for _ in range(n)]",
"def LIR(n): return [LI() for _ in range(n)]",
"LIR",
"def LI_(): return list(map(lambda x: int(x)-1, input().split()))",
"def LI_(): return list(map(lambda x: int(x)-1, input().split()))",
"LI_",
"def SR(n): return [S() for _ in range(n)]",
"def SR(n): return [S() for _ in range(n)]",
"SR",
"def LIR_(n): return [LI_() for _ in range(n)]",
"def LIR_(n): return [LI_() for _ in range(n)]",
"LIR_",
"def S(): return input().rstrip()",
"def S(): return input().rstrip()",
"S",
"def LSR(n): return [LS() for _ in range(n)]",
"def LSR(n): return [LS() for _ in range(n)]",
"LSR",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"def LF(): return list(map(float, input().split()))",
"def LF(): return list(map(float, input().split()))",
"LF",
"def II(): return int(input())",
"def II(): return int(input())",
"II",
"inf = 1e10",
"1e10",
"inf",
"def LFR(n): return [LI() for _ in range(n)]",
"def LFR(n): return [LI() for _ in range(n)]",
"LFR",
"def IR(n): return [II() for _ in range(n)]",
"def IR(n): return [II() for _ in range(n)]",
"IR",
"def LS(): return S().split()",
"def LS(): return S().split()",
"LS"
] |
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
#solve
def solve():
k, t = LI()
a = LI()
dp = [0] * (k + 1)
l = r = 0
dp[0] = 1
for ai in a:
for i in range(k, ai - 1, -1):
dp[i] |= dp[i - ai]
ans = inf
for i in range(k + 1):
if dp[i]:
ans = min(ans, max(k - i - i, i - (k - i)))
if ans:
print(ans - 1)
else:
print(0)
return
#main
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,
0,
13,
4,
13,
13,
0,
13,
4,
13,
13,
14,
40,
2,
13,
13,
2,
13,
17,
4,
13,
17,
4,
13,
2,
2,
13,
17,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
64,
2
],
[
64,
11
],
[
67,
13
],
[
61,
25
],
[
68,
28
],
[
55,
30
],
[
68,
33
],
[
62,
37
],
[
56,
38
],
[
56,
40
],
[
56,
49
],
[
62,
52
],
[
56,
53
],
[
55,
56
],
[
64,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
]
] |
[
"k , t = map(int,input().split())\na = list(map(int,input().split()))\nsuma = sum(a)\nmaxa = max(a)\n\nif suma - maxa >= maxa - 1:\n print(0)\nelse:\n print(maxa - 1 - (suma-maxa))",
"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",
"suma = sum(a)",
"suma",
"sum(a)",
"sum",
"a",
"maxa = max(a)",
"maxa",
"max(a)",
"max",
"a",
"if suma - maxa >= maxa - 1:\n print(0)\nelse:\n print(maxa - 1 - (suma-maxa))",
"suma - maxa >= maxa - 1",
"suma - maxa",
"suma",
"maxa",
"maxa - 1",
"maxa",
"1",
"print(0)",
"print",
"0",
"print(maxa - 1 - (suma-maxa))",
"print",
"maxa - 1 - (suma-maxa)",
"maxa - 1",
"maxa",
"1",
"suma-maxa",
"suma",
"maxa",
"maxa = max(a)",
"max(a)",
"maxa",
"t = map(int,input().split())",
"map(int,input().split())",
"t",
"suma = sum(a)",
"sum(a)",
"suma",
"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()))
suma = sum(a)
maxa = max(a)
if suma - maxa >= maxa - 1:
print(0)
else:
print(maxa - 1 - (suma-maxa))
|
[
7,
15,
13,
15,
15,
12,
13,
15,
13,
15,
0,
13,
2,
4,
13,
17,
17,
0,
13,
4,
13,
17,
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,
4,
13,
13,
0,
13,
2,
13,
13,
4,
13,
4,
13,
17,
2,
2,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
4,
13,
17,
10,
17,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
12,
13
] |
[
[
104,
11
],
[
98,
18
],
[
27,
26
],
[
96,
30
],
[
26,
35
],
[
38,
37
],
[
38,
39
],
[
43,
42
],
[
96,
46
],
[
42,
51
],
[
54,
53
],
[
57,
56
],
[
53,
59
],
[
62,
61
],
[
37,
63
],
[
56,
64
],
[
56,
72
],
[
61,
73
],
[
92,
76
],
[
80,
79
],
[
93,
84
],
[
101,
87
],
[
108,
89
],
[
92,
93
],
[
98,
99
],
[
101,
102
],
[
104,
105
]
] |
[
"# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd, ceil, atan, pi\ndef input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')\nimport string\n# string.ascii_lowercase\nfrom bisect import bisect_left\nMOD = int(1e9)+7\nINF = float('inf')\n\n\ndef solve():\n # n, m = [int(x) for x in input().split()] \n k, t = [int(x) for x in input().split()] \n a = [int(x) for x in input().split()] \n\n mx = max(a)\n el = k - mx\n print(max(0, mx - el - 1))\n \nt = 1\n# t = int(input())\nfor case in range(1,t+1):\n ans = solve()\n\n\n\"\"\"\na b a\nd c d\na b a\n\"\"\"",
"import sys",
"sys",
"from collections import deque, defaultdict",
"from math import sqrt, factorial, gcd, ceil, atan, pi",
"def input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')",
"input",
"import string",
"string",
"from bisect import bisect_left",
"MOD = int(1e9)+7",
"MOD",
"int(1e9)+7",
"int(1e9)",
"int",
"1e9",
"7",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"def solve():\n # n, m = [int(x) for x in input().split()] \n k, t = [int(x) for x in input().split()] \n a = [int(x) for x in input().split()] \n\n mx = max(a)\n el = k - mx\n print(max(0, mx - el - 1))\n ",
"solve",
"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()]",
"mx = max(a)",
"mx",
"max(a)",
"max",
"a",
"el = k - mx",
"el",
"k - mx",
"k",
"mx",
"print(max(0, mx - el - 1))",
"print",
"max(0, mx - el - 1)",
"max",
"0",
"mx - el - 1",
"mx - el",
"mx",
"el",
"1",
"t = 1",
"t",
"1",
"for case in range(1,t+1):\n ans = solve()",
"case",
"range(1,t+1)",
"range",
"1",
"t+1",
"t",
"1",
"ans = solve()",
"ans",
"solve()",
"solve",
"\"\"\"\na b a\nd c d\na b a\n\"\"\"",
"t = 1",
"1",
"t",
"def input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')",
"def input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')",
"input",
"INF = float('inf')",
"float('inf')",
"INF",
"ans = solve()",
"solve()",
"ans",
"MOD = int(1e9)+7",
"int(1e9)+7",
"MOD",
"def solve():\n # n, m = [int(x) for x in input().split()] \n k, t = [int(x) for x in input().split()] \n a = [int(x) for x in input().split()] \n\n mx = max(a)\n el = k - mx\n print(max(0, mx - el - 1))\n ",
"def solve():\n # n, m = [int(x) for x in input().split()] \n k, t = [int(x) for x in input().split()] \n a = [int(x) for x in input().split()] \n\n mx = max(a)\n el = k - mx\n print(max(0, mx - el - 1))\n ",
"solve"
] |
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')
def solve():
# n, m = [int(x) for x in input().split()]
k, t = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
mx = max(a)
el = k - mx
print(max(0, mx - el - 1))
t = 1
# t = int(input())
for case in range(1,t+1):
ans = solve()
"""
a b a
d c d
a b a
"""
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
39,
18,
13,
13,
13,
0,
13,
17,
14,
2,
13,
17,
28,
13,
4,
13,
13,
4,
18,
13,
13,
0,
13,
17,
14,
2,
18,
18,
13,
17,
17,
13,
14,
2,
18,
18,
13,
17,
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,
18,
18,
13,
17,
17,
4,
13,
2,
18,
18,
13,
17,
17,
17,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] |
[
[
131,
2
],
[
131,
11
],
[
134,
13
],
[
26,
25
],
[
132,
28
],
[
33,
30
],
[
135,
31
],
[
25,
32
],
[
135,
35
],
[
25,
36
],
[
119,
39
],
[
132,
43
],
[
47,
46
],
[
123,
49
],
[
135,
52
],
[
56,
55
],
[
135,
61
],
[
120,
64
],
[
126,
64
],
[
129,
64
],
[
135,
69
],
[
80,
75
],
[
135,
77
],
[
128,
82
],
[
135,
85
],
[
94,
89
],
[
135,
91
],
[
125,
96
],
[
135,
99
],
[
135,
106
],
[
135,
114
],
[
119,
120
],
[
131,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
]
] |
[
"k,t=map(int,input().split())\na=list(map(int,input().split()))\nfor i in range(t):\n a[i]=[a[i],i]\nprev=-1\nif t>1:\n for i in range(k):\n a.sort(reverse=True)\n if a[0][1]==prev:\n if a[1][0]==0:\n break\n else:\n a[1][0]-=1\n prev=a[1][1]\n else:\n a[0][0]-=1\n prev=a[0][1]\n print(a[0][0])\nelse:\n print(a[0][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",
"for i in range(t):\n a[i]=[a[i],i]",
"i",
"range(t)",
"range",
"t",
"a[i]=[a[i],i]",
"a[i]",
"a",
"i",
"[a[i],i]",
"a[i]",
"a",
"i",
"i",
"prev=-1",
"prev",
"-1",
"if t>1:\n for i in range(k):\n a.sort(reverse=True)\n if a[0][1]==prev:\n if a[1][0]==0:\n break\n else:\n a[1][0]-=1\n prev=a[1][1]\n else:\n a[0][0]-=1\n prev=a[0][1]\n print(a[0][0])\nelse:\n print(a[0][0]-1)",
"t>1",
"t",
"1",
"for i in range(k):\n a.sort(reverse=True)\n if a[0][1]==prev:\n if a[1][0]==0:\n break\n else:\n a[1][0]-=1\n prev=a[1][1]\n else:\n a[0][0]-=1\n prev=a[0][1]\n ",
"i",
"range(k)",
"range",
"k",
"a.sort(reverse=True)",
"a.sort",
"a",
"sort",
"reverse=True",
"reverse",
"True",
"if a[0][1]==prev:\n if a[1][0]==0:\n break\n else:\n a[1][0]-=1\n prev=a[1][1]\n else:\n a[0][0]-=1\n prev=a[0][1]\n ",
"a[0][1]==prev",
"a[0][1]",
"[0]",
"a",
"0",
"1",
"prev",
"if a[1][0]==0:\n break\n else:\n a[1][0]-=1\n prev=a[1][1]\n ",
"a[1][0]==0",
"a[1][0]",
"[1]",
"a",
"1",
"0",
"0",
"break",
"a[1][0]-=1",
"a[1][0]",
"[1]",
"a",
"1",
"0",
"1",
"prev=a[1][1]",
"prev",
"a[1][1]",
"[1]",
"a",
"1",
"1",
"a[0][0]-=1",
"a[0][0]",
"[0]",
"a",
"0",
"0",
"1",
"prev=a[0][1]",
"prev",
"a[0][1]",
"[0]",
"a",
"0",
"1",
"print(a[0][0])",
"print",
"a[0][0]",
"[0]",
"a",
"0",
"0",
"print(a[0][0]-1)",
"print",
"a[0][0]-1",
"a[0][0]",
"[0]",
"a",
"0",
"0",
"1",
"prev=-1",
"-1",
"prev",
"k,t=map(int,input().split())",
"map(int,input().split())",
"k",
"prev=a[0][1]",
"a[0][1]",
"prev",
"prev=a[1][1]",
"a[1][1]",
"prev",
"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()))
for i in range(t):
a[i]=[a[i],i]
prev=-1
if t>1:
for i in range(k):
a.sort(reverse=True)
if a[0][1]==prev:
if a[1][0]==0:
break
else:
a[1][0]-=1
prev=a[1][1]
else:
a[0][0]-=1
prev=a[0][1]
print(a[0][0])
else:
print(a[0][0]-1)
|
[
7,
15,
12,
13,
15,
13,
0,
13,
18,
13,
13,
4,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
17,
4,
13,
13,
0,
13,
13,
4,
18,
13,
13,
13,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
14,
2,
2,
13,
17,
17,
4,
18,
13,
13,
13,
2,
13,
17,
14,
2,
2,
13,
17,
17,
4,
18,
13,
13,
13,
2,
13,
17,
14,
2,
4,
13,
13,
17,
4,
13,
17,
4,
13,
4,
13,
2,
18,
13,
17,
17,
4,
13,
10,
12,
13
] |
[
[
8,
7
],
[
7,
12
],
[
16,
15
],
[
7,
19
],
[
15,
26
],
[
29,
28
],
[
28,
34
],
[
28,
39
],
[
43,
42
],
[
28,
47
],
[
50,
49
],
[
28,
54
],
[
42,
58
],
[
28,
65
],
[
42,
67
],
[
49,
72
],
[
28,
79
],
[
49,
81
],
[
28,
87
],
[
28,
98
],
[
105,
102
]
] |
[
"from sys import stdin\n\ndef main():\n import heapq\n input = stdin.readline\n input()\n a = [-1 * int(i) for i in input().split()]\n heapq.heapify(a)\n while len(a) > 1:\n u = heapq.heappop(a)\n v = heapq.heappop(a)\n if u + 1 < 0:\n heapq.heappush(a, u + 1)\n if v + 1 < 0:\n heapq.heappush(a, v + 1)\n if len(a) == 0:\n print(0)\n else:\n print(abs(a[0] + 1))\nmain()",
"from sys import stdin",
"def main():\n import heapq\n input = stdin.readline\n input()\n a = [-1 * int(i) for i in input().split()]\n heapq.heapify(a)\n while len(a) > 1:\n u = heapq.heappop(a)\n v = heapq.heappop(a)\n if u + 1 < 0:\n heapq.heappush(a, u + 1)\n if v + 1 < 0:\n heapq.heappush(a, v + 1)\n if len(a) == 0:\n print(0)\n else:\n print(abs(a[0] + 1))",
"main",
"import heapq",
"heapq",
"input = stdin.readline",
"input",
"stdin.readline",
"stdin",
"readline",
"input()",
"input",
"-1 * int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"-1 * int(i)",
"-1",
"int(i)",
"int",
"i",
"a = [-1 * int(i) for i in input().split()]",
"a",
"[-1 * int(i) for i in input().split()]",
"heapq.heapify(a)",
"heapq.heapify",
"heapq",
"heapify",
"a",
"while len(a) > 1:\n u = heapq.heappop(a)\n v = heapq.heappop(a)\n if u + 1 < 0:\n heapq.heappush(a, u + 1)\n if v + 1 < 0:\n heapq.heappush(a, v + 1)\n ",
"len(a) > 1",
"len(a)",
"len",
"a",
"1",
"u = heapq.heappop(a)",
"u",
"heapq.heappop(a)",
"heapq.heappop",
"heapq",
"heappop",
"a",
"v = heapq.heappop(a)",
"v",
"heapq.heappop(a)",
"heapq.heappop",
"heapq",
"heappop",
"a",
"if u + 1 < 0:\n heapq.heappush(a, u + 1)\n ",
"u + 1 < 0",
"u + 1",
"u",
"1",
"0",
"heapq.heappush(a, u + 1)",
"heapq.heappush",
"heapq",
"heappush",
"a",
"u + 1",
"u",
"1",
"if v + 1 < 0:\n heapq.heappush(a, v + 1)\n ",
"v + 1 < 0",
"v + 1",
"v",
"1",
"0",
"heapq.heappush(a, v + 1)",
"heapq.heappush",
"heapq",
"heappush",
"a",
"v + 1",
"v",
"1",
"if len(a) == 0:\n print(0)\n else:\n print(abs(a[0] + 1))",
"len(a) == 0",
"len(a)",
"len",
"a",
"0",
"print(0)",
"print",
"0",
"print(abs(a[0] + 1))",
"print",
"abs(a[0] + 1)",
"abs",
"a[0] + 1",
"a[0]",
"a",
"0",
"1",
"main()",
"main",
"def main():\n import heapq\n input = stdin.readline\n input()\n a = [-1 * int(i) for i in input().split()]\n heapq.heapify(a)\n while len(a) > 1:\n u = heapq.heappop(a)\n v = heapq.heappop(a)\n if u + 1 < 0:\n heapq.heappush(a, u + 1)\n if v + 1 < 0:\n heapq.heappush(a, v + 1)\n if len(a) == 0:\n print(0)\n else:\n print(abs(a[0] + 1))",
"def main():\n import heapq\n input = stdin.readline\n input()\n a = [-1 * int(i) for i in input().split()]\n heapq.heapify(a)\n while len(a) > 1:\n u = heapq.heappop(a)\n v = heapq.heappop(a)\n if u + 1 < 0:\n heapq.heappush(a, u + 1)\n if v + 1 < 0:\n heapq.heappush(a, v + 1)\n if len(a) == 0:\n print(0)\n else:\n print(abs(a[0] + 1))",
"main"
] |
from sys import stdin
def main():
import heapq
input = stdin.readline
input()
a = [-1 * int(i) for i in input().split()]
heapq.heapify(a)
while len(a) > 1:
u = heapq.heappop(a)
v = heapq.heappop(a)
if u + 1 < 0:
heapq.heappush(a, u + 1)
if v + 1 < 0:
heapq.heappush(a, v + 1)
if len(a) == 0:
print(0)
else:
print(abs(a[0] + 1))
main()
|
[
7,
15,
13,
15,
15,
13,
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,
4,
18,
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,
2,
13
] |
[
[
65,
9
],
[
65,
18
],
[
56,
20
],
[
57,
33
],
[
59,
36
],
[
57,
39
],
[
68,
41
],
[
63,
43
],
[
60,
44
],
[
60,
51
],
[
69,
53
],
[
56,
57
],
[
59,
60
],
[
65,
63
],
[
65,
66
],
[
68,
69
]
] |
[
"# coding: utf-8\nimport math\nfrom collections import deque\nimport copy\nimport bisect\nk, n = map(int,input().split())\nA = list(map(int,input().split()))\nA.sort()\nm=max(A)\ns=k-m\nprint(max(m-1-s, 0))",
"import math",
"math",
"from collections import deque",
"import copy",
"copy",
"import bisect",
"bisect",
"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.sort()",
"A.sort",
"A",
"sort",
"m=max(A)",
"m",
"max(A)",
"max",
"A",
"s=k-m",
"s",
"k-m",
"k",
"m",
"print(max(m-1-s, 0))",
"print",
"max(m-1-s, 0)",
"max",
"m-1-s",
"m-1",
"m",
"1",
"s",
"0",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"m=max(A)",
"max(A)",
"m",
"k, n = map(int,input().split())",
"map(int,input().split())",
"k",
"n = map(int,input().split())",
"map(int,input().split())",
"n",
"s=k-m",
"k-m",
"s"
] |
# coding: utf-8
import math
from collections import deque
import copy
import bisect
k, n = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
m=max(A)
s=k-m
print(max(m-1-s, 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,
4,
13,
13,
14,
40,
4,
13,
13,
2,
13,
17,
4,
13,
17,
14,
40,
4,
13,
13,
2,
2,
13,
17,
17,
4,
13,
2,
4,
13,
13,
2,
13,
17,
4,
13,
2,
2,
2,
13,
4,
13,
13,
13,
17,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] |
[
[
84,
2
],
[
84,
11
],
[
81,
13
],
[
78,
25
],
[
82,
29
],
[
82,
32
],
[
82,
37
],
[
79,
39
],
[
82,
48
],
[
79,
51
],
[
82,
59
],
[
79,
61
],
[
79,
68
],
[
82,
71
],
[
79,
72
],
[
84,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
]
] |
[
"k,t=map(int,input().split())\na=list(map(int,input().split()))\nnum=sum(a)-max(a)\nif max(a)<=num+1:\n print(0)\nelse:\n if max(a)<=(num+1)*2:\n print(max(a)-(num+1))\n else:\n print(num+max(a)-num-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",
"num=sum(a)-max(a)",
"num",
"sum(a)-max(a)",
"sum(a)",
"sum",
"a",
"max(a)",
"max",
"a",
"if max(a)<=num+1:\n print(0)\nelse:\n if max(a)<=(num+1)*2:\n print(max(a)-(num+1))\n else:\n print(num+max(a)-num-1)",
"max(a)<=num+1",
"max(a)",
"max",
"a",
"num+1",
"num",
"1",
"print(0)",
"print",
"0",
"if max(a)<=(num+1)*2:\n print(max(a)-(num+1))\n else:\n print(num+max(a)-num-1)",
"max(a)<=(num+1)*2",
"max(a)",
"max",
"a",
"(num+1)*2",
"num+1",
"num",
"1",
"2",
"print(max(a)-(num+1))",
"print",
"max(a)-(num+1)",
"max(a)",
"max",
"a",
"num+1",
"num",
"1",
"print(num+max(a)-num-1)",
"print",
"num+max(a)-num-1",
"num+max(a)-num",
"num+max(a)",
"num",
"max(a)",
"max",
"a",
"num",
"1",
"k,t=map(int,input().split())",
"map(int,input().split())",
"k",
"num=sum(a)-max(a)",
"sum(a)-max(a)",
"num",
"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()))
num=sum(a)-max(a)
if max(a)<=num+1:
print(0)
else:
if max(a)<=(num+1)*2:
print(max(a)-(num+1))
else:
print(num+max(a)-num-1)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
4,
13,
4,
13,
2,
2,
2,
4,
13,
13,
17,
17,
13,
17,
10,
4,
13,
10,
4,
13
] |
[
[
36,
2
],
[
36,
15
],
[
36,
16
],
[
37,
30
],
[
36,
34
],
[
36,
37
]
] |
[
"#!/usr/bin/env python3\nk, t, *a = map(int, open(0).read().split())\nprint(max(max(a)*2 - 1 - k, 0))",
"k, t, *a = map(int, open(0).read().split())",
"k",
"map(int, open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"t",
"*a",
"a",
"print(max(max(a)*2 - 1 - k, 0))",
"print",
"max(max(a)*2 - 1 - k, 0)",
"max",
"max(a)*2 - 1 - k",
"max(a)*2 - 1",
"max(a)*2",
"max(a)",
"max",
"a",
"2",
"1",
"k",
"0",
"t, *a = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"t",
"k, t, *a = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"k"
] |
#!/usr/bin/env python3
k, t, *a = map(int, open(0).read().split())
print(max(max(a)*2 - 1 - k, 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,
39,
28,
13,
13,
4,
13,
13,
4,
18,
13,
13,
39,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
13,
17,
4,
13,
2,
13,
17,
28,
13,
4,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
14,
2,
2,
13,
18,
18,
13,
17,
17,
40,
18,
18,
13,
17,
17,
17,
0,
18,
18,
13,
17,
17,
17,
0,
13,
18,
18,
13,
17,
17,
14,
2,
2,
18,
18,
13,
17,
17,
17,
2,
18,
18,
13,
17,
17,
17,
3,
0,
18,
18,
13,
17,
17,
17,
14,
2,
13,
18,
18,
13,
17,
17,
0,
13,
17,
0,
13,
18,
18,
13,
17,
17,
14,
2,
2,
18,
18,
13,
17,
17,
17,
2,
18,
18,
13,
17,
17,
17,
3,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
17,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] |
[
[
179,
2
],
[
179,
11
],
[
182,
13
],
[
167,
25
],
[
183,
32
],
[
168,
35
],
[
164,
41
],
[
170,
44
],
[
162,
48
],
[
180,
53
],
[
57,
56
],
[
180,
59
],
[
168,
64
],
[
67,
66
],
[
165,
71
],
[
177,
71
],
[
174,
71
],
[
168,
74
],
[
168,
80
],
[
90,
85
],
[
168,
87
],
[
173,
92
],
[
168,
95
],
[
168,
103
],
[
168,
110
],
[
121,
116
],
[
168,
118
],
[
165,
124
],
[
177,
124
],
[
174,
124
],
[
168,
127
],
[
185,
131
],
[
176,
134
],
[
168,
137
],
[
168,
145
],
[
168,
152
],
[
186,
159
],
[
171,
159
],
[
179,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
],
[
173,
174
],
[
176,
177
],
[
179,
180
],
[
182,
183
],
[
185,
186
]
] |
[
"K,T=map(int,input().split())\na=list(map(int,input().split()))\nb=[]\n\nfor i,an in enumerate(a):\n b.append([an,i])\nex = -1\nans = 0\n\nif T == 1:\n\tprint(K-1)\nelse:\n for i in range(K):\n list.sort(b, reverse=True)\n if ex == b[0][1] and b[1][0] != 0:\n b[1][0] -= 1\n ex = b[1][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n else:\n b[0][0] -= 1\n if ex == b[0][1]:\n ans+=1\n ex = b[0][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n print(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",
"b=[]",
"b",
"[]",
"for i,an in enumerate(a):\n b.append([an,i])",
"i",
"an",
"enumerate(a)",
"enumerate",
"a",
"b.append([an,i])",
"b.append",
"b",
"append",
"[an,i]",
"an",
"i",
"ex = -1",
"ex",
"-1",
"ans = 0",
"ans",
"0",
"if T == 1:\n\tprint(K-1)\nelse:\n for i in range(K):\n list.sort(b, reverse=True)\n if ex == b[0][1] and b[1][0] != 0:\n b[1][0] -= 1\n ex = b[1][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n else:\n b[0][0] -= 1\n if ex == b[0][1]:\n ans+=1\n ex = b[0][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n print(ans)",
"T == 1",
"T",
"1",
"print(K-1)",
"print",
"K-1",
"K",
"1",
"for i in range(K):\n list.sort(b, reverse=True)\n if ex == b[0][1] and b[1][0] != 0:\n b[1][0] -= 1\n ex = b[1][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n else:\n b[0][0] -= 1\n if ex == b[0][1]:\n ans+=1\n ex = b[0][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n ",
"i",
"range(K)",
"range",
"K",
"list.sort(b, reverse=True)",
"list.sort",
"list",
"sort",
"b",
"reverse=True",
"reverse",
"True",
"if ex == b[0][1] and b[1][0] != 0:\n b[1][0] -= 1\n ex = b[1][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n else:\n b[0][0] -= 1\n if ex == b[0][1]:\n ans+=1\n ex = b[0][1]\n if b[0][1] == 0 and b[1][1] == 0:\n break\n ",
"ex == b[0][1] and b[1][0] != 0",
"ex == b[0][1]",
"ex",
"b[0][1]",
"[0]",
"b",
"0",
"1",
"b[1][0] != 0",
"b[1][0]",
"[1]",
"b",
"1",
"0",
"0",
"b[1][0] -= 1",
"b[1][0]",
"[1]",
"b",
"1",
"0",
"1",
"ex = b[1][1]",
"ex",
"b[1][1]",
"[1]",
"b",
"1",
"1",
"if b[0][1] == 0 and b[1][1] == 0:\n break\n ",
"b[0][1] == 0 and b[1][1] == 0",
"b[0][1] == 0",
"b[0][1]",
"[0]",
"b",
"0",
"1",
"0",
"b[1][1] == 0",
"b[1][1]",
"[1]",
"b",
"1",
"1",
"0",
"break",
"b[0][0] -= 1",
"b[0][0]",
"[0]",
"b",
"0",
"0",
"1",
"if ex == b[0][1]:\n ans+=1\n ",
"ex == b[0][1]",
"ex",
"b[0][1]",
"[0]",
"b",
"0",
"1",
"ans+=1",
"ans",
"1",
"ex = b[0][1]",
"ex",
"b[0][1]",
"[0]",
"b",
"0",
"1",
"if b[0][1] == 0 and b[1][1] == 0:\n break\n ",
"b[0][1] == 0 and b[1][1] == 0",
"b[0][1] == 0",
"b[0][1]",
"[0]",
"b",
"0",
"1",
"0",
"b[1][1] == 0",
"b[1][1]",
"[1]",
"b",
"1",
"1",
"0",
"break",
"print(ans)",
"print",
"ans",
"T=map(int,input().split())",
"map(int,input().split())",
"T",
"ex = -1",
"-1",
"ex",
"b=[]",
"[]",
"b",
"ans = 0",
"0",
"ans",
"ex = b[1][1]",
"b[1][1]",
"ex",
"ex = b[0][1]",
"b[0][1]",
"ex",
"K,T=map(int,input().split())",
"map(int,input().split())",
"K",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"ans+=1",
"1",
"ans"
] |
K,T=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i,an in enumerate(a):
b.append([an,i])
ex = -1
ans = 0
if T == 1:
print(K-1)
else:
for i in range(K):
list.sort(b, reverse=True)
if ex == b[0][1] and b[1][0] != 0:
b[1][0] -= 1
ex = b[1][1]
if b[0][1] == 0 and b[1][1] == 0:
break
else:
b[0][0] -= 1
if ex == b[0][1]:
ans+=1
ex = b[0][1]
if b[0][1] == 0 and b[1][1] == 0:
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,
0,
13,
4,
13,
13,
4,
13,
4,
13,
17,
2,
2,
13,
17,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
50,
2
],
[
50,
11
],
[
56,
13
],
[
59,
25
],
[
57,
28
],
[
53,
30
],
[
57,
33
],
[
60,
41
],
[
54,
44
],
[
60,
45
],
[
50,
48
],
[
50,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] |
[
"k, t = map(int, input().split())\na = list(map(int, input().split()))\n\nmaxi = max(a)\nwa = sum(a)\nprint(max(0, maxi-1-(wa-maxi)))",
"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",
"wa = sum(a)",
"wa",
"sum(a)",
"sum",
"a",
"print(max(0, maxi-1-(wa-maxi)))",
"print",
"max(0, maxi-1-(wa-maxi))",
"max",
"0",
"maxi-1-(wa-maxi)",
"maxi-1",
"maxi",
"1",
"wa-maxi",
"wa",
"maxi",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"wa = sum(a)",
"sum(a)",
"wa",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"maxi = max(a)",
"max(a)",
"maxi"
] |
k, t = map(int, input().split())
a = list(map(int, input().split()))
maxi = max(a)
wa = sum(a)
print(max(0, maxi-1-(wa-maxi)))
|
[
7,
15,
13,
13,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
13,
13,
0,
13,
2,
4,
13,
13,
13,
4,
13,
4,
13,
17,
2,
2,
13,
13,
17,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13
] |
[
[
25,
24
],
[
87,
30
],
[
34,
34
],
[
104,
43
],
[
116,
48
],
[
119,
55
],
[
87,
57
],
[
119,
58
],
[
95,
60
],
[
90,
62
],
[
110,
64
],
[
96,
67
],
[
113,
69
],
[
96,
73
],
[
111,
74
],
[
111,
82
],
[
114,
83
],
[
95,
96
],
[
104,
105
],
[
119,
108
],
[
110,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
]
] |
[
"import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import accumulate, permutations, combinations, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom fractions import gcd\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nK, T = MAP()\na = LIST()\nma = max(a)\nleft = sum(a)-ma\nprint(max(0, ma-left-1))",
"import sys, re",
"sys",
"re",
"from collections import deque, defaultdict, Counter",
"from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians",
"from itertools import accumulate, permutations, combinations, product, groupby",
"from operator import itemgetter, mul",
"from copy import deepcopy",
"from string import ascii_lowercase, ascii_uppercase, digits",
"from bisect import bisect, bisect_left",
"from fractions import gcd",
"from heapq import heappush, heappop",
"from functools import reduce",
"def input(): return sys.stdin.readline().strip()",
"input",
"def INT(): return int(input())",
"INT",
"def MAP(): return map(int, input().split())",
"MAP",
"def LIST(): return list(map(int, input().split()))",
"LIST",
"MAP() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"MAP()",
"MAP",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"n",
"n",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"K, T = MAP()",
"K",
"MAP()",
"MAP",
"T",
"a = LIST()",
"a",
"LIST()",
"LIST",
"ma = max(a)",
"ma",
"max(a)",
"max",
"a",
"left = sum(a)-ma",
"left",
"sum(a)-ma",
"sum(a)",
"sum",
"a",
"ma",
"print(max(0, ma-left-1))",
"print",
"max(0, ma-left-1)",
"max",
"0",
"ma-left-1",
"ma-left",
"ma",
"left",
"1",
"def MAP(): return map(int, input().split())",
"def MAP(): return map(int, input().split())",
"MAP",
"def LIST(): return list(map(int, input().split()))",
"def LIST(): return list(map(int, input().split()))",
"LIST",
"def INT(): return int(input())",
"def INT(): return int(input())",
"INT",
"a = LIST()",
"LIST()",
"a",
"def input(): return sys.stdin.readline().strip()",
"def input(): return sys.stdin.readline().strip()",
"input",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"def ZIP(n): return zip(*(MAP() for _ in range(n)))",
"ZIP",
"INF = float('inf')",
"float('inf')",
"INF",
"K, T = MAP()",
"MAP()",
"K",
"ma = max(a)",
"max(a)",
"ma",
"left = sum(a)-ma",
"sum(a)-ma",
"left",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod",
"T = MAP()",
"MAP()",
"T"
] |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
K, T = MAP()
a = LIST()
ma = max(a)
left = sum(a)-ma
print(max(0, ma-left-1))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
13,
4,
13,
17,
2,
2,
17,
2,
4,
13,
13,
2,
2,
13,
17,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
49,
2
],
[
49,
11
],
[
43,
13
],
[
44,
35
],
[
50,
38
],
[
43,
44
],
[
49,
47
],
[
49,
50
]
] |
[
"#!/usr/bin/env python3\nk,t = map(int,input().split())\t\na = list(map(int,input().split()))\nprint(max(0,2*(max(a)-(k+1)//2)-1))",
"k,t = map(int,input().split())",
"k",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"print(max(0,2*(max(a)-(k+1)//2)-1))",
"print",
"max(0,2*(max(a)-(k+1)//2)-1)",
"max",
"0",
"2*(max(a)-(k+1)//2)-1",
"2*(max(a)-(k+1)//2)",
"2",
"max(a)-(k+1)//2",
"max(a)",
"max",
"a",
"(k+1)//2",
"k+1",
"k",
"1",
"2",
"1",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"t = map(int,input().split())",
"map(int,input().split())",
"t",
"k,t = map(int,input().split())",
"map(int,input().split())",
"k"
] |
#!/usr/bin/env python3
k,t = map(int,input().split())
a = list(map(int,input().split()))
print(max(0,2*(max(a)-(k+1)//2)-1))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
4,
13,
4,
13,
2,
2,
2,
17,
4,
13,
13,
13,
17,
17,
10,
4,
13,
10,
4,
13
] |
[
[
36,
2
],
[
36,
15
],
[
36,
16
],
[
37,
29
],
[
36,
34
],
[
36,
37
]
] |
[
"k,t,*A=map(int,open(0).read().split());print(max(2*max(A)-k-1,0))",
"k,t,*A=map(int,open(0).read().split())",
"k",
"map(int,open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"t",
"*A",
"A",
"print(max(2*max(A)-k-1,0))",
"print",
"max(2*max(A)-k-1,0)",
"max",
"2*max(A)-k-1",
"2*max(A)-k",
"2*max(A)",
"2",
"max(A)",
"max",
"A",
"k",
"1",
"0",
"t,*A=map(int,open(0).read().split())",
"map(int,open(0).read().split())",
"t",
"k,t,*A=map(int,open(0).read().split())",
"map(int,open(0).read().split())",
"k"
] |
k,t,*A=map(int,open(0).read().split());print(max(2*max(A)-k-1,0))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
4,
13,
13,
17,
17,
14,
40,
2,
13,
13,
17,
0,
18,
13,
13,
2,
18,
13,
13,
18,
13,
2,
13,
13,
0,
13,
17,
28,
13,
13,
4,
13,
13,
14,
40,
13,
9,
0,
13,
8,
2,
4,
13,
2,
13,
2,
13,
17,
4,
13,
2,
13,
2,
13,
17,
13,
13,
14,
40,
4,
13,
2,
2,
17,
13,
13,
17,
4,
13,
17,
4,
13,
2,
4,
13,
2,
2,
17,
13,
13,
17,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
8,
13,
10,
2,
13
] |
[
[
136,
2
],
[
136,
11
],
[
15,
14
],
[
14,
23
],
[
127,
25
],
[
142,
28
],
[
134,
33
],
[
39,
36
],
[
143,
37
],
[
42,
41
],
[
128,
41
],
[
45,
44
],
[
134,
47
],
[
44,
53
],
[
41,
54
],
[
60,
57
],
[
143,
58
],
[
44,
59
],
[
57,
61
],
[
143,
62
],
[
44,
63
],
[
143,
65
],
[
44,
67
],
[
41,
68
],
[
130,
70
],
[
143,
77
],
[
139,
83
],
[
134,
91
],
[
131,
96
],
[
140,
96
],
[
134,
98
],
[
131,
101
],
[
140,
101
],
[
140,
109
],
[
131,
109
],
[
134,
110
],
[
140,
123
],
[
131,
123
],
[
134,
124
],
[
127,
128
],
[
130,
131
],
[
136,
134
],
[
136,
137
],
[
139,
140
],
[
142,
143
]
] |
[
"K, T = map(int, input().split())\nnumbers = [int(x) for x in input().split()]\n\ntable = [False] * (K + 1)\n\ntable[0] = True\n\nfor n in numbers:\n for i in range(K, 0, -1):\n if i - n >= 0:\n table[i] = table[i] or table[i - n]\n \nm = 0\n\nfor i, t in enumerate(table):\n if not t:\n continue\n m = i if abs(i - K / 2) < abs(m - K / 2) else m\n\nif abs(2 * m - K) <= 1:\n print(0)\nelse:\n print(abs(2 * m - K) - 1)",
"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",
"numbers = [int(x) for x in input().split()]",
"numbers",
"[int(x) for x in input().split()]",
"table = [False] * (K + 1)",
"table",
"[False] * (K + 1)",
"[False]",
"False",
"K + 1",
"K",
"1",
"table[0] = True",
"table[0]",
"table",
"0",
"True",
"for n in numbers:\n for i in range(K, 0, -1):\n if i - n >= 0:\n table[i] = table[i] or table[i - n]\n ",
"n",
"numbers",
"for i in range(K, 0, -1):\n if i - n >= 0:\n table[i] = table[i] or table[i - n]\n ",
"i",
"range(K, 0, -1)",
"range",
"K",
"0",
"-1",
"if i - n >= 0:\n table[i] = table[i] or table[i - n]\n ",
"i - n >= 0",
"i - n",
"i",
"n",
"0",
"table[i] = table[i] or table[i - n]",
"table[i]",
"table",
"i",
"table[i] or table[i - n]",
"table[i]",
"table",
"i",
"table[i - n]",
"table",
"i - n",
"i",
"n",
"m = 0",
"m",
"0",
"for i, t in enumerate(table):\n if not t:\n continue\n m = i if abs(i - K / 2) < abs(m - K / 2) else m",
"i",
"t",
"enumerate(table)",
"enumerate",
"table",
"if not t:\n continue\n ",
"not t",
"t",
"continue",
"m = i if abs(i - K / 2) < abs(m - K / 2) else m",
"m",
"i if abs(i - K / 2) < abs(m - K / 2) else m",
"abs(i - K / 2) < abs(m - K / 2)",
"abs(i - K / 2)",
"abs",
"i - K / 2",
"i",
"K / 2",
"K",
"2",
"abs(m - K / 2)",
"abs",
"m - K / 2",
"m",
"K / 2",
"K",
"2",
"i",
"m",
"if abs(2 * m - K) <= 1:\n print(0)\nelse:\n print(abs(2 * m - K) - 1)",
"abs(2 * m - K) <= 1",
"abs(2 * m - K)",
"abs",
"2 * m - K",
"2 * m",
"2",
"m",
"K",
"1",
"print(0)",
"print",
"0",
"print(abs(2 * m - K) - 1)",
"print",
"abs(2 * m - K) - 1",
"abs(2 * m - K)",
"abs",
"2 * m - K",
"2 * m",
"2",
"m",
"K",
"1",
"numbers = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"numbers",
"m = 0",
"0",
"m",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"m = i if abs(i - K / 2) < abs(m - K / 2) else m",
"i if abs(i - K / 2) < abs(m - K / 2) else m",
"m",
"table = [False] * (K + 1)",
"[False] * (K + 1)",
"table"
] |
K, T = map(int, input().split())
numbers = [int(x) for x in input().split()]
table = [False] * (K + 1)
table[0] = True
for n in numbers:
for i in range(K, 0, -1):
if i - n >= 0:
table[i] = table[i] or table[i - n]
m = 0
for i, t in enumerate(table):
if not t:
continue
m = i if abs(i - K / 2) < abs(m - K / 2) else m
if abs(2 * m - K) <= 1:
print(0)
else:
print(abs(2 * m - K) - 1)
|
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
4,
13,
13,
17,
23,
4,
18,
4,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
17,
14,
2,
4,
13,
13,
17,
0,
13,
2,
13,
17,
3,
14,
2,
13,
18,
13,
17,
0,
13,
17,
0,
13,
17,
14,
40,
13,
17,
4,
18,
13,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
17,
4,
18,
13,
13,
13,
13,
14,
40,
13,
17,
4,
18,
13,
13,
13,
13,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13
] |
[
[
151,
4
],
[
151,
15
],
[
142,
17
],
[
143,
38
],
[
136,
40
],
[
157,
43
],
[
47,
46
],
[
152,
49
],
[
139,
53
],
[
143,
58
],
[
169,
60
],
[
143,
66
],
[
175,
69
],
[
170,
71
],
[
140,
71
],
[
167,
71
],
[
170,
76
],
[
140,
76
],
[
167,
76
],
[
143,
78
],
[
163,
81
],
[
145,
84
],
[
170,
88
],
[
140,
88
],
[
167,
88
],
[
143,
94
],
[
170,
95
],
[
140,
95
],
[
167,
95
],
[
166,
97
],
[
143,
102
],
[
160,
104
],
[
143,
109
],
[
154,
111
],
[
143,
117
],
[
167,
118
],
[
170,
118
],
[
140,
118
],
[
155,
121
],
[
161,
121
],
[
143,
127
],
[
155,
128
],
[
161,
128
],
[
172,
130
],
[
176,
134
],
[
137,
134
],
[
136,
137
],
[
139,
140
],
[
142,
143
],
[
145,
146
],
[
151,
149
],
[
151,
152
],
[
154,
155
],
[
157,
158
],
[
160,
161
],
[
163,
164
],
[
166,
167
],
[
169,
170
],
[
172,
173
],
[
175,
176
]
] |
[
"#https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b\n\nimport heapq\n\nk, t = list(map(int, input().split()))\ncakes = list(map(lambda x: int(x)*-1, input().split()))\nheapq.heapify(cakes)\nans = 0\ntop_change = True\nfor i in range(k):\n if top_change:\n first = heapq.heappop(cakes)\n first += 1\n if len(cakes) == 0:\n ans += first*-1\n break\n if first < cakes[0]:\n top_change = False\n else:\n top_change = True\n if first != 0:\n heapq.heappush(cakes, first)\n else:\n first = heapq.heappop(cakes)\n second = heapq.heappop(cakes)\n second += 1\n heapq.heappush(cakes, first)\n if second != 0:\n heapq.heappush(cakes, second)\n top_change = True\n\nprint(ans)\n",
"import heapq",
"heapq",
"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",
"cakes = list(map(lambda x: int(x)*-1, input().split()))",
"cakes",
"list(map(lambda x: int(x)*-1, input().split()))",
"list",
"map(lambda x: int(x)*-1, input().split())",
"map",
"lambda x: int(x)*-1",
"int(x)*-1",
"int(x)",
"int",
"x",
"-1",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"heapq.heapify(cakes)",
"heapq.heapify",
"heapq",
"heapify",
"cakes",
"ans = 0",
"ans",
"0",
"top_change = True",
"top_change",
"True",
"for i in range(k):\n if top_change:\n first = heapq.heappop(cakes)\n first += 1\n if len(cakes) == 0:\n ans += first*-1\n break\n if first < cakes[0]:\n top_change = False\n else:\n top_change = True\n if first != 0:\n heapq.heappush(cakes, first)\n else:\n first = heapq.heappop(cakes)\n second = heapq.heappop(cakes)\n second += 1\n heapq.heappush(cakes, first)\n if second != 0:\n heapq.heappush(cakes, second)\n top_change = True",
"i",
"range(k)",
"range",
"k",
"if top_change:\n first = heapq.heappop(cakes)\n first += 1\n if len(cakes) == 0:\n ans += first*-1\n break\n if first < cakes[0]:\n top_change = False\n else:\n top_change = True\n if first != 0:\n heapq.heappush(cakes, first)\n else:\n first = heapq.heappop(cakes)\n second = heapq.heappop(cakes)\n second += 1\n heapq.heappush(cakes, first)\n if second != 0:\n heapq.heappush(cakes, second)\n top_change = True",
"top_change",
"first = heapq.heappop(cakes)",
"first",
"heapq.heappop(cakes)",
"heapq.heappop",
"heapq",
"heappop",
"cakes",
"first += 1",
"first",
"1",
"if len(cakes) == 0:\n ans += first*-1\n break\n ",
"len(cakes) == 0",
"len(cakes)",
"len",
"cakes",
"0",
"ans += first*-1",
"ans",
"first*-1",
"first",
"-1",
"break",
"if first < cakes[0]:\n top_change = False\n else:\n top_change = True\n ",
"first < cakes[0]",
"first",
"cakes[0]",
"cakes",
"0",
"top_change = False",
"top_change",
"False",
"top_change = True",
"top_change",
"True",
"if first != 0:\n heapq.heappush(cakes, first)\n ",
"first != 0",
"first",
"0",
"heapq.heappush(cakes, first)",
"heapq.heappush",
"heapq",
"heappush",
"cakes",
"first",
"first = heapq.heappop(cakes)",
"first",
"heapq.heappop(cakes)",
"heapq.heappop",
"heapq",
"heappop",
"cakes",
"second = heapq.heappop(cakes)",
"second",
"heapq.heappop(cakes)",
"heapq.heappop",
"heapq",
"heappop",
"cakes",
"second += 1",
"second",
"1",
"heapq.heappush(cakes, first)",
"heapq.heappush",
"heapq",
"heappush",
"cakes",
"first",
"if second != 0:\n heapq.heappush(cakes, second)\n ",
"second != 0",
"second",
"0",
"heapq.heappush(cakes, second)",
"heapq.heappush",
"heapq",
"heappush",
"cakes",
"second",
"top_change = True",
"top_change",
"True",
"print(ans)",
"print",
"ans",
"ans = 0",
"0",
"ans",
"first = heapq.heappop(cakes)",
"heapq.heappop(cakes)",
"first",
"cakes = list(map(lambda x: int(x)*-1, input().split()))",
"list(map(lambda x: int(x)*-1, input().split()))",
"cakes",
"top_change = True",
"True",
"top_change",
"t = list(map(int, input().split()))",
"list(map(int, input().split()))",
"t",
"k, t = list(map(int, input().split()))",
"list(map(int, input().split()))",
"k",
"second += 1",
"1",
"second",
"top_change = True",
"True",
"top_change",
"second = heapq.heappop(cakes)",
"heapq.heappop(cakes)",
"second",
"top_change = False",
"False",
"top_change",
"first = heapq.heappop(cakes)",
"heapq.heappop(cakes)",
"first",
"first += 1",
"1",
"first",
"top_change = True",
"True",
"top_change",
"ans += first*-1",
"first*-1",
"ans"
] |
#https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b
import heapq
k, t = list(map(int, input().split()))
cakes = list(map(lambda x: int(x)*-1, input().split()))
heapq.heapify(cakes)
ans = 0
top_change = True
for i in range(k):
if top_change:
first = heapq.heappop(cakes)
first += 1
if len(cakes) == 0:
ans += first*-1
break
if first < cakes[0]:
top_change = False
else:
top_change = True
if first != 0:
heapq.heappush(cakes, first)
else:
first = heapq.heappop(cakes)
second = heapq.heappop(cakes)
second += 1
heapq.heappush(cakes, first)
if second != 0:
heapq.heappush(cakes, second)
top_change = True
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
0,
13,
18,
13,
17,
0,
13,
4,
13,
18,
13,
39,
17,
4,
13,
4,
13,
17,
2,
2,
13,
13,
17,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
58,
2
],
[
58,
11
],
[
61,
13
],
[
62,
26
],
[
52,
29
],
[
62,
31
],
[
64,
34
],
[
62,
38
],
[
53,
48
],
[
65,
49
],
[
52,
53
],
[
58,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
]
] |
[
"k,t = map(int, input().split())\nAs = list(map(int, input().split()))\n\nAs.sort()\na = As[-1]\nb = sum(As[:-1])\n\nprint(max(0,a-b-1))",
"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",
"As.sort()",
"As.sort",
"As",
"sort",
"a = As[-1]",
"a",
"As[-1]",
"As",
"-1",
"b = sum(As[:-1])",
"b",
"sum(As[:-1])",
"sum",
"As[:-1]",
"As",
":-1",
"-1",
"print(max(0,a-b-1))",
"print",
"max(0,a-b-1)",
"max",
"0",
"a-b-1",
"a-b",
"a",
"b",
"1",
"a = As[-1]",
"As[-1]",
"a",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"k,t = map(int, input().split())",
"map(int, input().split())",
"k",
"As = list(map(int, input().split()))",
"list(map(int, input().split()))",
"As",
"b = sum(As[:-1])",
"sum(As[:-1])",
"b"
] |
k,t = map(int, input().split())
As = list(map(int, input().split()))
As.sort()
a = As[-1]
b = sum(As[:-1])
print(max(0,a-b-1))
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
4,
18,
13,
13,
13,
28,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
13,
40,
4,
13,
13,
0,
13,
2,
40,
4,
18,
13,
13,
13,
17,
42,
13,
0,
13,
40,
4,
18,
13,
13,
13,
14,
2,
13,
17,
4,
18,
13,
13,
13,
40,
13,
0,
13,
2,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
39,
13,
10,
40,
13,
10,
2,
13
] |
[
[
81,
4
],
[
81,
13
],
[
87,
15
],
[
88,
21
],
[
24,
23
],
[
88,
33
],
[
23,
37
],
[
84,
39
],
[
88,
46
],
[
90,
51
],
[
88,
57
],
[
85,
60
],
[
94,
60
],
[
88,
66
],
[
85,
68
],
[
94,
68
],
[
93,
70
],
[
91,
72
],
[
94,
76
],
[
85,
76
],
[
81,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
],
[
93,
94
]
] |
[
"import heapq\n\nK, T = map(int, input().split())\n\nhp = []\nheapq.heapify(hp)\nfor i in input().split():\n heapq.heappush(hp, -int(i))\n\npre = -heapq.heappop(hp) - 1 \nwhile hp:\n q = -heapq.heappop(hp)\n if pre > 0:\n heapq.heappush(hp, -pre)\n pre = q - 1\nprint(pre)",
"import heapq",
"heapq",
"K, T = map(int, input().split())",
"K",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"hp = []",
"hp",
"[]",
"heapq.heapify(hp)",
"heapq.heapify",
"heapq",
"heapify",
"hp",
"for i in input().split():\n heapq.heappush(hp, -int(i))",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"heapq.heappush(hp, -int(i))",
"heapq.heappush",
"heapq",
"heappush",
"hp",
"-int(i)",
"int(i)",
"int",
"i",
"pre = -heapq.heappop(hp) - 1",
"pre",
"-heapq.heappop(hp) - 1",
"-heapq.heappop(hp)",
"heapq.heappop(hp)",
"heapq.heappop",
"heapq",
"heappop",
"hp",
"1",
"while hp:\n q = -heapq.heappop(hp)\n if pre > 0:\n heapq.heappush(hp, -pre)\n pre = q - 1",
"hp",
"q = -heapq.heappop(hp)",
"q",
"-heapq.heappop(hp)",
"heapq.heappop(hp)",
"heapq.heappop",
"heapq",
"heappop",
"hp",
"if pre > 0:\n heapq.heappush(hp, -pre)\n ",
"pre > 0",
"pre",
"0",
"heapq.heappush(hp, -pre)",
"heapq.heappush",
"heapq",
"heappush",
"hp",
"-pre",
"pre",
"pre = q - 1",
"pre",
"q - 1",
"q",
"1",
"print(pre)",
"print",
"pre",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"pre = -heapq.heappop(hp) - 1",
"-heapq.heappop(hp) - 1",
"pre",
"hp = []",
"[]",
"hp",
"q = -heapq.heappop(hp)",
"-heapq.heappop(hp)",
"q",
"pre = q - 1",
"q - 1",
"pre"
] |
import heapq
K, T = map(int, input().split())
hp = []
heapq.heapify(hp)
for i in input().split():
heapq.heappush(hp, -int(i))
pre = -heapq.heappop(hp) - 1
while hp:
q = -heapq.heappop(hp)
if pre > 0:
heapq.heappush(hp, -pre)
pre = q - 1
print(pre)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
41,
28,
13,
13,
4,
13,
13,
4,
39,
40,
13,
13,
0,
13,
13,
15,
13,
4,
18,
13,
13,
13,
0,
13,
17,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
13,
13,
14,
2,
13,
13,
0,
13,
4,
18,
13,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
13,
39,
13,
13,
0,
13,
17,
14,
40,
13,
17,
4,
18,
13,
13,
13,
39,
13,
13,
0,
13,
13,
0,
13,
17,
14,
40,
13,
17,
4,
18,
13,
13,
13,
39,
13,
13,
4,
13,
2,
40,
18,
18,
13,
17,
17,
17,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13
] |
[
[
147,
2
],
[
147,
12
],
[
150,
14
],
[
151,
32
],
[
132,
39
],
[
133,
47
],
[
151,
47
],
[
135,
49
],
[
133,
55
],
[
151,
55
],
[
162,
58
],
[
133,
63
],
[
151,
63
],
[
162,
64
],
[
163,
67
],
[
136,
68
],
[
169,
68
],
[
166,
68
],
[
159,
70
],
[
133,
75
],
[
151,
75
],
[
159,
76
],
[
168,
78
],
[
154,
79
],
[
133,
84
],
[
151,
84
],
[
144,
89
],
[
145,
93
],
[
160,
93
],
[
133,
99
],
[
151,
99
],
[
165,
104
],
[
163,
105
],
[
156,
107
],
[
157,
111
],
[
142,
111
],
[
133,
117
],
[
151,
117
],
[
133,
127
],
[
151,
127
],
[
132,
133
],
[
135,
136
],
[
147,
139
],
[
162,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
],
[
159,
154
],
[
156,
157
],
[
159,
160
],
[
162,
163
],
[
163,
165
],
[
165,
166
],
[
154,
168
],
[
168,
169
]
] |
[
"# -*- coding: utf-8 -*-\nK, T = map(int, input().split(' '))\nA = list(map(int, input().split(' ')))\nA = [(-a, i) for i, a in enumerate(A)]\n\nimport heapq\nheapq.heapify(A)\n\nprev = -1\nwhile len(A) > 1:\n a, i = heapq.heappop(A)\n if i == prev:\n b, j = heapq.heappop(A)\n prev = j\n\n heapq.heappush(A, (a, i))\n b += 1\n if b != 0:\n heapq.heappush(A, (b, j))\n\n else:\n prev = i\n a += 1\n if a != 0:\n heapq.heappush(A, (a, i))\n\n\n\nprint(- A[0][0] - 1)\n\n\n\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",
"' '",
"(-a, i) for i, a in enumerate(A)",
"for i, a in enumerate(A)",
"i",
"a",
"enumerate(A)",
"enumerate",
"A",
"for i, a in enumerate(A)",
"(-a, i)",
"-a",
"a",
"i",
"A = [(-a, i) for i, a in enumerate(A)]",
"A",
"[(-a, i) for i, a in enumerate(A)]",
"import heapq",
"heapq",
"heapq.heapify(A)",
"heapq.heapify",
"heapq",
"heapify",
"A",
"prev = -1",
"prev",
"-1",
"while len(A) > 1:\n a, i = heapq.heappop(A)\n if i == prev:\n b, j = heapq.heappop(A)\n prev = j\n\n heapq.heappush(A, (a, i))\n b += 1\n if b != 0:\n heapq.heappush(A, (b, j))\n\n else:\n prev = i\n a += 1\n if a != 0:\n heapq.heappush(A, (a, i))",
"len(A) > 1",
"len(A)",
"len",
"A",
"1",
"a, i = heapq.heappop(A)",
"a",
"heapq.heappop(A)",
"heapq.heappop",
"heapq",
"heappop",
"A",
"i",
"if i == prev:\n b, j = heapq.heappop(A)\n prev = j\n\n heapq.heappush(A, (a, i))\n b += 1\n if b != 0:\n heapq.heappush(A, (b, j))\n\n else:\n prev = i\n a += 1\n if a != 0:\n heapq.heappush(A, (a, i))",
"i == prev",
"i",
"prev",
"b, j = heapq.heappop(A)",
"b",
"heapq.heappop(A)",
"heapq.heappop",
"heapq",
"heappop",
"A",
"j",
"prev = j",
"prev",
"j",
"heapq.heappush(A, (a, i))",
"heapq.heappush",
"heapq",
"heappush",
"A",
"(a, i)",
"a",
"i",
"b += 1",
"b",
"1",
"if b != 0:\n heapq.heappush(A, (b, j))\n\n ",
"b != 0",
"b",
"0",
"heapq.heappush(A, (b, j))",
"heapq.heappush",
"heapq",
"heappush",
"A",
"(b, j)",
"b",
"j",
"prev = i",
"prev",
"i",
"a += 1",
"a",
"1",
"if a != 0:\n heapq.heappush(A, (a, i))",
"a != 0",
"a",
"0",
"heapq.heappush(A, (a, i))",
"heapq.heappush",
"heapq",
"heappush",
"A",
"(a, i)",
"a",
"i",
"print(- A[0][0] - 1)",
"print",
"- A[0][0] - 1",
"- A[0][0]",
"A[0][0]",
"[0]",
"A",
"0",
"0",
"1",
"A = [(-a, i) for i, a in enumerate(A)]",
"[(-a, i) for i, a in enumerate(A)]",
"A",
"prev = -1",
"-1",
"prev",
"K, T = map(int, input().split(' '))",
"map(int, input().split(' '))",
"K",
"a, i = heapq.heappop(A)",
"heapq.heappop(A)",
"a",
"b += 1",
"1",
"b",
"T = map(int, input().split(' '))",
"map(int, input().split(' '))",
"T",
"A = list(map(int, input().split(' ')))",
"list(map(int, input().split(' ')))",
"A",
"j = heapq.heappop(A)",
"heapq.heappop(A)",
"j",
"a += 1",
"1",
"a",
"b, j = heapq.heappop(A)",
"heapq.heappop(A)",
"b",
"i = heapq.heappop(A)",
"heapq.heappop(A)",
"i",
"prev = i",
"i",
"prev",
"prev = j",
"j",
"prev"
] |
# -*- coding: utf-8 -*-
K, T = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A = [(-a, i) for i, a in enumerate(A)]
import heapq
heapq.heapify(A)
prev = -1
while len(A) > 1:
a, i = heapq.heappop(A)
if i == prev:
b, j = heapq.heappop(A)
prev = j
heapq.heappush(A, (a, i))
b += 1
if b != 0:
heapq.heappush(A, (b, j))
else:
prev = i
a += 1
if a != 0:
heapq.heappush(A, (a, i))
print(- A[0][0] - 1)
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
4,
18,
13,
13,
17,
0,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
12,
4,
13,
4,
18,
18,
13,
13,
13,
0,
13,
12,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,
13,
12,
4,
13,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
0,
13,
2,
4,
13,
13,
18,
13,
17,
0,
13,
4,
13,
17,
2,
2,
18,
13,
17,
13,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13
] |
[
[
144,
29
],
[
129,
34
],
[
135,
41
],
[
132,
52
],
[
141,
67
],
[
87,
86
],
[
133,
88
],
[
87,
89
],
[
92,
91
],
[
142,
93
],
[
91,
96
],
[
100,
99
],
[
91,
103
],
[
91,
105
],
[
109,
108
],
[
91,
115
],
[
99,
117
],
[
108,
121
],
[
139,
127
],
[
129,
130
],
[
132,
133
],
[
135,
136
],
[
141,
142
],
[
144,
145
]
] |
[
"import sys\n\n# import re\nimport math\nimport collections\n# import decimal\nimport bisect\nimport itertools\nimport fractions\n# import functools\nimport copy\nimport heapq\nimport decimal\n# import statistics\nimport queue\nimport numpy as np\n\nsys.setrecursionlimit(10000001)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\n\ndef main():\n k, t = ns()\n a = na()\n a.sort()\n\n total = sum(a)-a[-1]\n\n ans = max(0, a[-1]-total-1)\n\n print(ans)\n\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"import math",
"math",
"import collections",
"collections",
"import bisect",
"bisect",
"import itertools",
"itertools",
"import fractions",
"fractions",
"import copy",
"copy",
"import heapq",
"heapq",
"import decimal",
"decimal",
"import queue",
"queue",
"import numpy as np",
"numpy",
"sys.setrecursionlimit(10000001)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10000001",
"INF = 10 ** 16",
"INF",
"10 ** 16",
"10",
"16",
"MOD = 10 ** 9 + 7",
"MOD",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"ni = lambda: int(sys.stdin.readline())",
"ni",
"lambda: int(sys.stdin.readline())",
"int(sys.stdin.readline())",
"int",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"ns = lambda: map(int, sys.stdin.readline().split())",
"ns",
"lambda: map(int, sys.stdin.readline().split())",
"map(int, sys.stdin.readline().split())",
"map",
"int",
"sys.stdin.readline().split()",
"sys.stdin.readline().split",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"split",
"na = lambda: list(map(int, sys.stdin.readline().split()))",
"na",
"lambda: list(map(int, sys.stdin.readline().split()))",
"list(map(int, sys.stdin.readline().split()))",
"list",
"map(int, sys.stdin.readline().split())",
"map",
"int",
"sys.stdin.readline().split()",
"sys.stdin.readline().split",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"split",
"def main():\n k, t = ns()\n a = na()\n a.sort()\n\n total = sum(a)-a[-1]\n\n ans = max(0, a[-1]-total-1)\n\n print(ans)",
"main",
"k, t = ns()",
"k",
"ns()",
"ns",
"t",
"a = na()",
"a",
"na()",
"na",
"a.sort()",
"a.sort",
"a",
"sort",
"total = sum(a)-a[-1]",
"total",
"sum(a)-a[-1]",
"sum(a)",
"sum",
"a",
"a[-1]",
"a",
"-1",
"ans = max(0, a[-1]-total-1)",
"ans",
"max(0, a[-1]-total-1)",
"max",
"0",
"a[-1]-total-1",
"a[-1]-total",
"a[-1]",
"a",
"-1",
"total",
"1",
"print(ans)",
"print",
"ans",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"MOD = 10 ** 9 + 7",
"10 ** 9 + 7",
"MOD",
"ns = lambda: map(int, sys.stdin.readline().split())",
"lambda: map(int, sys.stdin.readline().split())",
"ns",
"ni = lambda: int(sys.stdin.readline())",
"lambda: int(sys.stdin.readline())",
"ni",
"def main():\n k, t = ns()\n a = na()\n a.sort()\n\n total = sum(a)-a[-1]\n\n ans = max(0, a[-1]-total-1)\n\n print(ans)",
"def main():\n k, t = ns()\n a = na()\n a.sort()\n\n total = sum(a)-a[-1]\n\n ans = max(0, a[-1]-total-1)\n\n print(ans)",
"main",
"na = lambda: list(map(int, sys.stdin.readline().split()))",
"lambda: list(map(int, sys.stdin.readline().split()))",
"na",
"INF = 10 ** 16",
"10 ** 16",
"INF"
] |
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np
sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
# ===CODE===
def main():
k, t = ns()
a = na()
a.sort()
total = sum(a)-a[-1]
ans = max(0, a[-1]-total-1)
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,
14,
2,
13,
17,
4,
13,
2,
4,
13,
13,
17,
4,
18,
13,
13,
0,
13,
4,
13,
13,
14,
40,
2,
2,
4,
13,
13,
17,
17,
13,
4,
13,
17,
4,
13,
2,
2,
2,
17,
13,
4,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
80,
4
],
[
80,
13
],
[
74,
15
],
[
81,
28
],
[
75,
35
],
[
71,
42
],
[
75,
45
],
[
75,
52
],
[
72,
55
],
[
72,
65
],
[
75,
68
],
[
71,
72
],
[
74,
75
],
[
80,
78
],
[
80,
81
]
] |
[
"import sys\n\nk, t = map(int, input().split())\na = list(map(int, input().split()))\n\nif t == 1:\n print(sum(a) - 1)\n sys.exit()\n\nmax_a = max(a)\n\nif (sum(a) + 1) // 2 >= max_a:\n print(0)\nelse:\n print(2 * max_a - sum(a) - 1)",
"import sys",
"sys",
"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(sum(a) - 1)\n sys.exit()",
"t == 1",
"t",
"1",
"print(sum(a) - 1)",
"print",
"sum(a) - 1",
"sum(a)",
"sum",
"a",
"1",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"max_a = max(a)",
"max_a",
"max(a)",
"max",
"a",
"if (sum(a) + 1) // 2 >= max_a:\n print(0)\nelse:\n print(2 * max_a - sum(a) - 1)",
"(sum(a) + 1) // 2 >= max_a",
"(sum(a) + 1) // 2",
"sum(a) + 1",
"sum(a)",
"sum",
"a",
"1",
"2",
"max_a",
"print(0)",
"print",
"0",
"print(2 * max_a - sum(a) - 1)",
"print",
"2 * max_a - sum(a) - 1",
"2 * max_a - sum(a)",
"2 * max_a",
"2",
"max_a",
"sum(a)",
"sum",
"a",
"1",
"max_a = max(a)",
"max(a)",
"max_a",
"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"
] |
import sys
k, t = map(int, input().split())
a = list(map(int, input().split()))
if t == 1:
print(sum(a) - 1)
sys.exit()
max_a = max(a)
if (sum(a) + 1) // 2 >= max_a:
print(0)
else:
print(2 * max_a - sum(a) - 1)
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
41,
28,
13,
13,
4,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
4,
39,
40,
13,
13,
0,
13,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
18,
13,
17,
14,
2,
18,
13,
17,
17,
4,
18,
13,
13,
13,
39,
2,
18,
13,
17,
17,
13,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
14,
40,
13,
18,
13,
17,
0,
13,
18,
13,
17,
0,
18,
13,
17,
17,
0,
13,
18,
13,
17,
0,
18,
13,
17,
17,
14,
2,
18,
13,
17,
17,
4,
18,
13,
13,
13,
13,
14,
2,
18,
13,
17,
17,
4,
18,
13,
13,
13,
13,
14,
40,
13,
18,
18,
13,
17,
17,
4,
13,
2,
40,
18,
18,
13,
17,
17,
17,
4,
13,
40,
18,
18,
13,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
18,
13,
10,
18,
13,
10,
4,
13,
10,
13,
13
] |
[
[
181,
4
],
[
181,
14
],
[
196,
38
],
[
197,
44
],
[
193,
46
],
[
197,
51
],
[
187,
53
],
[
194,
55
],
[
194,
60
],
[
197,
67
],
[
194,
71
],
[
197,
79
],
[
175,
82
],
[
197,
87
],
[
172,
89
],
[
197,
94
],
[
188,
97
],
[
191,
97
],
[
185,
97
],
[
176,
99
],
[
184,
102
],
[
176,
104
],
[
110,
107
],
[
176,
108
],
[
190,
112
],
[
173,
114
],
[
120,
117
],
[
173,
118
],
[
176,
124
],
[
197,
131
],
[
176,
132
],
[
173,
136
],
[
197,
143
],
[
173,
144
],
[
191,
147
],
[
185,
147
],
[
188,
147
],
[
197,
150
],
[
197,
159
],
[
197,
168
],
[
172,
173
],
[
175,
176
],
[
181,
179
],
[
181,
182
],
[
184,
185
],
[
187,
188
],
[
190,
191
],
[
193,
194
],
[
196,
197
]
] |
[
"import heapq\nK,T=map(int,input().split(' '))\nA=[[-i,n] for n,i in enumerate(list(map(int,input().split(' '))))]\nheapq.heapify(A)\nA_max = heapq.heappop(A)\ntoday = A_max[1]\nif A_max[0]<-1:\n heapq.heappush(A,[A_max[0]+1,today])\nwhile len(A)>1:\n a=heapq.heappop(A)\n b=heapq.heappop(A)\n if today!=a[1]:\n today = a[1]\n a[0] += 1\n else:\n today = b[1]\n b[0] += 1\n if a[0]<0:\n heapq.heappush(A,a)\n if b[0]<0:\n heapq.heappush(A,b)\nif today != A[0][1]:\n print(-A[0][0]-1)\nelse:\n print(-A[0][0])",
"import heapq",
"heapq",
"K,T=map(int,input().split(' '))",
"K",
"map(int,input().split(' '))",
"map",
"int",
"input().split(' ')",
"().split",
"()",
"input",
"split",
"' '",
"T",
"[-i,n] for n,i in enumerate(list(map(int,input().split(' '))))",
"for n,i in enumerate(list(map(int,input().split(' '))))",
"n",
"i",
"enumerate(list(map(int,input().split(' '))))",
"enumerate",
"list(map(int,input().split(' ')))",
"list",
"map(int,input().split(' '))",
"map",
"int",
"input().split(' ')",
"().split",
"()",
"input",
"split",
"' '",
"for n,i in enumerate(list(map(int,input().split(' '))))",
"[-i,n]",
"-i",
"i",
"n",
"A=[[-i,n] for n,i in enumerate(list(map(int,input().split(' '))))]",
"A",
"[[-i,n] for n,i in enumerate(list(map(int,input().split(' '))))]",
"heapq.heapify(A)",
"heapq.heapify",
"heapq",
"heapify",
"A",
"A_max = heapq.heappop(A)",
"A_max",
"heapq.heappop(A)",
"heapq.heappop",
"heapq",
"heappop",
"A",
"today = A_max[1]",
"today",
"A_max[1]",
"A_max",
"1",
"if A_max[0]<-1:\n heapq.heappush(A,[A_max[0]+1,today])",
"A_max[0]<-1",
"A_max[0]",
"A_max",
"0",
"-1",
"heapq.heappush(A,[A_max[0]+1,today])",
"heapq.heappush",
"heapq",
"heappush",
"A",
"[A_max[0]+1,today]",
"A_max[0]+1",
"A_max[0]",
"A_max",
"0",
"1",
"today",
"while len(A)>1:\n a=heapq.heappop(A)\n b=heapq.heappop(A)\n if today!=a[1]:\n today = a[1]\n a[0] += 1\n else:\n today = b[1]\n b[0] += 1\n if a[0]<0:\n heapq.heappush(A,a)\n if b[0]<0:\n heapq.heappush(A,b)",
"len(A)>1",
"len(A)",
"len",
"A",
"1",
"a=heapq.heappop(A)",
"a",
"heapq.heappop(A)",
"heapq.heappop",
"heapq",
"heappop",
"A",
"b=heapq.heappop(A)",
"b",
"heapq.heappop(A)",
"heapq.heappop",
"heapq",
"heappop",
"A",
"if today!=a[1]:\n today = a[1]\n a[0] += 1\n else:\n today = b[1]\n b[0] += 1\n ",
"today!=a[1]",
"today",
"a[1]",
"a",
"1",
"today = a[1]",
"today",
"a[1]",
"a",
"1",
"a[0] += 1",
"a[0]",
"a",
"0",
"1",
"today = b[1]",
"today",
"b[1]",
"b",
"1",
"b[0] += 1",
"b[0]",
"b",
"0",
"1",
"if a[0]<0:\n heapq.heappush(A,a)\n ",
"a[0]<0",
"a[0]",
"a",
"0",
"0",
"heapq.heappush(A,a)",
"heapq.heappush",
"heapq",
"heappush",
"A",
"a",
"if b[0]<0:\n heapq.heappush(A,b)",
"b[0]<0",
"b[0]",
"b",
"0",
"0",
"heapq.heappush(A,b)",
"heapq.heappush",
"heapq",
"heappush",
"A",
"b",
"if today != A[0][1]:\n print(-A[0][0]-1)\nelse:\n print(-A[0][0])",
"today != A[0][1]",
"today",
"A[0][1]",
"[0]",
"A",
"0",
"1",
"print(-A[0][0]-1)",
"print",
"-A[0][0]-1",
"-A[0][0]",
"A[0][0]",
"[0]",
"A",
"0",
"0",
"1",
"print(-A[0][0])",
"print",
"-A[0][0]",
"A[0][0]",
"[0]",
"A",
"0",
"0",
"b=heapq.heappop(A)",
"heapq.heappop(A)",
"b",
"a=heapq.heappop(A)",
"heapq.heappop(A)",
"a",
"K,T=map(int,input().split(' '))",
"map(int,input().split(' '))",
"K",
"T=map(int,input().split(' '))",
"map(int,input().split(' '))",
"T",
"today = a[1]",
"a[1]",
"today",
"today = A_max[1]",
"A_max[1]",
"today",
"today = b[1]",
"b[1]",
"today",
"A_max = heapq.heappop(A)",
"heapq.heappop(A)",
"A_max",
"A=[[-i,n] for n,i in enumerate(list(map(int,input().split(' '))))]",
"[[-i,n] for n,i in enumerate(list(map(int,input().split(' '))))]",
"A"
] |
import heapq
K,T=map(int,input().split(' '))
A=[[-i,n] for n,i in enumerate(list(map(int,input().split(' '))))]
heapq.heapify(A)
A_max = heapq.heappop(A)
today = A_max[1]
if A_max[0]<-1:
heapq.heappush(A,[A_max[0]+1,today])
while len(A)>1:
a=heapq.heappop(A)
b=heapq.heappop(A)
if today!=a[1]:
today = a[1]
a[0] += 1
else:
today = b[1]
b[0] += 1
if a[0]<0:
heapq.heappush(A,a)
if b[0]<0:
heapq.heappush(A,b)
if today != A[0][1]:
print(-A[0][0]-1)
else:
print(-A[0][0])
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
4,
18,
13,
13,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
28,
13,
4,
13,
17,
13,
14,
2,
13,
18,
13,
13,
0,
13,
40,
2,
18,
13,
13,
13,
0,
13,
17,
0,
13,
18,
13,
13,
4,
13,
4,
13,
2,
13,
17,
17,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
40,
13,
10,
4,
13,
10,
18,
13,
10,
18,
13
] |
[
[
81,
2
],
[
81,
15
],
[
81,
16
],
[
69,
23
],
[
87,
28
],
[
34,
33
],
[
76,
37
],
[
70,
40
],
[
85,
40
],
[
33,
43
],
[
78,
45
],
[
33,
50
],
[
70,
51
],
[
85,
51
],
[
72,
53
],
[
84,
56
],
[
33,
59
],
[
73,
65
],
[
79,
65
],
[
88,
65
],
[
69,
70
],
[
72,
73
],
[
81,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
]
] |
[
"k,t,*a=map(int,open(0).read().split())\na.sort()\nx=a[0]\nans=a[0]\nfor i in range(1,t):\n if x<a[i]:\n ans=+(a[i]-x)\n else:\n ans=0\n x+=a[i]\nprint(max(ans-1,0))",
"k,t,*a=map(int,open(0).read().split())",
"k",
"map(int,open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"t",
"*a",
"a",
"a.sort()",
"a.sort",
"a",
"sort",
"x=a[0]",
"x",
"a[0]",
"a",
"0",
"ans=a[0]",
"ans",
"a[0]",
"a",
"0",
"for i in range(1,t):\n if x<a[i]:\n ans=+(a[i]-x)\n else:\n ans=0\n x+=a[i]",
"i",
"range(1,t)",
"range",
"1",
"t",
"if x<a[i]:\n ans=+(a[i]-x)\n else:\n ans=0\n ",
"x<a[i]",
"x",
"a[i]",
"a",
"i",
"ans=+(a[i]-x)",
"ans",
"+(a[i]-x)",
"a[i]-x",
"a[i]",
"a",
"i",
"x",
"ans=0",
"ans",
"0",
"x+=a[i]",
"x",
"a[i]",
"a",
"i",
"print(max(ans-1,0))",
"print",
"max(ans-1,0)",
"max",
"ans-1",
"ans",
"1",
"0",
"x=a[0]",
"a[0]",
"x",
"ans=0",
"0",
"ans",
"t,*a=map(int,open(0).read().split())",
"map(int,open(0).read().split())",
"t",
"ans=+(a[i]-x)",
"+(a[i]-x)",
"ans",
"k,t,*a=map(int,open(0).read().split())",
"map(int,open(0).read().split())",
"k",
"x+=a[i]",
"a[i]",
"x",
"ans=a[0]",
"a[0]",
"ans"
] |
k,t,*a=map(int,open(0).read().split())
a.sort()
x=a[0]
ans=a[0]
for i in range(1,t):
if x<a[i]:
ans=+(a[i]-x)
else:
ans=0
x+=a[i]
print(max(ans-1,0))
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
12,
39,
4,
13,
13,
13,
23,
23,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
13,
13,
4,
18,
13,
13,
0,
13,
17,
14,
2,
13,
17,
4,
13,
2,
13,
17,
4,
13,
0,
13,
17,
0,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
14,
40,
13,
18,
18,
13,
17,
17,
0,
18,
18,
13,
17,
17,
17,
0,
13,
18,
18,
13,
17,
17,
14,
2,
2,
13,
18,
18,
13,
17,
17,
2,
18,
18,
13,
17,
17,
17,
0,
18,
18,
13,
17,
17,
17,
0,
13,
18,
18,
13,
17,
17,
0,
13,
17,
4,
18,
13,
13,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
18,
13
] |
[
[
156,
4
],
[
156,
13
],
[
138,
15
],
[
157,
39
],
[
139,
42
],
[
46,
45
],
[
157,
49
],
[
142,
54
],
[
159,
59
],
[
144,
62
],
[
150,
65
],
[
69,
68
],
[
142,
71
],
[
145,
74
],
[
148,
74
],
[
163,
74
],
[
139,
77
],
[
86,
81
],
[
139,
83
],
[
162,
88
],
[
139,
91
],
[
145,
97
],
[
148,
97
],
[
163,
97
],
[
139,
100
],
[
139,
106
],
[
116,
111
],
[
139,
113
],
[
147,
118
],
[
139,
121
],
[
153,
125
],
[
139,
129
],
[
133,
132
],
[
154,
136
],
[
160,
136
],
[
138,
139
],
[
156,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
],
[
153,
154
],
[
156,
157
],
[
159,
160
],
[
162,
163
]
] |
[
"import sys\n\nK, T = map(int, input().split())\nA = list(map(lambda x, y: [int(x), y], sys.stdin.readline().rsplit(), range(T)))\nA.sort(reverse=True)\n\nif T == 1:\n print(K - 1)\n exit()\n\nres = 0\npre = -1\nt = []\nfor k in range(K):\n if pre != A[0][1]:\n A[0][0] -= 1\n pre = A[0][1]\n elif pre == A[0][1] and A[1][0] > 0:\n A[1][0] -= 1\n pre = A[1][1]\n else:\n res += 1\n A.sort(reverse=True)\n\nprint(res)",
"import sys",
"sys",
"K, T = map(int, input().split())",
"K",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"A = list(map(lambda x, y: [int(x), y], sys.stdin.readline().rsplit(), range(T)))",
"A",
"list(map(lambda x, y: [int(x), y], sys.stdin.readline().rsplit(), range(T)))",
"list",
"map(lambda x, y: [int(x), y], sys.stdin.readline().rsplit(), range(T))",
"map",
"lambda x, y: [int(x), y]",
"[int(x), y]",
"int(x)",
"int",
"x",
"y",
"x",
"y",
"sys.stdin.readline().rsplit()",
"sys.stdin.readline().rsplit",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rsplit",
"range(T)",
"range",
"T",
"A.sort(reverse=True)",
"A.sort",
"A",
"sort",
"reverse=True",
"reverse",
"True",
"if T == 1:\n print(K - 1)\n exit()",
"T == 1",
"T",
"1",
"print(K - 1)",
"print",
"K - 1",
"K",
"1",
"exit()",
"exit",
"res = 0",
"res",
"0",
"pre = -1",
"pre",
"-1",
"t = []",
"t",
"[]",
"for k in range(K):\n if pre != A[0][1]:\n A[0][0] -= 1\n pre = A[0][1]\n elif pre == A[0][1] and A[1][0] > 0:\n A[1][0] -= 1\n pre = A[1][1]\n else:\n res += 1\n A.sort(reverse=True)",
"k",
"range(K)",
"range",
"K",
"if pre != A[0][1]:\n A[0][0] -= 1\n pre = A[0][1]\n elif pre == A[0][1] and A[1][0] > 0:\n A[1][0] -= 1\n pre = A[1][1]\n else:\n res += 1\n ",
"pre != A[0][1]",
"pre",
"A[0][1]",
"[0]",
"A",
"0",
"1",
"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 pre == A[0][1] and A[1][0] > 0:\n A[1][0] -= 1\n pre = A[1][1]\n ",
"pre == A[0][1] and A[1][0] > 0",
"pre == A[0][1]",
"pre",
"A[0][1]",
"[0]",
"A",
"0",
"1",
"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",
"res += 1",
"res",
"1",
"A.sort(reverse=True)",
"A.sort",
"A",
"sort",
"reverse=True",
"reverse",
"True",
"print(res)",
"print",
"res",
"A = list(map(lambda x, y: [int(x), y], sys.stdin.readline().rsplit(), range(T)))",
"list(map(lambda x, y: [int(x), y], sys.stdin.readline().rsplit(), range(T)))",
"A",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"pre = -1",
"-1",
"pre",
"pre = A[1][1]",
"A[1][1]",
"pre",
"t = []",
"[]",
"t",
"res += 1",
"1",
"res",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"res = 0",
"0",
"res",
"pre = A[0][1]",
"A[0][1]",
"pre"
] |
import sys
K, T = map(int, input().split())
A = list(map(lambda x, y: [int(x), y], sys.stdin.readline().rsplit(), range(T)))
A.sort(reverse=True)
if T == 1:
print(K - 1)
exit()
res = 0
pre = -1
t = []
for k in range(K):
if pre != A[0][1]:
A[0][0] -= 1
pre = A[0][1]
elif pre == A[0][1] and A[1][0] > 0:
A[1][0] -= 1
pre = A[1][1]
else:
res += 1
A.sort(reverse=True)
print(res)
|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
41,
28,
13,
13,
4,
13,
13,
4,
39,
40,
13,
13,
0,
13,
13,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
13,
14,
2,
13,
17,
4,
13,
13,
39,
13,
13,
0,
13,
17,
14,
40,
13,
13,
0,
13,
13,
4,
13,
13,
39,
2,
13,
17,
13,
14,
2,
2,
4,
13,
13,
17,
2,
18,
18,
13,
17,
17,
17,
0,
13,
4,
13,
13,
13,
0,
13,
13,
4,
13,
13,
39,
2,
13,
17,
13,
4,
13,
13,
39,
13,
13,
0,
13,
17,
4,
13,
13,
39,
2,
13,
17,
13,
4,
13,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] |
[
[
158,
3
],
[
158,
16
],
[
158,
17
],
[
134,
32
],
[
135,
36
],
[
164,
38
],
[
170,
41
],
[
45,
44
],
[
156,
47
],
[
167,
49
],
[
135,
52
],
[
167,
53
],
[
162,
56
],
[
135,
60
],
[
149,
65
],
[
168,
69
],
[
171,
70
],
[
144,
70
],
[
147,
70
],
[
146,
72
],
[
168,
73
],
[
135,
76
],
[
162,
79
],
[
135,
87
],
[
135,
92
],
[
152,
97
],
[
135,
100
],
[
152,
101
],
[
143,
103
],
[
141,
104
],
[
135,
107
],
[
153,
110
],
[
135,
115
],
[
137,
120
],
[
135,
124
],
[
162,
127
],
[
138,
132
],
[
150,
132
],
[
165,
132
],
[
134,
135
],
[
137,
138
],
[
152,
141
],
[
141,
143
],
[
143,
144
],
[
168,
146
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
158,
156
],
[
158,
159
],
[
167,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
]
] |
[
"from heapq import heapify, heappop, heappush\n\n\nK, T, *A = map(int, open(0).read().split())\npq = [(-a, i) for i, a in enumerate(A)]\nheapify(pq)\n\nans = 0\nprev = -1\nfor _ in range(K):\n v, k = heappop(pq)\n if v == 0:\n heappush(pq, (v, k))\n ans += 1\n elif k != prev:\n prev = k\n heappush(pq, (v + 1, k))\n elif len(pq) > 1 and pq[0][0] < 0:\n v_nx, k_nx = heappop(pq)\n prev = k_nx\n heappush(pq, (v_nx + 1, k_nx))\n heappush(pq, (v, k))\n else:\n ans += 1\n heappush(pq, (v + 1, k))\nprint(ans)",
"from heapq import heapify, heappop, heappush",
"K, T, *A = map(int, open(0).read().split())",
"K",
"map(int, open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"T",
"*A",
"A",
"(-a, i) for i, a in enumerate(A)",
"for i, a in enumerate(A)",
"i",
"a",
"enumerate(A)",
"enumerate",
"A",
"for i, a in enumerate(A)",
"(-a, i)",
"-a",
"a",
"i",
"pq = [(-a, i) for i, a in enumerate(A)]",
"pq",
"[(-a, i) for i, a in enumerate(A)]",
"heapify(pq)",
"heapify",
"pq",
"ans = 0",
"ans",
"0",
"prev = -1",
"prev",
"-1",
"for _ in range(K):\n v, k = heappop(pq)\n if v == 0:\n heappush(pq, (v, k))\n ans += 1\n elif k != prev:\n prev = k\n heappush(pq, (v + 1, k))\n elif len(pq) > 1 and pq[0][0] < 0:\n v_nx, k_nx = heappop(pq)\n prev = k_nx\n heappush(pq, (v_nx + 1, k_nx))\n heappush(pq, (v, k))\n else:\n ans += 1\n heappush(pq, (v + 1, k))",
"_",
"range(K)",
"range",
"K",
"v, k = heappop(pq)",
"v",
"heappop(pq)",
"heappop",
"pq",
"k",
"if v == 0:\n heappush(pq, (v, k))\n ans += 1\n elif k != prev:\n prev = k\n heappush(pq, (v + 1, k))\n elif len(pq) > 1 and pq[0][0] < 0:\n v_nx, k_nx = heappop(pq)\n prev = k_nx\n heappush(pq, (v_nx + 1, k_nx))\n heappush(pq, (v, k))\n else:\n ans += 1\n heappush(pq, (v + 1, k))",
"v == 0",
"v",
"0",
"heappush(pq, (v, k))",
"heappush",
"pq",
"(v, k)",
"v",
"k",
"ans += 1",
"ans",
"1",
"elif k != prev:\n prev = k\n heappush(pq, (v + 1, k))\n ",
"k != prev",
"k",
"prev",
"prev = k",
"prev",
"k",
"heappush(pq, (v + 1, k))",
"heappush",
"pq",
"(v + 1, k)",
"v + 1",
"v",
"1",
"k",
"elif len(pq) > 1 and pq[0][0] < 0:\n v_nx, k_nx = heappop(pq)\n prev = k_nx\n heappush(pq, (v_nx + 1, k_nx))\n heappush(pq, (v, k))\n ",
"len(pq) > 1 and pq[0][0] < 0",
"len(pq) > 1",
"len(pq)",
"len",
"pq",
"1",
"pq[0][0] < 0",
"pq[0][0]",
"[0]",
"pq",
"0",
"0",
"0",
"v_nx, k_nx = heappop(pq)",
"v_nx",
"heappop(pq)",
"heappop",
"pq",
"k_nx",
"prev = k_nx",
"prev",
"k_nx",
"heappush(pq, (v_nx + 1, k_nx))",
"heappush",
"pq",
"(v_nx + 1, k_nx)",
"v_nx + 1",
"v_nx",
"1",
"k_nx",
"heappush(pq, (v, k))",
"heappush",
"pq",
"(v, k)",
"v",
"k",
"ans += 1",
"ans",
"1",
"heappush(pq, (v + 1, k))",
"heappush",
"pq",
"(v + 1, k)",
"v + 1",
"v",
"1",
"k",
"print(ans)",
"print",
"ans",
"pq = [(-a, i) for i, a in enumerate(A)]",
"[(-a, i) for i, a in enumerate(A)]",
"pq",
"ans += 1",
"1",
"ans",
"k_nx = heappop(pq)",
"heappop(pq)",
"k_nx",
"prev = k_nx",
"k_nx",
"prev",
"prev = k",
"k",
"prev",
"ans += 1",
"1",
"ans",
"v_nx, k_nx = heappop(pq)",
"heappop(pq)",
"v_nx",
"K, T, *A = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"K",
"T, *A = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"T",
"v, k = heappop(pq)",
"heappop(pq)",
"v",
"ans = 0",
"0",
"ans",
"k = heappop(pq)",
"heappop(pq)",
"k",
"prev = -1",
"-1",
"prev"
] |
from heapq import heapify, heappop, heappush
K, T, *A = map(int, open(0).read().split())
pq = [(-a, i) for i, a in enumerate(A)]
heapify(pq)
ans = 0
prev = -1
for _ in range(K):
v, k = heappop(pq)
if v == 0:
heappush(pq, (v, k))
ans += 1
elif k != prev:
prev = k
heappush(pq, (v + 1, k))
elif len(pq) > 1 and pq[0][0] < 0:
v_nx, k_nx = heappop(pq)
prev = k_nx
heappush(pq, (v_nx + 1, k_nx))
heappush(pq, (v, k))
else:
ans += 1
heappush(pq, (v + 1, k))
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,
4,
18,
13,
13,
13,
0,
13,
4,
13,
17,
2,
2,
13,
4,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
53,
2
],
[
53,
11
],
[
56,
13
],
[
59,
25
],
[
57,
28
],
[
57,
31
],
[
60,
33
],
[
62,
35
],
[
60,
41
],
[
57,
44
],
[
63,
48
],
[
53,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
],
[
62,
63
]
] |
[
"K,T = map(int,input().split())\na = list(map(int,input().split()))\nb = max(a)\na.remove(b)\nans = max(0, b - sum(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",
"b = max(a)",
"b",
"max(a)",
"max",
"a",
"a.remove(b)",
"a.remove",
"a",
"remove",
"b",
"ans = max(0, b - sum(a) - 1)",
"ans",
"max(0, b - sum(a) - 1)",
"max",
"0",
"b - sum(a) - 1",
"b - sum(a)",
"b",
"sum(a)",
"sum",
"a",
"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",
"a = list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"b = max(a)",
"max(a)",
"b",
"ans = max(0, b - sum(a) - 1)",
"max(0, b - sum(a) - 1)",
"ans"
] |
K,T = map(int,input().split())
a = list(map(int,input().split()))
b = max(a)
a.remove(b)
ans = max(0, b - sum(a) - 1)
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
13,
4,
13,
4,
18,
4,
13,
13,
4,
39,
4,
13,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
4,
18,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
13,
18,
18,
13,
13,
17,
14,
2,
4,
13,
13,
17,
0,
13,
17,
0,
13,
17,
0,
13,
18,
18,
13,
13,
17,
14,
2,
18,
18,
13,
13,
17,
17,
4,
18,
13,
13,
13,
0,
18,
18,
13,
13,
17,
17,
4,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
113,
2
],
[
113,
11
],
[
119,
30
],
[
125,
33
],
[
122,
36
],
[
40,
39
],
[
111,
42
],
[
120,
45
],
[
49,
48
],
[
107,
51
],
[
123,
55
],
[
117,
55
],
[
120,
58
],
[
108,
59
],
[
105,
59
],
[
120,
65
],
[
104,
68
],
[
128,
71
],
[
116,
74
],
[
120,
77
],
[
105,
78
],
[
108,
78
],
[
120,
84
],
[
105,
85
],
[
108,
85
],
[
120,
90
],
[
105,
92
],
[
108,
92
],
[
99,
94
],
[
120,
96
],
[
105,
97
],
[
108,
97
],
[
129,
102
],
[
126,
102
],
[
104,
105
],
[
107,
108
],
[
113,
111
],
[
113,
114
],
[
116,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
]
] |
[
"k, t = map(int, input().split())\na_list = [[int(value), index] for index, value in enumerate(input().split())]\nans = 0\nprev = -1\nfor i in range(k):\n a_list.sort(reverse=True)\n index = 0\n if prev == a_list[index][1]:\n if len(a_list) > 1:\n index += 1\n else:\n ans += 1\n prev = a_list[index][1]\n if a_list[index][0] == 1:\n a_list.pop(index)\n else:\n a_list[index][0] -= 1\nprint(ans)",
"k, t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"[int(value), index] for index, value in enumerate(input().split())",
"for index, value in enumerate(input().split())",
"index",
"value",
"enumerate(input().split())",
"enumerate",
"input().split()",
"().split",
"()",
"input",
"split",
"for index, value in enumerate(input().split())",
"[int(value), index]",
"int(value)",
"int",
"value",
"index",
"a_list = [[int(value), index] for index, value in enumerate(input().split())]",
"a_list",
"[[int(value), index] for index, value in enumerate(input().split())]",
"ans = 0",
"ans",
"0",
"prev = -1",
"prev",
"-1",
"for i in range(k):\n a_list.sort(reverse=True)\n index = 0\n if prev == a_list[index][1]:\n if len(a_list) > 1:\n index += 1\n else:\n ans += 1\n prev = a_list[index][1]\n if a_list[index][0] == 1:\n a_list.pop(index)\n else:\n a_list[index][0] -= 1",
"i",
"range(k)",
"range",
"k",
"a_list.sort(reverse=True)",
"a_list.sort",
"a_list",
"sort",
"reverse=True",
"reverse",
"True",
"index = 0",
"index",
"0",
"if prev == a_list[index][1]:\n if len(a_list) > 1:\n index += 1\n else:\n ans += 1\n ",
"prev == a_list[index][1]",
"prev",
"a_list[index][1]",
"[index]",
"a_list",
"index",
"1",
"if len(a_list) > 1:\n index += 1\n else:\n ans += 1\n ",
"len(a_list) > 1",
"len(a_list)",
"len",
"a_list",
"1",
"index += 1",
"index",
"1",
"ans += 1",
"ans",
"1",
"prev = a_list[index][1]",
"prev",
"a_list[index][1]",
"[index]",
"a_list",
"index",
"1",
"if a_list[index][0] == 1:\n a_list.pop(index)\n else:\n a_list[index][0] -= 1",
"a_list[index][0] == 1",
"a_list[index][0]",
"[index]",
"a_list",
"index",
"0",
"1",
"a_list.pop(index)",
"a_list.pop",
"a_list",
"pop",
"index",
"a_list[index][0] -= 1",
"a_list[index][0]",
"[index]",
"a_list",
"index",
"0",
"1",
"print(ans)",
"print",
"ans",
"index += 1",
"1",
"index",
"index = 0",
"0",
"index",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"prev = a_list[index][1]",
"a_list[index][1]",
"prev",
"a_list = [[int(value), index] for index, value in enumerate(input().split())]",
"[[int(value), index] for index, value in enumerate(input().split())]",
"a_list",
"prev = -1",
"-1",
"prev",
"ans = 0",
"0",
"ans",
"ans += 1",
"1",
"ans"
] |
k, t = map(int, input().split())
a_list = [[int(value), index] for index, value in enumerate(input().split())]
ans = 0
prev = -1
for i in range(k):
a_list.sort(reverse=True)
index = 0
if prev == a_list[index][1]:
if len(a_list) > 1:
index += 1
else:
ans += 1
prev = a_list[index][1]
if a_list[index][0] == 1:
a_list.pop(index)
else:
a_list[index][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,
4,
18,
13,
13,
0,
13,
17,
14,
2,
13,
17,
4,
13,
2,
13,
17,
4,
13,
0,
13,
18,
13,
17,
0,
13,
2,
4,
13,
13,
18,
13,
17,
14,
40,
13,
13,
4,
13,
17,
0,
13,
2,
2,
13,
13,
17,
4,
13,
4,
13,
13,
17,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13
] |
[
[
89,
2
],
[
89,
11
],
[
77,
13
],
[
78,
26
],
[
30,
29
],
[
90,
33
],
[
87,
38
],
[
92,
43
],
[
78,
45
],
[
80,
48
],
[
78,
52
],
[
78,
54
],
[
81,
58
],
[
93,
59
],
[
83,
64
],
[
93,
67
],
[
81,
68
],
[
84,
74
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
89,
87
],
[
89,
90
],
[
92,
93
]
] |
[
"k, t = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nif t == 1:\n print(k-1)\n exit()\n\nx = A[0]\ns = sum(A)-A[0]\nif s >= x:\n print(0)\nelse:\n ans = x-s-1\n print(max(ans, 0))",
"k, t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"A = list(map(int, input().split()))",
"A",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A.sort(reverse=True)",
"A.sort",
"A",
"sort",
"reverse=True",
"reverse",
"True",
"if t == 1:\n print(k-1)\n exit()",
"t == 1",
"t",
"1",
"print(k-1)",
"print",
"k-1",
"k",
"1",
"exit()",
"exit",
"x = A[0]",
"x",
"A[0]",
"A",
"0",
"s = sum(A)-A[0]",
"s",
"sum(A)-A[0]",
"sum(A)",
"sum",
"A",
"A[0]",
"A",
"0",
"if s >= x:\n print(0)\nelse:\n ans = x-s-1\n print(max(ans, 0))",
"s >= x",
"s",
"x",
"print(0)",
"print",
"0",
"ans = x-s-1",
"ans",
"x-s-1",
"x-s",
"x",
"s",
"1",
"print(max(ans, 0))",
"print",
"max(ans, 0)",
"max",
"ans",
"0",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"s = sum(A)-A[0]",
"sum(A)-A[0]",
"s",
"ans = x-s-1",
"x-s-1",
"ans",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"x = A[0]",
"A[0]",
"x"
] |
k, t = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
if t == 1:
print(k-1)
exit()
x = A[0]
s = sum(A)-A[0]
if s >= x:
print(0)
else:
ans = x-s-1
print(max(ans, 0))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
17,
28,
13,
13,
14,
2,
13,
2,
13,
17,
0,
13,
2,
13,
2,
13,
13,
3,
4,
13,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13
] |
[
[
61,
2
],
[
61,
11
],
[
70,
13
],
[
64,
25
],
[
71,
28
],
[
58,
30
],
[
34,
33
],
[
71,
33
],
[
33,
37
],
[
65,
39
],
[
67,
42
],
[
33,
44
],
[
65,
46
],
[
33,
47
],
[
68,
52
],
[
59,
52
],
[
61,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
]
] |
[
"k,t=map(int,input().split())\na=list(map(int,input().split()))\nsm=sum(a)\nn=1\nfor i in a:\n if i>sm//2:\n n=i-(sm-i)\n break\nprint(n-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",
"sm=sum(a)",
"sm",
"sum(a)",
"sum",
"a",
"n=1",
"n",
"1",
"for i in a:\n if i>sm//2:\n n=i-(sm-i)\n break",
"i",
"a",
"if i>sm//2:\n n=i-(sm-i)\n break",
"i>sm//2",
"i",
"sm//2",
"sm",
"2",
"n=i-(sm-i)",
"n",
"i-(sm-i)",
"i",
"sm-i",
"sm",
"i",
"break",
"print(n-1)",
"print",
"n-1",
"n",
"1",
"t=map(int,input().split())",
"map(int,input().split())",
"t",
"n=1",
"1",
"n",
"k,t=map(int,input().split())",
"map(int,input().split())",
"k",
"sm=sum(a)",
"sum(a)",
"sm",
"n=i-(sm-i)",
"i-(sm-i)",
"n",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a"
] |
k,t=map(int,input().split())
a=list(map(int,input().split()))
sm=sum(a)
n=1
for i in a:
if i>sm//2:
n=i-(sm-i)
break
print(n-1)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
0,
13,
18,
13,
17,
0,
13,
4,
13,
18,
13,
39,
17,
0,
13,
17,
14,
2,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
2,
2,
13,
13,
17,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13
] |
[
[
88,
2
],
[
88,
11
],
[
70,
13
],
[
71,
26
],
[
73,
29
],
[
71,
31
],
[
79,
34
],
[
71,
38
],
[
76,
42
],
[
89,
46
],
[
85,
49
],
[
68,
51
],
[
82,
54
],
[
74,
59
],
[
80,
60
],
[
83,
65
],
[
86,
65
],
[
77,
65
],
[
88,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
],
[
88,
89
]
] |
[
"K, T = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\namax = a[-1]\nasum = sum(a[:-1])\nans = 0\nif T == 1:\n ans = K - 1\nelse:\n ans = max(amax - asum - 1, 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",
"amax = a[-1]",
"amax",
"a[-1]",
"a",
"-1",
"asum = sum(a[:-1])",
"asum",
"sum(a[:-1])",
"sum",
"a[:-1]",
"a",
":-1",
"-1",
"ans = 0",
"ans",
"0",
"if T == 1:\n ans = K - 1\nelse:\n ans = max(amax - asum - 1, 0)",
"T == 1",
"T",
"1",
"ans = K - 1",
"ans",
"K - 1",
"K",
"1",
"ans = max(amax - asum - 1, 0)",
"ans",
"max(amax - asum - 1, 0)",
"max",
"amax - asum - 1",
"amax - asum",
"amax",
"asum",
"1",
"0",
"print(ans)",
"print",
"ans",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"amax = a[-1]",
"a[-1]",
"amax",
"ans = 0",
"0",
"ans",
"asum = sum(a[:-1])",
"sum(a[:-1])",
"asum",
"ans = max(amax - asum - 1, 0)",
"max(amax - asum - 1, 0)",
"ans",
"ans = K - 1",
"K - 1",
"ans",
"T = map(int, input().split())",
"map(int, input().split())",
"T"
] |
K, T = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
amax = a[-1]
asum = sum(a[:-1])
ans = 0
if T == 1:
ans = K - 1
else:
ans = max(amax - asum - 1, 0)
print(ans)
|
[
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,
13,
14,
2,
13,
17,
0,
13,
2,
13,
17,
14,
2,
13,
17,
0,
13,
2,
18,
13,
17,
18,
13,
17,
14,
40,
13,
17,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
2,
18,
13,
17,
18,
13,
17,
14,
40,
13,
17,
0,
13,
17,
0,
13,
4,
13,
18,
13,
39,
17,
14,
40,
2,
18,
13,
17,
17,
2,
18,
13,
17,
13,
0,
13,
17,
0,
13,
2,
2,
18,
13,
17,
2,
18,
13,
17,
13,
17,
0,
13,
13,
4,
13,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13
] |
[
[
157,
2
],
[
157,
13
],
[
130,
15
],
[
154,
27
],
[
131,
30
],
[
160,
32
],
[
158,
33
],
[
146,
36
],
[
142,
39
],
[
158,
41
],
[
146,
45
],
[
166,
48
],
[
155,
51
],
[
131,
51
],
[
155,
54
],
[
131,
54
],
[
167,
58
],
[
136,
61
],
[
127,
64
],
[
167,
66
],
[
163,
69
],
[
155,
72
],
[
131,
72
],
[
155,
75
],
[
131,
75
],
[
164,
79
],
[
133,
82
],
[
169,
85
],
[
155,
89
],
[
131,
89
],
[
155,
96
],
[
131,
96
],
[
155,
101
],
[
131,
101
],
[
170,
103
],
[
148,
105
],
[
151,
108
],
[
155,
112
],
[
131,
112
],
[
155,
116
],
[
131,
116
],
[
170,
118
],
[
139,
121
],
[
152,
122
],
[
149,
122
],
[
134,
122
],
[
128,
122
],
[
137,
122
],
[
143,
122
],
[
140,
125
],
[
127,
128
],
[
130,
131
],
[
133,
134
],
[
136,
137
],
[
152,
139
],
[
149,
139
],
[
134,
139
],
[
128,
139
],
[
137,
139
],
[
143,
139
],
[
139,
140
],
[
142,
143
],
[
157,
146
],
[
148,
149
],
[
151,
152
],
[
154,
155
],
[
157,
158
],
[
158,
160
],
[
160,
161
],
[
163,
164
],
[
166,
167
],
[
169,
170
]
] |
[
"#!/usr/bin/env python3\n\nK, T = list(map(int, input().split()))\na_list = list(map(int, input().split()))\na_list = sorted(a_list)\nk = K\n\nif T == 1:\n count = K - 1\nelif T == 2:\n diff = a_list[-1] - a_list[-2]\n if diff <= 1:\n count = 0\n else:\n count = diff - 1\nelse:\n # 一番多いケーキと2番目に多いケーキの個数の差\n diff = a_list[-1] - a_list[-2]\n if diff <= 1:\n count = 0\n else:\n x = sum(a_list[:-2])\n if (a_list[-1] - 1) <= (a_list[-2] + x):\n count = 0\n else:\n count = a_list[-1] - (a_list[-2] + x) - 1\nans = count\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",
"a_list = list(map(int, input().split()))",
"a_list",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a_list = sorted(a_list)",
"a_list",
"sorted(a_list)",
"sorted",
"a_list",
"k = K",
"k",
"K",
"if T == 1:\n count = K - 1\nelif T == 2:\n diff = a_list[-1] - a_list[-2]\n if diff <= 1:\n count = 0\n else:\n count = diff - 1\nelse:\n # 一番多いケーキと2番目に多いケーキの個数の差\n diff = a_list[-1] - a_list[-2]\n if diff <= 1:\n count = 0\n else:\n x = sum(a_list[:-2])\n if (a_list[-1] - 1) <= (a_list[-2] + x):\n count = 0\n else:\n count = a_list[-1] - (a_list[-2] + x) - 1",
"T == 1",
"T",
"1",
"count = K - 1",
"count",
"K - 1",
"K",
"1",
"elif T == 2:\n diff = a_list[-1] - a_list[-2]\n if diff <= 1:\n count = 0\n else:\n count = diff - 1",
"T == 2",
"T",
"2",
"diff = a_list[-1] - a_list[-2]",
"diff",
"a_list[-1] - a_list[-2]",
"a_list[-1]",
"a_list",
"-1",
"a_list[-2]",
"a_list",
"-2",
"if diff <= 1:\n count = 0\n else:\n count = diff - 1",
"diff <= 1",
"diff",
"1",
"count = 0",
"count",
"0",
"count = diff - 1",
"count",
"diff - 1",
"diff",
"1",
"diff = a_list[-1] - a_list[-2]",
"diff",
"a_list[-1] - a_list[-2]",
"a_list[-1]",
"a_list",
"-1",
"a_list[-2]",
"a_list",
"-2",
"if diff <= 1:\n count = 0\n else:\n x = sum(a_list[:-2])\n if (a_list[-1] - 1) <= (a_list[-2] + x):\n count = 0\n else:\n count = a_list[-1] - (a_list[-2] + x) - 1",
"diff <= 1",
"diff",
"1",
"count = 0",
"count",
"0",
"x = sum(a_list[:-2])",
"x",
"sum(a_list[:-2])",
"sum",
"a_list[:-2]",
"a_list",
":-2",
"-2",
"if (a_list[-1] - 1) <= (a_list[-2] + x):\n count = 0\n else:\n count = a_list[-1] - (a_list[-2] + x) - 1",
"(a_list[-1] - 1) <= (a_list[-2] + x)",
"a_list[-1] - 1",
"a_list[-1]",
"a_list",
"-1",
"1",
"a_list[-2] + x",
"a_list[-2]",
"a_list",
"-2",
"x",
"count = 0",
"count",
"0",
"count = a_list[-1] - (a_list[-2] + x) - 1",
"count",
"a_list[-1] - (a_list[-2] + x) - 1",
"a_list[-1] - (a_list[-2] + x)",
"a_list[-1]",
"a_list",
"-1",
"a_list[-2] + x",
"a_list[-2]",
"a_list",
"-2",
"x",
"1",
"ans = count",
"ans",
"count",
"print(ans)",
"print",
"ans",
"count = diff - 1",
"diff - 1",
"count",
"a_list = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a_list",
"count = 0",
"0",
"count",
"count = 0",
"0",
"count",
"ans = count",
"count",
"ans",
"count = K - 1",
"K - 1",
"count",
"T = list(map(int, input().split()))",
"list(map(int, input().split()))",
"T",
"count = 0",
"0",
"count",
"count = a_list[-1] - (a_list[-2] + x) - 1",
"a_list[-1] - (a_list[-2] + x) - 1",
"count",
"a_list = sorted(a_list)",
"sorted(a_list)",
"a_list",
"K, T = list(map(int, input().split()))",
"list(map(int, input().split()))",
"K",
"k = K",
"K",
"k",
"diff = a_list[-1] - a_list[-2]",
"a_list[-1] - a_list[-2]",
"diff",
"diff = a_list[-1] - a_list[-2]",
"a_list[-1] - a_list[-2]",
"diff",
"x = sum(a_list[:-2])",
"sum(a_list[:-2])",
"x"
] |
#!/usr/bin/env python3
K, T = list(map(int, input().split()))
a_list = list(map(int, input().split()))
a_list = sorted(a_list)
k = K
if T == 1:
count = K - 1
elif T == 2:
diff = a_list[-1] - a_list[-2]
if diff <= 1:
count = 0
else:
count = diff - 1
else:
# 一番多いケーキと2番目に多いケーキの個数の差
diff = a_list[-1] - a_list[-2]
if diff <= 1:
count = 0
else:
x = sum(a_list[:-2])
if (a_list[-1] - 1) <= (a_list[-2] + x):
count = 0
else:
count = a_list[-1] - (a_list[-2] + x) - 1
ans = count
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,
4,
13,
8,
2,
2,
2,
17,
4,
13,
13,
13,
17,
2,
2,
2,
17,
4,
13,
13,
13,
17,
17,
10,
13,
13,
10,
4,
13,
10,
4,
13
] |
[
[
56,
2
],
[
56,
11
],
[
15,
14
],
[
14,
23
],
[
50,
25
],
[
51,
36
],
[
54,
37
],
[
51,
45
],
[
54,
46
],
[
50,
51
],
[
56,
54
],
[
56,
57
]
] |
[
"K, T = map(int, input().split())\nA = [int(i) for i in input().split()]\n\nprint(2*max(A)-K-1 if 2*max(A)-K>0 else 0)",
"K, T = map(int, input().split())",
"K",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"A = [int(i) for i in input().split()]",
"A",
"[int(i) for i in input().split()]",
"print(2*max(A)-K-1 if 2*max(A)-K>0 else 0)",
"print",
"2*max(A)-K-1 if 2*max(A)-K>0 else 0",
"2*max(A)-K>0",
"2*max(A)-K",
"2*max(A)",
"2",
"max(A)",
"max",
"A",
"K",
"0",
"2*max(A)-K-1",
"2*max(A)-K",
"2*max(A)",
"2",
"max(A)",
"max",
"A",
"K",
"1",
"0",
"A = [int(i) for i in input().split()]",
"[int(i) for i in 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 = [int(i) for i in input().split()]
print(2*max(A)-K-1 if 2*max(A)-K>0 else 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,
2,
13,
17,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
13,
14,
40,
13,
13,
4,
13,
17,
4,
13,
2,
2,
2,
13,
13,
17,
17,
0,
13,
2,
2,
13,
17,
17,
0,
13,
4,
13,
13,
14,
40,
13,
13,
4,
13,
17,
4,
13,
2,
2,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] |
[
[
89,
2
],
[
89,
11
],
[
86,
13
],
[
84,
27
],
[
98,
31
],
[
84,
33
],
[
95,
36
],
[
87,
39
],
[
99,
42
],
[
96,
43
],
[
96,
52
],
[
99,
53
],
[
101,
57
],
[
84,
60
],
[
92,
64
],
[
87,
67
],
[
102,
70
],
[
93,
71
],
[
93,
79
],
[
102,
80
],
[
89,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
]
] |
[
"K,T=map(int,input().split())\nA=list(map(int,input().split()))\nif K%2==0:\n a=K//2\n b=max(A)\n if a>=b:\n print(0)\n else:\n print((b-a)*2-1)\nelse:\n a=K//2+1\n b=max(A)\n if a>=b:\n print(0)\n else:\n print((b-a)*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",
"if K%2==0:\n a=K//2\n b=max(A)\n if a>=b:\n print(0)\n else:\n print((b-a)*2-1)\nelse:\n a=K//2+1\n b=max(A)\n if a>=b:\n print(0)\n else:\n print((b-a)*2)",
"K%2==0",
"K%2",
"K",
"2",
"0",
"a=K//2",
"a",
"K//2",
"K",
"2",
"b=max(A)",
"b",
"max(A)",
"max",
"A",
"if a>=b:\n print(0)\n else:\n print((b-a)*2-1)",
"a>=b",
"a",
"b",
"print(0)",
"print",
"0",
"print((b-a)*2-1)",
"print",
"(b-a)*2-1",
"(b-a)*2",
"b-a",
"b",
"a",
"2",
"1",
"a=K//2+1",
"a",
"K//2+1",
"K//2",
"K",
"2",
"1",
"b=max(A)",
"b",
"max(A)",
"max",
"A",
"if a>=b:\n print(0)\n else:\n print((b-a)*2)",
"a>=b",
"a",
"b",
"print(0)",
"print",
"0",
"print((b-a)*2)",
"print",
"(b-a)*2",
"b-a",
"b",
"a",
"2",
"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",
"b=max(A)",
"max(A)",
"b",
"b=max(A)",
"max(A)",
"b",
"a=K//2",
"K//2",
"a",
"a=K//2+1",
"K//2+1",
"a"
] |
K,T=map(int,input().split())
A=list(map(int,input().split()))
if K%2==0:
a=K//2
b=max(A)
if a>=b:
print(0)
else:
print((b-a)*2-1)
else:
a=K//2+1
b=max(A)
if a>=b:
print(0)
else:
print((b-a)*2)
|
[
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,
14,
2,
13,
17,
4,
18,
13,
13,
0,
13,
17,
0,
13,
4,
13,
17,
2,
2,
18,
13,
17,
17,
4,
13,
18,
13,
39,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
67,
4
],
[
67,
13
],
[
64,
15
],
[
59,
28
],
[
65,
32
],
[
36,
35
],
[
61,
38
],
[
65,
45
],
[
65,
51
],
[
62,
56
],
[
67,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
]
] |
[
"import sys\n\nk,n=map(int,input().split())\na=list(map(int,input().split()))\nif n==1: print(a[0]-1);sys.exit()\n\na.sort(reverse=True)\nans=max(0,a[0]-1-sum(a[1:]))\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",
"if n==1: print(a[0]-1);sys.exit()",
"n==1",
"n",
"1",
"a.sort(reverse=True)",
"a.sort",
"a",
"sort",
"reverse=True",
"reverse",
"True",
"ans=max(0,a[0]-1-sum(a[1:]))",
"ans",
"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",
"print(ans)",
"print",
"ans",
"n=map(int,input().split())",
"map(int,input().split())",
"n",
"ans=max(0,a[0]-1-sum(a[1:]))",
"max(0,a[0]-1-sum(a[1:]))",
"ans",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a",
"k,n=map(int,input().split())",
"map(int,input().split())",
"k"
] |
import sys
k,n=map(int,input().split())
a=list(map(int,input().split()))
if n==1: print(a[0]-1);sys.exit()
a.sort(reverse=True)
ans=max(0,a[0]-1-sum(a[1:]))
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
0,
13,
17,
0,
13,
17,
13,
17,
28,
13,
13,
14,
2,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
2,
2,
4,
13,
13,
13,
4,
13,
13,
13,
17,
4,
13,
4,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
2,
13
] |
[
[
72,
2
],
[
72,
11
],
[
75,
13
],
[
76,
26
],
[
30,
29
],
[
78,
32
],
[
81,
34
],
[
38,
37
],
[
76,
37
],
[
79,
41
],
[
85,
41
],
[
82,
42
],
[
88,
42
],
[
84,
44
],
[
37,
45
],
[
87,
47
],
[
37,
48
],
[
90,
50
],
[
85,
55
],
[
79,
55
],
[
88,
56
],
[
82,
56
],
[
85,
59
],
[
79,
59
],
[
88,
60
],
[
82,
60
],
[
91,
66
],
[
72,
70
],
[
72,
73
],
[
75,
76
],
[
78,
79
],
[
81,
82
],
[
37,
84
],
[
84,
85
],
[
37,
87
],
[
87,
88
],
[
90,
91
]
] |
[
"k,t = map(int, input().split())\nal = list(map(int, input().split()))\n\nal.sort(reverse=True)\n\nx,y = 0,0\nfor a in al:\n if x<y:\n x += a\n else:\n y += a\n\nres = (max(x,y)-min(x,y)) - 1\nprint(max(res,0))",
"k,t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"al = list(map(int, input().split()))",
"al",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"al.sort(reverse=True)",
"al.sort",
"al",
"sort",
"reverse=True",
"reverse",
"True",
"x,y = 0,0",
"x",
"0",
"y",
"0",
"for a in al:\n if x<y:\n x += a\n else:\n y += a",
"a",
"al",
"if x<y:\n x += a\n else:\n y += a",
"x<y",
"x",
"y",
"x += a",
"x",
"a",
"y += a",
"y",
"a",
"res = (max(x,y)-min(x,y)) - 1",
"res",
"(max(x,y)-min(x,y)) - 1",
"max(x,y)-min(x,y)",
"max(x,y)",
"max",
"x",
"y",
"min(x,y)",
"min",
"x",
"y",
"1",
"print(max(res,0))",
"print",
"max(res,0)",
"max",
"res",
"0",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"k,t = map(int, input().split())",
"map(int, input().split())",
"k",
"al = list(map(int, input().split()))",
"list(map(int, input().split()))",
"al",
"x,y = 0,0",
"0",
"x",
"y = 0,0",
"0",
"y",
"x += a",
"a",
"x",
"y += a",
"a",
"y",
"res = (max(x,y)-min(x,y)) - 1",
"(max(x,y)-min(x,y)) - 1",
"res"
] |
k,t = map(int, input().split())
al = list(map(int, input().split()))
al.sort(reverse=True)
x,y = 0,0
for a in al:
if x<y:
x += a
else:
y += a
res = (max(x,y)-min(x,y)) - 1
print(max(res,0))
|
[
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,
4,
18,
13,
13,
17,
4,
13,
4,
13,
17,
2,
2,
18,
13,
17,
4,
13,
18,
13,
39,
17,
17,
10,
4,
13,
10,
18,
13,
10,
4,
13
] |
[
[
58,
2
],
[
58,
11
],
[
55,
13
],
[
56,
31
],
[
56,
42
],
[
56,
47
],
[
58,
53
],
[
55,
56
],
[
58,
59
]
] |
[
"K, T = map(int, input().split())\nalist = sorted(list(map(int, input().split())))[::-1]\nalist.append(0)\nprint(max(0, alist[0]-sum(alist[1:])-1))",
"K, T = map(int, input().split())",
"K",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"alist = sorted(list(map(int, input().split())))[::-1]",
"alist",
"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",
"alist.append(0)",
"alist.append",
"alist",
"append",
"0",
"print(max(0, alist[0]-sum(alist[1:])-1))",
"print",
"max(0, alist[0]-sum(alist[1:])-1)",
"max",
"0",
"alist[0]-sum(alist[1:])-1",
"alist[0]-sum(alist[1:])",
"alist[0]",
"alist",
"0",
"sum(alist[1:])",
"sum",
"alist[1:]",
"alist",
"1:",
"1",
"1",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"alist = sorted(list(map(int, input().split())))[::-1]",
"sorted(list(map(int, input().split())))[::-1]",
"alist",
"T = map(int, input().split())",
"map(int, input().split())",
"T"
] |
K, T = map(int, input().split())
alist = sorted(list(map(int, input().split())))[::-1]
alist.append(0)
print(max(0, alist[0]-sum(alist[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,
0,
13,
4,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
4,
13,
13,
0,
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,
4,
13,
10,
4,
13
] |
[
[
72,
2
],
[
72,
11
],
[
66,
13
],
[
63,
25
],
[
67,
28
],
[
67,
31
],
[
67,
35
],
[
67,
39
],
[
60,
41
],
[
67,
44
],
[
64,
47
],
[
61,
48
],
[
64,
53
],
[
61,
54
],
[
60,
61
],
[
63,
64
],
[
66,
67
],
[
72,
70
],
[
72,
73
]
] |
[
"K, T = map(int, input().split())\na = list(map(int, input().split()))\n\nx = max(a)\na.pop(a.index(max(a)))\ny = sum(a)\n\nif x > y:\n print(x-y-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",
"x = max(a)",
"x",
"max(a)",
"max",
"a",
"a.pop(a.index(max(a)))",
"a.pop",
"a",
"pop",
"a.index(max(a))",
"a.index",
"a",
"index",
"max(a)",
"max",
"a",
"y = sum(a)",
"y",
"sum(a)",
"sum",
"a",
"if x > y:\n print(x-y-1)\nelse:\n print(0)",
"x > y",
"x",
"y",
"print(x-y-1)",
"print",
"x-y-1",
"x-y",
"x",
"y",
"1",
"print(0)",
"print",
"0",
"y = sum(a)",
"sum(a)",
"y",
"x = max(a)",
"max(a)",
"x",
"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()))
x = max(a)
a.pop(a.index(max(a)))
y = sum(a)
if x > y:
print(x-y-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,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
2,
13,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
2,
2,
13,
17,
17,
14,
18,
18,
13,
13,
13,
0,
18,
18,
13,
2,
13,
17,
13,
17,
14,
2,
2,
13,
18,
13,
13,
2,
2,
13,
17,
17,
0,
18,
18,
13,
2,
13,
17,
2,
13,
18,
13,
13,
17,
0,
13,
17,
28,
13,
13,
4,
13,
18,
13,
17,
14,
13,
0,
13,
13,
0,
13,
2,
13,
2,
2,
17,
13,
17,
4,
13,
4,
13,
13,
17,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13
] |
[
[
155,
2
],
[
155,
11
],
[
152,
13
],
[
27,
26
],
[
141,
30
],
[
156,
38
],
[
137,
42
],
[
50,
45
],
[
138,
47
],
[
53,
52
],
[
141,
55
],
[
58,
57
],
[
156,
62
],
[
138,
68
],
[
52,
69
],
[
57,
70
],
[
79,
72
],
[
138,
74
],
[
52,
76
],
[
57,
78
],
[
57,
83
],
[
153,
85
],
[
52,
86
],
[
156,
89
],
[
104,
93
],
[
138,
95
],
[
52,
97
],
[
57,
100
],
[
153,
102
],
[
52,
103
],
[
143,
106
],
[
138,
114
],
[
146,
119
],
[
149,
122
],
[
156,
124
],
[
147,
128
],
[
144,
128
],
[
150,
134
],
[
137,
138
],
[
155,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
]
] |
[
"k,t = map(int,input().split())\na = list(map(int,input().split()))\n\ndp = [[False] * (k//2+1) for _ in range(t+1)]\n\ndp[0][0] = True\n\nfor i in range(t):\n for j in range(k//2+1):\n if dp[i][j]:\n dp[i+1][j] = True\n if j + a[i] < k//2+1:\n dp[i+1][j + a[i]] = True\n\ncnt = 0\nfor i,e in enumerate(dp[-1]):\n if e:\n cnt = i\n\nans = k - (2 * cnt + 1)\n\nprint(max(ans, 0))",
"k,t = map(int,input().split())",
"k",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"a = list(map(int,input().split()))",
"a",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"[False] * (k//2+1) for _ in range(t+1)",
"for _ in range(t+1)",
"_",
"range(t+1)",
"range",
"t+1",
"t",
"1",
"for _ in range(t+1)",
"[False] * (k//2+1)",
"[False]",
"False",
"k//2+1",
"k//2",
"k",
"2",
"1",
"dp = [[False] * (k//2+1) for _ in range(t+1)]",
"dp",
"[[False] * (k//2+1) for _ in range(t+1)]",
"dp[0][0] = True",
"dp[0][0]",
"[0]",
"dp",
"0",
"0",
"True",
"for i in range(t):\n for j in range(k//2+1):\n if dp[i][j]:\n dp[i+1][j] = True\n if j + a[i] < k//2+1:\n dp[i+1][j + a[i]] = True",
"i",
"range(t)",
"range",
"t",
"for j in range(k//2+1):\n if dp[i][j]:\n dp[i+1][j] = True\n if j + a[i] < k//2+1:\n dp[i+1][j + a[i]] = True",
"j",
"range(k//2+1)",
"range",
"k//2+1",
"k//2",
"k",
"2",
"1",
"if dp[i][j]:\n dp[i+1][j] = True\n if j + a[i] < k//2+1:\n dp[i+1][j + a[i]] = True",
"dp[i][j]",
"[i]",
"dp",
"i",
"j",
"dp[i+1][j] = True",
"dp[i+1][j]",
"[i+1]",
"dp",
"i+1",
"i",
"1",
"j",
"True",
"if j + a[i] < k//2+1:\n dp[i+1][j + a[i]] = True",
"j + a[i] < k//2+1",
"j + a[i]",
"j",
"a[i]",
"a",
"i",
"k//2+1",
"k//2",
"k",
"2",
"1",
"dp[i+1][j + a[i]] = True",
"dp[i+1][j + a[i]]",
"[i+1]",
"dp",
"i+1",
"i",
"1",
"j + a[i]",
"j",
"a[i]",
"a",
"i",
"True",
"cnt = 0",
"cnt",
"0",
"for i,e in enumerate(dp[-1]):\n if e:\n cnt = i",
"i",
"e",
"enumerate(dp[-1])",
"enumerate",
"dp[-1]",
"dp",
"-1",
"if e:\n cnt = i",
"e",
"cnt = i",
"cnt",
"i",
"ans = k - (2 * cnt + 1)",
"ans",
"k - (2 * cnt + 1)",
"k",
"2 * cnt + 1",
"2 * cnt",
"2",
"cnt",
"1",
"print(max(ans, 0))",
"print",
"max(ans, 0)",
"max",
"ans",
"0",
"dp = [[False] * (k//2+1) for _ in range(t+1)]",
"[[False] * (k//2+1) for _ in range(t+1)]",
"dp",
"t = map(int,input().split())",
"map(int,input().split())",
"t",
"cnt = 0",
"0",
"cnt",
"cnt = i",
"i",
"cnt",
"ans = k - (2 * cnt + 1)",
"k - (2 * cnt + 1)",
"ans",
"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()))
dp = [[False] * (k//2+1) for _ in range(t+1)]
dp[0][0] = True
for i in range(t):
for j in range(k//2+1):
if dp[i][j]:
dp[i+1][j] = True
if j + a[i] < k//2+1:
dp[i+1][j + a[i]] = True
cnt = 0
for i,e in enumerate(dp[-1]):
if e:
cnt = i
ans = k - (2 * cnt + 1)
print(max(ans, 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,
2,
4,
13,
13,
18,
13,
17,
0,
13,
18,
13,
17,
14,
40,
13,
13,
4,
13,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13
] |
[
[
54,
2
],
[
54,
11
],
[
57,
13
],
[
60,
27
],
[
58,
31
],
[
58,
33
],
[
51,
36
],
[
58,
38
],
[
61,
42
],
[
52,
43
],
[
54,
49
],
[
51,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
]
] |
[
"k,t = map(int, input().split())\na = sorted(list(map(int, input().split())))\nSum = sum(a)-a[-1]\nMax = a[-1]\nif Sum >= Max: ans = 0\nelse: ans = Max-Sum-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())))",
"a",
"sorted(list(map(int, input().split())))",
"sorted",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"Sum = sum(a)-a[-1]",
"Sum",
"sum(a)-a[-1]",
"sum(a)",
"sum",
"a",
"a[-1]",
"a",
"-1",
"Max = a[-1]",
"Max",
"a[-1]",
"a",
"-1",
"if Sum >= Max: ans = 0\nelse: ans = Max-Sum-1",
"Sum >= Max",
"Sum",
"Max",
"print(ans)",
"print",
"ans",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"Max = a[-1]",
"a[-1]",
"Max",
"k,t = map(int, input().split())",
"map(int, input().split())",
"k",
"a = sorted(list(map(int, input().split())))",
"sorted(list(map(int, input().split())))",
"a",
"Sum = sum(a)-a[-1]",
"sum(a)-a[-1]",
"Sum"
] |
k,t = map(int, input().split())
a = sorted(list(map(int, input().split())))
Sum = sum(a)-a[-1]
Max = a[-1]
if Sum >= Max: ans = 0
else: ans = Max-Sum-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,
18,
13,
17,
0,
13,
4,
13,
18,
13,
39,
17,
4,
13,
4,
13,
17,
2,
2,
13,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13
] |
[
[
53,
2
],
[
53,
11
],
[
56,
13
],
[
62,
27
],
[
57,
29
],
[
59,
32
],
[
57,
36
],
[
63,
46
],
[
60,
48
],
[
53,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
],
[
62,
63
]
] |
[
"n, k = map(int, input().split())\nl = sorted(list(map(int, input().split())))\nmx = l[-1]\ns = sum(l[:-1])\nprint(max(0, mx-1-s))\n",
"n, k = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"k",
"l = sorted(list(map(int, input().split())))",
"l",
"sorted(list(map(int, input().split())))",
"sorted",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"mx = l[-1]",
"mx",
"l[-1]",
"l",
"-1",
"s = sum(l[:-1])",
"s",
"sum(l[:-1])",
"sum",
"l[:-1]",
"l",
":-1",
"-1",
"print(max(0, mx-1-s))",
"print",
"max(0, mx-1-s)",
"max",
"0",
"mx-1-s",
"mx-1",
"mx",
"1",
"s",
"k = map(int, input().split())",
"map(int, input().split())",
"k",
"n, k = map(int, input().split())",
"map(int, input().split())",
"n",
"l = sorted(list(map(int, input().split())))",
"sorted(list(map(int, input().split())))",
"l",
"s = sum(l[:-1])",
"sum(l[:-1])",
"s",
"mx = l[-1]",
"l[-1]",
"mx"
] |
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())))
mx = l[-1]
s = sum(l[:-1])
print(max(0, mx-1-s))
|
[
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,
4,
13,
13,
0,
13,
17,
4,
13,
4,
13,
17,
2,
2,
18,
13,
17,
4,
13,
18,
13,
39,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
53,
2
],
[
53,
11
],
[
15,
14
],
[
14,
23
],
[
56,
25
],
[
31,
30
],
[
57,
40
],
[
57,
45
],
[
53,
51
],
[
53,
54
],
[
56,
57
]
] |
[
"K, T = map(int, input().split())\nA = sorted([int(i) for i in input().split()], reverse=True)\n\nprint(max(0, A[0]-sum(A[1:])-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 = sorted([int(i) for i in input().split()], reverse=True)",
"A",
"sorted([int(i) for i in input().split()], reverse=True)",
"sorted",
"[int(i) for i in input().split()]",
"reverse=True",
"reverse",
"True",
"print(max(0, A[0]-sum(A[1:])-1))",
"print",
"max(0, A[0]-sum(A[1:])-1)",
"max",
"0",
"A[0]-sum(A[1:])-1",
"A[0]-sum(A[1:])",
"A[0]",
"A",
"0",
"sum(A[1:])",
"sum",
"A[1:]",
"A",
"1:",
"1",
"1",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"A = sorted([int(i) for i in input().split()], reverse=True)",
"sorted([int(i) for i in input().split()], reverse=True)",
"A"
] |
K, T = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
print(max(0, A[0]-sum(A[1:])-1))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
15,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
39,
40,
18,
13,
13,
13,
4,
18,
13,
13,
39,
17,
17,
4,
18,
13,
13,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
13,
13,
14,
40,
13,
13,
4,
13,
13,
39,
2,
13,
17,
13,
0,
13,
13,
0,
13,
4,
13,
13,
13,
14,
2,
13,
17,
0,
13,
13,
4,
13,
13,
39,
2,
13,
17,
13,
4,
13,
13,
39,
13,
13,
0,
13,
17,
4,
13,
13,
39,
2,
13,
17,
13,
4,
13,
13,
39,
13,
13,
4,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] |
[
[
167,
2
],
[
167,
11
],
[
134,
14
],
[
27,
26
],
[
168,
29
],
[
34,
31
],
[
135,
32
],
[
26,
33
],
[
31,
36
],
[
135,
37
],
[
26,
38
],
[
135,
42
],
[
135,
49
],
[
135,
53
],
[
155,
55
],
[
149,
58
],
[
62,
61
],
[
147,
64
],
[
164,
66
],
[
135,
69
],
[
164,
70
],
[
150,
73
],
[
153,
73
],
[
162,
73
],
[
159,
74
],
[
61,
74
],
[
135,
77
],
[
165,
80
],
[
161,
84
],
[
159,
85
],
[
61,
85
],
[
143,
87
],
[
135,
90
],
[
143,
91
],
[
141,
94
],
[
152,
97
],
[
144,
98
],
[
135,
101
],
[
141,
104
],
[
135,
109
],
[
137,
114
],
[
135,
118
],
[
165,
121
],
[
135,
126
],
[
138,
132
],
[
156,
132
],
[
134,
135
],
[
137,
138
],
[
143,
141
],
[
143,
144
],
[
167,
147
],
[
149,
150
],
[
144,
152
],
[
152,
153
],
[
155,
156
],
[
164,
159
],
[
159,
161
],
[
61,
161
],
[
161,
162
],
[
164,
165
],
[
167,
168
]
] |
[
"K,T = map(int,input().split())\nfrom heapq import heapify, heappop, heappush\nA = list(map(int,input().split()))\nfor i in range(T):\n A[i] = (-A[i],i)\nA.append((0,999))\nA.sort()\nheapify(A)\nans = 0\npre = -1\n\nfor i in range(K):\n a,i = heappop(A)\n if pre != i:\n heappush(A,(a+1,i))\n pre = i\n else:\n a2,i2 = heappop(A)\n if a2 < 0:\n pre = i2\n heappush(A,(a2+1,i2))\n heappush(A,(a,i))\n else:\n ans += 1\n heappush(A,(a+1,i))\n heappush(A,(a2,i2))\nprint(ans)\n\n \n\n",
"K,T = map(int,input().split())",
"K",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"from heapq import heapify, heappop, heappush",
"A = list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in range(T):\n A[i] = (-A[i],i)",
"i",
"range(T)",
"range",
"T",
"A[i] = (-A[i],i)",
"A[i]",
"A",
"i",
"(-A[i],i)",
"-A[i]",
"A[i]",
"A",
"i",
"i",
"A.append((0,999))",
"A.append",
"A",
"append",
"(0,999)",
"0",
"999",
"A.sort()",
"A.sort",
"A",
"sort",
"heapify(A)",
"heapify",
"A",
"ans = 0",
"ans",
"0",
"pre = -1",
"pre",
"-1",
"for i in range(K):\n a,i = heappop(A)\n if pre != i:\n heappush(A,(a+1,i))\n pre = i\n else:\n a2,i2 = heappop(A)\n if a2 < 0:\n pre = i2\n heappush(A,(a2+1,i2))\n heappush(A,(a,i))\n else:\n ans += 1\n heappush(A,(a+1,i))\n heappush(A,(a2,i2))",
"i",
"range(K)",
"range",
"K",
"a,i = heappop(A)",
"a",
"heappop(A)",
"heappop",
"A",
"i",
"if pre != i:\n heappush(A,(a+1,i))\n pre = i\n else:\n a2,i2 = heappop(A)\n if a2 < 0:\n pre = i2\n heappush(A,(a2+1,i2))\n heappush(A,(a,i))\n else:\n ans += 1\n heappush(A,(a+1,i))\n heappush(A,(a2,i2))",
"pre != i",
"pre",
"i",
"heappush(A,(a+1,i))",
"heappush",
"A",
"(a+1,i)",
"a+1",
"a",
"1",
"i",
"pre = i",
"pre",
"i",
"a2,i2 = heappop(A)",
"a2",
"heappop(A)",
"heappop",
"A",
"i2",
"if a2 < 0:\n pre = i2\n heappush(A,(a2+1,i2))\n heappush(A,(a,i))\n else:\n ans += 1\n heappush(A,(a+1,i))\n heappush(A,(a2,i2))",
"a2 < 0",
"a2",
"0",
"pre = i2",
"pre",
"i2",
"heappush(A,(a2+1,i2))",
"heappush",
"A",
"(a2+1,i2)",
"a2+1",
"a2",
"1",
"i2",
"heappush(A,(a,i))",
"heappush",
"A",
"(a,i)",
"a",
"i",
"ans += 1",
"ans",
"1",
"heappush(A,(a+1,i))",
"heappush",
"A",
"(a+1,i)",
"a+1",
"a",
"1",
"i",
"heappush(A,(a2,i2))",
"heappush",
"A",
"(a2,i2)",
"a2",
"i2",
"print(ans)",
"print",
"ans",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"ans += 1",
"1",
"ans",
"a2,i2 = heappop(A)",
"heappop(A)",
"a2",
"i2 = heappop(A)",
"heappop(A)",
"i2",
"K,T = map(int,input().split())",
"map(int,input().split())",
"K",
"pre = -1",
"-1",
"pre",
"pre = i2",
"i2",
"pre",
"ans = 0",
"0",
"ans",
"i = heappop(A)",
"heappop(A)",
"i",
"pre = i",
"i",
"pre",
"a,i = heappop(A)",
"heappop(A)",
"a",
"T = map(int,input().split())",
"map(int,input().split())",
"T"
] |
K,T = map(int,input().split())
from heapq import heapify, heappop, heappush
A = list(map(int,input().split()))
for i in range(T):
A[i] = (-A[i],i)
A.append((0,999))
A.sort()
heapify(A)
ans = 0
pre = -1
for i in range(K):
a,i = heappop(A)
if pre != i:
heappush(A,(a+1,i))
pre = i
else:
a2,i2 = heappop(A)
if a2 < 0:
pre = i2
heappush(A,(a2+1,i2))
heappush(A,(a,i))
else:
ans += 1
heappush(A,(a+1,i))
heappush(A,(a2,i2))
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
2,
18,
13,
13,
13,
0,
13,
2,
2,
13,
2,
13,
17,
17,
0,
13,
4,
13,
17,
2,
13,
13,
0,
13,
18,
13,
13,
4,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
96,
2
],
[
96,
11
],
[
90,
13
],
[
91,
26
],
[
87,
29
],
[
72,
32
],
[
36,
35
],
[
97,
38
],
[
75,
40
],
[
91,
43
],
[
35,
44
],
[
88,
45
],
[
79,
45
],
[
81,
47
],
[
73,
50
],
[
85,
50
],
[
88,
52
],
[
79,
52
],
[
78,
56
],
[
76,
61
],
[
82,
62
],
[
84,
64
],
[
91,
66
],
[
35,
67
],
[
79,
70
],
[
88,
70
],
[
72,
73
],
[
75,
76
],
[
78,
79
],
[
81,
82
],
[
84,
85
],
[
87,
88
],
[
90,
91
],
[
96,
94
],
[
96,
97
]
] |
[
"k, t = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\ndouble_cnt = 0\ntotal = 0\nfor i in range(t):\n b = a[i] - double_cnt\n c = total - (double_cnt + 1) + 2\n double_cnt = max(0, b-c)\n total += a[i]\nprint(double_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.sort()",
"a.sort",
"a",
"sort",
"double_cnt = 0",
"double_cnt",
"0",
"total = 0",
"total",
"0",
"for i in range(t):\n b = a[i] - double_cnt\n c = total - (double_cnt + 1) + 2\n double_cnt = max(0, b-c)\n total += a[i]",
"i",
"range(t)",
"range",
"t",
"b = a[i] - double_cnt",
"b",
"a[i] - double_cnt",
"a[i]",
"a",
"i",
"double_cnt",
"c = total - (double_cnt + 1) + 2",
"c",
"total - (double_cnt + 1) + 2",
"total - (double_cnt + 1)",
"total",
"double_cnt + 1",
"double_cnt",
"1",
"2",
"double_cnt = max(0, b-c)",
"double_cnt",
"max(0, b-c)",
"max",
"0",
"b-c",
"b",
"c",
"total += a[i]",
"total",
"a[i]",
"a",
"i",
"print(double_cnt)",
"print",
"double_cnt",
"total = 0",
"0",
"total",
"b = a[i] - double_cnt",
"a[i] - double_cnt",
"b",
"double_cnt = max(0, b-c)",
"max(0, b-c)",
"double_cnt",
"c = total - (double_cnt + 1) + 2",
"total - (double_cnt + 1) + 2",
"c",
"total += a[i]",
"a[i]",
"total",
"double_cnt = 0",
"0",
"double_cnt",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"t = map(int, input().split())",
"map(int, input().split())",
"t"
] |
k, t = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
double_cnt = 0
total = 0
for i in range(t):
b = a[i] - double_cnt
c = total - (double_cnt + 1) + 2
double_cnt = max(0, b-c)
total += a[i]
print(double_cnt)
|
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
14,
2,
13,
17,
4,
13,
2,
13,
17,
4,
13,
4,
18,
13,
13,
0,
13,
2,
17,
17,
28,
13,
4,
13,
17,
13,
0,
13,
4,
13,
18,
13,
39,
13,
0,
13,
4,
13,
18,
13,
39,
13,
0,
13,
4,
13,
13,
4,
13,
2,
13,
13,
4,
13,
4,
13,
2,
13,
17,
17,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13
] |
[
[
130,
11
],
[
118,
18
],
[
131,
31
],
[
127,
34
],
[
116,
36
],
[
127,
37
],
[
109,
39
],
[
116,
41
],
[
125,
44
],
[
128,
49
],
[
110,
55
],
[
106,
58
],
[
64,
63
],
[
119,
65
],
[
125,
67
],
[
121,
69
],
[
110,
73
],
[
112,
77
],
[
110,
81
],
[
103,
85
],
[
107,
88
],
[
104,
88
],
[
122,
92
],
[
113,
93
],
[
104,
99
],
[
107,
99
],
[
103,
104
],
[
106,
107
],
[
109,
110
],
[
112,
113
],
[
118,
119
],
[
121,
122
],
[
127,
125
],
[
127,
128
],
[
130,
131
]
] |
[
"# https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b\n\nimport sys\nsys.setrecursionlimit(1 << 25)\nread = sys.stdin.readline\nrr = range\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\nK, T = read_ints()\nA = read_ints()\nif T == 1:\n # コーナーケース\n print(K - 1)\n exit()\n\n# 差が最も少なくなるように二分割すれば良い\n# 二分探索でもいいが線形探索で愚直に合計値を計算しても十分間に合う\nA.sort()\nans = 2**31\nfor i in rr(1, T):\n r = sum(A[:i])\n l = sum(A[i:])\n ans = min(ans, abs(r - l))\nprint(max(ans - 1, 0))",
"import sys",
"sys",
"sys.setrecursionlimit(1 << 25)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"1 << 25",
"1",
"25",
"read = sys.stdin.readline",
"read",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rr = range",
"rr",
"range",
"def read_ints():\n return list(map(int, read().split()))",
"read_ints",
"return list(map(int, read().split()))",
"list(map(int, read().split()))",
"list",
"map(int, read().split())",
"map",
"int",
"read().split()",
"().split",
"()",
"read",
"split",
"K, T = read_ints()",
"K",
"read_ints()",
"read_ints",
"T",
"A = read_ints()",
"A",
"read_ints()",
"read_ints",
"if T == 1:\n # コーナーケース\n print(K - 1)\n exit()\n\n# 差が最も少なくなるように二分割すれば良い\n# 二分探索でもいいが線形探索で愚直に合計値を計算しても十分間に合う",
"T == 1",
"T",
"1",
"print(K - 1)",
"print",
"K - 1",
"K",
"1",
"exit()",
"exit",
"A.sort()",
"A.sort",
"A",
"sort",
"ans = 2**31",
"ans",
"2**31",
"2",
"31",
"for i in rr(1, T):\n r = sum(A[:i])\n l = sum(A[i:])\n ans = min(ans, abs(r - l))",
"i",
"rr(1, T)",
"rr",
"1",
"T",
"r = sum(A[:i])",
"r",
"sum(A[:i])",
"sum",
"A[:i]",
"A",
":i",
"i",
"l = sum(A[i:])",
"l",
"sum(A[i:])",
"sum",
"A[i:]",
"A",
"i:",
"i",
"ans = min(ans, abs(r - l))",
"ans",
"min(ans, abs(r - l))",
"min",
"ans",
"abs(r - l)",
"abs",
"r - l",
"r",
"l",
"print(max(ans - 1, 0))",
"print",
"max(ans - 1, 0)",
"max",
"ans - 1",
"ans",
"1",
"0",
"ans = min(ans, abs(r - l))",
"min(ans, abs(r - l))",
"ans",
"ans = 2**31",
"2**31",
"ans",
"A = read_ints()",
"read_ints()",
"A",
"l = sum(A[i:])",
"sum(A[i:])",
"l",
"def read_ints():\n return list(map(int, read().split()))",
"def read_ints():\n return list(map(int, read().split()))",
"read_ints",
"rr = range",
"range",
"rr",
"r = sum(A[:i])",
"sum(A[:i])",
"r",
"T = read_ints()",
"read_ints()",
"T",
"K, T = read_ints()",
"read_ints()",
"K",
"read = sys.stdin.readline",
"sys.stdin.readline",
"read"
] |
# https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
rr = range
def read_ints():
return list(map(int, read().split()))
K, T = read_ints()
A = read_ints()
if T == 1:
# コーナーケース
print(K - 1)
exit()
# 差が最も少なくなるように二分割すれば良い
# 二分探索でもいいが線形探索で愚直に合計値を計算しても十分間に合う
A.sort()
ans = 2**31
for i in rr(1, T):
r = sum(A[:i])
l = sum(A[i:])
ans = min(ans, abs(r - l))
print(max(ans - 1, 0))
|
[
7,
15,
13,
12,
13,
15,
0,
13,
4,
13,
4,
13,
12,
2,
13,
17,
23,
13,
4,
13,
13,
42,
17,
14,
40,
4,
13,
13,
17,
3,
0,
13,
2,
17,
4,
13,
13,
0,
13,
2,
17,
4,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
13,
17,
4,
13,
13,
40,
13,
14,
2,
13,
17,
4,
13,
13,
40,
13,
14,
2,
4,
13,
13,
17,
4,
13,
2,
2,
17,
18,
13,
17,
17,
4,
13,
17,
29,
23,
13,
23,
13,
23,
13,
12,
13,
12,
13,
28,
13,
18,
13,
13,
28,
13,
4,
18,
13,
13,
27,
13,
0,
13,
4,
13,
0,
13,
4,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
13,
0,
13,
13,
4,
13,
13,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13
] |
[
[
8,
7
],
[
92,
17
],
[
7,
20
],
[
92,
20
],
[
7,
27
],
[
92,
27
],
[
32,
31
],
[
7,
36
],
[
92,
36
],
[
39,
38
],
[
7,
43
],
[
92,
43
],
[
46,
45
],
[
49,
48
],
[
45,
52
],
[
31,
52
],
[
7,
56
],
[
92,
56
],
[
45,
58
],
[
31,
58
],
[
48,
61
],
[
38,
61
],
[
7,
65
],
[
92,
65
],
[
48,
67
],
[
38,
67
],
[
7,
72
],
[
92,
72
],
[
7,
80
],
[
92,
80
],
[
88,
88
],
[
90,
90
],
[
92,
92
],
[
99,
98
],
[
104,
103
],
[
98,
106
],
[
103,
109
],
[
112,
111
],
[
96,
113
],
[
116,
115
],
[
111,
120
],
[
123,
122
],
[
111,
127
],
[
131,
130
],
[
122,
133
],
[
111,
139
],
[
142,
141
],
[
159,
144
],
[
115,
145
],
[
122,
146
],
[
141,
147
],
[
156,
153
]
] |
[
"#!/usr/bin/env python3\nimport sys\n\n\ndef solve(K: int, T: int, a: \"List[int]\"):\n from heapq import heapify, heappop, heappush\n\n a = list(map(lambda x:x*(-1), a))\n heapify(a)\n while True:\n if len(a) <= 1:\n break\n\n x = -1*heappop(a)\n y = -1*heappop(a)\n x -= 1\n y -= 1\n if x > 0:\n heappush(a, -x)\n if y > 0:\n heappush(a, -y)\n\n if len(a) == 1:\n print(-1*a[0]-1)\n else:\n print(0)\n\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n K = int(next(tokens)) # type: int\n T = int(next(tokens)) # type: int\n a = [ int(next(tokens)) for _ in range(T) ] # type: \"List[int]\"\n solve(K, T, a)\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"def solve(K: int, T: int, a: \"List[int]\"):\n from heapq import heapify, heappop, heappush\n\n a = list(map(lambda x:x*(-1), a))\n heapify(a)\n while True:\n if len(a) <= 1:\n break\n\n x = -1*heappop(a)\n y = -1*heappop(a)\n x -= 1\n y -= 1\n if x > 0:\n heappush(a, -x)\n if y > 0:\n heappush(a, -y)\n\n if len(a) == 1:\n print(-1*a[0]-1)\n else:\n print(0)\n\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)",
"solve",
"from heapq import heapify, heappop, heappush",
"a = list(map(lambda x:x*(-1), a))",
"a",
"list(map(lambda x:x*(-1), a))",
"list",
"map(lambda x:x*(-1), a)",
"map",
"lambda x:x*(-1)",
"x*(-1)",
"x",
"-1",
"x",
"a",
"heapify(a)",
"heapify",
"a",
"while True:\n if len(a) <= 1:\n break\n\n x = -1*heappop(a)\n y = -1*heappop(a)\n x -= 1\n y -= 1\n if x > 0:\n heappush(a, -x)\n if y > 0:\n heappush(a, -y)\n\n ",
"True",
"if len(a) <= 1:\n break\n\n ",
"len(a) <= 1",
"len(a)",
"len",
"a",
"1",
"break",
"x = -1*heappop(a)",
"x",
"-1*heappop(a)",
"-1",
"heappop(a)",
"heappop",
"a",
"y = -1*heappop(a)",
"y",
"-1*heappop(a)",
"-1",
"heappop(a)",
"heappop",
"a",
"x -= 1",
"x",
"1",
"y -= 1",
"y",
"1",
"if x > 0:\n heappush(a, -x)\n ",
"x > 0",
"x",
"0",
"heappush(a, -x)",
"heappush",
"a",
"-x",
"x",
"if y > 0:\n heappush(a, -y)\n\n ",
"y > 0",
"y",
"0",
"heappush(a, -y)",
"heappush",
"a",
"-y",
"y",
"if len(a) == 1:\n print(-1*a[0]-1)\n else:\n print(0)\n\n ",
"len(a) == 1",
"len(a)",
"len",
"a",
"1",
"print(-1*a[0]-1)",
"print",
"-1*a[0]-1",
"-1*a[0]",
"-1",
"a[0]",
"a",
"0",
"1",
"print(0)",
"print",
"0",
"return",
"K: int",
"K",
"T: int",
"T",
"a: \"List[int]\"",
"a",
"def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n K = int(next(tokens)) # type: int\n T = int(next(tokens)) # type: int\n a = [ int(next(tokens)) for _ in range(T) ] # type: \"List[int]\"\n solve(K, T, a)",
"main",
"def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n ",
"iterate_tokens",
"for line in sys.stdin:\n for word in line.split():\n yield word\n ",
"line",
"sys.stdin",
"sys",
"stdin",
"for word in line.split():\n yield word\n ",
"word",
"line.split()",
"line.split",
"line",
"split",
"yield word",
"word",
"tokens = iterate_tokens()",
"tokens",
"iterate_tokens()",
"iterate_tokens",
"K = int(next(tokens))",
"K",
"int(next(tokens))",
"int",
"next(tokens)",
"next",
"tokens",
"T = int(next(tokens))",
"T",
"int(next(tokens))",
"int",
"next(tokens)",
"next",
"tokens",
"int(next(tokens)) for _ in range(T)",
"for _ in range(T)",
"_",
"range(T)",
"range",
"T",
"for _ in range(T)",
"int(next(tokens))",
"int",
"next(tokens)",
"next",
"tokens",
"a = [ int(next(tokens)) for _ in range(T) ]",
"a",
"[ int(next(tokens)) for _ in range(T) ]",
"solve(K, T, a)",
"solve",
"K",
"T",
"a",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n K = int(next(tokens)) # type: int\n T = int(next(tokens)) # type: int\n a = [ int(next(tokens)) for _ in range(T) ] # type: \"List[int]\"\n solve(K, T, a)",
"def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n K = int(next(tokens)) # type: int\n T = int(next(tokens)) # type: int\n a = [ int(next(tokens)) for _ in range(T) ] # type: \"List[int]\"\n solve(K, T, a)",
"main",
"def solve(K: int, T: int, a: \"List[int]\"):\n from heapq import heapify, heappop, heappush\n\n a = list(map(lambda x:x*(-1), a))\n heapify(a)\n while True:\n if len(a) <= 1:\n break\n\n x = -1*heappop(a)\n y = -1*heappop(a)\n x -= 1\n y -= 1\n if x > 0:\n heappush(a, -x)\n if y > 0:\n heappush(a, -y)\n\n if len(a) == 1:\n print(-1*a[0]-1)\n else:\n print(0)\n\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)",
"def solve(K: int, T: int, a: \"List[int]\"):\n from heapq import heapify, heappop, heappush\n\n a = list(map(lambda x:x*(-1), a))\n heapify(a)\n while True:\n if len(a) <= 1:\n break\n\n x = -1*heappop(a)\n y = -1*heappop(a)\n x -= 1\n y -= 1\n if x > 0:\n heappush(a, -x)\n if y > 0:\n heappush(a, -y)\n\n if len(a) == 1:\n print(-1*a[0]-1)\n else:\n print(0)\n\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)",
"solve"
] |
#!/usr/bin/env python3
import sys
def solve(K: int, T: int, a: "List[int]"):
from heapq import heapify, heappop, heappush
a = list(map(lambda x:x*(-1), a))
heapify(a)
while True:
if len(a) <= 1:
break
x = -1*heappop(a)
y = -1*heappop(a)
x -= 1
y -= 1
if x > 0:
heappush(a, -x)
if y > 0:
heappush(a, -y)
if len(a) == 1:
print(-1*a[0]-1)
else:
print(0)
return
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
K = int(next(tokens)) # type: int
T = int(next(tokens)) # type: int
a = [ int(next(tokens)) for _ in range(T) ] # type: "List[int]"
solve(K, T, a)
if __name__ == '__main__':
main()
|
[
7,
15,
13,
12,
13,
29,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
29,
4,
13,
4,
13,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
29,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
13,
13,
0,
13,
2,
2,
13,
2,
13,
13,
17,
14,
2,
13,
17,
0,
13,
17,
4,
13,
13,
29,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] |
[
[
88,
21
],
[
27,
26
],
[
88,
30
],
[
26,
35
],
[
42,
41
],
[
85,
43
],
[
42,
44
],
[
47,
46
],
[
85,
48
],
[
51,
50
],
[
46,
53
],
[
56,
55
],
[
50,
58
],
[
41,
60
],
[
50,
61
],
[
55,
65
],
[
69,
68
],
[
68,
72
],
[
55,
72
],
[
91,
79
]
] |
[
"import sys\n# sys.setrecursionlimit(100000)\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef input_int():\n return int(input())\n\n\ndef input_int_list():\n return [int(i) for i in input().split()]\n\n\ndef main():\n k, t = input_int_list()\n A = input_int_list()\n _max = max(A)\n ans = (_max - (k - _max)) - 1\n if ans < 0:\n ans = 0\n print(ans)\n return\n\n\nif __name__ == \"__main__\":\n main()",
"import sys",
"sys",
"def input():\n return sys.stdin.readline().strip()",
"input",
"return sys.stdin.readline().strip()",
"sys.stdin.readline().strip()",
"sys.stdin.readline().strip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"strip",
"def input_int():\n return int(input())",
"input_int",
"return int(input())",
"int(input())",
"int",
"input()",
"input",
"def input_int_list():\n return [int(i) for i in input().split()]",
"input_int_list",
"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",
"return [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"def main():\n k, t = input_int_list()\n A = input_int_list()\n _max = max(A)\n ans = (_max - (k - _max)) - 1\n if ans < 0:\n ans = 0\n print(ans)\n return",
"main",
"k, t = input_int_list()",
"k",
"input_int_list()",
"input_int_list",
"t",
"A = input_int_list()",
"A",
"input_int_list()",
"input_int_list",
"_max = max(A)",
"_max",
"max(A)",
"max",
"A",
"ans = (_max - (k - _max)) - 1",
"ans",
"(_max - (k - _max)) - 1",
"_max - (k - _max)",
"_max",
"k - _max",
"k",
"_max",
"1",
"if ans < 0:\n ans = 0\n ",
"ans < 0",
"ans",
"0",
"ans = 0",
"ans",
"0",
"print(ans)",
"print",
"ans",
"return",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def input_int():\n return int(input())",
"def input_int():\n return int(input())",
"input_int",
"def input_int_list():\n return [int(i) for i in input().split()]",
"def input_int_list():\n return [int(i) for i in input().split()]",
"input_int_list",
"def input():\n return sys.stdin.readline().strip()",
"def input():\n return sys.stdin.readline().strip()",
"input",
"def main():\n k, t = input_int_list()\n A = input_int_list()\n _max = max(A)\n ans = (_max - (k - _max)) - 1\n if ans < 0:\n ans = 0\n print(ans)\n return",
"def main():\n k, t = input_int_list()\n A = input_int_list()\n _max = max(A)\n ans = (_max - (k - _max)) - 1\n if ans < 0:\n ans = 0\n print(ans)\n return",
"main"
] |
import sys
# sys.setrecursionlimit(100000)
def input():
return sys.stdin.readline().strip()
def input_int():
return int(input())
def input_int_list():
return [int(i) for i in input().split()]
def main():
k, t = input_int_list()
A = input_int_list()
_max = max(A)
ans = (_max - (k - _max)) - 1
if ans < 0:
ans = 0
print(ans)
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,
0,
13,
2,
13,
4,
13,
13,
0,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
2,
13,
17,
4,
13,
14,
40,
13,
2,
13,
17,
4,
13,
17,
4,
13,
0,
13,
2,
13,
17,
0,
13,
13,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
2,
13
] |
[
[
85,
2
],
[
85,
11
],
[
70,
13
],
[
76,
25
],
[
74,
27
],
[
71,
30
],
[
79,
32
],
[
71,
35
],
[
86,
38
],
[
74,
43
],
[
77,
49
],
[
80,
51
],
[
88,
59
],
[
80,
61
],
[
82,
64
],
[
77,
65
],
[
83,
68
],
[
89,
68
],
[
70,
71
],
[
85,
74
],
[
76,
77
],
[
79,
80
],
[
77,
82
],
[
82,
83
],
[
85,
86
],
[
88,
89
]
] |
[
"K, T = map(int, input().split())\nA = list(map(int, input().split()))\nres = K - max(A)\na = max(A)\nif T == 1:\n print(K - 1)\n exit()\nif res >= a + 1:\n print(0)\n exit()\n\nans = a - 1\nans -= res\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",
"res = K - max(A)",
"res",
"K - max(A)",
"K",
"max(A)",
"max",
"A",
"a = max(A)",
"a",
"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 res >= a + 1:\n print(0)\n exit()",
"res >= a + 1",
"res",
"a + 1",
"a",
"1",
"print(0)",
"print",
"0",
"exit()",
"exit",
"ans = a - 1",
"ans",
"a - 1",
"a",
"1",
"ans -= res",
"ans",
"res",
"print(ans)",
"print",
"ans",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"res = K - max(A)",
"K - max(A)",
"res",
"a = max(A)",
"max(A)",
"a",
"ans -= res",
"res",
"ans",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"ans = a - 1",
"a - 1",
"ans"
] |
K, T = map(int, input().split())
A = list(map(int, input().split()))
res = K - max(A)
a = max(A)
if T == 1:
print(K - 1)
exit()
if res >= a + 1:
print(0)
exit()
ans = a - 1
ans -= res
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,
17,
0,
13,
4,
18,
13,
13,
17,
0,
13,
4,
13,
13,
0,
13,
2,
2,
13,
13,
17,
14,
40,
13,
17,
4,
13,
13,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
74,
2
],
[
74,
11
],
[
65,
13
],
[
68,
25
],
[
66,
28
],
[
31,
30
],
[
80,
33
],
[
69,
36
],
[
66,
36
],
[
77,
40
],
[
69,
43
],
[
66,
43
],
[
71,
45
],
[
81,
48
],
[
78,
49
],
[
72,
53
],
[
72,
57
],
[
74,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
],
[
80,
81
]
] |
[
"# Problem B - K個のケーキ\n\n# input\nK, T = map(int, input().split())\na_nums = list(map(int, input().split()))\n\n# initialization\na_nums = sorted(a_nums, reverse=True)\na_max = a_nums.pop(0)\na_sum = sum(a_nums)\n\n# calc\ncheck = a_max - a_sum - 1\nif check>=0:\n print(check)\nelse:\n print(0)",
"K, T = map(int, input().split())",
"K",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"a_nums = list(map(int, input().split()))",
"a_nums",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"a_nums = sorted(a_nums, reverse=True)",
"a_nums",
"sorted(a_nums, reverse=True)",
"sorted",
"a_nums",
"reverse=True",
"reverse",
"True",
"a_max = a_nums.pop(0)",
"a_max",
"a_nums.pop(0)",
"a_nums.pop",
"a_nums",
"pop",
"0",
"a_sum = sum(a_nums)",
"a_sum",
"sum(a_nums)",
"sum",
"a_nums",
"check = a_max - a_sum - 1",
"check",
"a_max - a_sum - 1",
"a_max - a_sum",
"a_max",
"a_sum",
"1",
"if check>=0:\n print(check)\nelse:\n print(0)",
"check>=0",
"check",
"0",
"print(check)",
"print",
"check",
"print(0)",
"print",
"0",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"a_nums = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a_nums",
"a_nums = sorted(a_nums, reverse=True)",
"sorted(a_nums, reverse=True)",
"a_nums",
"check = a_max - a_sum - 1",
"a_max - a_sum - 1",
"check",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"a_sum = sum(a_nums)",
"sum(a_nums)",
"a_sum",
"a_max = a_nums.pop(0)",
"a_nums.pop(0)",
"a_max"
] |
# Problem B - K個のケーキ
# input
K, T = map(int, input().split())
a_nums = list(map(int, input().split()))
# initialization
a_nums = sorted(a_nums, reverse=True)
a_max = a_nums.pop(0)
a_sum = sum(a_nums)
# calc
check = a_max - a_sum - 1
if check>=0:
print(check)
else:
print(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,
4,
13,
4,
13,
17,
2,
2,
2,
17,
18,
13,
17,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
15,
28
],
[
15,
40
],
[
4,
42
],
[
52,
49
]
] |
[
"def main():\n cakes, variation = map(int, input().split())\n cake_num = list(map(int, input().split()))\n cake_num.sort()\n print(max(0, 2 * cake_num[-1] - cakes - 1))\n\n\nif __name__ == '__main__':\n main()\n",
"def main():\n cakes, variation = map(int, input().split())\n cake_num = list(map(int, input().split()))\n cake_num.sort()\n print(max(0, 2 * cake_num[-1] - cakes - 1))",
"main",
"cakes, variation = map(int, input().split())",
"cakes",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"variation",
"cake_num = list(map(int, input().split()))",
"cake_num",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"cake_num.sort()",
"cake_num.sort",
"cake_num",
"sort",
"print(max(0, 2 * cake_num[-1] - cakes - 1))",
"print",
"max(0, 2 * cake_num[-1] - cakes - 1)",
"max",
"0",
"2 * cake_num[-1] - cakes - 1",
"2 * cake_num[-1] - cakes",
"2 * cake_num[-1]",
"2",
"cake_num[-1]",
"cake_num",
"-1",
"cakes",
"1",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n cakes, variation = map(int, input().split())\n cake_num = list(map(int, input().split()))\n cake_num.sort()\n print(max(0, 2 * cake_num[-1] - cakes - 1))",
"def main():\n cakes, variation = map(int, input().split())\n cake_num = list(map(int, input().split()))\n cake_num.sort()\n print(max(0, 2 * cake_num[-1] - cakes - 1))",
"main"
] |
def main():
cakes, variation = map(int, input().split())
cake_num = list(map(int, input().split()))
cake_num.sort()
print(max(0, 2 * cake_num[-1] - cakes - 1))
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
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,
4,
13,
10,
2,
13
] |
[
[
56,
2
],
[
56,
11
],
[
50,
13
],
[
47,
25
],
[
51,
28
],
[
59,
30
],
[
51,
34
],
[
48,
35
],
[
48,
43
],
[
60,
44
],
[
47,
48
],
[
50,
51
],
[
56,
54
],
[
56,
57
],
[
59,
60
]
] |
[
"k, t = map(int, input().split())\na = list(map(int, input().split()))\nma = max(a)\ns = sum(a) - ma\nprint(max(0, ma - s - 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",
"ma = max(a)",
"ma",
"max(a)",
"max",
"a",
"s = sum(a) - ma",
"s",
"sum(a) - ma",
"sum(a)",
"sum",
"a",
"ma",
"print(max(0, ma - s - 1))",
"print",
"max(0, ma - s - 1)",
"max",
"0",
"ma - s - 1",
"ma - s",
"ma",
"s",
"1",
"ma = max(a)",
"max(a)",
"ma",
"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",
"s = sum(a) - ma",
"sum(a) - ma",
"s"
] |
k, t = map(int, input().split())
a = list(map(int, input().split()))
ma = max(a)
s = sum(a) - ma
print(max(0, ma - s - 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,
4,
13,
4,
13,
2,
2,
13,
17,
2,
13,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
15,
28
],
[
32,
31
],
[
35,
34
],
[
15,
36
],
[
34,
44
],
[
4,
47
],
[
34,
48
],
[
58,
55
]
] |
[
"#!/usr/bin python3\n# -*- coding: utf-8 -*-\n\ndef main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.sort(reverse=True)\n x=A[0]\n print(max(x-1-(K-x),0))\n\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 x=A[0]\n print(max(x-1-(K-x),0))",
"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",
"x=A[0]",
"x",
"A[0]",
"A",
"0",
"print(max(x-1-(K-x),0))",
"print",
"max(x-1-(K-x),0)",
"max",
"x-1-(K-x)",
"x-1",
"x",
"1",
"K-x",
"K",
"x",
"0",
"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 x=A[0]\n print(max(x-1-(K-x),0))",
"def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.sort(reverse=True)\n x=A[0]\n print(max(x-1-(K-x),0))",
"main"
] |
#!/usr/bin python3
# -*- coding: utf-8 -*-
def main():
K, T = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
x=A[0]
print(max(x-1-(K-x),0))
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
4,
13,
4,
13,
17,
2,
2,
13,
2,
2,
13,
13,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
53,
2
],
[
53,
11
],
[
44,
13
],
[
47,
25
],
[
45,
28
],
[
54,
36
],
[
54,
39
],
[
48,
40
],
[
44,
45
],
[
47,
48
],
[
53,
51
],
[
53,
54
]
] |
[
"k, t = map(int, input().split())\nal = list(map(int, input().split()))\n\nm = max(al)\nprint(max(0, k-(k-m)*2-1))",
"k, t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"al = list(map(int, input().split()))",
"al",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m = max(al)",
"m",
"max(al)",
"max",
"al",
"print(max(0, k-(k-m)*2-1))",
"print",
"max(0, k-(k-m)*2-1)",
"max",
"0",
"k-(k-m)*2-1",
"k-(k-m)*2",
"k",
"(k-m)*2",
"k-m",
"k",
"m",
"2",
"1",
"al = list(map(int, input().split()))",
"list(map(int, input().split()))",
"al",
"m = max(al)",
"max(al)",
"m",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k"
] |
k, t = map(int, input().split())
al = list(map(int, input().split()))
m = max(al)
print(max(0, k-(k-m)*2-1))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
13,
4,
13,
2,
2,
18,
13,
17,
17,
2,
4,
13,
13,
18,
13,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
48,
2
],
[
48,
11
],
[
51,
13
],
[
52,
33
],
[
52,
39
],
[
52,
41
],
[
48,
46
],
[
48,
49
],
[
51,
52
]
] |
[
"k, t = map(int, input().split())\na = sorted(list(map(int, input().split())))\n\nprint(max(a[-1]-1-(sum(a)-a[-1]), 0))",
"k, t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"a = sorted(list(map(int, input().split())))",
"a",
"sorted(list(map(int, input().split())))",
"sorted",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"print(max(a[-1]-1-(sum(a)-a[-1]), 0))",
"print",
"max(a[-1]-1-(sum(a)-a[-1]), 0)",
"max",
"a[-1]-1-(sum(a)-a[-1])",
"a[-1]-1",
"a[-1]",
"a",
"-1",
"1",
"sum(a)-a[-1]",
"sum(a)",
"sum",
"a",
"a[-1]",
"a",
"-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(list(map(int, input().split())))",
"sorted(list(map(int, input().split())))",
"a"
] |
k, t = map(int, input().split())
a = sorted(list(map(int, input().split())))
print(max(a[-1]-1-(sum(a)-a[-1]), 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,
17,
4,
18,
13,
13,
0,
13,
17,
0,
13,
4,
13,
17,
2,
2,
4,
13,
13,
4,
13,
18,
13,
39,
17,
17,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
15,
28
],
[
15,
33
],
[
37,
36
],
[
40,
39
],
[
15,
47
],
[
15,
51
],
[
39,
57
],
[
66,
63
]
] |
[
"def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.append(0)\n A.sort(reverse=True)\n ans =max(0, max(A) - sum(A[1:]) - 1)\n print(ans)\n\nif __name__ == \"__main__\":\n main()",
"def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.append(0)\n A.sort(reverse=True)\n ans =max(0, max(A) - sum(A[1:]) - 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",
"A.append(0)",
"A.append",
"A",
"append",
"0",
"A.sort(reverse=True)",
"A.sort",
"A",
"sort",
"reverse=True",
"reverse",
"True",
"ans =max(0, max(A) - sum(A[1:]) - 1)",
"ans",
"max(0, max(A) - sum(A[1:]) - 1)",
"max",
"0",
"max(A) - sum(A[1:]) - 1",
"max(A) - sum(A[1:])",
"max(A)",
"max",
"A",
"sum(A[1:])",
"sum",
"A[1:]",
"A",
"1:",
"1",
"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 A.append(0)\n A.sort(reverse=True)\n ans =max(0, max(A) - sum(A[1:]) - 1)\n print(ans)",
"def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n A.append(0)\n A.sort(reverse=True)\n ans =max(0, max(A) - sum(A[1:]) - 1)\n print(ans)",
"main"
] |
def main():
K, T = map(int, input().split())
A = list(map(int, input().split()))
A.append(0)
A.sort(reverse=True)
ans =max(0, max(A) - sum(A[1:]) - 1)
print(ans)
if __name__ == "__main__":
main()
|
[
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,
18,
13,
17,
17,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
17,
0,
13,
39,
17,
17,
0,
13,
17,
42,
17,
0,
13,
2,
13,
17,
0,
18,
13,
18,
13,
13,
17,
0,
13,
17,
14,
2,
18,
13,
18,
13,
13,
17,
0,
18,
13,
13,
2,
4,
13,
13,
17,
14,
2,
18,
13,
13,
13,
14,
40,
18,
13,
18,
13,
17,
18,
13,
18,
13,
17,
0,
13,
2,
13,
17,
0,
13,
17,
3,
0,
13,
17,
4,
13,
2,
4,
13,
13,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
7,
6
],
[
7,
15
],
[
18,
17
],
[
15,
30
],
[
17,
36
],
[
17,
45
],
[
49,
48
],
[
52,
51
],
[
57,
56
],
[
62,
61
],
[
56,
63
],
[
120,
63
],
[
111,
63
],
[
71,
66
],
[
17,
67
],
[
84,
68
],
[
51,
69
],
[
61,
70
],
[
6,
70
],
[
74,
73
],
[
66,
77
],
[
17,
78
],
[
84,
79
],
[
51,
80
],
[
61,
81
],
[
6,
81
],
[
87,
84
],
[
51,
85
],
[
61,
86
],
[
6,
86
],
[
51,
90
],
[
84,
94
],
[
51,
95
],
[
61,
96
],
[
6,
96
],
[
15,
97
],
[
17,
101
],
[
51,
103
],
[
17,
106
],
[
51,
108
],
[
112,
111
],
[
61,
113
],
[
6,
113
],
[
117,
116
],
[
121,
120
],
[
17,
127
],
[
116,
128
],
[
73,
128
],
[
137,
134
]
] |
[
"import sys\ndef main():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n if t == 1:\n print(a[0]-1)\n sys.exit()\n a.sort(reverse = True)\n key = [0, 1]\n num = 0\n while True:\n k = num%2\n a[key[k]]-=1\n sub = 0\n if a[key[k]] == 0:\n key[k] = max(key) + 1\n if key[k] < t:\n if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n num = k-1\n else:\n sub = 1\n break\n num += 1\n print(sum(a)-sub)\n \nif __name__ == \"__main__\":\n main()",
"import sys",
"sys",
"def main():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n if t == 1:\n print(a[0]-1)\n sys.exit()\n a.sort(reverse = True)\n key = [0, 1]\n num = 0\n while True:\n k = num%2\n a[key[k]]-=1\n sub = 0\n if a[key[k]] == 0:\n key[k] = max(key) + 1\n if key[k] < t:\n if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n num = k-1\n else:\n sub = 1\n break\n num += 1\n print(sum(a)-sub)\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(a[0]-1)\n sys.exit()\n ",
"t == 1",
"t",
"1",
"print(a[0]-1)",
"print",
"a[0]-1",
"a[0]",
"a",
"0",
"1",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"a.sort(reverse = True)",
"a.sort",
"a",
"sort",
"reverse = True",
"reverse",
"True",
"key = [0, 1]",
"key",
"[0, 1]",
"0",
"1",
"num = 0",
"num",
"0",
"while True:\n k = num%2\n a[key[k]]-=1\n sub = 0\n if a[key[k]] == 0:\n key[k] = max(key) + 1\n if key[k] < t:\n if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n num = k-1\n else:\n sub = 1\n break\n num += 1\n ",
"True",
"k = num%2",
"k",
"num%2",
"num",
"2",
"a[key[k]]-=1",
"a[key[k]]",
"a",
"key[k]",
"key",
"k",
"1",
"sub = 0",
"sub",
"0",
"if a[key[k]] == 0:\n key[k] = max(key) + 1\n if key[k] < t:\n if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n num = k-1\n else:\n sub = 1\n break\n ",
"a[key[k]] == 0",
"a[key[k]]",
"a",
"key[k]",
"key",
"k",
"0",
"key[k] = max(key) + 1",
"key[k]",
"key",
"k",
"max(key) + 1",
"max(key)",
"max",
"key",
"1",
"if key[k] < t:\n if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n num = k-1\n else:\n sub = 1\n break\n ",
"key[k] < t",
"key[k]",
"key",
"k",
"t",
"if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n ",
"a[key[0]] >= a[key[1]]",
"a[key[0]]",
"a",
"key[0]",
"key",
"0",
"a[key[1]]",
"a",
"key[1]",
"key",
"1",
"num = k-1",
"num",
"k-1",
"k",
"1",
"sub = 1",
"sub",
"1",
"break",
"num += 1",
"num",
"1",
"print(sum(a)-sub)",
"print",
"sum(a)-sub",
"sum(a)",
"sum",
"a",
"sub",
"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(a[0]-1)\n sys.exit()\n a.sort(reverse = True)\n key = [0, 1]\n num = 0\n while True:\n k = num%2\n a[key[k]]-=1\n sub = 0\n if a[key[k]] == 0:\n key[k] = max(key) + 1\n if key[k] < t:\n if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n num = k-1\n else:\n sub = 1\n break\n num += 1\n print(sum(a)-sub)\n ",
"def main():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n if t == 1:\n print(a[0]-1)\n sys.exit()\n a.sort(reverse = True)\n key = [0, 1]\n num = 0\n while True:\n k = num%2\n a[key[k]]-=1\n sub = 0\n if a[key[k]] == 0:\n key[k] = max(key) + 1\n if key[k] < t:\n if a[key[0]] >= a[key[1]]:k=0\n else:k = 1\n num = k-1\n else:\n sub = 1\n break\n num += 1\n print(sum(a)-sub)\n ",
"main"
] |
import sys
def main():
k, t = map(int, input().split())
a = list(map(int, input().split()))
if t == 1:
print(a[0]-1)
sys.exit()
a.sort(reverse = True)
key = [0, 1]
num = 0
while True:
k = num%2
a[key[k]]-=1
sub = 0
if a[key[k]] == 0:
key[k] = max(key) + 1
if key[k] < t:
if a[key[0]] >= a[key[1]]:k=0
else:k = 1
num = k-1
else:
sub = 1
break
num += 1
print(sum(a)-sub)
if __name__ == "__main__":
main()
|
[
7,
15,
15,
15,
15,
13,
15,
13,
15,
13,
41,
28,
13,
4,
18,
4,
18,
18,
18,
13,
13,
13,
13,
13,
4,
4,
13,
13,
12,
13,
12,
13,
41,
28,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
4,
13,
13,
12,
13,
12,
13,
0,
13,
4,
13,
4,
18,
18,
13,
13,
13,
14,
2,
18,
13,
17,
17,
29,
18,
13,
39,
17,
29,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
29,
13,
23,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
29,
13,
23,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
29,
13,
23,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
29,
13,
23,
13,
4,
18,
13,
13,
17,
0,
13,
17,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
39,
28,
13,
13,
4,
13,
13,
40,
13,
42,
2,
4,
13,
13,
17,
0,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
17,
0,
13,
17,
14,
13,
4,
13,
13,
13,
14,
13,
4,
13,
13,
13,
14,
40,
13,
4,
13,
17,
4,
13,
2,
40,
18,
13,
17,
17,
29,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] |
[
[
13,
12
],
[
12,
27
],
[
35,
34
],
[
34,
47
],
[
54,
53
],
[
53,
65
],
[
53,
70
],
[
53,
74
],
[
80,
79
],
[
89,
82
],
[
222,
85
],
[
89,
89
],
[
95,
94
],
[
104,
97
],
[
237,
100
],
[
104,
104
],
[
110,
109
],
[
119,
112
],
[
225,
115
],
[
119,
119
],
[
125,
124
],
[
134,
127
],
[
243,
130
],
[
134,
134
],
[
239,
141
],
[
147,
146
],
[
237,
148
],
[
147,
149
],
[
152,
151
],
[
237,
153
],
[
156,
155
],
[
159,
158
],
[
151,
158
],
[
155,
162
],
[
158,
164
],
[
155,
169
],
[
173,
172
],
[
155,
175
],
[
178,
177
],
[
155,
180
],
[
183,
182
],
[
186,
185
],
[
155,
191
],
[
182,
192
],
[
172,
192
],
[
155,
197
],
[
185,
198
],
[
177,
198
],
[
155,
201
],
[
155,
210
],
[
228,
219
],
[
239,
240
]
] |
[
"#!usr/bin/env python3\nfrom collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom itertools import permutations, accumulate\nimport sys\nimport math\nimport bisect\ndef LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS():return [list(x) for x in sys.stdin.readline().split()]\ndef S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res\ndef IR(n):\n return [I() for i in range(n)]\ndef LIR(n):\n return [LI() for i in range(n)]\ndef SR(n):\n return [S() for i in range(n)]\ndef LSR(n):\n return [LS() for i in range(n)]\n\nsys.setrecursionlimit(1000000)\nmod = 1000000007\n\ndef solve():\n k,t = LI()\n a = LI()\n q = []\n for i in a:\n heappush(q,-i)\n while len(q) > 1:\n x = heappop(q)\n y = heappop(q)\n x += 1\n y += 1\n if x:\n heappush(q,x)\n if y:\n heappush(q,y)\n if not q:\n print(0)\n else:\n print(-q[0]-1)\n return\n\n#Solve\nif __name__ == \"__main__\":\n solve()",
"from collections import defaultdict, deque",
"from heapq import heappush, heappop",
"from itertools import permutations, accumulate",
"import sys",
"sys",
"import math",
"math",
"import bisect",
"bisect",
"int(x) for x in sys.stdin.buffer.readline().split()",
"for x in sys.stdin.buffer.readline().split()",
"x",
"sys.stdin.buffer.readline().split()",
"sys.stdin.buffer.readline().split",
"sys.stdin.buffer.readline()",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"split",
"for x in sys.stdin.buffer.readline().split()",
"int(x)",
"int",
"x",
"def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]",
"LI",
"def I(): return int(sys.stdin.buffer.readline())",
"I",
"list(x) for x in sys.stdin.readline().split()",
"for x in sys.stdin.readline().split()",
"x",
"sys.stdin.readline().split()",
"sys.stdin.readline().split",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"split",
"for x in sys.stdin.readline().split()",
"list(x)",
"list",
"x",
"def LS():return [list(x) for x in sys.stdin.readline().split()]",
"LS",
"def S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res",
"S",
"res = list(sys.stdin.readline())",
"res",
"list(sys.stdin.readline())",
"list",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"if res[-1] == \"\\n\":\n return res[:-1]\n ",
"res[-1] == \"\\n\"",
"res[-1]",
"res",
"-1",
"\"\\n\"",
"return res[:-1]",
"res[:-1]",
"res",
":-1",
"-1",
"return res",
"res",
"def IR(n):\n return [I() for i in range(n)]",
"IR",
"I() for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"I()",
"I",
"return [I() for i in range(n)]",
"[I() for i in range(n)]",
"n",
"n",
"def LIR(n):\n return [LI() for i in range(n)]",
"LIR",
"LI() for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"LI()",
"LI",
"return [LI() for i in range(n)]",
"[LI() for i in range(n)]",
"n",
"n",
"def SR(n):\n return [S() for i in range(n)]",
"SR",
"S() for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"S()",
"S",
"return [S() for i in range(n)]",
"[S() for i in range(n)]",
"n",
"n",
"def LSR(n):\n return [LS() for i in range(n)]",
"LSR",
"LS() for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"LS()",
"LS",
"return [LS() for i in range(n)]",
"[LS() for i in range(n)]",
"n",
"n",
"sys.setrecursionlimit(1000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"1000000",
"mod = 1000000007",
"mod",
"1000000007",
"def solve():\n k,t = LI()\n a = LI()\n q = []\n for i in a:\n heappush(q,-i)\n while len(q) > 1:\n x = heappop(q)\n y = heappop(q)\n x += 1\n y += 1\n if x:\n heappush(q,x)\n if y:\n heappush(q,y)\n if not q:\n print(0)\n else:\n print(-q[0]-1)\n return\n\n#Solve",
"solve",
"k,t = LI()",
"k",
"LI()",
"LI",
"t",
"a = LI()",
"a",
"LI()",
"LI",
"q = []",
"q",
"[]",
"for i in a:\n heappush(q,-i)\n ",
"i",
"a",
"heappush(q,-i)",
"heappush",
"q",
"-i",
"i",
"while len(q) > 1:\n x = heappop(q)\n y = heappop(q)\n x += 1\n y += 1\n if x:\n heappush(q,x)\n if y:\n heappush(q,y)\n ",
"len(q) > 1",
"len(q)",
"len",
"q",
"1",
"x = heappop(q)",
"x",
"heappop(q)",
"heappop",
"q",
"y = heappop(q)",
"y",
"heappop(q)",
"heappop",
"q",
"x += 1",
"x",
"1",
"y += 1",
"y",
"1",
"if x:\n heappush(q,x)\n ",
"x",
"heappush(q,x)",
"heappush",
"q",
"x",
"if y:\n heappush(q,y)\n ",
"y",
"heappush(q,y)",
"heappush",
"q",
"y",
"if not q:\n print(0)\n else:\n print(-q[0]-1)\n ",
"not q",
"q",
"print(0)",
"print",
"0",
"print(-q[0]-1)",
"print",
"-q[0]-1",
"-q[0]",
"q[0]",
"q",
"0",
"1",
"return",
"if __name__ == \"__main__\":\n solve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"solve()",
"solve",
"def I(): return int(sys.stdin.buffer.readline())",
"def I(): return int(sys.stdin.buffer.readline())",
"I",
"def S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res",
"def S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res",
"S",
"def solve():\n k,t = LI()\n a = LI()\n q = []\n for i in a:\n heappush(q,-i)\n while len(q) > 1:\n x = heappop(q)\n y = heappop(q)\n x += 1\n y += 1\n if x:\n heappush(q,x)\n if y:\n heappush(q,y)\n if not q:\n print(0)\n else:\n print(-q[0]-1)\n return\n\n#Solve",
"def solve():\n k,t = LI()\n a = LI()\n q = []\n for i in a:\n heappush(q,-i)\n while len(q) > 1:\n x = heappop(q)\n y = heappop(q)\n x += 1\n y += 1\n if x:\n heappush(q,x)\n if y:\n heappush(q,y)\n if not q:\n print(0)\n else:\n print(-q[0]-1)\n return\n\n#Solve",
"solve",
"def LSR(n):\n return [LS() for i in range(n)]",
"def LSR(n):\n return [LS() for i in range(n)]",
"LSR",
"def LIR(n):\n return [LI() for i in range(n)]",
"def LIR(n):\n return [LI() for i in range(n)]",
"LIR",
"def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]",
"def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]",
"LI",
"mod = 1000000007",
"1000000007",
"mod",
"def LS():return [list(x) for x in sys.stdin.readline().split()]",
"def LS():return [list(x) for x in sys.stdin.readline().split()]",
"LS",
"def IR(n):\n return [I() for i in range(n)]",
"def IR(n):\n return [I() for i in range(n)]",
"IR",
"def SR(n):\n return [S() for i in range(n)]",
"def SR(n):\n return [S() for i in range(n)]",
"SR"
] |
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
k,t = LI()
a = LI()
q = []
for i in a:
heappush(q,-i)
while len(q) > 1:
x = heappop(q)
y = heappop(q)
x += 1
y += 1
if x:
heappush(q,x)
if y:
heappush(q,y)
if not q:
print(0)
else:
print(-q[0]-1)
return
#Solve
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,
0,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
2,
39,
13,
18,
13,
13,
15,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
14,
2,
2,
13,
17,
17,
0,
18,
13,
13,
4,
18,
13,
13,
0,
18,
13,
13,
4,
18,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
17,
0,
13,
4,
13,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
14,
2,
2,
13,
17,
17,
0,
18,
13,
13,
4,
18,
13,
13,
0,
18,
13,
13,
4,
18,
13,
13,
0,
13,
17,
28,
13,
4,
13,
17,
13,
14,
2,
18,
13,
2,
13,
17,
18,
13,
13,
0,
13,
17,
4,
13,
4,
13,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] |
[
[
196,
2
],
[
196,
11
],
[
175,
13
],
[
176,
26
],
[
30,
29
],
[
199,
32
],
[
36,
35
],
[
197,
38
],
[
187,
40
],
[
176,
45
],
[
35,
46
],
[
202,
49
],
[
188,
52
],
[
200,
52
],
[
208,
54
],
[
194,
58
],
[
61,
60
],
[
194,
63
],
[
60,
67
],
[
74,
71
],
[
209,
72
],
[
60,
73
],
[
203,
76
],
[
82,
79
],
[
209,
80
],
[
60,
81
],
[
203,
84
],
[
178,
87
],
[
91,
90
],
[
194,
94
],
[
209,
98
],
[
90,
100
],
[
79,
102
],
[
71,
102
],
[
209,
103
],
[
90,
104
],
[
184,
106
],
[
205,
109
],
[
188,
112
],
[
200,
112
],
[
211,
114
],
[
194,
118
],
[
121,
120
],
[
194,
123
],
[
120,
127
],
[
134,
131
],
[
212,
132
],
[
209,
132
],
[
120,
133
],
[
206,
136
],
[
203,
136
],
[
142,
139
],
[
212,
140
],
[
209,
140
],
[
120,
141
],
[
206,
144
],
[
203,
144
],
[
181,
147
],
[
151,
150
],
[
194,
154
],
[
212,
158
],
[
209,
158
],
[
150,
160
],
[
139,
162
],
[
131,
162
],
[
79,
162
],
[
71,
162
],
[
212,
163
],
[
209,
163
],
[
150,
164
],
[
190,
166
],
[
185,
172
],
[
179,
172
],
[
191,
173
],
[
182,
173
],
[
175,
176
],
[
178,
179
],
[
181,
182
],
[
184,
185
],
[
187,
188
],
[
190,
191
],
[
196,
194
],
[
196,
197
],
[
199,
200
],
[
202,
203
],
[
205,
206
],
[
208,
209
],
[
211,
212
]
] |
[
"k, t = map(int, input().split())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\nC = []\nfor i in range(t):\n C += [i]*A[i]\n\nfrom collections import deque\nB = deque(C)\nL = [-1]*k\nfor i in range(k):\n if i%2 == 0:\n L[i] = B.popleft()\n else:\n L[i] = B.pop()\n\nans1 = 0\nfor i in range(1, k):\n if L[i-1] == L[i]:\n ans1 += 1\n\nB = deque(C)\nL = [-1]*k\nfor i in range(k):\n if i%2 == 0:\n L[i] = B.pop()\n else:\n L[i] = B.popleft()\n\nans2 = 0\nfor i in range(1, k):\n if L[i-1] == L[i]:\n ans2 += 1\n\nprint(min(ans1, ans2))",
"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",
"C = []",
"C",
"[]",
"for i in range(t):\n C += [i]*A[i]",
"i",
"range(t)",
"range",
"t",
"C += [i]*A[i]",
"C",
"[i]*A[i]",
"[i]",
"i",
"A[i]",
"A",
"i",
"from collections import deque",
"B = deque(C)",
"B",
"deque(C)",
"deque",
"C",
"L = [-1]*k",
"L",
"[-1]*k",
"[-1]",
"-1",
"k",
"for i in range(k):\n if i%2 == 0:\n L[i] = B.popleft()\n else:\n L[i] = B.pop()",
"i",
"range(k)",
"range",
"k",
"if i%2 == 0:\n L[i] = B.popleft()\n else:\n L[i] = B.pop()",
"i%2 == 0",
"i%2",
"i",
"2",
"0",
"L[i] = B.popleft()",
"L[i]",
"L",
"i",
"B.popleft()",
"B.popleft",
"B",
"popleft",
"L[i] = B.pop()",
"L[i]",
"L",
"i",
"B.pop()",
"B.pop",
"B",
"pop",
"ans1 = 0",
"ans1",
"0",
"for i in range(1, k):\n if L[i-1] == L[i]:\n ans1 += 1",
"i",
"range(1, k)",
"range",
"1",
"k",
"if L[i-1] == L[i]:\n ans1 += 1",
"L[i-1] == L[i]",
"L[i-1]",
"L",
"i-1",
"i",
"1",
"L[i]",
"L",
"i",
"ans1 += 1",
"ans1",
"1",
"B = deque(C)",
"B",
"deque(C)",
"deque",
"C",
"L = [-1]*k",
"L",
"[-1]*k",
"[-1]",
"-1",
"k",
"for i in range(k):\n if i%2 == 0:\n L[i] = B.pop()\n else:\n L[i] = B.popleft()",
"i",
"range(k)",
"range",
"k",
"if i%2 == 0:\n L[i] = B.pop()\n else:\n L[i] = B.popleft()",
"i%2 == 0",
"i%2",
"i",
"2",
"0",
"L[i] = B.pop()",
"L[i]",
"L",
"i",
"B.pop()",
"B.pop",
"B",
"pop",
"L[i] = B.popleft()",
"L[i]",
"L",
"i",
"B.popleft()",
"B.popleft",
"B",
"popleft",
"ans2 = 0",
"ans2",
"0",
"for i in range(1, k):\n if L[i-1] == L[i]:\n ans2 += 1",
"i",
"range(1, k)",
"range",
"1",
"k",
"if L[i-1] == L[i]:\n ans2 += 1",
"L[i-1] == L[i]",
"L[i-1]",
"L",
"i-1",
"i",
"1",
"L[i]",
"L",
"i",
"ans2 += 1",
"ans2",
"1",
"print(min(ans1, ans2))",
"print",
"min(ans1, ans2)",
"min",
"ans1",
"ans2",
"A = list(map(int, input().split()))",
"list(map(int, input().split()))",
"A",
"ans1 = 0",
"0",
"ans1",
"ans2 = 0",
"0",
"ans2",
"ans1 += 1",
"1",
"ans1",
"C += [i]*A[i]",
"[i]*A[i]",
"C",
"ans2 += 1",
"1",
"ans2",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"C = []",
"[]",
"C",
"B = deque(C)",
"deque(C)",
"B",
"B = deque(C)",
"deque(C)",
"B",
"L = [-1]*k",
"[-1]*k",
"L",
"L = [-1]*k",
"[-1]*k",
"L"
] |
k, t = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
C = []
for i in range(t):
C += [i]*A[i]
from collections import deque
B = deque(C)
L = [-1]*k
for i in range(k):
if i%2 == 0:
L[i] = B.popleft()
else:
L[i] = B.pop()
ans1 = 0
for i in range(1, k):
if L[i-1] == L[i]:
ans1 += 1
B = deque(C)
L = [-1]*k
for i in range(k):
if i%2 == 0:
L[i] = B.pop()
else:
L[i] = B.popleft()
ans2 = 0
for i in range(1, k):
if L[i-1] == L[i]:
ans2 += 1
print(min(ans1, ans2))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
4,
18,
13,
13,
0,
13,
39,
17,
28,
13,
13,
4,
18,
13,
13,
2,
18,
13,
17,
13,
4,
13,
4,
13,
2,
4,
13,
2,
18,
13,
17,
2,
18,
13,
13,
17,
40,
18,
13,
17,
2,
18,
13,
13,
17,
10,
4,
13,
10,
39,
13,
10,
4,
13
] |
[
[
70,
2
],
[
70,
15
],
[
70,
16
],
[
67,
23
],
[
28,
27
],
[
68,
31
],
[
68,
35
],
[
27,
37
],
[
68,
47
],
[
68,
51
],
[
68,
56
],
[
68,
60
],
[
70,
65
],
[
67,
68
],
[
70,
71
]
] |
[
"#!/usr/bin/env python3\nk, t, *a = map(int, open(0).read().split())\na.sort()\nc = [0]\nfor i in a:\n c.append(c[-1]+i)\nprint(min(abs(c[-1] - c[i]*2) - (c[-1]!= c[i]*2) for i in range(t+1)))",
"k, t, *a = map(int, open(0).read().split())",
"k",
"map(int, open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"t",
"*a",
"a",
"a.sort()",
"a.sort",
"a",
"sort",
"c = [0]",
"c",
"[0]",
"0",
"for i in a:\n c.append(c[-1]+i)",
"i",
"a",
"c.append(c[-1]+i)",
"c.append",
"c",
"append",
"c[-1]+i",
"c[-1]",
"c",
"-1",
"i",
"print(min(abs(c[-1] - c[i]*2) - (c[-1]!= c[i]*2) for i in range(t+1)))",
"print",
"min(abs(c[-1] - c[i]*2) - (c[-1]!= c[i]*2) for i in range(t+1))",
"min",
"abs(c[-1] - c[i]*2) - (c[-1]!= c[i]*2)",
"abs(c[-1] - c[i]*2)",
"abs",
"c[-1] - c[i]*2",
"c[-1]",
"c",
"-1",
"c[i]*2",
"c[i]",
"c",
"i",
"2",
"c[-1]!= c[i]*2",
"c[-1]",
"c",
"-1",
"c[i]*2",
"c[i]",
"c",
"i",
"2",
"k, t, *a = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"k",
"c = [0]",
"[0]",
"c",
"t, *a = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"t"
] |
#!/usr/bin/env python3
k, t, *a = map(int, open(0).read().split())
a.sort()
c = [0]
for i in a:
c.append(c[-1]+i)
print(min(abs(c[-1] - c[i]*2) - (c[-1]!= c[i]*2) for i in range(t+1)))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
14,
2,
13,
2,
13,
17,
14,
2,
13,
17,
4,
13,
4,
13,
17,
2,
2,
13,
2,
13,
13,
17,
4,
13,
2,
2,
13,
2,
13,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] |
[
[
79,
2
],
[
79,
11
],
[
76,
13
],
[
70,
16
],
[
73,
28
],
[
71,
31
],
[
74,
34
],
[
80,
36
],
[
80,
40
],
[
74,
49
],
[
80,
51
],
[
74,
52
],
[
74,
58
],
[
80,
60
],
[
74,
61
],
[
79,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
]
] |
[
"k,t = map(int,input().split())\nans = 0\nl = list(map(int,input().split()))\nm = max(l)\nif m > k//2:\n if k%2:\n print(max(0,m-(k-m)-1))\n else:\n print(m-(k-m)-1)\nelse:\n print(0)",
"k,t = map(int,input().split())",
"k",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"ans = 0",
"ans",
"0",
"l = list(map(int,input().split()))",
"l",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m = max(l)",
"m",
"max(l)",
"max",
"l",
"if m > k//2:\n if k%2:\n print(max(0,m-(k-m)-1))\n else:\n print(m-(k-m)-1)\nelse:\n print(0)",
"m > k//2",
"m",
"k//2",
"k",
"2",
"if k%2:\n print(max(0,m-(k-m)-1))\n else:\n print(m-(k-m)-1)",
"k%2",
"k",
"2",
"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",
"print(m-(k-m)-1)",
"print",
"m-(k-m)-1",
"m-(k-m)",
"m",
"k-m",
"k",
"m",
"1",
"print(0)",
"print",
"0",
"t = map(int,input().split())",
"map(int,input().split())",
"t",
"l = list(map(int,input().split()))",
"list(map(int,input().split()))",
"l",
"m = max(l)",
"max(l)",
"m",
"ans = 0",
"0",
"ans",
"k,t = map(int,input().split())",
"map(int,input().split())",
"k"
] |
k,t = map(int,input().split())
ans = 0
l = list(map(int,input().split()))
m = max(l)
if m > k//2:
if k%2:
print(max(0,m-(k-m)-1))
else:
print(m-(k-m)-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,
13,
2,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
48,
2
],
[
48,
11
],
[
51,
13
],
[
45,
25
],
[
52,
28
],
[
46,
36
],
[
43,
38
],
[
46,
39
],
[
48,
43
],
[
45,
46
],
[
48,
49
],
[
51,
52
]
] |
[
"k, t = map(int, input().split())\nL = list(map(int, input().split()))\nM = max(L)\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",
"L = list(map(int, input().split()))",
"L",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"M = max(L)",
"M",
"max(L)",
"max",
"L",
"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",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"M = max(L)",
"max(L)",
"M",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"L = list(map(int, input().split()))",
"list(map(int, input().split()))",
"L"
] |
k, t = map(int, input().split())
L = list(map(int, input().split()))
M = max(L)
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,
4,
18,
13,
13,
0,
13,
17,
4,
13,
4,
13,
2,
2,
18,
13,
17,
17,
2,
13,
18,
13,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
51,
2
],
[
51,
11
],
[
54,
13
],
[
55,
26
],
[
30,
29
],
[
55,
38
],
[
49,
42
],
[
55,
44
],
[
51,
49
],
[
51,
52
],
[
54,
55
]
] |
[
"K,T=map(int,input().split())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\nprint(max(A[0]-1-(K-A[0]),0))",
"K,T=map(int,input().split())",
"K",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"A=list(map(int,input().split()))",
"A",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"A.sort(reverse=True)",
"A.sort",
"A",
"sort",
"reverse=True",
"reverse",
"True",
"print(max(A[0]-1-(K-A[0]),0))",
"print",
"max(A[0]-1-(K-A[0]),0)",
"max",
"A[0]-1-(K-A[0])",
"A[0]-1",
"A[0]",
"A",
"0",
"1",
"K-A[0]",
"K",
"A[0]",
"A",
"0",
"0",
"K,T=map(int,input().split())",
"map(int,input().split())",
"K",
"T=map(int,input().split())",
"map(int,input().split())",
"T",
"A=list(map(int,input().split()))",
"list(map(int,input().split()))",
"A"
] |
K,T=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
print(max(A[0]-1-(K-A[0]),0))
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
2,
2,
4,
13,
13,
17,
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
],
[
47,
25
],
[
54,
32
],
[
45,
35
],
[
54,
38
],
[
48,
42
],
[
50,
45
],
[
47,
48
],
[
50,
51
],
[
53,
54
]
] |
[
"k,t=map(int,input().split())\na=list(map(int,input().split()))\n\nans=max(max(a)-1 - (k-max(a)),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",
"ans=max(max(a)-1 - (k-max(a)),0)",
"ans",
"max(max(a)-1 - (k-max(a)),0)",
"max",
"max(a)-1 - (k-max(a))",
"max(a)-1",
"max(a)",
"max",
"a",
"1",
"k-max(a)",
"k",
"max(a)",
"max",
"a",
"0",
"print(ans)",
"print",
"ans",
"k,t=map(int,input().split())",
"map(int,input().split())",
"k",
"ans=max(max(a)-1 - (k-max(a)),0)",
"max(max(a)-1 - (k-max(a)),0)",
"ans",
"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()))
ans=max(max(a)-1 - (k-max(a)),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,
0,
13,
4,
13,
13,
4,
13,
4,
13,
17,
2,
2,
13,
17,
2,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
51,
2
],
[
51,
11
],
[
45,
13
],
[
48,
25
],
[
46,
28
],
[
49,
36
],
[
43,
39
],
[
49,
40
],
[
51,
43
],
[
45,
46
],
[
48,
49
],
[
51,
52
]
] |
[
"k, T = map(int, input().split())\nt = list(map(int, input().split()))\n\nmt = max(t)\n\nprint(max(0, mt-1-(k-mt)))",
"k, T = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"t = list(map(int, input().split()))",
"t",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"mt = max(t)",
"mt",
"max(t)",
"max",
"t",
"print(max(0, mt-1-(k-mt)))",
"print",
"max(0, mt-1-(k-mt))",
"max",
"0",
"mt-1-(k-mt)",
"mt-1",
"mt",
"1",
"k-mt",
"k",
"mt",
"k, T = map(int, input().split())",
"map(int, input().split())",
"k",
"t = list(map(int, input().split()))",
"list(map(int, input().split()))",
"t",
"mt = max(t)",
"max(t)",
"mt",
"T = map(int, input().split())",
"map(int, input().split())",
"T"
] |
k, T = map(int, input().split())
t = list(map(int, input().split()))
mt = max(t)
print(max(0, mt-1-(k-mt)))
|
[
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,
2,
17,
4,
13,
13,
4,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
53,
2
],
[
53,
11
],
[
44,
13
],
[
47,
25
],
[
45,
35
],
[
45,
38
],
[
48,
42
],
[
44,
45
],
[
47,
48
],
[
53,
51
],
[
53,
54
]
] |
[
"K, T = map(int,input().split())\nA = list(map(int,input().split()))\nans = max(0, 2 * max(A) - sum(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, 2 * max(A) - sum(A) - 1)",
"ans",
"max(0, 2 * max(A) - sum(A) - 1)",
"max",
"0",
"2 * max(A) - sum(A) - 1",
"2 * max(A) - sum(A)",
"2 * max(A)",
"2",
"max(A)",
"max",
"A",
"sum(A)",
"sum",
"A",
"1",
"print(ans)",
"print",
"ans",
"A = list(map(int,input().split()))",
"list(map(int,input().split()))",
"A",
"ans = max(0, 2 * max(A) - sum(A) - 1)",
"max(0, 2 * max(A) - sum(A) - 1)",
"ans",
"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()))
ans = max(0, 2 * max(A) - sum(A) - 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,
18,
13,
17,
0,
13,
4,
13,
18,
13,
39,
17,
14,
40,
2,
13,
17,
13,
4,
13,
2,
2,
13,
13,
17,
4,
13,
17,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
63,
2
],
[
63,
11
],
[
60,
13
],
[
57,
25
],
[
61,
27
],
[
66,
30
],
[
61,
34
],
[
67,
40
],
[
58,
42
],
[
58,
47
],
[
67,
48
],
[
63,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
]
] |
[
"k, t = map(int, input().split())\na = sorted(map(int, input().split()))\nmv = a[-1]\nnmv = sum(a[:-1])\n# print(mv, nmv)\nif nmv+1 <= mv:\n print(mv - nmv - 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(map(int, input().split()))",
"a",
"sorted(map(int, input().split()))",
"sorted",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"mv = a[-1]",
"mv",
"a[-1]",
"a",
"-1",
"nmv = sum(a[:-1])",
"nmv",
"sum(a[:-1])",
"sum",
"a[:-1]",
"a",
":-1",
"-1",
"if nmv+1 <= mv:\n print(mv - nmv - 1)\nelse:\n print(0)",
"nmv+1 <= mv",
"nmv+1",
"nmv",
"1",
"mv",
"print(mv - nmv - 1)",
"print",
"mv - nmv - 1",
"mv - nmv",
"mv",
"nmv",
"1",
"print(0)",
"print",
"0",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"mv = a[-1]",
"a[-1]",
"mv",
"a = sorted(map(int, input().split()))",
"sorted(map(int, input().split()))",
"a",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"nmv = sum(a[:-1])",
"sum(a[:-1])",
"nmv"
] |
k, t = map(int, input().split())
a = sorted(map(int, input().split()))
mv = a[-1]
nmv = sum(a[:-1])
# print(mv, nmv)
if nmv+1 <= mv:
print(mv - nmv - 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,
17,
0,
13,
2,
17,
17,
28,
13,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
13,
0,
13,
18,
13,
13,
0,
13,
13,
14,
40,
13,
13,
0,
18,
13,
13,
17,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
40,
13,
13,
2,
18,
13,
13,
13,
0,
13,
18,
13,
13,
0,
13,
13,
14,
2,
13,
17,
0,
18,
13,
13,
17,
0,
13,
13,
0,
13,
17,
0,
18,
13,
13,
17,
0,
13,
13,
4,
13,
13,
10,
18,
13,
10,
13,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
18,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13
] |
[
[
173,
2
],
[
173,
11
],
[
176,
13
],
[
152,
25
],
[
179,
28
],
[
34,
33
],
[
174,
36
],
[
155,
38
],
[
167,
41
],
[
45,
44
],
[
177,
49
],
[
177,
53
],
[
44,
54
],
[
156,
55
],
[
135,
55
],
[
134,
57
],
[
177,
59
],
[
44,
60
],
[
137,
62
],
[
44,
63
],
[
180,
66
],
[
171,
66
],
[
144,
66
],
[
162,
66
],
[
138,
67
],
[
168,
67
],
[
72,
69
],
[
177,
70
],
[
138,
71
],
[
168,
71
],
[
161,
74
],
[
138,
75
],
[
168,
75
],
[
158,
77
],
[
140,
80
],
[
84,
83
],
[
177,
88
],
[
83,
92
],
[
138,
93
],
[
168,
93
],
[
177,
96
],
[
83,
97
],
[
159,
98
],
[
150,
98
],
[
149,
100
],
[
177,
102
],
[
83,
103
],
[
146,
105
],
[
83,
106
],
[
150,
109
],
[
159,
109
],
[
115,
112
],
[
177,
113
],
[
138,
114
],
[
168,
114
],
[
143,
117
],
[
138,
118
],
[
168,
118
],
[
182,
120
],
[
126,
123
],
[
177,
124
],
[
147,
125
],
[
141,
125
],
[
170,
128
],
[
147,
129
],
[
141,
129
],
[
183,
132
],
[
153,
132
],
[
134,
135
],
[
44,
137
],
[
137,
138
],
[
140,
141
],
[
138,
143
],
[
168,
143
],
[
143,
144
],
[
83,
146
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
],
[
138,
161
],
[
168,
161
],
[
161,
162
],
[
173,
165
],
[
167,
168
],
[
147,
170
],
[
141,
170
],
[
170,
171
],
[
173,
174
],
[
176,
177
],
[
179,
180
],
[
182,
183
]
] |
[
"k, t = map(int, input().split())\na = list(map(int, input().split()))\n\nans = 0\npre_index = 10**5\nfor i in range(k):\n max_value = 0\n max_index = 0\n for j in range(len(a)):\n if a[j] > max_value:\n max_value = a[j]\n max_index = j\n \n if pre_index != max_index:\n a[max_index] -= 1\n pre_index = max_index\n else:\n second_max_value = 0\n second_max_index = 0\n for j in range(len(a)):\n if j != max_index and a[j] > second_max_value:\n second_max_value = a[j]\n second_max_index = j\n if second_max_value == 0:\n a[max_index] -= 1\n pre_index = max_index\n ans += 1\n else:\n a[second_max_index] -= 1\n pre_index = second_max_index\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",
"pre_index = 10**5",
"pre_index",
"10**5",
"10",
"5",
"for i in range(k):\n max_value = 0\n max_index = 0\n for j in range(len(a)):\n if a[j] > max_value:\n max_value = a[j]\n max_index = j\n \n if pre_index != max_index:\n a[max_index] -= 1\n pre_index = max_index\n else:\n second_max_value = 0\n second_max_index = 0\n for j in range(len(a)):\n if j != max_index and a[j] > second_max_value:\n second_max_value = a[j]\n second_max_index = j\n if second_max_value == 0:\n a[max_index] -= 1\n pre_index = max_index\n ans += 1\n else:\n a[second_max_index] -= 1\n pre_index = second_max_index",
"i",
"range(k)",
"range",
"k",
"max_value = 0",
"max_value",
"0",
"max_index = 0",
"max_index",
"0",
"for j in range(len(a)):\n if a[j] > max_value:\n max_value = a[j]\n max_index = j\n \n ",
"j",
"range(len(a))",
"range",
"len(a)",
"len",
"a",
"if a[j] > max_value:\n max_value = a[j]\n max_index = j\n \n ",
"a[j] > max_value",
"a[j]",
"a",
"j",
"max_value",
"max_value = a[j]",
"max_value",
"a[j]",
"a",
"j",
"max_index = j",
"max_index",
"j",
"if pre_index != max_index:\n a[max_index] -= 1\n pre_index = max_index\n else:\n second_max_value = 0\n second_max_index = 0\n for j in range(len(a)):\n if j != max_index and a[j] > second_max_value:\n second_max_value = a[j]\n second_max_index = j\n if second_max_value == 0:\n a[max_index] -= 1\n pre_index = max_index\n ans += 1\n else:\n a[second_max_index] -= 1\n pre_index = second_max_index",
"pre_index != max_index",
"pre_index",
"max_index",
"a[max_index] -= 1",
"a[max_index]",
"a",
"max_index",
"1",
"pre_index = max_index",
"pre_index",
"max_index",
"second_max_value = 0",
"second_max_value",
"0",
"second_max_index = 0",
"second_max_index",
"0",
"for j in range(len(a)):\n if j != max_index and a[j] > second_max_value:\n second_max_value = a[j]\n second_max_index = j\n ",
"j",
"range(len(a))",
"range",
"len(a)",
"len",
"a",
"if j != max_index and a[j] > second_max_value:\n second_max_value = a[j]\n second_max_index = j\n ",
"j != max_index and a[j] > second_max_value",
"j != max_index",
"j",
"max_index",
"a[j] > second_max_value",
"a[j]",
"a",
"j",
"second_max_value",
"second_max_value = a[j]",
"second_max_value",
"a[j]",
"a",
"j",
"second_max_index = j",
"second_max_index",
"j",
"if second_max_value == 0:\n a[max_index] -= 1\n pre_index = max_index\n ans += 1\n else:\n a[second_max_index] -= 1\n pre_index = second_max_index",
"second_max_value == 0",
"second_max_value",
"0",
"a[max_index] -= 1",
"a[max_index]",
"a",
"max_index",
"1",
"pre_index = max_index",
"pre_index",
"max_index",
"ans += 1",
"ans",
"1",
"a[second_max_index] -= 1",
"a[second_max_index]",
"a",
"second_max_index",
"1",
"pre_index = second_max_index",
"pre_index",
"second_max_index",
"print(ans)",
"print",
"ans",
"max_value = a[j]",
"a[j]",
"max_value",
"max_index = j",
"j",
"max_index",
"second_max_index = 0",
"0",
"second_max_index",
"pre_index = max_index",
"max_index",
"pre_index",
"second_max_index = j",
"j",
"second_max_index",
"second_max_value = a[j]",
"a[j]",
"second_max_value",
"ans = 0",
"0",
"ans",
"max_value = 0",
"0",
"max_value",
"second_max_value = 0",
"0",
"second_max_value",
"pre_index = max_index",
"max_index",
"pre_index",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"max_index = 0",
"0",
"max_index",
"pre_index = second_max_index",
"second_max_index",
"pre_index",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"pre_index = 10**5",
"10**5",
"pre_index",
"ans += 1",
"1",
"ans"
] |
k, t = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
pre_index = 10**5
for i in range(k):
max_value = 0
max_index = 0
for j in range(len(a)):
if a[j] > max_value:
max_value = a[j]
max_index = j
if pre_index != max_index:
a[max_index] -= 1
pre_index = max_index
else:
second_max_value = 0
second_max_index = 0
for j in range(len(a)):
if j != max_index and a[j] > second_max_value:
second_max_value = a[j]
second_max_index = j
if second_max_value == 0:
a[max_index] -= 1
pre_index = max_index
ans += 1
else:
a[second_max_index] -= 1
pre_index = second_max_index
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,
0,
13,
2,
4,
13,
13,
2,
2,
4,
13,
13,
4,
13,
13,
17,
4,
13,
4,
13,
17,
13,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
28,
27
],
[
15,
31
],
[
15,
36
],
[
15,
39
],
[
27,
46
],
[
55,
52
]
] |
[
"def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n ans = max(A) - (sum(A) - max(A) + 1)\n print(max(0,ans))\n\n\nif __name__ == \"__main__\":\n main()",
"def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n ans = max(A) - (sum(A) - max(A) + 1)\n print(max(0,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 = max(A) - (sum(A) - max(A) + 1)",
"ans",
"max(A) - (sum(A) - max(A) + 1)",
"max(A)",
"max",
"A",
"sum(A) - max(A) + 1",
"sum(A) - max(A)",
"sum(A)",
"sum",
"A",
"max(A)",
"max",
"A",
"1",
"print(max(0,ans))",
"print",
"max(0,ans)",
"max",
"0",
"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 = max(A) - (sum(A) - max(A) + 1)\n print(max(0,ans))",
"def main():\n K, T = map(int, input().split())\n A = list(map(int, input().split()))\n ans = max(A) - (sum(A) - max(A) + 1)\n print(max(0,ans))",
"main"
] |
def main():
K, T = map(int, input().split())
A = list(map(int, input().split()))
ans = max(A) - (sum(A) - max(A) + 1)
print(max(0,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,
4,
13,
4,
13,
2,
2,
18,
13,
17,
4,
13,
18,
13,
39,
17,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
45,
2
],
[
45,
11
],
[
48,
13
],
[
49,
31
],
[
49,
36
],
[
45,
43
],
[
45,
46
],
[
48,
49
]
] |
[
"K, T = map(int, input().split())\nA = sorted(map(int, input().split()))\n\nprint(max(A[-1] - sum(A[:-1]) - 1, 0))",
"K, T = map(int, input().split())",
"K",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"T",
"A = sorted(map(int, input().split()))",
"A",
"sorted(map(int, input().split()))",
"sorted",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"print(max(A[-1] - sum(A[:-1]) - 1, 0))",
"print",
"max(A[-1] - sum(A[:-1]) - 1, 0)",
"max",
"A[-1] - sum(A[:-1]) - 1",
"A[-1] - sum(A[:-1])",
"A[-1]",
"A",
"-1",
"sum(A[:-1])",
"sum",
"A[:-1]",
"A",
":-1",
"-1",
"1",
"0",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K",
"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(A[-1] - sum(A[:-1]) - 1, 0))
|
[
7,
15,
13,
12,
13,
12,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
0,
13,
2,
13,
13,
14,
40,
13,
2,
13,
17,
4,
13,
17,
0,
13,
2,
13,
17,
4,
13,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13
] |
[
[
74,
15
],
[
54,
17
],
[
74,
18
],
[
59,
20
],
[
54,
24
],
[
71,
26
],
[
60,
29
],
[
65,
31
],
[
75,
33
],
[
72,
34
],
[
72,
37
],
[
66,
39
],
[
62,
45
],
[
66,
47
],
[
63,
51
],
[
72,
51
],
[
74,
57
],
[
59,
60
],
[
62,
63
],
[
65,
66
],
[
71,
72
],
[
74,
75
]
] |
[
"import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nK, T = mapint()\nAs = list(mapint())\nmaxi = max(As)\nrest = K-maxi\nif maxi<=rest+1:\n print(0)\nelse:\n maxi -= rest+1\n print(maxi)",
"import sys",
"sys",
"def input(): return sys.stdin.readline().strip()",
"input",
"def mapint(): return map(int, input().split())",
"mapint",
"sys.setrecursionlimit(10**9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10**9",
"10",
"9",
"K, T = mapint()",
"K",
"mapint()",
"mapint",
"T",
"As = list(mapint())",
"As",
"list(mapint())",
"list",
"mapint()",
"mapint",
"maxi = max(As)",
"maxi",
"max(As)",
"max",
"As",
"rest = K-maxi",
"rest",
"K-maxi",
"K",
"maxi",
"if maxi<=rest+1:\n print(0)\nelse:\n maxi -= rest+1\n print(maxi)",
"maxi<=rest+1",
"maxi",
"rest+1",
"rest",
"1",
"print(0)",
"print",
"0",
"maxi -= rest+1",
"maxi",
"rest+1",
"rest",
"1",
"print(maxi)",
"print",
"maxi",
"def mapint(): return map(int, input().split())",
"def mapint(): return map(int, input().split())",
"mapint",
"T = mapint()",
"mapint()",
"T",
"As = list(mapint())",
"list(mapint())",
"As",
"maxi -= rest+1",
"rest+1",
"maxi",
"rest = K-maxi",
"K-maxi",
"rest",
"def input(): return sys.stdin.readline().strip()",
"def input(): return sys.stdin.readline().strip()",
"input",
"maxi = max(As)",
"max(As)",
"maxi",
"K, T = mapint()",
"mapint()",
"K"
] |
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
K, T = mapint()
As = list(mapint())
maxi = max(As)
rest = K-maxi
if maxi<=rest+1:
print(0)
else:
maxi -= rest+1
print(maxi)
|
[
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,
2,
13,
4,
13,
13,
0,
13,
2,
13,
2,
13,
17,
14,
40,
13,
17,
4,
13,
17,
4,
13,
2,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
2,
13
] |
[
[
59,
2
],
[
59,
13
],
[
53,
15
],
[
62,
27
],
[
57,
29
],
[
54,
32
],
[
65,
34
],
[
57,
36
],
[
63,
38
],
[
66,
42
],
[
66,
50
],
[
53,
54
],
[
59,
57
],
[
59,
60
],
[
62,
63
],
[
65,
66
]
] |
[
"\nK,T = list(map(int, input().split()))\nAs = list(map(int, input().split()))\n\ngoods = K - max(As)\nans = K - goods * 2\n\nif ans <= 0:\n print(0)\nelse:\n print(ans-1)\n\n",
"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",
"As = list(map(int, input().split()))",
"As",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"goods = K - max(As)",
"goods",
"K - max(As)",
"K",
"max(As)",
"max",
"As",
"ans = K - goods * 2",
"ans",
"K - goods * 2",
"K",
"goods * 2",
"goods",
"2",
"if ans <= 0:\n print(0)\nelse:\n print(ans-1)",
"ans <= 0",
"ans",
"0",
"print(0)",
"print",
"0",
"print(ans-1)",
"print",
"ans-1",
"ans",
"1",
"As = list(map(int, input().split()))",
"list(map(int, input().split()))",
"As",
"K,T = list(map(int, input().split()))",
"list(map(int, input().split()))",
"K",
"T = list(map(int, input().split()))",
"list(map(int, input().split()))",
"T",
"goods = K - max(As)",
"K - max(As)",
"goods",
"ans = K - goods * 2",
"K - goods * 2",
"ans"
] |
K,T = list(map(int, input().split()))
As = list(map(int, input().split()))
goods = K - max(As)
ans = K - goods * 2
if ans <= 0:
print(0)
else:
print(ans-1)
|
[
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,
4,
13,
13,
0,
13,
4,
13,
13,
14,
40,
13,
2,
13,
13,
0,
13,
2,
2,
13,
2,
13,
13,
17,
0,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13
] |
[
[
4,
3
],
[
3,
12
],
[
76,
14
],
[
76,
16
],
[
20,
19
],
[
19,
28
],
[
61,
30
],
[
64,
35
],
[
62,
38
],
[
65,
41
],
[
74,
43
],
[
65,
44
],
[
67,
46
],
[
65,
49
],
[
74,
51
],
[
65,
52
],
[
70,
55
],
[
71,
59
],
[
68,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
76,
74
],
[
76,
77
]
] |
[
"K, T = [int(x) for x in input().split()]\na = list([int(x) for x in input().split()])\n\nmax_cake = max(a)\n\nif max_cake >= K - max_cake:\n result = max_cake - (K - max_cake) - 1\nelse:\n result = 0\n\nprint(result)",
"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 = list([int(x) for x in input().split()])",
"a",
"list([int(x) for x in input().split()])",
"list",
"[int(x) for x in input().split()]",
"max_cake = max(a)",
"max_cake",
"max(a)",
"max",
"a",
"if max_cake >= K - max_cake:\n result = max_cake - (K - max_cake) - 1\nelse:\n result = 0",
"max_cake >= K - max_cake",
"max_cake",
"K - max_cake",
"K",
"max_cake",
"result = max_cake - (K - max_cake) - 1",
"result",
"max_cake - (K - max_cake) - 1",
"max_cake - (K - max_cake)",
"max_cake",
"K - max_cake",
"K",
"max_cake",
"1",
"result = 0",
"result",
"0",
"print(result)",
"print",
"result",
"a = list([int(x) for x in input().split()])",
"list([int(x) for x in input().split()])",
"a",
"max_cake = max(a)",
"max(a)",
"max_cake",
"result = max_cake - (K - max_cake) - 1",
"max_cake - (K - max_cake) - 1",
"result",
"result = 0",
"0",
"result",
"K, T = [int(x) for x in input().split()]",
"[int(x) for x in input().split()]",
"K",
"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 = list([int(x) for x in input().split()])
max_cake = max(a)
if max_cake >= K - max_cake:
result = max_cake - (K - max_cake) - 1
else:
result = 0
print(result)
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
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,
13,
4,
13,
17,
2,
2,
4,
13,
13,
2,
4,
13,
13,
4,
13,
13,
17,
29,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
17,
16
],
[
17,
25
],
[
28,
27
],
[
27,
47
],
[
27,
51
],
[
27,
54
],
[
66,
63
]
] |
[
"import numpy as np\nimport functools\nimport math\nimport scipy\nimport fractions\nimport itertools\n \ndef solve():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n print(max(0, max(a)-(sum(a)-max(a))-1))\n return 0\n\nif __name__ == \"__main__\":\n solve()",
"import numpy as np",
"numpy",
"import functools",
"functools",
"import math",
"math",
"import scipy",
"scipy",
"import fractions",
"fractions",
"import itertools",
"itertools",
"def solve():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n print(max(0, max(a)-(sum(a)-max(a))-1))\n return 0",
"solve",
"k, t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"a = list(map(int, input().split()))",
"a",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"print(max(0, max(a)-(sum(a)-max(a))-1))",
"print",
"max(0, max(a)-(sum(a)-max(a))-1)",
"max",
"0",
"max(a)-(sum(a)-max(a))-1",
"max(a)-(sum(a)-max(a))",
"max(a)",
"max",
"a",
"sum(a)-max(a)",
"sum(a)",
"sum",
"a",
"max(a)",
"max",
"a",
"1",
"return 0",
"0",
"if __name__ == \"__main__\":\n solve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"solve()",
"solve",
"def solve():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n print(max(0, max(a)-(sum(a)-max(a))-1))\n return 0",
"def solve():\n k, t = map(int, input().split())\n a = list(map(int, input().split()))\n print(max(0, max(a)-(sum(a)-max(a))-1))\n return 0",
"solve"
] |
import numpy as np
import functools
import math
import scipy
import fractions
import itertools
def solve():
k, t = map(int, input().split())
a = list(map(int, input().split()))
print(max(0, max(a)-(sum(a)-max(a))-1))
return 0
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,
0,
13,
4,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
4,
13,
2,
2,
18,
13,
13,
17,
2,
13,
18,
13,
13,
17,
4,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
71,
2
],
[
71,
11
],
[
56,
13
],
[
68,
25
],
[
57,
28
],
[
59,
30
],
[
57,
33
],
[
69,
35
],
[
65,
37
],
[
57,
43
],
[
60,
44
],
[
63,
44
],
[
72,
47
],
[
57,
49
],
[
60,
50
],
[
63,
50
],
[
66,
54
],
[
56,
57
],
[
59,
60
],
[
71,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
]
] |
[
"k, t = map(int, input().split())\na = list(map(int, input().split()))\n\nmaxA = max(a)\n# print(a)\nt = a.index(maxA)\n# 最大を置いて,間に挟んでいく\n# 間に挟める個数はk - a[t]個ある\n# a[t] - 1個はdefault\nans = max(a[t] - 1 - (k - a[t]), 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",
"maxA = max(a)",
"maxA",
"max(a)",
"max",
"a",
"t = a.index(maxA)",
"t",
"a.index(maxA)",
"a.index",
"a",
"index",
"maxA",
"ans = max(a[t] - 1 - (k - a[t]), 0)",
"ans",
"max(a[t] - 1 - (k - a[t]), 0)",
"max",
"a[t] - 1 - (k - a[t])",
"a[t] - 1",
"a[t]",
"a",
"t",
"1",
"k - a[t]",
"k",
"a[t]",
"a",
"t",
"0",
"print(ans)",
"print",
"ans",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"t = a.index(maxA)",
"a.index(maxA)",
"t",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"ans = max(a[t] - 1 - (k - a[t]), 0)",
"max(a[t] - 1 - (k - a[t]), 0)",
"ans",
"maxA = max(a)",
"max(a)",
"maxA",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k"
] |
k, t = map(int, input().split())
a = list(map(int, input().split()))
maxA = max(a)
# print(a)
t = a.index(maxA)
# 最大を置いて,間に挟んでいく
# 間に挟める個数はk - a[t]個ある
# a[t] - 1個はdefault
ans = max(a[t] - 1 - (k - a[t]), 0)
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
4,
18,
13,
13,
4,
13,
4,
13,
17,
2,
2,
18,
13,
17,
4,
13,
18,
13,
39,
2,
13,
17,
17,
10,
4,
13,
10,
4,
13
] |
[
[
45,
2
],
[
45,
15
],
[
45,
16
],
[
43,
38
],
[
45,
43
],
[
45,
46
]
] |
[
"K,T,*a = map(int, open(0).read().split())\na.sort()\nprint(max(0,a[-1]-sum(a[:T-1])-1))",
"K,T,*a = map(int, open(0).read().split())",
"K",
"map(int, open(0).read().split())",
"map",
"int",
"open(0).read().split()",
"(0).read().split",
"(0).read()",
"(0).read",
"(0)",
"open",
"0",
"read",
"split",
"T",
"*a",
"a",
"a.sort()",
"a.sort",
"a",
"sort",
"print(max(0,a[-1]-sum(a[:T-1])-1))",
"print",
"max(0,a[-1]-sum(a[:T-1])-1)",
"max",
"0",
"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,*a = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"T",
"K,T,*a = map(int, open(0).read().split())",
"map(int, open(0).read().split())",
"K"
] |
K,T,*a = map(int, open(0).read().split())
a.sort()
print(max(0,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,
0,
13,
4,
13,
13,
14,
40,
2,
2,
13,
17,
17,
13,
4,
13,
17,
4,
13,
2,
2,
2,
13,
17,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
59,
2
],
[
59,
11
],
[
56,
13
],
[
53,
25
],
[
57,
28
],
[
60,
33
],
[
54,
36
],
[
54,
45
],
[
60,
47
],
[
59,
51
],
[
53,
54
],
[
56,
57
],
[
59,
60
]
] |
[
"k, t = map(int, input().split())\na = list(map(int, input().split()))\nnum = max(a)\nif (k + 1) // 2 >= num:\n print(0)\nelse:\n print(num * 2 - 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",
"num = max(a)",
"num",
"max(a)",
"max",
"a",
"if (k + 1) // 2 >= num:\n print(0)\nelse:\n print(num * 2 - k - 1)",
"(k + 1) // 2 >= num",
"(k + 1) // 2",
"k + 1",
"k",
"1",
"2",
"num",
"print(0)",
"print",
"0",
"print(num * 2 - k - 1)",
"print",
"num * 2 - k - 1",
"num * 2 - k",
"num * 2",
"num",
"2",
"k",
"1",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"num = max(a)",
"max(a)",
"num",
"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()))
num = max(a)
if (k + 1) // 2 >= num:
print(0)
else:
print(num * 2 - k - 1)
|
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
0,
13,
2,
2,
18,
13,
17,
17,
4,
13,
18,
13,
39,
17,
14,
40,
13,
17,
4,
13,
13,
4,
13,
17,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
61,
2
],
[
61,
13
],
[
64,
15
],
[
65,
28
],
[
55,
31
],
[
65,
35
],
[
65,
41
],
[
56,
46
],
[
56,
50
],
[
55,
56
],
[
61,
59
],
[
61,
62
],
[
64,
65
]
] |
[
"k,t=list(map(int,input().split()))\na=list(map(int,input().split()))\na.sort()\ntmp=a[-1]-1-sum(a[:-1])\nif tmp>=0:\n print(tmp)\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",
"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",
"tmp=a[-1]-1-sum(a[:-1])",
"tmp",
"a[-1]-1-sum(a[:-1])",
"a[-1]-1",
"a[-1]",
"a",
"-1",
"1",
"sum(a[:-1])",
"sum",
"a[:-1]",
"a",
":-1",
"-1",
"if tmp>=0:\n print(tmp)\nelse:\n print(0)",
"tmp>=0",
"tmp",
"0",
"print(tmp)",
"print",
"tmp",
"print(0)",
"print",
"0",
"tmp=a[-1]-1-sum(a[:-1])",
"a[-1]-1-sum(a[:-1])",
"tmp",
"t=list(map(int,input().split()))",
"list(map(int,input().split()))",
"t",
"k,t=list(map(int,input().split()))",
"list(map(int,input().split()))",
"k",
"a=list(map(int,input().split()))",
"list(map(int,input().split()))",
"a"
] |
k,t=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
tmp=a[-1]-1-sum(a[:-1])
if tmp>=0:
print(tmp)
else:
print(0)
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
17,
4,
18,
13,
13,
2,
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,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
40,
13,
13,
14,
2,
18,
13,
13,
13,
0,
13,
18,
13,
13,
0,
13,
13,
14,
40,
13,
17,
0,
18,
13,
13,
17,
0,
13,
13,
4,
13,
4,
13,
13,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
12,
13
] |
[
[
121,
4
],
[
118,
11
],
[
124,
18
],
[
33,
32
],
[
122,
39
],
[
33,
41
],
[
44,
43
],
[
122,
52
],
[
56,
55
],
[
59,
58
],
[
62,
61
],
[
32,
64
],
[
67,
66
],
[
70,
69
],
[
73,
72
],
[
41,
75
],
[
72,
78
],
[
58,
79
],
[
104,
79
],
[
43,
83
],
[
72,
84
],
[
66,
85
],
[
87,
85
],
[
88,
87
],
[
43,
89
],
[
72,
90
],
[
93,
92
],
[
72,
93
],
[
92,
96
],
[
69,
96
],
[
102,
99
],
[
43,
100
],
[
92,
101
],
[
69,
101
],
[
105,
104
],
[
92,
105
],
[
69,
105
],
[
43,
110
],
[
128,
116
],
[
118,
119
],
[
121,
122
],
[
124,
125
]
] |
[
"import sys\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\ndef main():\n k, t = map(int, readline().split())\n a = list(map(int, readline().split()))\n ans = 0\n prev = -1\n\n for _ in range(k):\n max_a = 0\n cur = -1\n for i in range(t):\n if i != prev:\n if a[i] > max_a:\n max_a = a[i]\n cur = i\n if cur != -1:\n a[cur] -= 1\n prev = cur\n\n print(sum(a))\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"readline = sys.stdin.readline",
"readline",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"MOD = 10 ** 9 + 7",
"MOD",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"INF = float('INF')",
"INF",
"float('INF')",
"float",
"'INF'",
"sys.setrecursionlimit(10 ** 5)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 5",
"10",
"5",
"def main():\n k, t = map(int, readline().split())\n a = list(map(int, readline().split()))\n ans = 0\n prev = -1\n\n for _ in range(k):\n max_a = 0\n cur = -1\n for i in range(t):\n if i != prev:\n if a[i] > max_a:\n max_a = a[i]\n cur = i\n if cur != -1:\n a[cur] -= 1\n prev = cur\n\n print(sum(a))",
"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",
"ans = 0",
"ans",
"0",
"prev = -1",
"prev",
"-1",
"for _ in range(k):\n max_a = 0\n cur = -1\n for i in range(t):\n if i != prev:\n if a[i] > max_a:\n max_a = a[i]\n cur = i\n if cur != -1:\n a[cur] -= 1\n prev = cur\n\n ",
"_",
"range(k)",
"range",
"k",
"max_a = 0",
"max_a",
"0",
"cur = -1",
"cur",
"-1",
"for i in range(t):\n if i != prev:\n if a[i] > max_a:\n max_a = a[i]\n cur = i\n ",
"i",
"range(t)",
"range",
"t",
"if i != prev:\n if a[i] > max_a:\n max_a = a[i]\n cur = i\n ",
"i != prev",
"i",
"prev",
"if a[i] > max_a:\n max_a = a[i]\n cur = i\n ",
"a[i] > max_a",
"a[i]",
"a",
"i",
"max_a",
"max_a = a[i]",
"max_a",
"a[i]",
"a",
"i",
"cur = i",
"cur",
"i",
"if cur != -1:\n a[cur] -= 1\n prev = cur\n\n ",
"cur != -1",
"cur",
"-1",
"a[cur] -= 1",
"a[cur]",
"a",
"cur",
"1",
"prev = cur",
"prev",
"cur",
"print(sum(a))",
"print",
"sum(a)",
"sum",
"a",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"MOD = 10 ** 9 + 7",
"10 ** 9 + 7",
"MOD",
"readline = sys.stdin.readline",
"sys.stdin.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 ans = 0\n prev = -1\n\n for _ in range(k):\n max_a = 0\n cur = -1\n for i in range(t):\n if i != prev:\n if a[i] > max_a:\n max_a = a[i]\n cur = i\n if cur != -1:\n a[cur] -= 1\n prev = cur\n\n print(sum(a))",
"def main():\n k, t = map(int, readline().split())\n a = list(map(int, readline().split()))\n ans = 0\n prev = -1\n\n for _ in range(k):\n max_a = 0\n cur = -1\n for i in range(t):\n if i != prev:\n if a[i] > max_a:\n max_a = a[i]\n cur = i\n if cur != -1:\n a[cur] -= 1\n prev = cur\n\n print(sum(a))",
"main"
] |
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
k, t = map(int, readline().split())
a = list(map(int, readline().split()))
ans = 0
prev = -1
for _ in range(k):
max_a = 0
cur = -1
for i in range(t):
if i != prev:
if a[i] > max_a:
max_a = a[i]
cur = i
if cur != -1:
a[cur] -= 1
prev = cur
print(sum(a))
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
18,
13,
17,
13,
4,
13,
18,
13,
17,
0,
13,
4,
18,
4,
13,
13,
41,
28,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
13,
18,
13,
13,
0,
13,
18,
13,
13,
0,
13,
13,
28,
13,
4,
13,
4,
13,
13,
14,
40,
13,
13,
0,
13,
18,
13,
13,
4,
13,
4,
13,
17,
2,
2,
13,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
13,
13,
10,
18,
13,
10,
4,
13,
10,
13,
13
] |
[
[
99,
2
],
[
111,
9
],
[
100,
13
],
[
123,
15
],
[
100,
19
],
[
105,
22
],
[
31,
30
],
[
106,
30
],
[
30,
35
],
[
126,
37
],
[
108,
40
],
[
96,
43
],
[
102,
46
],
[
50,
49
],
[
127,
54
],
[
97,
57
],
[
115,
57
],
[
127,
59
],
[
49,
60
],
[
114,
62
],
[
127,
64
],
[
49,
65
],
[
117,
67
],
[
49,
68
],
[
71,
70
],
[
127,
75
],
[
70,
78
],
[
118,
79
],
[
109,
79
],
[
120,
81
],
[
127,
83
],
[
70,
84
],
[
115,
92
],
[
97,
92
],
[
121,
93
],
[
103,
93
],
[
96,
97
],
[
99,
100
],
[
102,
103
],
[
105,
106
],
[
108,
109
],
[
111,
112
],
[
114,
115
],
[
49,
117
],
[
117,
118
],
[
120,
121
],
[
123,
124
],
[
126,
127
]
] |
[
"#3問目\nKT = input().split()\nK,T = int(KT[0]), int(KT[1])\nA = input().split()\nintA = [int(s) for s in A]\nsaidai_i = 0\nsaidai = 0\nwithoutSaidaiSum = 0\nfor i in range(len(intA)):\n if(saidai < intA[i]):\n saidai = intA[i]\n saidai_i = i\nfor i in range(len(intA)):\n if(i != saidai_i):\n withoutSaidaiSum += intA[i]\nprint(max(0, saidai-withoutSaidaiSum-1))",
"KT = input().split()",
"KT",
"input().split()",
"().split",
"()",
"input",
"split",
"K,T = int(KT[0]), int(KT[1])",
"K",
"int(KT[0])",
"int",
"KT[0]",
"KT",
"0",
"T",
"int(KT[1])",
"int",
"KT[1]",
"KT",
"1",
"A = input().split()",
"A",
"input().split()",
"().split",
"()",
"input",
"split",
"int(s) for s in A",
"for s in A",
"s",
"A",
"for s in A",
"int(s)",
"int",
"s",
"intA = [int(s) for s in A]",
"intA",
"[int(s) for s in A]",
"saidai_i = 0",
"saidai_i",
"0",
"saidai = 0",
"saidai",
"0",
"withoutSaidaiSum = 0",
"withoutSaidaiSum",
"0",
"for i in range(len(intA)):\n if(saidai < intA[i]):\n saidai = intA[i]\n saidai_i = i",
"i",
"range(len(intA))",
"range",
"len(intA)",
"len",
"intA",
"if(saidai < intA[i]):\n saidai = intA[i]\n saidai_i = i",
"saidai < intA[i]",
"saidai",
"intA[i]",
"intA",
"i",
"saidai = intA[i]",
"saidai",
"intA[i]",
"intA",
"i",
"saidai_i = i",
"saidai_i",
"i",
"for i in range(len(intA)):\n if(i != saidai_i):\n withoutSaidaiSum += intA[i]",
"i",
"range(len(intA))",
"range",
"len(intA)",
"len",
"intA",
"if(i != saidai_i):\n withoutSaidaiSum += intA[i]",
"i != saidai_i",
"i",
"saidai_i",
"withoutSaidaiSum += intA[i]",
"withoutSaidaiSum",
"intA[i]",
"intA",
"i",
"print(max(0, saidai-withoutSaidaiSum-1))",
"print",
"max(0, saidai-withoutSaidaiSum-1)",
"max",
"0",
"saidai-withoutSaidaiSum-1",
"saidai-withoutSaidaiSum",
"saidai",
"withoutSaidaiSum",
"1",
"saidai = 0",
"0",
"saidai",
"KT = input().split()",
"input().split()",
"KT",
"withoutSaidaiSum = 0",
"0",
"withoutSaidaiSum",
"A = input().split()",
"input().split()",
"A",
"saidai_i = 0",
"0",
"saidai_i",
"K,T = int(KT[0]), int(KT[1])",
"int(KT[0])",
"K",
"saidai = intA[i]",
"intA[i]",
"saidai",
"saidai_i = i",
"i",
"saidai_i",
"withoutSaidaiSum += intA[i]",
"intA[i]",
"withoutSaidaiSum",
"T = int(KT[0]), int(KT[1])",
"int(KT[1])",
"T",
"intA = [int(s) for s in A]",
"[int(s) for s in A]",
"intA"
] |
#3問目
KT = input().split()
K,T = int(KT[0]), int(KT[1])
A = input().split()
intA = [int(s) for s in A]
saidai_i = 0
saidai = 0
withoutSaidaiSum = 0
for i in range(len(intA)):
if(saidai < intA[i]):
saidai = intA[i]
saidai_i = i
for i in range(len(intA)):
if(i != saidai_i):
withoutSaidaiSum += intA[i]
print(max(0, saidai-withoutSaidaiSum-1))
|
[
7,
15,
15,
15,
15,
13,
15,
13,
15,
13,
4,
18,
13,
13,
17,
0,
13,
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,
0,
13,
2,
13,
13,
4,
13,
4,
13,
17,
2,
2,
13,
13,
17,
10,
4,
13,
10,
12,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13
] |
[
[
77,
16
],
[
86,
39
],
[
72,
41
],
[
86,
42
],
[
80,
44
],
[
72,
46
],
[
83,
48
],
[
81,
51
],
[
74,
53
],
[
87,
55
],
[
84,
56
],
[
84,
64
],
[
75,
65
],
[
86,
69
],
[
74,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
86,
87
]
] |
[
"#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,permutations,accumulate, product # (string,3) 3回\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\n#import 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# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# 四捨五入g\nimport sys\nsys.setrecursionlimit(10000000)\n#mod = 10**9 + 7\n#mod = 9982443453\nmod = 998244353\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\nn,t = readInts()\nT = readInts()\nma = max(T)\nrest = n - ma\nprint(max(0,ma - rest - 1))",
"from fractions import gcd",
"from itertools import combinations,permutations,accumulate, product",
"from collections import deque,defaultdict,Counter",
"import decimal",
"decimal",
"import re",
"re",
"import sys",
"sys",
"sys.setrecursionlimit(10000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10000000",
"mod = 998244353",
"mod",
"998244353",
"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",
"n,t = readInts()",
"n",
"readInts()",
"readInts",
"t",
"T = readInts()",
"T",
"readInts()",
"readInts",
"ma = max(T)",
"ma",
"max(T)",
"max",
"T",
"rest = n - ma",
"rest",
"n - ma",
"n",
"ma",
"print(max(0,ma - rest - 1))",
"print",
"max(0,ma - rest - 1)",
"max",
"0",
"ma - rest - 1",
"ma - rest",
"ma",
"rest",
"1",
"t = readInts()",
"readInts()",
"t",
"def readInts():\n return list(map(int,input().split()))",
"def readInts():\n return list(map(int,input().split()))",
"readInts",
"rest = n - ma",
"n - ma",
"rest",
"mod = 998244353",
"998244353",
"mod",
"T = readInts()",
"readInts()",
"T",
"ma = max(T)",
"max(T)",
"ma",
"n,t = readInts()",
"readInts()",
"n",
"def I():\n return int(input())",
"def I():\n return int(input())",
"I"
] |
#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,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
return list(map(int,input().split()))
def I():
return int(input())
n,t = readInts()
T = readInts()
ma = max(T)
rest = n - ma
print(max(0,ma - rest - 1))
|
[
7,
12,
13,
29,
4,
13,
4,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
29,
13,
23,
13,
12,
13,
29,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
29,
4,
18,
13,
13,
13,
13,
23,
13,
23,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
18,
13,
13,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
39,
42,
2,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
13,
13,
14,
40,
2,
13,
13,
4,
18,
13,
13,
13,
29,
4,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
39,
42,
2,
4,
13,
13,
13,
0,
13,
4,
13,
13,
13,
17,
14,
40,
2,
13,
13,
4,
18,
13,
13,
13,
29,
4,
13,
13,
23,
13,
23,
13,
23,
13,
15,
15,
15,
15,
13,
15,
15,
15,
13,
15,
13,
15,
13,
15,
15,
15,
15,
15,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
0,
13,
17,
14,
2,
4,
13,
13,
17,
4,
13,
2,
18,
13,
17,
17,
4,
13,
4,
13,
2,
2,
18,
13,
17,
17,
4,
13,
18,
13,
39,
17,
17,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
4,
13
] |
[
[
37,
36
],
[
48,
39
],
[
48,
48
],
[
71,
68
],
[
73,
69
],
[
71,
71
],
[
73,
73
],
[
79,
78
],
[
96,
81
],
[
92,
87
],
[
94,
88
],
[
92,
92
],
[
94,
94
],
[
96,
96
],
[
101,
100
],
[
100,
106
],
[
135,
107
],
[
110,
109
],
[
131,
114
],
[
133,
115
],
[
109,
119
],
[
100,
120
],
[
100,
123
],
[
109,
125
],
[
100,
129
],
[
131,
131
],
[
133,
133
],
[
135,
135
],
[
140,
139
],
[
139,
145
],
[
173,
146
],
[
149,
148
],
[
259,
150
],
[
169,
151
],
[
171,
152
],
[
148,
157
],
[
139,
158
],
[
139,
161
],
[
148,
163
],
[
139,
167
],
[
169,
169
],
[
171,
171
],
[
173,
173
],
[
285,
199
],
[
288,
206
],
[
274,
208
],
[
288,
209
],
[
261,
211
],
[
277,
213
],
[
262,
216
],
[
220,
219
],
[
262,
225
],
[
262,
231
],
[
262,
241
],
[
262,
247
],
[
261,
262
],
[
288,
268
],
[
285,
286
],
[
288,
289
]
] |
[
"def getN():\n return int(input())\ndef getNM():\n return map(int, input().split())\ndef getList():\n return list(map(int, input().split()))\ndef getArray(intn):\n return [int(input()) for i in range(intn)]\ndef input():\n return sys.stdin.readline().rstrip()\ndef rand_N(ran1, ran2):\n return random.randint(ran1, ran2)\ndef rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]\ndef rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)\n\ndef rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)\n\nfrom collections import defaultdict, deque, Counter\nfrom sys import exit\nfrom decimal import *\nimport heapq\nfrom math import sqrt\nfrom fractions import gcd\nimport random\nimport string\nimport copy\nfrom itertools import combinations, permutations, product\nfrom operator import mul, itemgetter\nfrom functools import reduce\nfrom bisect import bisect_left, bisect_right\n\nimport sys\nsys.setrecursionlimit(1000000000)\nmod = 10 ** 9 + 7\n\n#############\n# Main Code #\n#############\n\nK, T = getNM()\nA = getList()\nA.sort(reverse = True)\n\nif len(A) == 1:\n print(A[0] - 1)\nelse:\n print(max((A[0] - 1) - sum(A[1:]), 0))",
"def getN():\n return int(input())",
"getN",
"return int(input())",
"int(input())",
"int",
"input()",
"input",
"def getNM():\n return map(int, input().split())",
"getNM",
"return map(int, input().split())",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def getList():\n return list(map(int, input().split()))",
"getList",
"return list(map(int, input().split()))",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"getArray",
"int(input()) for i in range(intn)",
"for i in range(intn)",
"i",
"range(intn)",
"range",
"intn",
"for i in range(intn)",
"int(input())",
"int",
"input()",
"input",
"return [int(input()) for i in range(intn)]",
"[int(input()) for i in range(intn)]",
"intn",
"intn",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"return sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"rand_N",
"return random.randint(ran1, ran2)",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"ran1",
"ran1",
"ran2",
"ran2",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"rand_List",
"random.randint(ran1, ran2) for i in range(rantime)",
"for i in range(rantime)",
"i",
"range(rantime)",
"range",
"rantime",
"for i in range(rantime)",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"return [random.randint(ran1, ran2) for i in range(rantime)]",
"[random.randint(ran1, ran2) for i in range(rantime)]",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"rand_ints_nodup",
"ns = []",
"ns",
"[]",
"while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n ",
"len(ns) < rantime",
"len(ns)",
"len",
"ns",
"rantime",
"n = random.randint(ran1, ran2)",
"n",
"random.randint(ran1, ran2)",
"random.randint",
"random",
"randint",
"ran1",
"ran2",
"if not n in ns:\n ns.append(n)\n ",
"not n in ns",
"n in ns",
"n",
"ns",
"ns.append(n)",
"ns.append",
"ns",
"append",
"n",
"return sorted(ns)",
"sorted(ns)",
"sorted",
"ns",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"rand_query",
"r_query = []",
"r_query",
"[]",
"while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n ",
"len(r_query) < rantime",
"len(r_query)",
"len",
"r_query",
"rantime",
"n_q = rand_ints_nodup(ran1, ran2, 2)",
"n_q",
"rand_ints_nodup(ran1, ran2, 2)",
"rand_ints_nodup",
"ran1",
"ran2",
"2",
"if not n_q in r_query:\n r_query.append(n_q)\n ",
"not n_q in r_query",
"n_q in r_query",
"n_q",
"r_query",
"r_query.append(n_q)",
"r_query.append",
"r_query",
"append",
"n_q",
"return sorted(r_query)",
"sorted(r_query)",
"sorted",
"r_query",
"ran1",
"ran1",
"ran2",
"ran2",
"rantime",
"rantime",
"from collections import defaultdict, deque, Counter",
"from sys import exit",
"from decimal import *",
"import heapq",
"heapq",
"from math import sqrt",
"from fractions import gcd",
"import random",
"random",
"import string",
"string",
"import copy",
"copy",
"from itertools import combinations, permutations, product",
"from operator import mul, itemgetter",
"from functools import reduce",
"from bisect import bisect_left, bisect_right",
"import sys",
"sys",
"sys.setrecursionlimit(1000000000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"1000000000",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"K, T = getNM()",
"K",
"getNM()",
"getNM",
"T",
"A = getList()",
"A",
"getList()",
"getList",
"A.sort(reverse = True)",
"A.sort",
"A",
"sort",
"reverse = True",
"reverse",
"True",
"if len(A) == 1:\n print(A[0] - 1)\nelse:\n print(max((A[0] - 1) - sum(A[1:]), 0))",
"len(A) == 1",
"len(A)",
"len",
"A",
"1",
"print(A[0] - 1)",
"print",
"A[0] - 1",
"A[0]",
"A",
"0",
"1",
"print(max((A[0] - 1) - sum(A[1:]), 0))",
"print",
"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",
"def input():\n return sys.stdin.readline().rstrip()",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"def getArray(intn):\n return [int(input()) for i in range(intn)]",
"getArray",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"def rand_ints_nodup(ran1, ran2, rantime):\n ns = []\n while len(ns) < rantime:\n n = random.randint(ran1, ran2)\n if not n in ns:\n ns.append(n)\n return sorted(ns)",
"rand_ints_nodup",
"A = getList()",
"getList()",
"A",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"def rand_N(ran1, ran2):\n return random.randint(ran1, ran2)",
"rand_N",
"K, T = getNM()",
"getNM()",
"K",
"def getN():\n return int(input())",
"def getN():\n return int(input())",
"getN",
"def getNM():\n return map(int, input().split())",
"def getNM():\n return map(int, input().split())",
"getNM",
"def getList():\n return list(map(int, input().split()))",
"def getList():\n return list(map(int, input().split()))",
"getList",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"def rand_List(ran1, ran2, rantime):\n return [random.randint(ran1, ran2) for i in range(rantime)]",
"rand_List",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"def rand_query(ran1, ran2, rantime):\n r_query = []\n while len(r_query) < rantime:\n n_q = rand_ints_nodup(ran1, ran2, 2)\n if not n_q in r_query:\n r_query.append(n_q)\n return sorted(r_query)",
"rand_query",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod",
"T = getNM()",
"getNM()",
"T"
] |
def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
K, T = getNM()
A = getList()
A.sort(reverse = True)
if len(A) == 1:
print(A[0] - 1)
else:
print(max((A[0] - 1) - sum(A[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,
4,
18,
13,
13,
0,
13,
4,
13,
18,
13,
39,
17,
4,
13,
4,
13,
17,
2,
2,
18,
13,
17,
17,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
4,
13
] |
[
[
65,
4
],
[
71,
12
],
[
66,
19
],
[
71,
21
],
[
59,
23
],
[
66,
32
],
[
60,
36
],
[
68,
39
],
[
60,
43
],
[
60,
54
],
[
69,
57
],
[
59,
60
],
[
71,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
]
] |
[
"import sys\ninput = sys.stdin.readline\nfrom collections import *\n\nK, T = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\ns = sum(a[:-1])\nprint(max(0, a[-1]-1-s))",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"from collections import *",
"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",
"s = sum(a[:-1])",
"s",
"sum(a[:-1])",
"sum",
"a[:-1]",
"a",
":-1",
"-1",
"print(max(0, a[-1]-1-s))",
"print",
"max(0, a[-1]-1-s)",
"max",
"0",
"a[-1]-1-s",
"a[-1]-1",
"a[-1]",
"a",
"-1",
"1",
"s",
"a = list(map(int, input().split()))",
"list(map(int, input().split()))",
"a",
"T = map(int, input().split())",
"map(int, input().split())",
"T",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"s = sum(a[:-1])",
"sum(a[:-1])",
"s",
"K, T = map(int, input().split())",
"map(int, input().split())",
"K"
] |
import sys
input = sys.stdin.readline
from collections import *
K, T = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a[:-1])
print(max(0, a[-1]-1-s))
|
[
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,
0,
13,
2,
13,
13,
4,
13,
2,
13,
2,
2,
13,
17,
17,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
63,
2
],
[
63,
11
],
[
66,
13
],
[
69,
25
],
[
67,
28
],
[
70,
31
],
[
61,
34
],
[
57,
43
],
[
61,
45
],
[
70,
46
],
[
61,
50
],
[
58,
53
],
[
57,
58
],
[
63,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
]
] |
[
"k, t = map(int, input().split())\naaa = list(map(int, input().split()))\nm = max(aaa)\nif m <= (k + 1) // 2:\n print(0)\n exit()\n\nothers = k - m\nprint(k - (others * 2 + 1))",
"k, t = map(int, input().split())",
"k",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"t",
"aaa = list(map(int, input().split()))",
"aaa",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m = max(aaa)",
"m",
"max(aaa)",
"max",
"aaa",
"if m <= (k + 1) // 2:\n print(0)\n exit()",
"m <= (k + 1) // 2",
"m",
"(k + 1) // 2",
"k + 1",
"k",
"1",
"2",
"print(0)",
"print",
"0",
"exit()",
"exit",
"others = k - m",
"others",
"k - m",
"k",
"m",
"print(k - (others * 2 + 1))",
"print",
"k - (others * 2 + 1)",
"k",
"others * 2 + 1",
"others * 2",
"others",
"2",
"1",
"others = k - m",
"k - m",
"others",
"k, t = map(int, input().split())",
"map(int, input().split())",
"k",
"t = map(int, input().split())",
"map(int, input().split())",
"t",
"aaa = list(map(int, input().split()))",
"list(map(int, input().split()))",
"aaa",
"m = max(aaa)",
"max(aaa)",
"m"
] |
k, t = map(int, input().split())
aaa = list(map(int, input().split()))
m = max(aaa)
if m <= (k + 1) // 2:
print(0)
exit()
others = k - m
print(k - (others * 2 + 1))
|
[
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,
0,
13,
4,
18,
13,
13,
4,
13,
13,
4,
13,
4,
13,
2,
2,
18,
13,
13,
17,
2,
13,
18,
13,
13,
17,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13
] |
[
[
4,
3
],
[
3,
12
],
[
67,
14
],
[
67,
16
],
[
20,
19
],
[
19,
28
],
[
58,
30
],
[
61,
33
],
[
59,
36
],
[
59,
40
],
[
59,
48
],
[
62,
49
],
[
65,
52
],
[
59,
54
],
[
62,
55
],
[
58,
59
],
[
61,
62
],
[
67,
65
],
[
67,
68
]
] |
[
"# CODE FESTIVAL 2016 予選 C: B – K個のケーキ / K Cakes\nK, T = [int(s) for s in input().split()]\na = [int(s) for s in input().split()]\n\nmax_index = a.index(max(a))\n\nprint(max(a[max_index] - 1 - (K - a[max_index]), 0))",
"int(s) for s in input().split()",
"for s in input().split()",
"s",
"input().split()",
"().split",
"()",
"input",
"split",
"for s in input().split()",
"int(s)",
"int",
"s",
"K, T = [int(s) for s in input().split()]",
"K",
"[int(s) for s in input().split()]",
"T",
"int(s) for s in input().split()",
"for s in input().split()",
"s",
"input().split()",
"().split",
"()",
"input",
"split",
"for s in input().split()",
"int(s)",
"int",
"s",
"a = [int(s) for s in input().split()]",
"a",
"[int(s) for s in input().split()]",
"max_index = a.index(max(a))",
"max_index",
"a.index(max(a))",
"a.index",
"a",
"index",
"max(a)",
"max",
"a",
"print(max(a[max_index] - 1 - (K - a[max_index]), 0))",
"print",
"max(a[max_index] - 1 - (K - a[max_index]), 0)",
"max",
"a[max_index] - 1 - (K - a[max_index])",
"a[max_index] - 1",
"a[max_index]",
"a",
"max_index",
"1",
"K - a[max_index]",
"K",
"a[max_index]",
"a",
"max_index",
"0",
"a = [int(s) for s in input().split()]",
"[int(s) for s in input().split()]",
"a",
"max_index = a.index(max(a))",
"a.index(max(a))",
"max_index",
"K, T = [int(s) for s in input().split()]",
"[int(s) for s in input().split()]",
"K",
"T = [int(s) for s in input().split()]",
"[int(s) for s in input().split()]",
"T"
] |
# CODE FESTIVAL 2016 予選 C: B – K個のケーキ / K Cakes
K, T = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
max_index = a.index(max(a))
print(max(a[max_index] - 1 - (K - a[max_index]), 0))
|
[
7,
15,
13,
15,
13,
12,
13,
29,
4,
13,
4,
18,
18,
13,
13,
13,
12,
13,
29,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
0,
13,
17,
0,
13,
18,
13,
17,
0,
13,
4,
13,
18,
13,
39,
17,
0,
13,
4,
13,
2,
2,
13,
17,
13,
17,
4,
13,
13,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] |
[
[
52,
51
],
[
99,
53
],
[
52,
54
],
[
57,
56
],
[
105,
58
],
[
56,
61
],
[
65,
64
],
[
68,
67
],
[
56,
69
],
[
73,
72
],
[
56,
76
],
[
81,
80
],
[
67,
85
],
[
72,
87
],
[
80,
91
],
[
102,
93
]
] |
[
"#!/usr/bin/env python3\nimport collections as cl\nimport sys\n\n\ndef II():\n return int(sys.stdin.readline())\n\n\ndef MI():\n return map(int, sys.stdin.readline().split())\n\n\ndef LI():\n return list(map(int, sys.stdin.readline().split()))\n\n\ndef main():\n K, T = MI()\n types = LI()\n\n types.sort(reverse=True)\n max_num = types[0]\n others_num = sum(types[1:])\n ans = max(max_num - 1 - others_num, 0)\n print(ans)\n\n\nmain()",
"import collections as cl",
"collections",
"import sys",
"sys",
"def II():\n return int(sys.stdin.readline())",
"II",
"return int(sys.stdin.readline())",
"int(sys.stdin.readline())",
"int",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"def MI():\n return map(int, sys.stdin.readline().split())",
"MI",
"return map(int, sys.stdin.readline().split())",
"map(int, sys.stdin.readline().split())",
"map",
"int",
"sys.stdin.readline().split()",
"sys.stdin.readline().split",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"split",
"def LI():\n return list(map(int, sys.stdin.readline().split()))",
"LI",
"return list(map(int, sys.stdin.readline().split()))",
"list(map(int, sys.stdin.readline().split()))",
"list",
"map(int, sys.stdin.readline().split())",
"map",
"int",
"sys.stdin.readline().split()",
"sys.stdin.readline().split",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"split",
"def main():\n K, T = MI()\n types = LI()\n\n types.sort(reverse=True)\n max_num = types[0]\n others_num = sum(types[1:])\n ans = max(max_num - 1 - others_num, 0)\n print(ans)",
"main",
"K, T = MI()",
"K",
"MI()",
"MI",
"T",
"types = LI()",
"types",
"LI()",
"LI",
"types.sort(reverse=True)",
"types.sort",
"types",
"sort",
"reverse=True",
"reverse",
"True",
"max_num = types[0]",
"max_num",
"types[0]",
"types",
"0",
"others_num = sum(types[1:])",
"others_num",
"sum(types[1:])",
"sum",
"types[1:]",
"types",
"1:",
"1",
"ans = max(max_num - 1 - others_num, 0)",
"ans",
"max(max_num - 1 - others_num, 0)",
"max",
"max_num - 1 - others_num",
"max_num - 1",
"max_num",
"1",
"others_num",
"0",
"print(ans)",
"print",
"ans",
"main()",
"main",
"def II():\n return int(sys.stdin.readline())",
"def II():\n return int(sys.stdin.readline())",
"II",
"def MI():\n return map(int, sys.stdin.readline().split())",
"def MI():\n return map(int, sys.stdin.readline().split())",
"MI",
"def main():\n K, T = MI()\n types = LI()\n\n types.sort(reverse=True)\n max_num = types[0]\n others_num = sum(types[1:])\n ans = max(max_num - 1 - others_num, 0)\n print(ans)",
"def main():\n K, T = MI()\n types = LI()\n\n types.sort(reverse=True)\n max_num = types[0]\n others_num = sum(types[1:])\n ans = max(max_num - 1 - others_num, 0)\n print(ans)",
"main",
"def LI():\n return list(map(int, sys.stdin.readline().split()))",
"def LI():\n return list(map(int, sys.stdin.readline().split()))",
"LI"
] |
#!/usr/bin/env python3
import collections as cl
import sys
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def main():
K, T = MI()
types = LI()
types.sort(reverse=True)
max_num = types[0]
others_num = sum(types[1:])
ans = max(max_num - 1 - others_num, 0)
print(ans)
main()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.