message
stringlengths
2
22.8k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
16
109k
cluster
float64
1
1
__index_level_0__
int64
32
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,210
1
164,420
Tags: graphs Correct Solution: ``` def solve(roads): if roads: min_way = min(roads) return min_way + 1 return '-1' def roads_backery2city(backery, all_roads): roads = [] for u, v, w in all_roads: if backery[u] and not backery[v] or backery[v] and not backery[u]: roads.append(w) return roads n, m, ...
output
1
82,210
1
164,421
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,211
1
164,422
Tags: graphs Correct Solution: ``` from sys import stdin,stdout n,m,k=[int(x) for x in stdin.readline().split()] d={} for i in range(m): u,v,l=[int(x) for x in stdin.readline().split()] if u not in d: d[u]={v:l} elif v not in d[u]: d[u][v]=l else: if d[u][v]>l: d[u][...
output
1
82,211
1
164,423
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,212
1
164,424
Tags: graphs Correct Solution: ``` n, m, k = map(int, input().split()) if k == 0: print(-1) quit() edge = [] for _ in range(m): u, v, l = map(int, input().split()) edge.append((u, v, l)) a = list(map(int, input().split())) tr = [True]*(n+1) for i in a: tr[i] = False ans = float("+inf") fo...
output
1
82,212
1
164,425
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,213
1
164,426
Tags: graphs Correct Solution: ``` n, m, k = map(int, input().split()) g = [[] for i in range(n)] for i in range(m): s, v, w = map(int, input().split()) s, v = s - 1, v - 1 g[s].append((v, w)) g[v].append((s, w)) if not k: print(-1) exit() stores = {num - 1 for num in map(int, input().split()...
output
1
82,213
1
164,427
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,214
1
164,428
Tags: graphs Correct Solution: ``` import math n, m, k = input().split(' ') n = int(n) k = int(k) m = int(m) e = {} for _ in range(m): a, b, c = input().split(' ') a = int(a) b = int(b) c = int(c) x = e.get(a, []) x.append((b, c)) e[a] = x x = e.get(b, []) x.append((a, c)) ...
output
1
82,214
1
164,429
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,215
1
164,430
Tags: graphs Correct Solution: ``` import sys n, m, k = map(int, input().split()) r = [input().split() for j in range(m)] a, v = set(),sys.maxsize if k: a.update(input().split()) for ri in r: if (ri[0] in a) ^ (ri[1] in a): v = min(v, int(ri[2])) print(-1 if v == sys.maxsize else v) ```
output
1
82,215
1
164,431
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,216
1
164,432
Tags: graphs Correct Solution: ``` n, m, k = map(int, input(). split(' ')) a = [[] for i in range(n)] for i in range(m): u, v, l = map(int, input().split(' ')) a[u - 1].append([v - 1, l]) a[v - 1].append([u - 1, l]) if k != 0: cklad = set(list(map(lambda x: int(x) - 1, input().split(' ')))) min1 = ...
output
1
82,216
1
164,433
Provide tags and a correct Python 3 solution for this coding contest problem. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supp...
instruction
0
82,217
1
164,434
Tags: graphs Correct Solution: ``` def bakery(): inp = list(map(int, input().split(" "))) citiesCount, roadsCount, bakeriesCount = inp[0], inp[1], inp[2] roads = [] bkrs = [] result = 0 for i in range(0, roadsCount): roads.append(list(map(int, input().split(" ")))) if bakeriesCount !...
output
1
82,217
1
164,435
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,218
1
164,436
Yes
output
1
82,218
1
164,437
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,219
1
164,438
Yes
output
1
82,219
1
164,439
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,220
1
164,440
Yes
output
1
82,220
1
164,441
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,221
1
164,442
Yes
output
1
82,221
1
164,443
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,222
1
164,444
No
output
1
82,222
1
164,445
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,223
1
164,446
No
output
1
82,223
1
164,447
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,224
1
164,448
No
output
1
82,224
1
164,449
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in ...
instruction
0
82,225
1
164,450
No
output
1
82,225
1
164,451
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,283
1
164,566
Tags: implementation, math Correct Solution: ``` from math import gcd a,b = map(int,input().split(' ')) gcd = gcd(a,b) a,b = a/gcd, b/gcd if abs(a-b) <= 1: print('Equal') elif a < b: print('Dasha') else: print('Masha') ```
output
1
82,283
1
164,567
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,284
1
164,568
Tags: implementation, math Correct Solution: ``` from math import gcd a, b = (int(x) for x in input().split()) upper = a * b / gcd(a,b) m, d = upper/b, upper/a if a < b: d -= 1 else: m -= 1 if d > m: print("Dasha") elif m > d: print("Masha") else: print("Equal") ```
output
1
82,284
1
164,569
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,285
1
164,570
Tags: implementation, math Correct Solution: ``` a,b=map(int,input().split()) d=a f=b def gcd(a,b): if a == 0: return b return gcd(b % a,a) def lcm(a,b): return (a*b) / gcd(a,b) z=lcm(a,b) #print(z) x=(z-1)//d y=(z-1)//f #print(x,y) if(a>b): x=x+1 else: y=y+1 #pri...
output
1
82,285
1
164,571
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,286
1
164,572
Tags: implementation, math Correct Solution: ``` import math import sys input=sys.stdin.readline a,b=list(map(int,input().split())) x=math.gcd(a,b) a,b=a//x,b//x if abs(a-b)==1: print('Equal') elif a<b: print('Dasha') else: print('Masha') ```
output
1
82,286
1
164,573
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,287
1
164,574
Tags: implementation, math Correct Solution: ``` from math import gcd n,m=map(int,input().split()) lcm=n*m//(gcd(n,m)) a,b=lcm//n,lcm//m # print() if abs(a-b)<=1: print("Equal") elif a>b: print("Dasha") else: print("Masha") ```
output
1
82,287
1
164,575
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,288
1
164,576
Tags: implementation, math Correct Solution: ``` '''input 2 3 ''' from math import gcd def lcm(a,b): h=gcd(a,b) l=(a*b)//(h) return l d,m=map(int,input().strip().split(' ')) l=lcm(d,m) a=l//d-1 b=l//m-1 if a<b: a+=1 else: b+=1 if a<b: print("Masha") elif a>b: print("Dasha") else: print("Equal") ''' d=5 m=3 0-3...
output
1
82,288
1
164,577
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,289
1
164,578
Tags: implementation, math Correct Solution: ``` a, b = map(int, input().split(' ')) def gcd(x, y): while(y): x, y = y, x % y return x def lcm(x, y): lcm = (x*y)//gcd(x,y) return lcm abm = lcm(a, b) ca = abm / a cb = abm / b if a < b: cb += 1 else: ca += 1 if ca > cb: print("Dasha") ...
output
1
82,289
1
164,579
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free tim...
instruction
0
82,290
1
164,580
Tags: implementation, math Correct Solution: ``` a,b = input().split(" ") a,b = int(a),int(b) c=a-b if(a%c == 0 and b%c == 0): print("Equal") elif(a>b): print("Masha") else: print("Dasha") # Made By Mostafa_Khaled ```
output
1
82,290
1
164,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,291
1
164,582
Yes
output
1
82,291
1
164,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,292
1
164,584
Yes
output
1
82,292
1
164,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,293
1
164,586
Yes
output
1
82,293
1
164,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,294
1
164,588
Yes
output
1
82,294
1
164,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,295
1
164,590
No
output
1
82,295
1
164,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,296
1
164,592
No
output
1
82,296
1
164,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,297
1
164,594
No
output
1
82,297
1
164,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other...
instruction
0
82,298
1
164,596
No
output
1
82,298
1
164,597
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,777
1
165,554
Tags: constructive algorithms, dfs and similar Correct Solution: ``` from collections import Counter from sys import stdin input = stdin.readline for _ in range(int(input())): n = int(input()) a = [int(x) for x in input().split()] d = {} c = Counter() for i, e in enumerate(a, start=1): c[...
output
1
82,777
1
165,555
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,778
1
165,556
Tags: constructive algorithms, dfs and similar Correct Solution: ``` for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) if len(set(a)) == 1: print("NO") else: print("YES") ind1 = 0 a1 = a[0] for i in range(1, n): if a[i]...
output
1
82,778
1
165,557
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,779
1
165,558
Tags: constructive algorithms, dfs and similar Correct Solution: ``` import sys import math from collections import defaultdict,Counter # input=sys.stdin.readline # def print(x): # sys.stdout.write(str(x)+"\n") # sys.stdout=open("CP1/output.txt",'w') # sys.stdin=open("CP1/input.txt",'r') import os import sys fro...
output
1
82,779
1
165,559
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,780
1
165,560
Tags: constructive algorithms, dfs and similar Correct Solution: ``` from sys import stdin,stdout from collections import defaultdict ans = [] def main(): n = int(stdin.readline()) arr = list(map(int,stdin.readline().split())) dictt = defaultdict(list) semians = [] for i in range(n): dictt...
output
1
82,780
1
165,561
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,781
1
165,562
Tags: constructive algorithms, dfs and similar Correct Solution: ``` for _ in range(int(input()) if True else 1): n = int(input()) a = list(map(int, input().split())) if len(set(a)) == 1: print("NO") continue print("YES") p = list(set(a)) i1 = a.index(p[0]) i2 = a.index(p[1])...
output
1
82,781
1
165,563
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,782
1
165,564
Tags: constructive algorithms, dfs and similar Correct Solution: ``` def district_connect(arr): if len(set(arr))==1: print("NO") return [] l = [] k = arr[0] for i in arr: if i!=k: index = arr.index(i) break for i in range(1,len(arr)): if arr[i]...
output
1
82,782
1
165,565
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,783
1
165,566
Tags: constructive algorithms, dfs and similar Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Wed Oct 21 01:51:10 2020 @author: Dark Soul """ t=int(input('')) for _ in range(t): n=int(input('')) arr=list(map(int,input().split())) sol=[] for i in range(n): sol.append([arr[i],i+1])...
output
1
82,783
1
165,567
Provide tags and a correct Python 3 solution for this coding contest problem. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two dis...
instruction
0
82,784
1
165,568
Tags: constructive algorithms, dfs and similar Correct Solution: ``` for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) c = {} for j, i in enumerate(a): c[i] = c.get(i, []) + [j+1] x = list(c.values()) if len(x) == 1: print('NO') continu...
output
1
82,784
1
165,569
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,785
1
165,570
Yes
output
1
82,785
1
165,571
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,786
1
165,572
Yes
output
1
82,786
1
165,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,787
1
165,574
Yes
output
1
82,787
1
165,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,788
1
165,576
Yes
output
1
82,788
1
165,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,789
1
165,578
No
output
1
82,789
1
165,579
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,790
1
165,580
No
output
1
82,790
1
165,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,791
1
165,582
No
output
1
82,791
1
165,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other. You are the mayor of the city and want to build n-1 ...
instruction
0
82,792
1
165,584
No
output
1
82,792
1
165,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Good old Berland has n cities and m roads. Each road connects a pair of distinct cities and is bidirectional. Between any pair of cities, there is at most one road. For each road, we know its le...
instruction
0
82,912
1
165,824
No
output
1
82,912
1
165,825
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Good old Berland has n cities and m roads. Each road connects a pair of distinct cities and is bidirectional. Between any pair of cities, there is at most one road. For each road, we know its le...
instruction
0
82,913
1
165,826
No
output
1
82,913
1
165,827