message
stringlengths
2
20.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
1.95k
109k
cluster
float64
17
17
__index_level_0__
int64
3.91k
217k
Provide tags and a correct Python 3 solution for this coding contest problem. The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, th...
instruction
0
68,633
17
137,266
Tags: greedy, implementation Correct Solution: ``` import random def genTemp(): sl = "" firstTime = True while firstTime or sl in pre or sl in post: sl = "" firstTime = False for i in range(6): sl += chr(random.randint(ord("a"), ord("z"))) return sl n = int(input())...
output
1
68,633
17
137,267
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,869
17
137,738
"Correct Solution: ``` import re n = int(input()) for _ in range(n): dataset = input() stage = 1 while (re.match('\[[0-9]+\]', dataset) is None): iterator = re.finditer('\[([0-9]+\]\[)+[0-9]+\]', dataset) for match in iterator: areas = list(map(int, match.group()[1:-1].split('][...
output
1
68,869
17
137,739
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,870
17
137,740
"Correct Solution: ``` def cost(s): lens = len(s) if lens == 1: return int(s[0]) // 2 + 1 costs = [cost(x) for x in s] costs.sort() return sum(costs[:lens // 2 + 1]) n = int(input()) for _ in range(n): s = input() s = s.replace("][", "],[") s = eval(s) print(cost(s)) ```
output
1
68,870
17
137,741
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,871
17
137,742
"Correct Solution: ``` # -*- coding: utf-8 -*- from sys import setrecursionlimit setrecursionlimit(100000) def cal(L): if type(L[0][0]) == list: L = [[cal(l)*2] for l in L] return sum(sorted([-(-l[0]//2) for l in L])[:-(-len(L)//2)]) for _ in range(int(input())): print(cal(eval(input().replace("][...
output
1
68,871
17
137,743
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,872
17
137,744
"Correct Solution: ``` N=int(input()) for i in range(N): s__=input() s_="" s=[] #step1 for i in range(len(s__)): if s__[i].isdigit(): s_+=s__[i] else: s_+=" "+s__[i]+" " s_=s_.split(" ") for i in range(len(s_)): if s_[i]!='': s.appe...
output
1
68,872
17
137,745
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,873
17
137,746
"Correct Solution: ``` N=int(input()) for i in range(N): S=input() stack=[] num=[0] st="" N=len(S) for j in range(N): i=S[j] #print(num) #print(stack) #print('"'+i+'"',st) if i=="[": stack.append(0) num.append(0) elif i=="]"...
output
1
68,873
17
137,747
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,874
17
137,748
"Correct Solution: ``` def AC(): def solve(s): if s.count('[')==1: return int(s[1:-1]) elif '][' in s and ']][[' not in s: tmp = sorted(map(int,s[2:-2].split(']['))) ans=0 for i in range(len(tmp)//2+1): ans+=tmp[i]//2+1 retu...
output
1
68,874
17
137,749
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,875
17
137,750
"Correct Solution: ``` #2005_c """ n = int(input()) k = list("mcxi") for i in range(n): d = {"m":0,"c":0,"x":0,"i":0} a,b = input().split() a = list(a) b = list(b) a.insert(0,1) b.insert(0,1) for j in range(1,len(a)): if a[j] in k: if a[j-1] in k: d[a[j]]...
output
1
68,875
17
137,751
Provide a correct Python 3 solution for this coding contest problem. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electo...
instruction
0
68,876
17
137,752
"Correct Solution: ``` import re n = int(input()) for _ in range(n): dataset = input() stage = 1 while (re.match('\[[0-9]+\]', dataset) is None): iterator = re.finditer('\[([0-9]+\]\[)+[0-9]+\]', dataset) minimum_votes = [] for i, match in enumerate(iterator): areas = li...
output
1
68,876
17
137,753
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first ...
instruction
0
68,877
17
137,754
Yes
output
1
68,877
17
137,755
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first ...
instruction
0
68,878
17
137,756
Yes
output
1
68,878
17
137,757
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first ...
instruction
0
68,879
17
137,758
Yes
output
1
68,879
17
137,759
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first ...
instruction
0
68,880
17
137,760
Yes
output
1
68,880
17
137,761
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first ...
instruction
0
68,881
17
137,762
No
output
1
68,881
17
137,763
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,055
17
138,110
Tags: greedy, implementation, sortings Correct Solution: ``` import math def inp_n(): return int(input()) def inp_list(): return list(map(int, input().split())) def inp_mul_num(): return map(int, input().split()) def is_odd(n): if n & 1: return True return False for _ in range(inp_n())...
output
1
69,055
17
138,111
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,056
17
138,112
Tags: greedy, implementation, sortings Correct Solution: ``` t = int(input()) while int(t)>0: n = int(input()) q = input() a = q.split() for i in range(0, n*2): a[i] = int(a[i]) a.sort() s = a[n]-a[n-1] print(s) t -= 1 ```
output
1
69,056
17
138,113
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,057
17
138,114
Tags: greedy, implementation, sortings Correct Solution: ``` for i in range(int(input())): n = int(input()) nums = sorted([int(a) for a in input().split()]) print(nums[n]-nums[n-1]) ```
output
1
69,057
17
138,115
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,058
17
138,116
Tags: greedy, implementation, sortings Correct Solution: ``` """ Author : thekushalghosh Team : CodeDiggers """ import sys,math input = sys.stdin.readline ############ ---- USER DEFINED INPUT FUNCTIONS ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split())...
output
1
69,058
17
138,117
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,059
17
138,118
Tags: greedy, implementation, sortings Correct Solution: ``` import sys t=int(input()) for i in range(t): n=int(input()) arr=list(eval(input().replace(' ',','))) if type(arr) is int: arr=[arr] arr.sort() print(arr[n]-arr[n-1]) sys.stdout.flush() ```
output
1
69,059
17
138,119
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,060
17
138,120
Tags: greedy, implementation, sortings Correct Solution: ``` import sys T = int(sys.stdin.readline().strip()) for t in range (0, T): n = int(sys.stdin.readline().strip()) a = list(map(int, sys.stdin.readline().strip().split())) a.sort() print(a[n]-a[n-1]) ```
output
1
69,060
17
138,121
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,061
17
138,122
Tags: greedy, implementation, sortings Correct Solution: ``` from sys import stdin from collections import deque from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin def ii(): return int(stdin.readline()) def fi(): return float(stdin.readline()) def mi(): return map(int, stdin.readline()....
output
1
69,061
17
138,123
Provide tags and a correct Python 3 solution for this coding contest problem. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median ...
instruction
0
69,062
17
138,124
Tags: greedy, implementation, sortings Correct Solution: ``` # Problem: B # Date: February 11 2020 # Author: OBJECT.705X t=int(input()) while t: n=int(input()) a=[int(x) for x in input().split()] a=sorted(a) print(a[n]-a[n-1]) t-=1 ```
output
1
69,062
17
138,125
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,063
17
138,126
Yes
output
1
69,063
17
138,127
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,064
17
138,128
Yes
output
1
69,064
17
138,129
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,065
17
138,130
Yes
output
1
69,065
17
138,131
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,066
17
138,132
Yes
output
1
69,066
17
138,133
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,067
17
138,134
No
output
1
69,067
17
138,135
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,068
17
138,136
No
output
1
69,068
17
138,137
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,069
17
138,138
No
output
1
69,069
17
138,139
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements...
instruction
0
69,070
17
138,140
No
output
1
69,070
17
138,141
Provide tags and a correct Python 3 solution for this coding contest problem. Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that...
instruction
0
69,171
17
138,342
Tags: implementation Correct Solution: ``` n,m = map(int,input().split()) pos,x = m,[] for _ in range(n): a,b = map(int,input().split()) x.append((min(a,b),max(a,b))) x.sort(); l,h = x[0][0],x[0][1] for j in x: if j[0] > pos: if j[0] <= h: pos = j[0] h = j[1] if j[1] < h else...
output
1
69,171
17
138,343
Provide tags and a correct Python 3 solution for this coding contest problem. Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that...
instruction
0
69,172
17
138,344
Tags: implementation Correct Solution: ``` import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def tinput(): return input().split() def rinput(): return map(int, tinput()) def rlinput(): return list(rinput()) n,x0 = rinput() left = [] right ...
output
1
69,172
17
138,345
Provide tags and a correct Python 3 solution for this coding contest problem. Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that...
instruction
0
69,173
17
138,346
Tags: implementation Correct Solution: ``` n,k=map(int, input().split()) minn=-1; maxx=1001 for _ in range(n): x,y=sorted(map(int, input().split())) if x>minn: minn=x if y<maxx: maxx=y if minn<=k<=maxx: print(0) elif maxx<minn: print(-1) else: print(min(abs(minn-k), abs(k-maxx))) ```
output
1
69,173
17
138,347
Provide tags and a correct Python 3 solution for this coding contest problem. Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that...
instruction
0
69,175
17
138,350
Tags: implementation Correct Solution: ``` # Getting Segment Count and initial Location. count,loc = tuple(map(int,input().split(' '))) # Method to determine if intersection is possible. def empty_intersection(tOne,tTwo): return True # Method to Perform intersection of two segements. def and_segments(t0,t1): an...
output
1
69,175
17
138,351
Provide tags and a correct Python 3 solution for this coding contest problem. Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that...
instruction
0
69,176
17
138,352
Tags: implementation Correct Solution: ``` """ Template written to be used by Python Programmers. Use at your own risk!!!! Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces). """ import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappus...
output
1
69,176
17
138,353
Provide tags and a correct Python 3 solution for this coding contest problem. Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that...
instruction
0
69,177
17
138,354
Tags: implementation Correct Solution: ``` n,x=[int(x) for x in input().split()] a,b=[int(x) for x in input().split()] l,r=min(a,b),max(a,b) # print(l,r) f=0 for i in range(n-1): # print(l,r) a,b=[int(x) for x in input().split()] l2,r2=min(a,b),max(a,b) if r2<l or r<l2: f=1 break ...
output
1
69,177
17
138,355
Provide tags and a correct Python 3 solution for this coding contest problem. Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that...
instruction
0
69,178
17
138,356
Tags: implementation Correct Solution: ``` n,x=map(int,input().split()) li=[] pos=[x] flag=0 for i in range(n): a=list(map(int,input().split())) l,r=min(a[0],a[1]),max(a[0],a[1]) if l<=x and r>=x: li.append([l,r]) elif x<l: x=l pos.append(x) for i in li: l,r=i if x<l or r<x: flag=1 break li....
output
1
69,178
17
138,357
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,692
17
139,384
"Correct Solution: ``` n = int(input()) ma = 20 mv = 0 while n > 0: a,v = map(int,input().split()) if mv < v: ma,mv = a,v elif mv == v and ma >= a: ma,mv = a,v n -= 1 print(ma,mv) ```
output
1
69,692
17
139,385
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,693
17
139,386
"Correct Solution: ``` # AOJ 0095 Surf Smelt Fishing Contest # Python3 2018.6.21 bal4u n = int(input()) tbl = [0]*(n+1) vmax = 0 for i in range(n): a, v = list(map(int, input().split())) tbl[a] += v if tbl[a] > vmax: vmax = tbl[a] for i in range(1, n+1): if tbl[i] == vmax: print(i, vmax) break ```
output
1
69,693
17
139,387
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,694
17
139,388
"Correct Solution: ``` from operator import itemgetter n = int(input()) rs = [list(map(int,input().split())) for i in range(n)] rs = sorted(rs,key=itemgetter(0)) print(' '.join(map(str, sorted(rs, key=itemgetter(1),reverse=True)[0]))) ```
output
1
69,694
17
139,389
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,695
17
139,390
"Correct Solution: ``` d={} for _ in[0]*int(input()): a,v=map(int,input().split()) d.setdefault(v,[]) d[v]+=[a] m=max(d) print(min(d[m]),m) ```
output
1
69,695
17
139,391
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,696
17
139,392
"Correct Solution: ``` N = int(input()) maxA = -1 maxV = -1 for l in range(N): a,v = [int(i) for i in input().split()] if v > maxV: maxV = v maxA = a elif v == maxV: maxA = min(a, maxA) print(maxA, maxV) ```
output
1
69,696
17
139,393
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,697
17
139,394
"Correct Solution: ``` a={} for i in range(int(input())): b,c=map(int,input().split()) a[b]=c d=max(a.items(),key=lambda x:x[1]) print(*d) ```
output
1
69,697
17
139,395
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,698
17
139,396
"Correct Solution: ``` print(*sorted([list(map(int, input().split())) for _ in [0]*int(input())], key=lambda x:(-x[1],x[0]))[0]) ```
output
1
69,698
17
139,397
Provide a correct Python 3 solution for this coding contest problem. A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish cau...
instruction
0
69,699
17
139,398
"Correct Solution: ``` # -*- coding: utf-8 -*- import sys import os import math N = int(input()) A = [None] * N for i in range(N): id, num = map(int, input().split()) id -= 1 A[id] = num max_value = max(A) max_index = A.index(max_value) print(max_index + 1, max_value) ```
output
1
69,699
17
139,399
Provide tags and a correct Python 3 solution for this coding contest problem. There is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem). Let's simplify this game a bit. Formally, there are n par...
instruction
0
70,060
17
140,120
Tags: implementation Correct Solution: ``` # cook your dish here for i in range(int(input())): n=int(input()) l=list(map(int,input().split())) l1=[0]*(n+1) for j in range(n): l1[l[j]]+=1 ans=0 for j in range(1,n+1): if l1[j]==1: ans=1 num=l.index(j) ...
output
1
70,060
17
140,121
Provide tags and a correct Python 3 solution for this coding contest problem. There is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem). Let's simplify this game a bit. Formally, there are n par...
instruction
0
70,061
17
140,122
Tags: implementation Correct Solution: ``` for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) d = {i:0 for i in a} for i in a: if i not in d: d[i] = 1 d[i] += 1 x = int(1e9) for i,j in zip(d.keys(),d.values()): if j == 1: if i < x: x = i if x == int(1e9): print(-1...
output
1
70,061
17
140,123
Provide tags and a correct Python 3 solution for this coding contest problem. There is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem). Let's simplify this game a bit. Formally, there are n par...
instruction
0
70,062
17
140,124
Tags: implementation Correct Solution: ``` def main(): n = int(input()) counter = dict() numbers = map(int, input().split()) for i, elem in enumerate(numbers): if elem not in counter: counter[elem] = i+1 else: counter[elem] = None result = sorted([(x, i) for (...
output
1
70,062
17
140,125
Provide tags and a correct Python 3 solution for this coding contest problem. There is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem). Let's simplify this game a bit. Formally, there are n par...
instruction
0
70,063
17
140,126
Tags: implementation Correct Solution: ``` #from math import * from bisect import * from collections import * from random import * from decimal import * from random import * import sys input=sys.stdin.readline def inp(): return int(input()) def st(): return input().rstrip('\n') def lis(): return list(map(in...
output
1
70,063
17
140,127
Provide tags and a correct Python 3 solution for this coding contest problem. There is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem). Let's simplify this game a bit. Formally, there are n par...
instruction
0
70,064
17
140,128
Tags: implementation Correct Solution: ``` from collections import Counter def main(): for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) d=dict(Counter(a)) l=[] for i,j in enumerate(a): if(d[j]==1): l.append([j,i]) ...
output
1
70,064
17
140,129