lang
stringclasses
1 value
prompt
stringlengths
1.38k
11.3k
eval_prompt
stringlengths
37
8.09k
ground_truth
stringlengths
1
328
unit_tests
stringclasses
145 values
task_id
stringlengths
23
25
split
stringclasses
2 values
python
Complete the code in python to solve this programming problem: Description: There is a chip on the coordinate line. Initially, the chip is located at the point $$$0$$$. You can perform any number of moves; each move increases the coordinate of the chip by some positive integer (which is called the length of the move)....
n,k=map(int,input().split());M=998244353 f,z=[1]+[0]*n,[0]*(n+1);l=0 while l<=n-k: s=[0]*k for {{completion}}: j=i%k s[j],f[i],z[i]=(s[j]+f[i])%M,s[j],(z[i]+s[j])%M l+=k;k+=1 print(*z[1:])
i in range(l,n+1)
[{"input": "8 1", "output": ["1 1 2 2 3 4 5 6"]}, {"input": "10 2", "output": ["0 1 0 1 1 1 1 2 2 2"]}]
control_completion_008076
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In ...
def readline(): line = input() while not line: line = input() return line def main(): t = int(readline()) for _ in range(t): m = int(readline()) a = [ [], [] ] a[0] += list(map(int, readline().split())) a[1] = list(map(int, readline().split())) h = ...
(i-1) % 4 == 0
[{"input": "4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0", "output": ["5\n19\n17\n3"]}]
control_completion_008132
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom. The columns are numbered from $$$1$$$ to $$$m$$$ from left to right.The robot starts in a cell $$$(1, 1)$$$. In ...
def readline(): line = input() while not line: line = input() return line def main(): t = int(readline()) for _ in range(t): m = int(readline()) a = [ [], [] ] a[0] += list(map(int, readline().split())) a[1] = list(map(int, readline().split())) h = ...
(i-2) % 4 == 0
[{"input": "4\n\n3\n\n0 0 1\n\n4 3 2\n\n5\n\n0 4 8 12 16\n\n2 6 10 14 18\n\n4\n\n0 10 10 10\n\n10 10 10 10\n\n2\n\n0 0\n\n0 0", "output": ["5\n19\n17\n3"]}]
control_completion_008133
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$...
import sys; input = sys.stdin.readline def seg(start, end): if {{completion}}: val = max(arr[start], 0) return [(val, val, val, arr[start])] mid = (start + end) // 2 l = seg(start, mid) r = seg(mid + 1, end) result = [] for i in range((end - start + 1) // 2): ...
start == end
[{"input": "3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1", "output": ["18\n8\n13"]}]
control_completion_008160
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$...
import sys; input = sys.stdin.readline def seg(start, end): if start == end: val = max(arr[start], 0) return [(val, val, val, arr[start])] mid = (start + end) // 2 l = seg(start, mid) r = seg(mid + 1, end) result = [] for {{completion}}: lb, ls, lp, lS = l[i] ...
i in range((end - start + 1) // 2)
[{"input": "3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1", "output": ["18\n8\n13"]}]
control_completion_008161
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given an array of length $$$2^n$$$. The elements of the array are numbered from $$$1$$$ to $$$2^n$$$.You have to process $$$q$$$ queries to this array. In the $$$i$$$-th query, you will be given an integer $$$k$$$ ($$$0 \le k \le n-1$$...
import sys input = lambda: sys.stdin.readline().rstrip() class Node: def __init__(self, seg, suf, pref, sum) -> None: self.best = seg self.suf = suf self.pref = pref self.sum = sum def merge(a, b): seg = max(a.best, b.best, a.suf + b.pref) suf = max(b.suf, b...
i in range((r - l) // 2)
[{"input": "3\n-3 5 -3 2 8 -20 6 -1\n3\n1\n0\n1", "output": ["18\n8\n13"]}]
control_completion_008162
control_fixed
python
Complete the code in python to solve this programming problem: Description: Consider a hallway, which can be represented as the matrix with $$$2$$$ rows and $$$n$$$ columns. Let's denote the cell on the intersection of the $$$i$$$-th row and the $$$j$$$-th column as $$$(i, j)$$$. The distance between the cells $$$(i_1...
import sys input = lambda: sys.stdin.readline().rstrip() def solve(): N = int(input()) G = [[int(x) for x in input()] + [0] for _ in range(2)] dp = [[0] * 2 for _ in range(N + 1)] # number of 1 cells robot will clean when it arrives at cell (j, i) from the left for j in range(2): ...
G[1 - j][i]
[{"input": "2\n01\n11", "output": ["2"]}, {"input": "2\n01\n01", "output": ["2"]}, {"input": "4\n0101\n1011", "output": ["4"]}, {"input": "4\n0000\n0000", "output": ["0"]}, {"input": "5\n00011\n10101", "output": ["4"]}, {"input": "6\n011111\n111111", "output": ["8"]}, {"input": "10\n0101001010\n1010100110", "output": [...
control_completion_008234
control_fixed
python
Complete the code in python to solve this programming problem: Description: Consider a hallway, which can be represented as the matrix with $$$2$$$ rows and $$$n$$$ columns. Let's denote the cell on the intersection of the $$$i$$$-th row and the $$$j$$$-th column as $$$(i, j)$$$. The distance between the cells $$$(i_1...
import sys inf = float('inf') mod = 998244353 input = lambda: sys.stdin.readline().rstrip() inpnm = lambda: map(int, input().split()) inparr = lambda: [int(i) for i in input().split()] inpint = lambda: int(input()) n=inpint() s=[] for i in range(2): s.append([i for i in list(input())]+['0','0']) #pri...
s[j^1][i]=='1'
[{"input": "2\n01\n11", "output": ["2"]}, {"input": "2\n01\n01", "output": ["2"]}, {"input": "4\n0101\n1011", "output": ["4"]}, {"input": "4\n0000\n0000", "output": ["0"]}, {"input": "5\n00011\n10101", "output": ["4"]}, {"input": "6\n011111\n111111", "output": ["8"]}, {"input": "10\n0101001010\n1010100110", "output": [...
control_completion_008235
control_fixed
python
Complete the code in python to solve this programming problem: Description: Consider a hallway, which can be represented as the matrix with $$$2$$$ rows and $$$n$$$ columns. Let's denote the cell on the intersection of the $$$i$$$-th row and the $$$j$$$-th column as $$$(i, j)$$$. The distance between the cells $$$(i_1...
import sys input = lambda: sys.stdin.readline().rstrip() def solve(): N = int(input()) G = [[int(x) for x in input()] + [0] for _ in range(2)] dp = [[0] * 2 for _ in range(N + 1)] for j in range(2): dp[N - 1][j] = G[1 - j][N - 1] for i in range(N - 2, - 1, -1): ...
G[j][i + 1]
[{"input": "2\n01\n11", "output": ["2"]}, {"input": "2\n01\n01", "output": ["2"]}, {"input": "4\n0101\n1011", "output": ["4"]}, {"input": "4\n0000\n0000", "output": ["0"]}, {"input": "5\n00011\n10101", "output": ["4"]}, {"input": "6\n011111\n111111", "output": ["8"]}, {"input": "10\n0101001010\n1010100110", "output": [...
control_completion_008236
control_fixed
python
Complete the code in python to solve this programming problem: Description: Vasya has a grid with $$$2$$$ rows and $$$n$$$ columns. He colours each cell red, green, or blue.Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same. In...
import sys if __name__ == "__main__": input_arr = sys.stdin.read().split() tc = int(input_arr[0]) pos = 1 for i in range(tc): n, row1, row2 = input_arr[pos:pos + 3] row1n, row2n = [], [] for k,j in zip(row1, row2): if {{completion}}: k = "B...
k == "G"
[{"input": "6\n\n2\n\nRG\n\nRB\n\n4\n\nGRBG\n\nGBGB\n\n5\n\nGGGGG\n\nBBBBB\n\n7\n\nBBBBBBB\n\nRRRRRRR\n\n8\n\nRGBRRGBR\n\nRGGRRBGR\n\n1\n\nG\n\nG", "output": ["YES\nNO\nYES\nNO\nYES\nYES"]}]
control_completion_008313
control_fixed
python
Complete the code in python to solve this programming problem: Description: Vasya has a grid with $$$2$$$ rows and $$$n$$$ columns. He colours each cell red, green, or blue.Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same. In...
import sys if __name__ == "__main__": input_arr = sys.stdin.read().split() tc = int(input_arr[0]) pos = 1 for i in range(tc): n, row1, row2 = input_arr[pos:pos + 3] row1n, row2n = [], [] for k,j in zip(row1, row2): if k == "G": k = "B" ...
j == "G"
[{"input": "6\n\n2\n\nRG\n\nRB\n\n4\n\nGRBG\n\nGBGB\n\n5\n\nGGGGG\n\nBBBBB\n\n7\n\nBBBBBBB\n\nRRRRRRR\n\n8\n\nRGBRRGBR\n\nRGGRRBGR\n\n1\n\nG\n\nG", "output": ["YES\nNO\nYES\nNO\nYES\nYES"]}]
control_completion_008314
control_fixed
python
Complete the code in python to solve this programming problem: Description: Polycarp has a string $$$s$$$ consisting of lowercase Latin letters.He encodes it using the following algorithm.He goes through the letters of the string $$$s$$$ from left to right and for each letter Polycarp considers its number in the alpha...
import sys if __name__ == "__main__": input_arr = list(map(int, sys.stdin.read().split())) n = input_arr[0] pos = 1 for i in range(n): n, code = input_arr[pos:pos+2] code_str = str(code) result = [] j = n-1 while j >= 0: if j >= 2: ...
sub[-1] == "0"
[{"input": "9\n\n6\n\n315045\n\n4\n\n1100\n\n7\n\n1213121\n\n6\n\n120120\n\n18\n\n315045615018035190\n\n7\n\n1111110\n\n7\n\n1111100\n\n5\n\n11111\n\n4\n\n2606", "output": ["code\naj\nabacaba\nll\ncodeforces\naaaak\naaaaj\naaaaa\nzf"]}]
control_completion_008430
control_fixed
python
Complete the code in python to solve this programming problem: Description: Polycarp has a string $$$s$$$ consisting of lowercase Latin letters.He encodes it using the following algorithm.He goes through the letters of the string $$$s$$$ from left to right and for each letter Polycarp considers its number in the alpha...
from sys import stdin from collections import deque lst = list(map(int, stdin.read().split())) _s = 0 def inp(n=1): global _s ret = lst[_s:_s + n] _s += n return ret def inp1(): return inp()[0] t = inp1() for _ in range(t): n = inp1() s = str(inp1())[::-1] alph = "0abcdefghijk...
s[i] == "0"
[{"input": "9\n\n6\n\n315045\n\n4\n\n1100\n\n7\n\n1213121\n\n6\n\n120120\n\n18\n\n315045615018035190\n\n7\n\n1111110\n\n7\n\n1111100\n\n5\n\n11111\n\n4\n\n2606", "output": ["code\naj\nabacaba\nll\ncodeforces\naaaak\naaaaj\naaaaa\nzf"]}]
control_completion_008431
control_fixed
python
Complete the code in python to solve this programming problem: Description: Vlad went into his appartment house entrance, now he is on the $$$1$$$-th floor. He was going to call the elevator to go up to his apartment.There are only two elevators in his house. Vlad knows for sure that: the first elevator is currently ...
import sys def calculate(x, y1, y2): x = int(x) y1 = int(y1) y2 = int(y2) diff1 = abs(x - 1) diff2 = abs(y1-y2) if y2 == 1 else abs(y1-y2)+y2-1 if diff1 < diff2: return 1 elif diff2 < diff1: return 2 else: return 3 if __name__ == "__main__": ...
len(input) == 3
[{"input": "3\n\n1 2 3\n\n3 1 2\n\n3 2 1", "output": ["1\n3\n2"]}]
control_completion_008448
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given two non-empty strings $$$s$$$ and $$$t$$$, consisting of Latin letters.In one move, you can choose an occurrence of the string $$$t$$$ in the string $$$s$$$ and replace it with dots.Your task is to remove all occurrences of the s...
# from __future__ import annotations import csv import datetime import string import sys import time from collections import defaultdict from contextlib import contextmanager from typing import List, Optional def solve() -> None: s = next_token() t = next_token() ls = len(s) lt = len(t) is_start = [s[i:i +...
tt[0] == l[0] + r[0] + 1
[{"input": "8\n\nabababacababa\n\naba\n\nddddddd\n\ndddd\n\nxyzxyz\n\nxyz\n\nabc\n\nabcd\n\nabacaba\n\nabaca\n\nabc\n\ndef\n\naaaaaaaa\n\na\n\naaaaaaaa\n\naa", "output": ["2 2\n1 4\n2 1\n0 1\n1 1\n0 1\n8 1\n3 6"]}]
control_completion_008491
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given two non-empty strings $$$s$$$ and $$$t$$$, consisting of Latin letters.In one move, you can choose an occurrence of the string $$$t$$$ in the string $$$s$$$ and replace it with dots.Your task is to remove all occurrences of the s...
# from __future__ import annotations import csv import datetime import string import sys import time from collections import defaultdict from contextlib import contextmanager from typing import List, Optional def solve() -> None: s = next_token() t = next_token() ls = len(s) lt = len(t) is_start = [s[i:i +...
tt is None or tt[0] > l[0] + r[0] + 1
[{"input": "8\n\nabababacababa\n\naba\n\nddddddd\n\ndddd\n\nxyzxyz\n\nxyz\n\nabc\n\nabcd\n\nabacaba\n\nabaca\n\nabc\n\ndef\n\naaaaaaaa\n\na\n\naaaaaaaa\n\naa", "output": ["2 2\n1 4\n2 1\n0 1\n1 1\n0 1\n8 1\n3 6"]}]
control_completion_008492
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given two non-empty strings $$$s$$$ and $$$t$$$, consisting of Latin letters.In one move, you can choose an occurrence of the string $$$t$$$ in the string $$$s$$$ and replace it with dots.Your task is to remove all occurrences of the s...
# from __future__ import annotations import csv import datetime import string import sys import time from collections import defaultdict from contextlib import contextmanager from typing import List, Optional def solve() -> None: s = next_token() t = next_token() ls = len(s) lt = len(t) is_start = [s[i:i +...
tt[0] == l[0] + r[0] + 1
[{"input": "8\n\nabababacababa\n\naba\n\nddddddd\n\ndddd\n\nxyzxyz\n\nxyz\n\nabc\n\nabcd\n\nabacaba\n\nabaca\n\nabc\n\ndef\n\naaaaaaaa\n\na\n\naaaaaaaa\n\naa", "output": ["2 2\n1 4\n2 1\n0 1\n1 1\n0 1\n8 1\n3 6"]}]
control_completion_008493
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are given two non-empty strings $$$s$$$ and $$$t$$$, consisting of Latin letters.In one move, you can choose an occurrence of the string $$$t$$$ in the string $$$s$$$ and replace it with dots.Your task is to remove all occurrences of the s...
# from __future__ import annotations import csv import datetime import string import sys import time from collections import defaultdict from contextlib import contextmanager from typing import List, Optional def solve() -> None: s = next_token() t = next_token() ls = len(s) lt = len(t) is_start = [s[i:i +...
tt is None or tt[0] > l[0] + r[0] + 1
[{"input": "8\n\nabababacababa\n\naba\n\nddddddd\n\ndddd\n\nxyzxyz\n\nxyz\n\nabc\n\nabcd\n\nabacaba\n\nabaca\n\nabc\n\ndef\n\naaaaaaaa\n\na\n\naaaaaaaa\n\naa", "output": ["2 2\n1 4\n2 1\n0 1\n1 1\n0 1\n8 1\n3 6"]}]
control_completion_008494
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given the string $$$s$$$ of decimal digits (0-9) of length $$$n$$$.A substring is a sequence of consecutive characters of a string. The substring of this string is defined by a pair of indexes — with its left and right ends. So, each pair of i...
from __future__ import annotations import csv import datetime import string import sys import time from collections import defaultdict from contextlib import contextmanager from typing import List def solve() -> None: a = [int(c) % 9 for c in next_token()] n = len(a) sa = list(a) for i in range(1, n): sa...
len(indices[v1]) > 0 and len(indices[v2]) > 0
[{"input": "5\n\n1003004\n\n4 1\n\n1 2 1\n\n179572007\n\n4 2\n\n2 7 3\n\n2 7 4\n\n111\n\n2 1\n\n2 2 6\n\n0000\n\n1 2\n\n1 4 0\n\n1 4 1\n\n484\n\n1 5\n\n2 2 0\n\n2 3 7\n\n1 2 5\n\n3 3 8\n\n2 2 6", "output": ["2 4\n1 5\n1 2\n-1 -1\n1 2\n-1 -1\n1 3\n1 3\n-1 -1\n-1 -1\n-1 -1"]}]
control_completion_008510
control_fixed
python
Complete the code in python to solve this programming problem: Description: Given the string $$$s$$$ of decimal digits (0-9) of length $$$n$$$.A substring is a sequence of consecutive characters of a string. The substring of this string is defined by a pair of indexes — with its left and right ends. So, each pair of i...
from __future__ import annotations import csv import datetime import string import sys import time from collections import defaultdict from contextlib import contextmanager from typing import List def solve() -> None: a = [int(c) % 9 for c in next_token()] n = len(a) sa = list(a) for i in range(1, n): sa...
len(indices[v1]) > 1
[{"input": "5\n\n1003004\n\n4 1\n\n1 2 1\n\n179572007\n\n4 2\n\n2 7 3\n\n2 7 4\n\n111\n\n2 1\n\n2 2 6\n\n0000\n\n1 2\n\n1 4 0\n\n1 4 1\n\n484\n\n1 5\n\n2 2 0\n\n2 3 7\n\n1 2 5\n\n3 3 8\n\n2 2 6", "output": ["2 4\n1 5\n1 2\n-1 -1\n1 2\n-1 -1\n1 3\n1 3\n-1 -1\n-1 -1\n-1 -1"]}]
control_completion_008511
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
# from collections import Counter """ standing at point i, why choose to jump to a point j? if jump: a*(j-i) + cost(j,n) if not jump(ie. start from i): every unconquered kingdom require the distance j-i be conqured, totally n-j times, -> (j-i)*b*(n-j) + cost(j,n) compare the two equations: when a < b*(n-j)...
a<b*(n-i)
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008534
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
import sys lines = list(map(str.strip, sys.stdin.readlines())) def cum_sum(nums): curr = 0 result = [0]*len(nums) for {{completion}}: curr += num result[idx] = curr return result for i in range(1, len(lines), 2): n, a, b = map(int, lines[i].split(" ")) nums = [0] +...
idx, num in enumerate(nums)
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008535
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
import sys lines = list(map(str.strip, sys.stdin.readlines())) def cum_sum(nums): curr = 0 result = [0]*len(nums) for idx, num in enumerate(nums): curr += num result[idx] = curr return result for i in range(1, len(lines), 2): n, a, b = map(int, lines[i].split(" ")) ...
f in range(0, n+1)
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008536
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
#Name: Codeforces Round #782 (Div. 4) #Code: #Rating: 00 #Date: 14/06/2022 #Author: auros25 #Done: #sys.stdin.readline().strip() #sys.stdout.write(+"\n") import sys #import bisect for lol in range(int(sys.stdin.readline().strip())): n, a, b = list(map(int, sys.stdin.readline().strip(...
k >=n
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008537
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
for _ in range(int(input())): n,a,b=map(int, input().split()) w=[int(x) for x in input().split()] fb=sum(w)*b fa=0 ans = fb cap = 0 cur = n for x in w: fb -= x * b cur -= 1 if {{completion}}: ans += (x - cap) * a ans -= (x - cap) * cur * b cap = x #print(cap) print(ans)
(x - cap) * a + fb - (x - cap) * cur * b < fb
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008538
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
t = int(input()) for i in range(t): li = input().split() n = int(li[0]) a = int(li[1]) b = int(li[2]) x = input().split() ans = 0 now = 0 for j in range(n): ans += b*(int(x[j])-now) if {{completion}}: ans += a*(int(x[j])-now) now = int...
a < b*(n-j-1)
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008539
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
def solve(): n,a,b=map(int,input().split()) xs=list(map(int,input().split())) cum=0 ans=sum(xs)*b for {{completion}}: x=xs[-i-1] ans=min(ans,x*(a+b)+(cum-x*i)*b) cum+=x print(ans) for _ in range(int(input())): solve()
i in range(n)
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008540
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
# import io,os # read = io.BytesIO(os.read(0, os.fstat(0).st_size)) # I = lambda: [*map(int, read.readline().split())] import sys I=lambda:[*map(int,sys.stdin.readline().split())] t, = I() for _ in range(t): n, a, b = I() x = [0] + I() suffixes = [0] for {{completion}}: move = x[i + 1] - x[i] to...
i in range(n - 1, -1, -1)
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008541
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
# import io,os # read = io.BytesIO(os.read(0, os.fstat(0).st_size)) # I = lambda: [*map(int, read.readline().split())] import sys I=lambda:[*map(int,sys.stdin.readline().split())] t, = I() for _ in range(t): n, a, b = I() x = [0] + I() suffixes = [0] for i in range(n - 1, -1, -1): move = x[i + 1] -...
i in range(n + 1)
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008542
control_fixed
python
Complete the code in python to solve this programming problem: Description: You are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at $$$0$$$. There are $$$n$$$ unconquered kingdom...
def f(ar,a,b): ans=0 c=0 n=len(ar) for id,i in enumerate(ar): d=i-c ans+=d*b if {{completion}}: ans+=d*a c=i return ans r=lambda :map(int,input().strip().split()) for _ in range(int(input())): n,a,b=r() ar=list(r()) print(f...
d*a<(n-id-1)*(d)*b
[{"input": "4\n5 2 7\n3 5 12 13 21\n5 6 3\n1 5 6 21 30\n2 9 3\n10 15\n11 27182 31415\n16 18 33 98 874 989 4848 20458 34365 38117 72030", "output": ["173\n171\n75\n3298918744"]}]
control_completion_008543
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
for {{completion}}:n,r,b=map(int,s.split());b+=1;c=r//b*'R'+'B';print((r%b*('R'+c)+n*c)[:n])
s in[*open(0)][1:]
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008556
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
for {{completion}}: n,r,b=map(int,input().split()) t=((r-1)//(b+1)+1) k=t*(b+1)-r res=('R'*t+'B')*(b+1-k)+('R'*(t-1)+'B')*k print(res[:-1]) #
_ in range(int(input()))
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008557
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
tc=int(input()) for {{completion}}: n,a,b=map(int,input().split());b+=1 print((('R'*(a//b+1)+'B')*(a%b)+('R'*(a//b)+'B')*(b-a%b))[:-1])
_ in range(tc)
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008558
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
def solve(): n, r, b = list(map(int, input().split(" "))) d = r // (b+1) rem = r%(b+1) s = '' for i in range(b): if{{completion}}: s += 'R' rem-= 1 s += 'R'*d + 'B' s += 'R'*d s+='R'*rem print(s) for t in range(int(input())): solve()
(rem > 0)
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008559
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
for {{completion}}:n,r,b=map(int,n.split());b+=1;n=r//b*'R';print((r%b*(n+'RB')+(b-r%b)*(n+'B'))[:-1])
n in[*open(0)][1:]
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008560
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
t=int(input()) for {{completion}}: n,r,b=map(int,input().split()) eq=r//(b+1) rem=r%(b+1) print(rem*((eq+1)*"R"+"B")+(b-rem)*(eq*("R")+"B")+eq*"R")
i in range(0,t)
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008561
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
for t in range(int(input())): n,r,b = map(int,input().split()) s = [] while r and b: s.append("R") s.append("B") r-=1 b-=1 s.append("R") r-=1 j = 0 while r: s[j]+='R' r-=1 j+=2 if {{completion}}: j=0 ...
j>=len(s)
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008562
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
for {{completion}}: n,r,b=map(int,l.split()) b+=1 c=(r//b)*'R'+'B' print(((r%b)*('R'+c)+n*c)[:n])
l in [*open(0)][1:]
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008563
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
t = int(input()) for i in range(t): x = input().split() r = int(x[1]) b = int(x[2]) x = "" p = r%(b+1) q = r//(b+1) for {{completion}}: x += "R"*(q+1)+"B" for i in range(b+1-p): x+= "R"*(q)+"B" print(x[:-1])
i in range(p)
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008564
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
t = int(input()) for i in range(t): x = input().split() r = int(x[1]) b = int(x[2]) x = "" p = r%(b+1) q = r//(b+1) for i in range(p): x += "R"*(q+1)+"B" for {{completion}}: x+= "R"*(q)+"B" print(x[:-1])
i in range(b+1-p)
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008565
control_fixed
python
Complete the code in python to solve this programming problem: Description: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less s...
for {{completion}}:n,r,b=map(int,n.split());b+=1;print((r%b*('R'*(r//b+1)+'B')+(b-r%b)*(r//b*'R'+'B'))[:-1])
n in[*open(0)][1:]
[{"input": "3\n7 4 3\n6 5 1\n19 13 6", "output": ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR"]}, {"input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2", "output": ["RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"]}]
control_completion_008566
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
for s in[*open(0)][2::2]: c=[*map(int,s.split())] a=[1 if x else 0 for x in c]+[1] for {{completion}}: a[x+i-i*a[i]]=0 print(*a[:-1])
i,x in enumerate(c)
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008596
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
import sys def solve(): n = int(input()) num = list(map(int , input().split())) ret = [1]*n for i in range(n): j = num[i] if {{completion}}: j += i if j < n: ret[j] = 0 print(*ret) for _ in range(int(input())): solve()
j == 0 or ret[i] == 0
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008597
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
import sys def solve(): n = int(input()) num = list(map(int , input().split())) ret = [1]*n for i in range(n): j = num[i] if j == 0 or ret[i] == 0: j += i if {{completion}}: ret[j] = 0 print(*ret) for _ in range(int(input())): ...
j < n
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008598
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) a, e, se, s = [], [0]*n, 0, sum(c) for {{completion}}: se -= e[i-1] n1 = s//i t = 0 if c[i-1] < i + se else 1 a.append(t) s -= (n1 + (i-1)*t) e[i-n1-1] += 1...
i in range(n, 0, -1)
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008599
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
from sys import stdin,stderr def rl(): return [int(w) for w in stdin.readline().split()] t, = rl() for _ in range(t): n, = rl() c = rl() a = [1] * n for i in range(n): j = c[i] if {{completion}}: j += i if j < n: a[j] = 0 print(*a) ...
j == 0 or a[i] == 0
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008600
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
from sys import stdin,stderr def rl(): return [int(w) for w in stdin.readline().split()] t, = rl() for _ in range(t): n, = rl() c = rl() a = [1] * n for i in range(n): j = c[i] if j == 0 or a[i] == 0: j += i if {{completion}}: a[j] = 0 ...
j < n
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008601
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
for _ in range(int(input())): n=int(input()) C=list(map(int,input().split())) z=sum(C)//n d=[0]*(n+1) ans=[] for i in range(n-1,-1,-1): d[i]+=d[i+1] d[i]-=1 d[i-z]+=1 if {{completion}}: ans.append(1) z-=1 else: ...
z and C[i]+d[i]==i
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008602
control_fixed
python
Complete the code in python to solve this programming problem: Description: Suppose you had an array $$$A$$$ of $$$n$$$ elements, each of which is $$$0$$$ or $$$1$$$.Let us define a function $$$f(k,A)$$$ which returns another array $$$B$$$, the result of sorting the first $$$k$$$ elements of $$$A$$$ in non-decreasing ...
import sys input = sys.stdin.readline T = int(input()) for t in range(T): N=int(input()) C=list(map(int,input().split())) ans=[0]*N k=sum(C)//N i=N-1 while i>-1 and k>0: if {{completion}}: ans[i]=1 k-=1 else: C[i-k]+=N-i ...
C[i]==N
[{"input": "5\n4\n2 4 2 4\n7\n0 3 4 2 3 2 7\n3\n0 0 0\n4\n0 0 0 4\n3\n1 2 3", "output": ["1 1 0 1 \n0 1 1 0 0 0 1 \n0 0 0 \n0 0 0 1 \n1 0 1"]}]
control_completion_008603
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is an undirected, connected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. A walk from vertex $$$u$$$ to vertex $$$v$$$ is defined as a sequence of vertices $$$p_1,p_2,\ldots,p_k$$$ (which are not necessarily distinct) starting ...
import sys input = sys.stdin.readline class DSU: def __init__(self, n): self.UF = list(range(n)) self.sz = [0]*n def find(self, u): UF = self.UF if UF[u]!=u: UF[u] = self.find(UF[u]) return UF[u] def union(self,u,v): UF = self...
w & (1<<k)
[{"input": "6 7\n1 2 1\n2 3 3\n3 1 5\n4 5 2\n5 6 4\n6 4 6\n3 4 1\n3\n1 5\n1 2\n5 3", "output": ["2\n0\n1"]}, {"input": "9 8\n1 2 5\n2 3 11\n3 4 10\n3 5 10\n5 6 2\n5 7 1\n7 8 5\n7 9 5\n10\n5 7\n2 5\n7 1\n6 4\n5 2\n7 6\n4 1\n6 2\n4 7\n2 8", "output": ["0\n0\n2\n0\n0\n2\n1\n0\n1\n1"]}]
control_completion_008615
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is an undirected, connected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. A walk from vertex $$$u$$$ to vertex $$$v$$$ is defined as a sequence of vertices $$$p_1,p_2,\ldots,p_k$$$ (which are not necessarily distinct) starting ...
import sys input = sys.stdin.readline class DSU: def __init__(self, n): self.UF = list(range(n)) self.sz = [0]*n def find(self, u): UF = self.UF if UF[u]!=u: UF[u] = self.find(UF[u]) return UF[u] def union(self,u,v): UF = self...
DSUs[k].find(u) == DSUs[k].find(v)
[{"input": "6 7\n1 2 1\n2 3 3\n3 1 5\n4 5 2\n5 6 4\n6 4 6\n3 4 1\n3\n1 5\n1 2\n5 3", "output": ["2\n0\n1"]}, {"input": "9 8\n1 2 5\n2 3 11\n3 4 10\n3 5 10\n5 6 2\n5 7 1\n7 8 5\n7 9 5\n10\n5 7\n2 5\n7 1\n6 4\n5 2\n7 6\n4 1\n6 2\n4 7\n2 8", "output": ["0\n0\n2\n0\n0\n2\n1\n0\n1\n1"]}]
control_completion_008616
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is an undirected, connected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. A walk from vertex $$$u$$$ to vertex $$$v$$$ is defined as a sequence of vertices $$$p_1,p_2,\ldots,p_k$$$ (which are not necessarily distinct) starting ...
import sys input = sys.stdin.readline def bit(w, b): if w & (1 << b): return 1 return 0 class DSU: def __init__(self, n): self.n = n self.parent = [i for i in range(self.n)] self.SZ = [1 for _ in range(self.n)] def root(self, node): if self...
bit(w, j)
[{"input": "6 7\n1 2 1\n2 3 3\n3 1 5\n4 5 2\n5 6 4\n6 4 6\n3 4 1\n3\n1 5\n1 2\n5 3", "output": ["2\n0\n1"]}, {"input": "9 8\n1 2 5\n2 3 11\n3 4 10\n3 5 10\n5 6 2\n5 7 1\n7 8 5\n7 9 5\n10\n5 7\n2 5\n7 1\n6 4\n5 2\n7 6\n4 1\n6 2\n4 7\n2 8", "output": ["0\n0\n2\n0\n0\n2\n1\n0\n1\n1"]}]
control_completion_008617
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is an undirected, connected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. A walk from vertex $$$u$$$ to vertex $$$v$$$ is defined as a sequence of vertices $$$p_1,p_2,\ldots,p_k$$$ (which are not necessarily distinct) starting ...
import sys input = sys.stdin.readline def bit(w, b): if w & (1 << b): return 1 return 0 class DSU: def __init__(self, n): self.n = n self.parent = [i for i in range(self.n)] self.SZ = [1 for _ in range(self.n)] def root(self, node): if self...
bit(w, j) and bit(w, 0)
[{"input": "6 7\n1 2 1\n2 3 3\n3 1 5\n4 5 2\n5 6 4\n6 4 6\n3 4 1\n3\n1 5\n1 2\n5 3", "output": ["2\n0\n1"]}, {"input": "9 8\n1 2 5\n2 3 11\n3 4 10\n3 5 10\n5 6 2\n5 7 1\n7 8 5\n7 9 5\n10\n5 7\n2 5\n7 1\n6 4\n5 2\n7 6\n4 1\n6 2\n4 7\n2 8", "output": ["0\n0\n2\n0\n0\n2\n1\n0\n1\n1"]}]
control_completion_008618
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is an undirected, connected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. A walk from vertex $$$u$$$ to vertex $$$v$$$ is defined as a sequence of vertices $$$p_1,p_2,\ldots,p_k$$$ (which are not necessarily distinct) starting ...
from sys import stdin input = stdin.readline inp = lambda : list(map(int,input().split())) class dsu: def __init__(self , n): self.p = [0]*(n + 1) self.rank = [0]*(n + 1) for i in range(1 , n + 1): self.p[i] = i def find(self , node): if(self.p...
(value[i][zero[i].find(u)] == 1)
[{"input": "6 7\n1 2 1\n2 3 3\n3 1 5\n4 5 2\n5 6 4\n6 4 6\n3 4 1\n3\n1 5\n1 2\n5 3", "output": ["2\n0\n1"]}, {"input": "9 8\n1 2 5\n2 3 11\n3 4 10\n3 5 10\n5 6 2\n5 7 1\n7 8 5\n7 9 5\n10\n5 7\n2 5\n7 1\n6 4\n5 2\n7 6\n4 1\n6 2\n4 7\n2 8", "output": ["0\n0\n2\n0\n0\n2\n1\n0\n1\n1"]}]
control_completion_008619
control_fixed
python
Complete the code in python to solve this programming problem: Description: There is an undirected, connected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. A walk from vertex $$$u$$$ to vertex $$$v$$$ is defined as a sequence of vertices $$$p_1,p_2,\ldots,p_k$$$ (which are not necessarily distinct) starting ...
from sys import stdin input = stdin.readline inp = lambda : list(map(int,input().split())) class dsu: def __init__(self , n): self.p = [0]*(n + 1) self.rank = [0]*(n + 1) for i in range(1 , n + 1): self.p[i] = i def find(self , node): if(self.p...
(w >> i & 1)
[{"input": "6 7\n1 2 1\n2 3 3\n3 1 5\n4 5 2\n5 6 4\n6 4 6\n3 4 1\n3\n1 5\n1 2\n5 3", "output": ["2\n0\n1"]}, {"input": "9 8\n1 2 5\n2 3 11\n3 4 10\n3 5 10\n5 6 2\n5 7 1\n7 8 5\n7 9 5\n10\n5 7\n2 5\n7 1\n6 4\n5 2\n7 6\n4 1\n6 2\n4 7\n2 8", "output": ["0\n0\n2\n0\n0\n2\n1\n0\n1\n1"]}]
control_completion_008620
control_fixed