message
stringlengths
2
39.6k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
450
109k
cluster
float64
2
2
__index_level_0__
int64
900
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,748
2
119,496
Tags: constructive algorithms, math, sortings Correct Solution: ``` number = int(input()) gregory = list(map(int, input().split())) andrew = list(map(int, input().split())) glen, alen = len(gregory), len(andrew) def canSync(g, a): gdiffs, adiffs = [], [] for i in range(1, len(g)): gdiffs.append(g[i] - ...
output
1
59,748
2
119,497
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,749
2
119,498
Tags: constructive algorithms, math, sortings Correct Solution: ``` def problemaI(): n = int(input()) c = [int(x) for x in input().split()] t = [int(x) for x in input().split()] c_p = sorted([c[i+1]-c[i] for i in range(n-1)]) t_p = sorted([t[i+1]-t[i] for i in range(n-1)]) if(c_p!=t_p): print("No") return...
output
1
59,749
2
119,499
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,750
2
119,500
Tags: constructive algorithms, math, sortings Correct Solution: ``` import math try: while True: n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) f=a[0]==b[0] a=sorted([a[i+1]-a[i] for i in range(n-1)]) b=sorted([b[i+1]-b[i] for i in range(n-1)]) print('YES' if f and a==b ...
output
1
59,750
2
119,501
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,751
2
119,502
Tags: constructive algorithms, math, sortings Correct Solution: ``` input() c = list(map(int, input().split())) t = list(map(int, input().split())) cd = [] td = [] for i in range(len(c) - 1): cd.append(c[i+1] - c[i]) for i in range(len(t) -1 ): td.append(t[i+1] - t[i]) cd.sort() td.sort() if c[0] == t[0] a...
output
1
59,751
2
119,503
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,752
2
119,504
Tags: constructive algorithms, math, sortings Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) def dif(x): c = [] for i in range(n-1): c.append(x[i+1] - x[i]) return c if list(sorted(dif(a))) == list(sorted(dif(b))) and a[0] == b[0] and a[n-1] == b[n-...
output
1
59,752
2
119,505
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,753
2
119,506
Tags: constructive algorithms, math, sortings Correct Solution: ``` # -*- coding: utf-8 -*- # @Date : 2019-02-08 08:18:25 # @Author : raj lath (oorja.halt@gmail.com) # @Link : link # @Version : 1.0.0 from sys import stdin max_val=int(10e12) min_val=int(-10e12) def read_int() : return int(stdin.readline()...
output
1
59,753
2
119,507
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,754
2
119,508
Tags: constructive algorithms, math, sortings Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=sorted([a[i+1]-a[i] for i in range(n-1)]) d=sorted([b[i+1]-b[i] for i in range(n-1)]) print('YNEOS'[a[0]!=b[0] or c!=d::2]) ```
output
1
59,754
2
119,509
Provide tags and a correct Python 3 solution for this coding contest problem. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n - 1), and after that s...
instruction
0
59,755
2
119,510
Tags: constructive algorithms, math, sortings Correct Solution: ``` n = int(input()) c = list(map(int, input().split())) t = list(map(int, input().split())) c_diffs = [c[i] - c[i - 1] for i in range(1, n)] t_diffs = [t[i] - t[i - 1] for i in range(1, n)] print('Yes' if c[0] == t[0] and c[-1] == t[-1] and sorted(c_dif...
output
1
59,755
2
119,511
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,756
2
119,512
Yes
output
1
59,756
2
119,513
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,757
2
119,514
Yes
output
1
59,757
2
119,515
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,758
2
119,516
Yes
output
1
59,758
2
119,517
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,759
2
119,518
Yes
output
1
59,759
2
119,519
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,760
2
119,520
No
output
1
59,760
2
119,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,761
2
119,522
No
output
1
59,761
2
119,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,762
2
119,524
No
output
1
59,762
2
119,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with ...
instruction
0
59,763
2
119,526
No
output
1
59,763
2
119,527
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,300
2
120,600
Tags: brute force, implementation Correct Solution: ``` R=range S=str.split I=input L=S('Anka Chapay Cleo Troll Dracul Snowy Hexadecimal') h={} for i in R(7):h[L[i]]=i d=[[]for i in R(9)] for z in '0'*int(I()):a,_,b=S(I());d[h[a]]+=[h[b]] a,b,c=map(int,S(I())) o=[10**9,0] def C(q,w,e,n): if n==7: if not(q a...
output
1
60,300
2
120,601
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,301
2
120,602
Tags: brute force, implementation Correct Solution: ``` heroes = ['Anka', 'Chapay', 'Cleo', 'Troll', 'Dracul', 'Snowy', 'Hexadecimal'] num_heroes = len(heroes) likes = [ [ False for j in range(num_heroes) ] for i in range(num_heroes) ] n = int(input()) for i in range(n): u, _, v = input().split() likes[heroes.i...
output
1
60,301
2
120,603
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,302
2
120,604
Tags: brute force, implementation Correct Solution: ``` import math import itertools if __name__ == '__main__': N = int(input()) likes = [input() for i in range(N)] likes = [line.split() for line in likes] likes = [(words[0], words[2]) for words in likes] a, b, c = (float(val) for val in input().sp...
output
1
60,302
2
120,605
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,303
2
120,606
Tags: brute force, implementation Correct Solution: ``` from itertools import combinations def main(): heroes = ("Anka", "Chapay", "Cleo", "Troll", "Dracul", "Snowy", "Hexadecimal") sympaty = [[False] * 7 for _ in range(7)] for _ in range(int(input())): a, _, b = input().split() sympaty[he...
output
1
60,303
2
120,607
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,304
2
120,608
Tags: brute force, implementation Correct Solution: ``` from itertools import * p = {'An': 0, 'Ch': 1, 'Cl': 2, 'Tr': 3, 'Dr': 4, 'Sn': 5, 'He': 6} def f(): u, l, v = input().split() return p[u[:2]], p[v[:2]] s = [f() for k in range(int(input()))] a, b, c = map(int, input().split()) d = l = 9e9 for i in rang...
output
1
60,304
2
120,609
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,305
2
120,610
Tags: brute force, implementation Correct Solution: ``` names = ['Anka', 'Chapay', 'Cleo', 'Troll', 'Dracul', 'Snowy', \ 'Hexadecimal'] minDif = (10 ** 1000, 1) totLikes = 0 def less(a, b): # a < b return a[0] * b[1] < a[1] * b[0] def eq(a, b): return a[0] * b[1] == a[1] * b[0] def rec(cur, grou...
output
1
60,305
2
120,611
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,306
2
120,612
Tags: brute force, implementation Correct Solution: ``` minn=[10**10] maxx=[0] A=[] B=[] C=[] N=['Anka','Chapay','Cleo','Troll','Dracul','Snowy','Hexadecimal'] k={} T=[0]*7 for i in range(7): k[N[i]]=i C=[] for i in range(7): C.append([0]*7) def Solve(i): if(i==7): a=[] b=[] c=[] ...
output
1
60,306
2
120,613
Provide tags and a correct Python 3 solution for this coding contest problem. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven b...
instruction
0
60,307
2
120,614
Tags: brute force, implementation Correct Solution: ``` from itertools import product, permutations, combinations n = int(input()) names = {} nex = 0 mama = 128 liking = [0]*mama likes = [[0]*7 for _ in range(7)] def getName(name): global nex if name in names: return names[name] names[name] = nex ...
output
1
60,307
2
120,615
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,308
2
120,616
Yes
output
1
60,308
2
120,617
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,309
2
120,618
Yes
output
1
60,309
2
120,619
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,310
2
120,620
Yes
output
1
60,310
2
120,621
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,311
2
120,622
Yes
output
1
60,311
2
120,623
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,312
2
120,624
No
output
1
60,312
2
120,625
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,313
2
120,626
No
output
1
60,313
2
120,627
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,314
2
120,628
No
output
1
60,314
2
120,629
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of d...
instruction
0
60,315
2
120,630
No
output
1
60,315
2
120,631
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Harry, upon inquiring Helena Ravenclaw's ghost, came to know that she told Tom Riddle or You-know-who about Rowena Ravenclaw's diadem and that he stole it from her. Harry thought that Riddle w...
instruction
0
60,332
2
120,664
No
output
1
60,332
2
120,665
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Harry, upon inquiring Helena Ravenclaw's ghost, came to know that she told Tom Riddle or You-know-who about Rowena Ravenclaw's diadem and that he stole it from her. Harry thought that Riddle w...
instruction
0
60,333
2
120,666
No
output
1
60,333
2
120,667
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Harry, upon inquiring Helena Ravenclaw's ghost, came to know that she told Tom Riddle or You-know-who about Rowena Ravenclaw's diadem and that he stole it from her. Harry thought that Riddle w...
instruction
0
60,334
2
120,668
No
output
1
60,334
2
120,669
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Harry, upon inquiring Helena Ravenclaw's ghost, came to know that she told Tom Riddle or You-know-who about Rowena Ravenclaw's diadem and that he stole it from her. Harry thought that Riddle w...
instruction
0
60,335
2
120,670
No
output
1
60,335
2
120,671
Provide tags and a correct Python 3 solution for this coding contest problem. Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connec...
instruction
0
60,992
2
121,984
Tags: dfs and similar, divide and conquer, dp, trees Correct Solution: ``` from collections import defaultdict import sys input=sys.stdin.readline class graph: def __init__(self,n,mark): self.d=defaultdict(list) self.n=n self.mark=mark def add(self,s,d): self.d[s].appen...
output
1
60,992
2
121,985
Provide tags and a correct Python 3 solution for this coding contest problem. Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connec...
instruction
0
60,993
2
121,986
Tags: dfs and similar, divide and conquer, dp, trees Correct Solution: ``` import heapq def dfs(graph, start): n = len(graph) dist = [-0 for i in range(n + 1)] visited = [False for i in range(n + 1)] visited[start] = True stack = [] dist[start] = 0 heapq.heappush(stack, start) while ...
output
1
60,993
2
121,987
Provide tags and a correct Python 3 solution for this coding contest problem. Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connec...
instruction
0
60,994
2
121,988
Tags: dfs and similar, divide and conquer, dp, trees Correct Solution: ``` import collections class Graph: def __init__(self, n, dir): self.node_cnt = n self.__directed = dir self.__adjList = [] for i in range(n): self.__adjList.append([]) def addEdge(self, u, v): self.__adjList[u].append(v) if not self...
output
1
60,994
2
121,989
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped ...
instruction
0
60,995
2
121,990
No
output
1
60,995
2
121,991
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped ...
instruction
0
60,996
2
121,992
No
output
1
60,996
2
121,993
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped ...
instruction
0
60,997
2
121,994
No
output
1
60,997
2
121,995
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped ...
instruction
0
60,998
2
121,996
No
output
1
60,998
2
121,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony. <image> A sequence of positive integers bi is harmony if and only if for every two ...
instruction
0
61,047
2
122,094
No
output
1
61,047
2
122,095
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony. <image> A sequence of positive integers bi is harmony if and only if for every two ...
instruction
0
61,048
2
122,096
No
output
1
61,048
2
122,097
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony. <image> A sequence of positive integers bi is harmony if and only if for every two ...
instruction
0
61,049
2
122,098
No
output
1
61,049
2
122,099
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony. <image> A sequence of positive integers bi is harmony if and only if for every two ...
instruction
0
61,050
2
122,100
No
output
1
61,050
2
122,101
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a computer game. In this game, you have to fight n monsters. To defend from monsters, you need a shield. Each shield has two parameters: its current durability a and its defence rating b. Each monster has only one parameter:...
instruction
0
61,651
2
123,302
Tags: binary search, combinatorics, probabilities Correct Solution: ``` import sys,bisect r=lambda:map(int,sys.stdin.readline().split()) M=998244353 def f(b):return pow(b,M-2,M) n,m=r() d=sorted(r()) p=[0] for v in d:p+=[p[-1]+v] for _ in range(m):a,b=r();i=bisect.bisect(d,b-1);v=n-i; print([(p[i]*a*f(v+v*v)-p[-1]*(a*f...
output
1
61,651
2
123,303
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a computer game. In this game, you have to fight n monsters. To defend from monsters, you need a shield. Each shield has two parameters: its current durability a and its defence rating b. Each monster has only one parameter:...
instruction
0
61,652
2
123,304
Tags: binary search, combinatorics, probabilities Correct Solution: ``` import sys,bisect r=lambda:sys.stdin.readline().split() M=998244353 n,m=map(int,r()) d=[int(x) for x in r()] d.sort() suf=[x for x in d] i=n-1 for i in range(n-2,-1,-1): suf[i]+=suf[i+1] while m>0: m-=1 a,b=map(int,r()) l=bisect.bisect_...
output
1
61,652
2
123,305
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a computer game. In this game, you have to fight n monsters. To defend from monsters, you need a shield. Each shield has two parameters: its current durability a and its defence rating b. Each monster has only one parameter:...
instruction
0
61,653
2
123,306
Tags: binary search, combinatorics, probabilities Correct Solution: ``` from fractions import Fraction import sys input =sys.stdin.readline d=dict() def find(L ,n): if n in d:return d[n] lo =0 hi =len(L) while lo <hi: mid =(lo +hi )//2 if L[mid] <n: lo =mid +1 else: ...
output
1
61,653
2
123,307