message stringlengths 2 49.9k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 446 108k | cluster float64 13 13 | __index_level_0__ int64 892 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_n.
In one operation you can delete an element... | instruction | 0 | 16,982 | 13 | 33,964 |
Tags: data structures, dsu, graphs, greedy, sortings, trees
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
def _find(s, u):
par = []
while s[u] != u:
par.append(u)
u = s[u]
for v in par: s[v] = u
return u
def _union(s, u1, u2):
su1, su2 = _find(s, u1), _find(s, ... | output | 1 | 16,982 | 13 | 33,965 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_n.
In one operation you can delete an element... | instruction | 0 | 16,983 | 13 | 33,966 |
Tags: data structures, dsu, graphs, greedy, sortings, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**4)
M, N = map(int, input().split())
NN = N + M
e = [-1] * NN
def find(x):
if e[x] < 0: return x
e[x] = find(e[x])
return e[x]
def join(a, b):
a, b = find(a), find(b)
... | output | 1 | 16,983 | 13 | 33,967 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_n.
In one operation you can delete an element... | instruction | 0 | 16,984 | 13 | 33,968 |
Tags: data structures, dsu, graphs, greedy, sortings, trees
Correct Solution:
```
import sys
input=sys.stdin.readline
class UnionFind():
def __init__(self,n):
self.n=n
self.root=[-1]*(n+1)
self.rank=[0]*(n+1)
def FindRoot(self,x):
if self.root[x]<0:
return x
else:
self.root[x]=self.... | output | 1 | 16,984 | 13 | 33,969 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_n.
In one operation you can delete an element... | instruction | 0 | 16,985 | 13 | 33,970 |
Tags: data structures, dsu, graphs, greedy, sortings, trees
Correct Solution:
```
#!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
def main():
m,n = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input(... | output | 1 | 16,985 | 13 | 33,971 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_n.
In one operation you can delete an element... | instruction | 0 | 16,986 | 13 | 33,972 |
Tags: data structures, dsu, graphs, greedy, sortings, trees
Correct Solution:
```
import sys, io, os
BUFSIZE = 8192
class FastIO(io.IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = io.BytesIO()
self.writable = "x" in file.mode or "r" not in file.... | output | 1 | 16,986 | 13 | 33,973 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_... | instruction | 0 | 16,987 | 13 | 33,974 |
Yes | output | 1 | 16,987 | 13 | 33,975 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_... | instruction | 0 | 16,988 | 13 | 33,976 |
Yes | output | 1 | 16,988 | 13 | 33,977 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_... | instruction | 0 | 16,989 | 13 | 33,978 |
Yes | output | 1 | 16,989 | 13 | 33,979 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_... | instruction | 0 | 16,990 | 13 | 33,980 |
Yes | output | 1 | 16,990 | 13 | 33,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_... | instruction | 0 | 16,991 | 13 | 33,982 |
No | output | 1 | 16,991 | 13 | 33,983 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_... | instruction | 0 | 16,992 | 13 | 33,984 |
No | output | 1 | 16,992 | 13 | 33,985 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_... | instruction | 0 | 16,993 | 13 | 33,986 |
No | output | 1 | 16,993 | 13 | 33,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,424 | 13 | 34,848 |
Tags: implementation, trees
Correct Solution:
```
count = int(input())
tree = {}
for _ in range(count - 1):
edge = input().split()
if edge[0] in tree:
tree[edge[0]].append(edge[1])
else:
tree[edge[0]] = [edge[1]]
if edge[1] in tree:
tree[edge[1]].append(edge[0])
else:
... | output | 1 | 17,424 | 13 | 34,849 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,425 | 13 | 34,850 |
Tags: implementation, trees
Correct Solution:
```
n = int(input())
deg = [0 for i in range(1,n+1)]
odeg = []
for i in range(n-1):
[a, b] = [int(i) for i in input().split()]
deg[a-1] += 1
deg[b-1] += 1
mxdv = 0
mxd = 0
for i in range(n):
if deg[i]>mxd:
mxd=deg[i]
mxdv=i
if deg[i]==1:
odeg.append(i+... | output | 1 | 17,425 | 13 | 34,851 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,426 | 13 | 34,852 |
Tags: implementation, trees
Correct Solution:
```
n = int(input())
dic = {}
for i in range(n):
dic.update({i+1:0})
for i in range(n-1):
s = input().split()
dic[int(s[0])]+=1
dic[int(s[1])]+=1
cl = []
count1=0
count2=0
count3=0
for x in dic.keys():
if dic[x]==1:
count1+=1
cl.append(x... | output | 1 | 17,426 | 13 | 34,853 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,427 | 13 | 34,854 |
Tags: implementation, trees
Correct Solution:
```
import sys
import filecmp
import math
FILE_IO = False
CURR_PATH = []
list_of_connections = [[] for _ in range(100001)]
def dfs(vertex):
visited, stack = set(), [vertex]
while stack:
vertex = stack.pop()
if vertex not in visited:
v... | output | 1 | 17,427 | 13 | 34,855 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,428 | 13 | 34,856 |
Tags: implementation, trees
Correct Solution:
```
#!/usr/bin/env python3
n = int(input().strip())
degs = [0 for _ in range(n)]
for _ in range(n - 1):
[u, v] = map(int, input().strip().split())
degs[u - 1] += 1
degs[v - 1] += 1
ni = [None, [], [], []]
for v, d in enumerate(degs):
dd = min(d, 3)
ni[dd].append(v)
... | output | 1 | 17,428 | 13 | 34,857 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,429 | 13 | 34,858 |
Tags: implementation, trees
Correct Solution:
```
import collections;
def getIntList():
return list(map(int, input().split()));
def getTransIntList(n):
first=getIntList();
m=len(first);
result=[[0]*n for _ in range(m)];
for i in range(m):
result[i][0]=first[i];
for j in range(1, n):
... | output | 1 | 17,429 | 13 | 34,859 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,430 | 13 | 34,860 |
Tags: implementation, trees
Correct Solution:
```
n=int(input())
d={}
for i in range(n-1):
a,b=map(int,input().split())
d[a],d[b]=d.get(a,0)+1,d.get(b,0)+1
root=[]
lev=[]
for a, b in d.items():
if b>2: root.append(a)
if b==1: lev.append(a)
if len(root)>1:
print("No")
else:
if len(root)==0:
... | output | 1 | 17,430 | 13 | 34,861 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the spli... | instruction | 0 | 17,431 | 13 | 34,862 |
Tags: implementation, trees
Correct Solution:
```
#Zad
from collections import Counter
n=int(input())
tree=[]
for i in range(n-1):
tree.extend(list(map(int,input().split())))
ans=Counter(tree)
if ans.most_common(2)[1][1]>2: print('No')
else:
print('Yes')
if n==2:
print(1)
print('1 2')
el... | output | 1 | 17,431 | 13 | 34,863 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,432 | 13 | 34,864 |
Yes | output | 1 | 17,432 | 13 | 34,865 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,433 | 13 | 34,866 |
Yes | output | 1 | 17,433 | 13 | 34,867 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,434 | 13 | 34,868 |
Yes | output | 1 | 17,434 | 13 | 34,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,435 | 13 | 34,870 |
Yes | output | 1 | 17,435 | 13 | 34,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,436 | 13 | 34,872 |
No | output | 1 | 17,436 | 13 | 34,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,437 | 13 | 34,874 |
No | output | 1 | 17,437 | 13 | 34,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,438 | 13 | 34,876 |
No | output | 1 | 17,438 | 13 | 34,877 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he ask... | instruction | 0 | 17,439 | 13 | 34,878 |
No | output | 1 | 17,439 | 13 | 34,879 |
Provide a correct Python 3 solution for this coding contest problem.
You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answer is a... | instruction | 0 | 17,642 | 13 | 35,284 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 17,642 | 13 | 35,285 |
Provide a correct Python 3 solution for this coding contest problem.
You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answer is a... | instruction | 0 | 17,643 | 13 | 35,286 |
"Correct Solution:
```
import sys
from heapq import heappush, heappop
readline = sys.stdin.buffer.readline
write = sys.stdout.write
def solve():
N, M, C = map(int, readline().split())
if N == M == C == 0:
return False
G = [[] for i in range(N)]
for i in range(M):
f, t, c = map(int, read... | output | 1 | 17,643 | 13 | 35,287 |
Provide a correct Python 3 solution for this coding contest problem.
An undirected graph is given. Each edge of the graph disappears with a constant probability. Calculate the probability with which the remained graph is connected.
Input
The first line contains three integers N (1 \leq N \leq 14), M (0 \leq M \leq... | instruction | 0 | 17,646 | 13 | 35,292 |
"Correct Solution:
```
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N, M, P = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
u, v = map(int, readline().split())
G[u-1].append(v-1)
G[v-1].appen... | output | 1 | 17,646 | 13 | 35,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 17,774 | 13 | 35,548 |
Tags: math, number theory, trees
Correct Solution:
```
from collections import Counter
def gcd(x, y):
while y != 0:
(x, y) = (y, x % y)
return x
def main():
n=int(input())
arr=readIntArr()
adj=[[] for _ in range(n)]
for _ in range(n-1):
u,v=readIntArr()
u-=1;v-=1
... | output | 1 | 17,774 | 13 | 35,549 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 17,775 | 13 | 35,550 |
Tags: math, number theory, trees
Correct Solution:
```
from math import gcd
from collections import deque
from bisect import bisect_left
from sys import setrecursionlimit
MOD = 1000000007
def modInt(mod):
class ModInt:
def __init__(self, value):
self.value = value % mod
def __int__(... | output | 1 | 17,775 | 13 | 35,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 17,776 | 13 | 35,552 |
Tags: math, number theory, trees
Correct Solution:
```
n = int(input())
beauty = list(map(int, input().strip().split()))
tree = [[] for i in range(n)]
mod = 1000000007
used = [False for i in range(n)]
def gcd(a,b):
mn = min(a,b)
mx = max(a,b)
if mn == 0:
return mx
md = mx%mn
if md == 0:
... | output | 1 | 17,776 | 13 | 35,553 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 17,777 | 13 | 35,554 |
Tags: math, number theory, trees
Correct Solution:
```
from math import gcd
from collections import deque
from bisect import bisect_left
from sys import setrecursionlimit
MOD = 1000000007
def main():
n = int(input())
setrecursionlimit(n+100)
xx = [0] + [int(x) for x in input().split()]
edges = []
... | output | 1 | 17,777 | 13 | 35,555 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 17,778 | 13 | 35,556 |
Tags: math, number theory, trees
Correct Solution:
```
from collections import Counter
from types import GeneratorType
def bootstrap(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*args, **kwargs)
else:
to = f(*args, **kwargs)
while True:
... | output | 1 | 17,778 | 13 | 35,557 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 17,779 | 13 | 35,558 |
Tags: math, number theory, trees
Correct Solution:
```
from math import gcd
from collections import deque
from bisect import bisect_left
from sys import setrecursionlimit
MOD = 1000000007
def main():
n = int(input())
setrecursionlimit(n+100)
xx = [0] + [int(x) for x in input().split()]
edges = []
... | output | 1 | 17,779 | 13 | 35,559 |
Provide tags and a correct Python 2 solution for this coding contest problem.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?
Yo... | instruction | 0 | 17,780 | 13 | 35,560 |
Tags: math, number theory, trees
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
from fractions import gcd
raw_input = stdin.readline
pr = stdout.write
mod=10**9+7
def ni():
return int(raw_input())
def li():
ret... | output | 1 | 17,780 | 13 | 35,561 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting probl... | instruction | 0 | 17,781 | 13 | 35,562 |
No | output | 1 | 17,781 | 13 | 35,563 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting probl... | instruction | 0 | 17,782 | 13 | 35,564 |
No | output | 1 | 17,782 | 13 | 35,565 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting probl... | instruction | 0 | 17,783 | 13 | 35,566 |
No | output | 1 | 17,783 | 13 | 35,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached 100 million subscribers. In order to celebrate this, he posted a video with an interesting probl... | instruction | 0 | 17,784 | 13 | 35,568 |
No | output | 1 | 17,784 | 13 | 35,569 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,042 | 13 | 36,084 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
import os,io
from sys import stdout
import collections
# import random
# import math
# from operator import itemgetter
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# from collections import Counter
# from decimal import Decimal
# im... | output | 1 | 18,042 | 13 | 36,085 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,043 | 13 | 36,086 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))
def solve():
t = int(input())
for _ in range(t):
n, p = read_tuple(int)
n_vertices = 2 * n + p
for i in range(1, n + 1... | output | 1 | 18,043 | 13 | 36,087 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,044 | 13 | 36,088 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
'''input
1
6 0
'''
# practicing a skill right after sleep improves it a lot quickly
from sys import stdin, setrecursionlimit
# main starts
t = int(stdin.readline().strip())
for _ in range(t):
n, p = list(map(int, stdin.readline().split()))
cou... | output | 1 | 18,044 | 13 | 36,089 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,045 | 13 | 36,090 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
for _ in range(int(input())):
n, p = map(int, input().split())
p += 2 * n
for i in range(n):
for j in range(i + 1, n):
if p == 0:
break
print(i + 1, j + 1)
p -= 1
``` | output | 1 | 18,045 | 13 | 36,091 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,046 | 13 | 36,092 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
import re
t = int(input())
for i in range(t):
x = input()
x = re.split(r"\s" , x)
x1 = int(x[0])
x2 = int(x[1])
cnt = 0
for j in range(x1):
m = j+1
while(m < x1):
print(f"{j+1} {m+1}")
... | output | 1 | 18,046 | 13 | 36,093 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,047 | 13 | 36,094 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
for _ in range(int(input())):
n,p=map(int, input().split())
d={}
ans=0
for i in range(1,n+1):
d[i]=[]
for i in range(1,n+1):
for j in range(1,n+1):
if len(d[i])==2*n+p:
break
... | output | 1 | 18,047 | 13 | 36,095 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,048 | 13 | 36,096 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
for i in range(int(input())):
n, p = map(int, input().split())
all = 2 * n + p
for j in range(1, n + 1):
for k in range(j + 1, n + 1):
if all <= 0:
break
print(j, k)
all -= 1
... | output | 1 | 18,048 | 13 | 36,097 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n),... | instruction | 0 | 18,049 | 13 | 36,098 |
Tags: brute force, constructive algorithms, graphs
Correct Solution:
```
for t in range(int(input())):
n, p = map(int, input().split())
i, j = 1, 2
for k in range(2 * n + p):
print(i, j)
j += 1
if j > n:
i += 1
j = i + 1
``` | output | 1 | 18,049 | 13 | 36,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.