Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
1.02k
43.5k
conversation_id
int64
853
107k
embedding
sequence
cluster
int64
24
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) k,m,s=n-1,0,0 while True: if k<0 and a[k]!=1: print(max(m,s)) exit() if a[k]==1: s+=1 else: m=max(m,s) s=0 k-=1 ```
853
[ 0.5205078125, 0.446533203125, 0.003475189208984375, 0.12127685546875, -0.254638671875, -0.1591796875, -0.4560546875, -0.11724853515625, 0.0557861328125, 0.7763671875, 0.7119140625, -0.0130767822265625, 0.429931640625, -0.79833984375, -0.43359375, -0.1834716796875, -0.6669921875, -0...
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) * 2 cnt = 0 answ = 0 for i in range(2 * n): if a[i]: cnt += 1 else: answ = max(answ, cnt) cnt = 0 print(answ) ```
854
[ 0.486083984375, 0.4072265625, 0.01346588134765625, 0.11279296875, -0.2308349609375, -0.1646728515625, -0.450927734375, -0.1387939453125, 0.07305908203125, 0.75439453125, 0.71142578125, 0.0017452239990234375, 0.41162109375, -0.80859375, -0.4404296875, -0.174072265625, -0.66162109375, ...
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` num=int(input()) a=list(map(int, input().split())) b=[] a+=a #Same list is added to eachother bcz he can take consecutive rests i.e when a[n-1]==1 and a[0]==1 that is he can take rest before work and at end so his rest count increases count=0 i=0 while i<2*num-1: count=0 if a[i]==1: count+=1 for j in range(i+1, 2*num): #To find consecutive resting 1s if a[j]==0: break else: count+=1 i=j else: i+=1 b+=[count] print(max(b)) ```
855
[ 0.54736328125, 0.408447265625, 0.026702880859375, 0.10919189453125, -0.235595703125, -0.175537109375, -0.4658203125, -0.1298828125, 0.0770263671875, 0.75732421875, 0.7265625, -0.01397705078125, 0.43212890625, -0.78662109375, -0.436767578125, -0.16650390625, -0.67626953125, -0.78857...
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` hours = int(input().strip()) schedule = input().strip().replace(' ', '') schedule = ''.join([schedule, schedule]) schedule = schedule.split('0') print(len(sorted(schedule, key=len)[-1])) ```
856
[ 0.5380859375, 0.426513671875, -0.0160369873046875, 0.11956787109375, -0.2476806640625, -0.1358642578125, -0.46875, -0.1005859375, 0.061065673828125, 0.72509765625, 0.71875, -0.03387451171875, 0.45068359375, -0.80908203125, -0.440673828125, -0.1495361328125, -0.6787109375, -0.713378...
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` f = int(input()) lis = list(map(int, input().split())) * 2 maxi = 0 cont = 0 for i in lis: if(i == 1): cont += 1 if (cont > maxi): maxi = cont else: cont = 0 print(maxi) ```
857
[ 0.5, 0.36572265625, 0.1031494140625, 0.12481689453125, -0.2208251953125, -0.205078125, -0.459716796875, -0.1619873046875, 0.0462646484375, 0.72412109375, 0.66845703125, 0.0227508544921875, 0.479736328125, -0.80859375, -0.41943359375, -0.1905517578125, -0.67822265625, -0.6923828125,...
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` from itertools import groupby print(max([0] + [sum(1 for _ in g) for k, g in groupby(list(map(int, (input(), input())[1].split(' '))) * 2) if k == 1])) ```
858
[ 0.5078125, 0.36865234375, -0.02166748046875, 0.1346435546875, -0.235595703125, -0.1722412109375, -0.464599609375, -0.1463623046875, 0.11065673828125, 0.7392578125, 0.6826171875, -0.02490234375, 0.443603515625, -0.771484375, -0.427978515625, -0.15380859375, -0.69384765625, -0.762207...
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` n = int(input()) a = list(map(lambda w: len(w), (''.join(input().split())).split('0'))) ans = max(a) if len(a) > 1: ans = max(ans, a[0]+a[-1]) print(ans) ```
859
[ 0.5029296875, 0.410400390625, 0.0216217041015625, 0.12841796875, -0.2423095703125, -0.14892578125, -0.457275390625, -0.12890625, 0.06842041015625, 0.73876953125, 0.6943359375, -0.02484130859375, 0.42041015625, -0.7666015625, -0.431640625, -0.1634521484375, -0.6767578125, -0.7319335...
24
Provide tags and a correct Python 3 solution for this coding contest problem. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Tags: implementation Correct Solution: ``` n = int(input()) b = input() b = b+" "+b b = b.split("0") b = [len(x.split()) for x in b] print(max(b)) ```
860
[ 0.51220703125, 0.411865234375, -0.0022563934326171875, 0.147216796875, -0.25732421875, -0.1285400390625, -0.4287109375, -0.1309814453125, 0.060760498046875, 0.73681640625, 0.71875, -0.02288818359375, 0.42822265625, -0.80859375, -0.422119140625, -0.1890869140625, -0.6669921875, -0.7...
24
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Submitted Solution: ``` n=int(input()) d=input().split() f=0 rest=[0] for i in range(n-1,-1*n,-1): if d[i]=='1': f+=1 rest.append(f) else: f=0 print(max(rest)) ``` Yes
861
[ 0.53076171875, 0.40869140625, 0.037506103515625, 0.1685791015625, -0.344482421875, -0.0435791015625, -0.4091796875, 0.029815673828125, 0.06353759765625, 0.6728515625, 0.69189453125, -0.021331787109375, 0.33837890625, -0.76220703125, -0.404296875, -0.1710205078125, -0.58544921875, -...
24
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Submitted Solution: ``` n = int(input()) a = list(map(int, input().split())) contigous = 0 max_cont = 0 from_0 = False for i in range(n): if a[i]: contigous += 1 else: max_cont = max(max_cont, contigous) contigous = 0 max_cont = max(max_cont, contigous) if a[0] and a[-1]: contigous = 0 for i in range(n): if a[i]: contigous += 1 else: break for j in range(n-1, -1, -1): if a[j]: contigous += 1 else: break max_cont = max(max_cont, contigous) print(max_cont) ``` Yes
862
[ 0.51171875, 0.407958984375, 0.041046142578125, 0.1767578125, -0.34521484375, -0.043914794921875, -0.398193359375, 0.047576904296875, 0.08038330078125, 0.67578125, 0.650390625, -0.027099609375, 0.35986328125, -0.7919921875, -0.406005859375, -0.19287109375, -0.60205078125, -0.7744140...
24
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day. Days go one after another endlessly and Polycarp uses the same schedule for each day. What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day. Input The first line contains n (1 ≀ n ≀ 2β‹…10^5) β€” number of hours per day. The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i. Output Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day. Examples Input 5 1 0 1 0 1 Output 2 Input 6 0 1 0 1 1 0 Output 2 Input 7 1 0 1 1 1 0 1 Output 3 Input 3 0 0 0 Output 0 Note In the first example, the maximal rest starts in last hour and goes to the first hour of the next day. In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour. In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour. In the fourth example, Polycarp has no rest at all. Submitted Solution: ``` n = int(input()) s = input().split(' ') mas = [] k = 0 for i in range(n): if s[i] == '0': mas.append(k) mas.append(0) k = 0 else: k += 1 mas.append(k) mas.append(mas[0]+mas[-1]) print(max(mas)) ``` Yes
863
[ 0.5283203125, 0.411376953125, 0.05072021484375, 0.140869140625, -0.301025390625, -0.038726806640625, -0.446044921875, -0.01189422607421875, 0.061248779296875, 0.68505859375, 0.72119140625, -0.007724761962890625, 0.30859375, -0.78515625, -0.408935546875, -0.168701171875, -0.55078125, ...
24
End of preview. Expand in Data Studio

Dataset Card for "python3-standardized_cluster_24"

More Information needed

Downloads last month
8