message
stringlengths
2
30.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
237
109k
cluster
float64
10
10
__index_level_0__
int64
474
217k
Provide tags and a correct Python 3 solution for this coding contest problem. 'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 ...
instruction
0
68,483
10
136,966
Tags: greedy, math Correct Solution: ``` n,m = map(int,input().split()) mat = list(map(int,input().split())) auction = list(map(int,input().split())) aucpoint = [mat[i-1] for i in auction] aucpoint.sort(reverse = True) for i in auction: mat[i-1] = 0 s = sum(mat) for point in aucpoint: if s > point: s *=...
output
1
68,483
10
136,967
Provide tags and a correct Python 3 solution for this coding contest problem. 'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 ...
instruction
0
68,484
10
136,968
Tags: greedy, math Correct Solution: ``` # your code goes herefrom collections import defaultdict import bisect from itertools import accumulate, count import os import sys import math from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd...
output
1
68,484
10
136,969
Provide tags and a correct Python 3 solution for this coding contest problem. 'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 ...
instruction
0
68,485
10
136,970
Tags: greedy, math Correct Solution: ``` n, m = list(map(int, input().split())) lst = list(map(int, input().split())) au = list(map(int, input().split())) res = sum(lst) ls = [] for i in range(m): res -= lst[au[i] - 1] ls.append(lst[au[i] - 1]) ls.sort(reverse = True) for i in range(len(ls)): res += max(ls...
output
1
68,485
10
136,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen c...
instruction
0
68,504
10
137,008
Yes
output
1
68,504
10
137,009
Provide tags and a correct Python 3 solution for this coding contest problem. Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to ...
instruction
0
68,570
10
137,140
Tags: geometry Correct Solution: ``` from fractions import Fraction def higher(x1, y1, x2, y2): if x1 == 0: if x2 == 0: return def min_days(p, q, pr): ma = max(a for a, b in pr) mb = max(b for a, b in pr) pr.sort(key=lambda t: (t[0], -t[1])) ch = [(0, mb)] for a, b in pr...
output
1
68,570
10
137,141
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Mo...
instruction
0
68,571
10
137,142
No
output
1
68,571
10
137,143
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Mo...
instruction
0
68,572
10
137,144
No
output
1
68,572
10
137,145
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,708
10
139,416
"Correct Solution: ``` for i in range(1, 101): count = 0 temp = 0 SetCount = 0 try: str1 = input() list1 = str1.split(" ") str2 = input() list2 = str2.split(" ") list2.sort(key=int, reverse=True) for m in range(0, int(list1[0])): if (m+1) % in...
output
1
69,708
10
139,417
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,709
10
139,418
"Correct Solution: ``` # Aizu Problem 0227: Thanksgiving import sys, math, os, bisect # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") while True: n, m = [int(_) for _ in input().split()] if n == m == 0: break prices = sorted([int(_)...
output
1
69,709
10
139,419
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,710
10
139,420
"Correct Solution: ``` while 1: _,m=map(int, input().split()) if m==0:break p=sorted(map(int,input().split()),reverse=1) print(sum(p)-sum(p[m-1::m])) ```
output
1
69,710
10
139,421
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,711
10
139,422
"Correct Solution: ``` while True: n, m = map(int, input().split()) if n == 0: break price = sorted(map(int, input().split()), reverse=True) print(sum(price) - sum(price[m - 1::m])) ```
output
1
69,711
10
139,423
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,712
10
139,424
"Correct Solution: ``` while True: try: n,m = list(map(int,input().split())) if n == 0 and m == 0: break amari = n % m yasai = list(map(int,input().split())) yasai.sort() s = 0 if amari > 0: s = sum(yasai[0:amari]) i = 0 ...
output
1
69,712
10
139,425
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,713
10
139,426
"Correct Solution: ``` while True : n, m = map(int, input().split()) if n == 0 and m == 0 : break p = list(map(int, input().split())) p.sort(reverse=True) cst = 0 for i in range(n) : if (i+1) % m != 0 : cst += p[i] print(cst) ```
output
1
69,713
10
139,427
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,714
10
139,428
"Correct Solution: ``` # -*- coding: utf-8 -*- """ Thanksgiving http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0227 """ import sys def solve(n, m, prices): ans = 0 for i in range(0, n, m): t = prices[i:i+m] if len(t) == m: t[-1] = 0 ans += sum(t) return ans ...
output
1
69,714
10
139,429
Provide a correct Python 3 solution for this coding contest problem. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of thr...
instruction
0
69,715
10
139,430
"Correct Solution: ``` while True: n, m = map(int, input().split()) if n == 0: break plst = sorted(list(map(int, input().split())), reverse=True) s = sum(plst) for i in range(m - 1, n, m): s -= plst[i] print(s) ```
output
1
69,715
10
139,431
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,716
10
139,432
Yes
output
1
69,716
10
139,433
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,717
10
139,434
Yes
output
1
69,717
10
139,435
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,718
10
139,436
Yes
output
1
69,718
10
139,437
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,719
10
139,438
Yes
output
1
69,719
10
139,439
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,720
10
139,440
No
output
1
69,720
10
139,441
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,721
10
139,442
No
output
1
69,721
10
139,443
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,722
10
139,444
No
output
1
69,722
10
139,445
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find ...
instruction
0
69,723
10
139,446
No
output
1
69,723
10
139,447
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,760
10
139,520
"Correct Solution: ``` while True: N,M = map(int,input().split()) if N == 0: break src = [] for i in range(N): d,p = map(int,input().split()) src.append((p,d)) money = M ans = 0 for p,d in sorted(src,reverse=True): guard = min(d,money) money -= guard a...
output
1
69,760
10
139,521
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,761
10
139,522
"Correct Solution: ``` da = list(map(int,input().split())) k = [[0 for i in range(2)]for j in range(10001)] i = 0 su = 0 j = 0 while da[0] + da[1] != 0: i = 0 su = 0 j = 0 for i in range(da[0]): k[i][0],k[i][1] = map(int,input().split()) k = sorted(k,key = lambda x: x[1],reverse = True) while j != i + 1: ...
output
1
69,761
10
139,523
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,762
10
139,524
"Correct Solution: ``` #月曜五時間目 実践的プログラミング #ソートして襲われてはいけない時には、できるだけ護衛をつけるようにすることが最適であるので #ソートした後に左から貪欲に護衛をつけていって、お金がなくなったらそのまま何もしないと言う戦略で正解した。 #時間:15分 #Princess' Marriage #学んだこと:ソートして貪欲に考える #URL: https://onlinejudge.u-aizu.ac.jp/challenges/search/titles/2019 def solve(): N,M=map(int,input().split()) if N==0 and ...
output
1
69,762
10
139,525
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,763
10
139,526
"Correct Solution: ``` while True: n,m=map(int,input().split()) matrix=[] if n==m==0: break else: for i in range(n): D,P=map(int,input().split()) matrix.append([D,P]) matrix.sort(key = lambda x:x[1],reverse=True) i=0 while m>0 and i<=n-1: pp=matrix[i][1] dd=matrix[i...
output
1
69,763
10
139,527
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,764
10
139,528
"Correct Solution: ``` while True: n,m=map(int,input().split()) if n==0 and m==0: break pd=[list(map(int,input().split()))[::-1] for i in range(n)] pd.sort() pd.reverse() ans=0 for i in pd: if m>i[1]: m-=i[1] elif m>0: ans+=i[0]*(i[1]-m) ...
output
1
69,764
10
139,529
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,765
10
139,530
"Correct Solution: ``` while 1: N,M=map(int,input().split()) if not N and not M:break s=0 t=[] for _ in range(N): a,b=map(int,input().split()) s+=a*b t.extend([(b,a)]) for i in sorted(t)[::-1]: if i[1]<=M: s-=i[0]*i[1] M-=i[1] elif ...
output
1
69,765
10
139,531
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,766
10
139,532
"Correct Solution: ``` while True: n, m = (int(s) for s in input().split()) if not n: break sections = sorted(([int(s) for s in input().split()] for i in range(n)), key=lambda x: x[1], reverse=True) for i, (d, p) in enumerate(sections): m -= d if m <= 0: ...
output
1
69,766
10
139,533
Provide a correct Python 3 solution for this coding contest problem. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was co...
instruction
0
69,767
10
139,534
"Correct Solution: ``` b=True while b: n,m=map(int,input().split()) if n==0 and m==0: b=False exit else: l=[] for i in range(n): l1=list(map(int,input().split())) l1=l1[::-1] l.append(l1) l=sorted(l) l=l[::-1] s=0 for i in range(n): s+=l[i][0]*l[i][1] fo...
output
1
69,767
10
139,535
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,768
10
139,536
Yes
output
1
69,768
10
139,537
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,769
10
139,538
Yes
output
1
69,769
10
139,539
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,770
10
139,540
Yes
output
1
69,770
10
139,541
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,771
10
139,542
Yes
output
1
69,771
10
139,543
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,772
10
139,544
No
output
1
69,772
10
139,545
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,773
10
139,546
No
output
1
69,773
10
139,547
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,774
10
139,548
No
output
1
69,774
10
139,549
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimu...
instruction
0
69,775
10
139,550
No
output
1
69,775
10
139,551
Provide a correct Python 3 solution for this coding contest problem. You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have...
instruction
0
69,787
10
139,574
"Correct Solution: ``` import sys from collections import deque readline = sys.stdin.readline write = sys.stdout.write def solve(): N, W = map(int, readline().split()) vs = [0]*N; ws = [0]*N; ms = [0]*N for i in range(N): vs[i], ws[i], ms[i] = map(int, readline().split()) V0 = max(vs) V = ...
output
1
69,787
10
139,575
Provide a correct Python 3 solution for this coding contest problem. You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have...
instruction
0
69,788
10
139,576
"Correct Solution: ``` #!python3 iim = lambda: map(int, input().rstrip().split()) from heapq import heappush, heappop def resolve(): N, W = iim() S = [list(iim()) for i in range(N)] def f1(v, w, m): mm = [] i = 1 while i <= m: yield i m -= i i <...
output
1
69,788
10
139,577
Provide a correct Python 3 solution for this coding contest problem. You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have...
instruction
0
69,789
10
139,578
"Correct Solution: ``` from typing import Tuple, List from heapq import heappush, heappop def max_value(max_weight: int, items: List[Tuple[int, int]]) -> float: def _cost(weight: int, value: int, i: int) -> Tuple[int, float]: # Use value as negative cost for j in range(i, n): v, w = it...
output
1
69,789
10
139,579
Provide a correct Python 3 solution for this coding contest problem. You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have...
instruction
0
69,790
10
139,580
"Correct Solution: ``` def main(): from collections import deque from functools import cmp_to_key N, W, *A = map(int, open(0).read().split()) A = [list(a) for a in zip(*[iter(A)]*3)] Vmax = max(v for v, w, m in A) Vsum = 0 B = [] for i, (v, w, m) in enumerate(A): m_upper = ...
output
1
69,790
10
139,581
Provide a correct Python 3 solution for this coding contest problem. You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have...
instruction
0
69,791
10
139,582
"Correct Solution: ``` #!/usr/bin/env python3 # DPL_1_I: Combinatorial - Knapsack Problem with Limitations II from heapq import heappush, heappop def max_value(t, xs): def _cost(weight, value, i): for j in range(i, n): v, w = xs[j] if weight + w > t: return (-value...
output
1
69,791
10
139,583
Provide tags and a correct Python 3 solution for this coding contest problem. As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the n...
instruction
0
70,730
10
141,460
Tags: brute force, greedy Correct Solution: ``` from sys import stdin from collections import deque n,m = map(int, stdin.readline().split()) pc=dict() ph=dict() costs=[] class Cost: def __init__(self, id, cost, party) -> None: self.id=id self.cost=cost self.party=party self.removed=F...
output
1
70,730
10
141,461
Provide tags and a correct Python 3 solution for this coding contest problem. As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the n...
instruction
0
70,731
10
141,462
Tags: brute force, greedy Correct Solution: ``` #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase import io from fractions import Fraction import collections from itertools import permutations from collections impor...
output
1
70,731
10
141,463
Provide tags and a correct Python 3 solution for this coding contest problem. As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the n...
instruction
0
70,732
10
141,464
Tags: brute force, greedy Correct Solution: ``` n, m = map(int, input().split()) pc = [(0, 0) for _ in range(n)] party_votes = [0 for _ in range(m)] for i in range(n): p, c = map(int, input().split()) pc[i] = (p - 1, c) party_votes[p - 1] += 1 pc.sort(key=lambda x: x[1]) min_cost = 10**20 for votes in...
output
1
70,732
10
141,465
Provide tags and a correct Python 3 solution for this coding contest problem. As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the n...
instruction
0
70,733
10
141,466
Tags: brute force, greedy Correct Solution: ``` from sys import stdin n,m = map(int, stdin.readline().split()) pc=dict() ph=dict() prices = [] for i in range(n): p,c=map(int,stdin.readline().split()) if p != 1: prices.append(c) pc.setdefault(p,[]).append(len(prices)-1) ph[p] = ph.setdefault(...
output
1
70,733
10
141,467
Provide tags and a correct Python 3 solution for this coding contest problem. As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the n...
instruction
0
70,734
10
141,468
Tags: brute force, greedy Correct Solution: ``` import sys import os def solve(m, candidates): n = len(candidates) candidates.sort(key=lambda x: x[1]) party = dict() granted = 0 for i in range(len(candidates)): p = candidates[i][0] c = candidates[i][1] if p == 1: ...
output
1
70,734
10
141,469
Provide tags and a correct Python 3 solution for this coding contest problem. As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the n...
instruction
0
70,735
10
141,470
Tags: brute force, greedy Correct Solution: ``` import sys f=sys.stdin out=sys.stdout n,m=map(int,f.readline().rstrip('\r\n').split()) cos={} cost=[] nvot=[0 for i in range(m+1)] party=[[] for i in range(m+1)] for i in range(n): p,c=map(int,f.readline().rstrip('\r\n').split()) if p!=1: if c in cos: cos[c]+...
output
1
70,735
10
141,471