message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide tags and a correct Python 3 solution for this coding contest problem. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try to make a new task. Firstly we will use the fo...
instruction
0
28,619
14
57,238
Tags: greedy Correct Solution: ``` n = int(input()) l = [input().split() for i in range(n)] p = [int(x)-1 for x in input().split()] cur = "" poss = True for i in range(n): per = l[p[i]] if per[0] > cur: if per[1] > cur: cur = min(per[0],per[1]) else: cur = per[0] els...
output
1
28,619
14
57,239
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,620
14
57,240
Yes
output
1
28,620
14
57,241
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,621
14
57,242
Yes
output
1
28,621
14
57,243
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,622
14
57,244
Yes
output
1
28,622
14
57,245
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,623
14
57,246
Yes
output
1
28,623
14
57,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,624
14
57,248
No
output
1
28,624
14
57,249
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,625
14
57,250
No
output
1
28,625
14
57,251
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,626
14
57,252
No
output
1
28,626
14
57,253
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull. Let's try...
instruction
0
28,627
14
57,254
No
output
1
28,627
14
57,255
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,676
14
57,352
Tags: *special, constructive algorithms, implementation Correct Solution: ``` numbers = int(input()) line = input() dic = {} parts = line.split(" ") maxi=parts[0] for x in parts: if x in dic.keys(): dic[x]+=1 else: dic[x]=1 if dic[x]>dic[maxi]: maxi = x print(maxi) ```
output
1
28,676
14
57,353
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,677
14
57,354
Tags: *special, constructive algorithms, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) b = [[], []] maxl = -1 for i in range(len(a)): photo = a[i] if b[0].count(photo) == 0: b[0].append(photo) b[1].append(0) nom = b[0].index(photo) nom = b[...
output
1
28,677
14
57,355
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,678
14
57,356
Tags: *special, constructive algorithms, implementation Correct Solution: ``` n = int(input()) likes = list(map(int, input().split(' '))) max_likes = 0 max_likes_pid = -1 lc = {} for pid in likes: lc[pid] = lc.get(pid, 0) + 1 if lc[pid] > max_likes: max_likes = lc[pid] max_likes_pid = pid print(max_likes_pid) ...
output
1
28,678
14
57,357
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,679
14
57,358
Tags: *special, constructive algorithms, implementation Correct Solution: ``` n = int(input()) a = [0]*1000001 m = 0 l = list(map(int, input().split())) for i in range(n): a[l[i]] += 1 if a[l[i]] > m: m = a[l[i]] j = l[i] print(j) ```
output
1
28,679
14
57,359
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,680
14
57,360
Tags: *special, constructive algorithms, implementation Correct Solution: ``` n = int(input()) like = list(map(int , input().split())) id = 0 A = [0] * 1000005 for i in range(n) : A[like[i]] += 1 if A[like[i]] > A[id] : id = like[i] print(id) ```
output
1
28,680
14
57,361
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,681
14
57,362
Tags: *special, constructive algorithms, implementation Correct Solution: ``` likes_num = int(input()) likes = dict() #{photo_id: [total_likes, last_like_time]} time = 0 for i in input().split(): if i in likes: likes[i][0] += 1 likes[i][1] = time else: likes[i] = [1, time] time += 1...
output
1
28,681
14
57,363
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,682
14
57,364
Tags: *special, constructive algorithms, implementation Correct Solution: ``` # n, k = map(int, input().split()) n = int(input()) v = [int(i) for i in input().split()] mapa = {} ma = 0 res = -1 for i in v: if i not in mapa: mapa[i] = 0 mapa[i] += 1 if mapa[i] > ma: ma = mapa[i] re...
output
1
28,682
14
57,365
Provide tags and a correct Python 3 solution for this coding contest problem. After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: th...
instruction
0
28,683
14
57,366
Tags: *special, constructive algorithms, implementation Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) b = [0 for i in range(1000001)] m = 0 f = 0 for i in range(n): k = a[i] b[k] += 1 if b[k] > m: m = b[k] f = k print(f) ```
output
1
28,683
14
57,367
Provide tags and a correct Python 3 solution for this coding contest problem. Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) β€” who knows? Every one of them has an integer sequences...
instruction
0
28,708
14
57,416
Tags: binary search, data structures Correct Solution: ``` from bisect import bisect HISENTINEL = 10**9 + 1 LOSENTINEL = -HISENTINEL def main(): length = int(input()) a = [int(fld) for fld in input().strip().split()] b = [int(fld) for fld in input().strip().split()] print(countmaxminsubseq(a, b)) ...
output
1
28,708
14
57,417
Provide tags and a correct Python 3 solution for this coding contest problem. Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences. Input Same as the easy version, but the limits have changed:...
instruction
0
28,765
14
57,530
Tags: data structures, greedy Correct Solution: ``` import sys input = sys.stdin.readline from collections import deque, defaultdict from heapq import heappush, heappop n, k = map(int, input().split()) A = list(map(int, input().split())) dic = defaultdict(deque) for i, a in enumerate(A): dic[a].append(i) hp = [] # ...
output
1
28,765
14
57,531
Provide tags and a correct Python 3 solution for this coding contest problem. Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences. Input Same as the easy version, but the limits have changed:...
instruction
0
28,766
14
57,532
Tags: data structures, greedy Correct Solution: ``` import sys import heapq from collections import namedtuple Record = namedtuple('Record', ['index', 'book_id']) l1 = sys.stdin.readline() l2 = sys.stdin.readline() n, k = map(int, l1.split(' ')) books = list(map(int, l2.split(' '))) cost = 0 cache = set() prev = di...
output
1
28,766
14
57,533
Provide tags and a correct Python 3 solution for this coding contest problem. Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences. Input Same as the easy version, but the limits have changed:...
instruction
0
28,767
14
57,534
Tags: data structures, greedy Correct Solution: ``` # https://codeforces.com/problemset/problem/802/B import heapq n, k = map(int, input().split()) a = list(map(int, input().split())) d = {} pos = {} Q = [] cnt = 0 for i, x in enumerate(a): if x not in pos: pos[x] = [] pos[x].append(i...
output
1
28,767
14
57,535
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences. Input Same as...
instruction
0
28,771
14
57,542
No
output
1
28,771
14
57,543
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Why I have to finish so many assignments??? Jamie is getting very busy with his school life. He starts to forget the assignments that he has to do. He decided to write the things down on a to-d...
instruction
0
28,792
14
57,584
No
output
1
28,792
14
57,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Why I have to finish so many assignments??? Jamie is getting very busy with his school life. He starts to forget the assignments that he has to do. He decided to write the things down on a to-d...
instruction
0
28,793
14
57,586
No
output
1
28,793
14
57,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Why I have to finish so many assignments??? Jamie is getting very busy with his school life. He starts to forget the assignments that he has to do. He decided to write the things down on a to-d...
instruction
0
28,794
14
57,588
No
output
1
28,794
14
57,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Why I have to finish so many assignments??? Jamie is getting very busy with his school life. He starts to forget the assignments that he has to do. He decided to write the things down on a to-d...
instruction
0
28,795
14
57,590
No
output
1
28,795
14
57,591
Provide a correct Python 3 solution for this coding contest problem. Problem Statement We have planted $N$ flower seeds, all of which come into different flowers. We want to make all the flowers come out together. Each plant has a value called vitality, which is initially zero. Watering and spreading fertilizers cau...
instruction
0
29,059
14
58,118
"Correct Solution: ``` import sys def main(): readline = sys.stdin.readline write = sys.stdout.write def gcd(m, n): while n: m, n = n, m % n return m def init(p, q=1): g = gcd(p, q) return p//g, q//g def add(A, B): pa, qa = A pb, qb = B ...
output
1
29,059
14
58,119
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,135
14
58,270
Tags: implementation, math Correct Solution: ``` q=int(input()) for i in range(q): ans=[] q=True n,x,y,d=map(int,input().split()) if abs(x-y)%d==0: ans.append(abs(x-y)//d) q=False if (y-1)%d==0: ans.append((y-1)//d+int((x-1)/d+0.99999999999999)) q=False if (n-y)%d...
output
1
29,135
14
58,271
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,136
14
58,272
Tags: implementation, math Correct Solution: ``` def retarray(): return list(map(int, input().split())) t = int(input()) for _ in range(t): n, x, y, d = retarray() res = -1 if abs(x-y) % d == 0 : res = abs(x-y)//d else: if (y - 1) % d == 0 : res = x//d + (y-1)//d + (1 if x%d else 0) if (n - y) % d =...
output
1
29,136
14
58,273
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,137
14
58,274
Tags: implementation, math Correct Solution: ``` def do(): import math n,x,y,d = map(int, input().split()) x-=1 y-=1 n-=1 res = 10 ** 18 if x==y: print(0) return if (y-x) % d == 0: print(abs((y-x)) // d) return cnt = 0 cnt = math.ceil(x / d) i...
output
1
29,137
14
58,275
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,138
14
58,276
Tags: implementation, math Correct Solution: ``` from math import ceil n = int(input()) for i in range(n): n, x, y, d = list(map(int, input().split())) max_num = 10 ** 10 if abs(y - x) % d == 0: max_num = abs(y - x) // d if y % d == 1: a = ceil(x / d) + (y - 1) // d if a < max_n...
output
1
29,138
14
58,277
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,139
14
58,278
Tags: implementation, math Correct Solution: ``` m=int(input()) for i in range(0,m): l = 0 n,x,y,d=map(int,input().split()) a = 7289567892756268 b = 11111111111111111 c = 1000000000000000 w = 0 if x > y: w = (x - y) else: w = (y - x) if w % d == 0: a = w // d...
output
1
29,139
14
58,279
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,140
14
58,280
Tags: implementation, math Correct Solution: ``` t=int(input()) for i in range(0,t): n,x,y,d=map(int,input().split()) if(abs(y-x)%d==0): print(abs(y-x)//d) else: if((y-1)%d==0 or (n-y)%d==0): if((y-1)%d==0 and (n-y)%d==0): print(min(((x-1)//d+bool((x-1)%d)+(y-1)//...
output
1
29,140
14
58,281
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,141
14
58,282
Tags: implementation, math Correct Solution: ``` import math def solve(n,x,y,d): vals = [] if (y-x)%d==0: vals.append(abs(y-x)//d) if y%d==1: # down moves = math.ceil((x-1)/d) # up moves += (y-1)//d vals.append(moves) if (n-y)%d==0: # up moves = math.ceil((n-x)/d) # down moves += (n-y)//d va...
output
1
29,141
14
58,283
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to ...
instruction
0
29,142
14
58,284
Tags: implementation, math Correct Solution: ``` from math import ceil n = int(input()) for i in range(n): n,x,y,d = map(int,input().split()) ans1 = ans2 = 10**18 dist = abs(x-y) if dist%d==0: print(dist//d) elif (y-1)%d and (n-y)%d: print(-1) else: if (y-1)%d==0: ans1 = (y-1)//d + (x-1)//d + (1 if (...
output
1
29,142
14
58,285
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,143
14
58,286
Yes
output
1
29,143
14
58,287
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,144
14
58,288
Yes
output
1
29,144
14
58,289
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,145
14
58,290
Yes
output
1
29,145
14
58,291
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,146
14
58,292
Yes
output
1
29,146
14
58,293
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,147
14
58,294
No
output
1
29,147
14
58,295
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,148
14
58,296
No
output
1
29,148
14
58,297
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,149
14
58,298
No
output
1
29,149
14
58,299
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There ar...
instruction
0
29,150
14
58,300
No
output
1
29,150
14
58,301
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Getting so far in this contest is not an easy feat. By solving all the previous problems, you have impressed the gods greatly. Thus, they decided to spare you the story for this problem and gran...
instruction
0
29,348
14
58,696
No
output
1
29,348
14
58,697
Provide tags and a correct Python 3 solution for this coding contest problem. Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President ...
instruction
0
29,426
14
58,852
Tags: data structures, dp, implementation Correct Solution: ``` def readInt(): return int(input()) def readIntList(): l = input() return list(map(int, l.split(" "))) def build(tree, elem, v, l, r): if(l == r): tree[v] = elem[l] else: m = (l + r) // 2 build(tree, elem, v * 2...
output
1
29,426
14
58,853
Provide tags and a correct Python 3 solution for this coding contest problem. Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President ...
instruction
0
29,427
14
58,854
Tags: data structures, dp, implementation Correct Solution: ``` from sys import maxsize, stdout, stdin,stderr mod = int(1e9+7) import sys def I(): return int(stdin.readline()) def lint(): return [int(x) for x in stdin.readline().split()] def S(): return list(map(str,input().strip())) def grid(r, c): return [lint() for ...
output
1
29,427
14
58,855
Provide tags and a correct Python 3 solution for this coding contest problem. Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President ...
instruction
0
29,428
14
58,856
Tags: data structures, dp, implementation Correct Solution: ``` def main(): from itertools import accumulate n, k = map(int, input().split()) l = [0] l.extend(accumulate(map(int, input().split()))) ma = mab = 0 for i, x, y, z in zip(range(1, n), l, l[k:], l[k * 2:]): if ma < y - x: ...
output
1
29,428
14
58,857
Provide tags and a correct Python 3 solution for this coding contest problem. Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President ...
instruction
0
29,429
14
58,858
Tags: data structures, dp, implementation Correct Solution: ``` import sys try: sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') except: pass n, k = map(int, input().split()) a = list(map(int, input().split())) dp = [0]*(n-k+1) sum_ = sum(a[:k]) dp[0] = sum_ for i in range(k, n): ...
output
1
29,429
14
58,859
Provide tags and a correct Python 3 solution for this coding contest problem. Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President ...
instruction
0
29,430
14
58,860
Tags: data structures, dp, implementation Correct Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split()))+[0] forward = [0]*n backward = [0]*n sm = sum(a[:k]) mx = sm for i in range(1+n-2*k): mx = max(mx, sm) forward[i] = mx sm -= a[i] sm += a[i+k] sm = sum(a[n-k:]) ind...
output
1
29,430
14
58,861
Provide tags and a correct Python 3 solution for this coding contest problem. Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President ...
instruction
0
29,431
14
58,862
Tags: data structures, dp, implementation Correct Solution: ``` import math import time from collections import defaultdict,deque,Counter from sys import stdin,stdout from bisect import bisect_left,bisect_right import sys from heapq import heapify, heappush, heappop n,k=map(int,stdin.readline().split()) a=list(map(int...
output
1
29,431
14
58,863