message
stringlengths
2
48.6k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
318
108k
cluster
float64
8
8
__index_level_0__
int64
636
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The ...
instruction
0
105,735
8
211,470
Tags: brute force, implementation Correct Solution: ``` input() heights = list(map(int, input().split())) max_cnt = 0 for i in range(0, len(heights)): cur_h = heights[i] cnt = 1 if i > 0: for j in range(i - 1, -1, -1): if heights[j] <= cur_h: cnt += 1 cu...
output
1
105,735
8
211,471
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The ...
instruction
0
105,736
8
211,472
Tags: brute force, implementation Correct Solution: ``` n = int(input()) height = list(map(int,input().split())) ans = 1 for i in range(n): count = 1 for j in range(i,0,-1): if (height[j-1] <= height[j]): count += 1 else: break for j in range(i,n-1): if (heig...
output
1
105,736
8
211,473
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The ...
instruction
0
105,737
8
211,474
Tags: brute force, implementation Correct Solution: ``` n = int(input()) lst = list(map(int,input().split())) mp = {} for i in range(n): lef = i-1 rig = i+1 num = 1 while lef >= 0: if lst[lef] <= lst[lef+1]: num+=1 lef-=1 else: break while rig < n:...
output
1
105,737
8
211,475
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,738
8
211,476
Yes
output
1
105,738
8
211,477
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,739
8
211,478
Yes
output
1
105,739
8
211,479
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,740
8
211,480
Yes
output
1
105,740
8
211,481
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,741
8
211,482
Yes
output
1
105,741
8
211,483
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,742
8
211,484
No
output
1
105,742
8
211,485
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,743
8
211,486
No
output
1
105,743
8
211,487
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,744
8
211,488
No
output
1
105,744
8
211,489
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangl...
instruction
0
105,745
8
211,490
No
output
1
105,745
8
211,491
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n × m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom starting from 1) and m columns (numbered from the left...
instruction
0
105,747
8
211,494
Tags: constructive algorithms Correct Solution: ``` corr = lambda x, y: 1 <= x <= n and 1 <= y <= m T = int(input()) a = [] while T: a.append(T % 6) T //= 6 L = len(a) n = m = L * 2 + 2 ans = [(1, 2, 2, 2), (2, 1, 2, 2)] f = [[1] * 9 for i in range(7)] f[1][2] = f[2][2] = f[2][6] = f[3][5] = 0 f[4][5] = f[4][6...
output
1
105,747
8
211,495
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n × m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom startin...
instruction
0
105,748
8
211,496
No
output
1
105,748
8
211,497
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n × m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom startin...
instruction
0
105,749
8
211,498
No
output
1
105,749
8
211,499
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n × m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom startin...
instruction
0
105,750
8
211,500
No
output
1
105,750
8
211,501
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n × m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom startin...
instruction
0
105,751
8
211,502
No
output
1
105,751
8
211,503
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building! There are n walruses taking part in the contest. Each walrus is given a unique number from 1 to n. A...
instruction
0
105,846
8
211,692
No
output
1
105,846
8
211,693
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building! There are n walruses taking part in the contest. Each walrus is given a unique number from 1 to n. A...
instruction
0
105,847
8
211,694
No
output
1
105,847
8
211,695
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building! There are n walruses taking part in the contest. Each walrus is given a unique number from 1 to n. A...
instruction
0
105,848
8
211,696
No
output
1
105,848
8
211,697
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building! There are n walruses taking part in the contest. Each walrus is given a unique number from 1 to n. A...
instruction
0
105,849
8
211,698
No
output
1
105,849
8
211,699
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,850
8
211,700
Tags: binary search, data structures Correct Solution: ``` import itertools import operator from bisect import bisect def main(): N = int(input()) V = tuple(map(int, input().split())) T = tuple(map(int, input().split())) templ = [0] + list(itertools.accumulate(T, operator.add)) M = [0] * (N + 2) ...
output
1
105,850
8
211,701
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,851
8
211,702
Tags: binary search, data structures Correct Solution: ``` import math,sys,bisect,heapq from collections import defaultdict,Counter,deque from itertools import groupby,accumulate #sys.setrecursionlimit(200000000) int1 = lambda x: int(x) - 1 input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__ ilele = la...
output
1
105,851
8
211,703
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,852
8
211,704
Tags: binary search, data structures Correct Solution: ``` import heapq heap = [] n = int(input()) V = list(map(int, input().split())) T = list(map(int, input().split())) tmp = 0 for i in range(n): ans = 0 heapq.heappush(heap, tmp+V[i]) while len(heap) and heap[0]<=tmp+T[i]: ans += heapq.heappop(hea...
output
1
105,852
8
211,705
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,853
8
211,706
Tags: binary search, data structures Correct Solution: ``` n = int(input()) import heapq as hq heap = [] # total = 0 temp = 0 ans = [-1 for _ in range(n)] volumes = [int(x) for x in input().split()] temps = [int(x) for x in input().split()] # prevtemp = 0 for i in range(n): # hq.heappush(heap, volumes[i]) ...
output
1
105,853
8
211,707
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,854
8
211,708
Tags: binary search, data structures Correct Solution: ``` # import sys # from io import StringIO # # sys.stdin = StringIO(open(__file__.replace('.py', '.in')).read()) def bin_search_base(arr, val, base_index): lo = base_index hi = len(arr) - 1 while lo < hi: if hi - lo == 1 and arr[lo] - arr[bas...
output
1
105,854
8
211,709
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,855
8
211,710
Tags: binary search, data structures Correct Solution: ``` import heapq n = int(input()) V = list(map(int, input().split())) T = list(map(int, input().split())) a = [] ans = [] tmp = 0 for i in range(0, n): heapq.heappush(a, tmp + V[i]) tmpAns = 0 while(len(a) and a[0] <= tmp + T[i]): tmpAns +=...
output
1
105,855
8
211,711
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,856
8
211,712
Tags: binary search, data structures Correct Solution: ``` n = int(input()) vs = [int(x) for x in input().split()] ts = [int(x) for x in input().split()] from heapq import * q = [] heapify(q) sts = ts[:] for i in range(1, n): sts[i] += sts[i-1] res = [] for i in range(n): v = vs[i] t = ts[i] v...
output
1
105,856
8
211,713
Provide tags and a correct Python 3 solution for this coding contest problem. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will mak...
instruction
0
105,857
8
211,714
Tags: binary search, data structures Correct Solution: ``` from itertools import accumulate from bisect import bisect n = int(input()) vs = list(map(int, input().split())) ts = list(map(int, input().split())) fully_melt = [0] * n result = [0] * n dprint = lambda *args: None #dprint = print ts_accum = list(accumulat...
output
1
105,857
8
211,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,858
8
211,716
Yes
output
1
105,858
8
211,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,859
8
211,718
Yes
output
1
105,859
8
211,719
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,860
8
211,720
Yes
output
1
105,860
8
211,721
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,861
8
211,722
Yes
output
1
105,861
8
211,723
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,862
8
211,724
No
output
1
105,862
8
211,725
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,863
8
211,726
No
output
1
105,863
8
211,727
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,864
8
211,728
No
output
1
105,864
8
211,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some...
instruction
0
105,865
8
211,730
No
output
1
105,865
8
211,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,452
8
212,904
Yes
output
1
106,452
8
212,905
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,453
8
212,906
Yes
output
1
106,453
8
212,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,454
8
212,908
Yes
output
1
106,454
8
212,909
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,455
8
212,910
Yes
output
1
106,455
8
212,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,456
8
212,912
No
output
1
106,456
8
212,913
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,457
8
212,914
No
output
1
106,457
8
212,915
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,458
8
212,916
No
output
1
106,458
8
212,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets. Overall Vasya has got m devices and k electr...
instruction
0
106,459
8
212,918
No
output
1
106,459
8
212,919
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,476
8
212,952
Tags: brute force Correct Solution: ``` n,m=map(int,input().split()) l=sorted(list(map(int,input().split()))) a=0 for i in range(n-1): for j in range(i+1,n): if(l[j]-l[i]<=m): a+=1 else: break print(a*2) ```
output
1
106,476
8
212,953
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,477
8
212,954
Tags: brute force Correct Solution: ``` n, d = map(int, input().split()) c = list(map(int, input().split())) counter = 0 for i in range(len(c)): for j in range(i+1, len(c)): if abs(c[i] - c[j]) <= d: counter += 2 print(counter) ```
output
1
106,477
8
212,955
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,478
8
212,956
Tags: brute force Correct Solution: ``` x,y=[ int(a) for a in input().split()] l=[int(b) for b in input().split()] count=0 k=len(l)-1 for i in range(len(l)-1): for j in range(i+1,len(l)): if abs(l[j]-l[i])<=y: count=count+1 print(count*2) ```
output
1
106,478
8
212,957
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,479
8
212,958
Tags: brute force Correct Solution: ``` import sys def solution(n, d, a_arr): count = 0 for i in range(len(a_arr)): for j in range(len(a_arr)): if i == j: continue diff = abs(a_arr[i]-a_arr[j]) #print(diff, d, count) if diff <= d: ...
output
1
106,479
8
212,959
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,480
8
212,960
Tags: brute force Correct Solution: ``` (n, d) = map(int, input().split()) a = list(map(int, input().split())) a.sort() result = 0 for i in range(len(a) - 1): for j in range(i+1, len(a)): if abs(a[i] - a[j]) <= d: result += 2 print(result) ```
output
1
106,480
8
212,961
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,481
8
212,962
Tags: brute force Correct Solution: ``` n, d = [int(s) for s in input().split(' ')] a = [int(s) for s in input().split(' ')] a.sort() pairs = 0 for i in range(n - 1): for j in range(i + 1, n): if a[j] - a[i] <= d: pairs += 2 else: break print(pairs) ```
output
1
106,481
8
212,963