message
stringlengths
2
67k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
463
109k
cluster
float64
19
19
__index_level_0__
int64
926
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k. During each turn Vova can choos...
instruction
0
97,021
19
194,042
Tags: binary search, math Correct Solution: ``` for q in range(int(input())): k,n,a,b=map(int,input().split(" ")) rem=k-n*b if rem<=0: print(-1) else: val=(rem-1)//(a-b) if val>n: print(n) else: print(val) ```
output
1
97,021
19
194,043
Provide tags and a correct Python 3 solution for this coding contest problem. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k. During each turn Vova can choos...
instruction
0
97,022
19
194,044
Tags: binary search, math Correct Solution: ``` def f(ans, k, b, n, a): works = True r = k if ans > n: works = False else: if r > a * ans: r -= a * ans if not (((r - 1) // b) >= n - ans and r > b * (n - ans)): works = False else: ...
output
1
97,022
19
194,045
Provide tags and a correct Python 3 solution for this coding contest problem. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k. During each turn Vova can choos...
instruction
0
97,023
19
194,046
Tags: binary search, math Correct Solution: ``` #!/usr/bin/env python3 from sys import stdin import math def solve(tc): k, n, a, b = map(int, stdin.readline().split()) if k<=b*n: print(-1) return r = (k - (b * n)) // (a - b) if (k-(b*n)) % (a-b) == 0: r -= 1 print(min(r,n)...
output
1
97,023
19
194,047
Provide tags and a correct Python 3 solution for this coding contest problem. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k. During each turn Vova can choos...
instruction
0
97,024
19
194,048
Tags: binary search, math Correct Solution: ``` for q in range(int(input())): k, n, a, b = map(int, input().split()) if k <= n * b: print(-1) else: l = 0 r = 10 ** 9 while l + 1 < r: x = (l + r) // 2 if (k - x * a - 1) // b + x >= n: l ...
output
1
97,024
19
194,049
Provide tags and a correct Python 3 solution for this coding contest problem. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k. During each turn Vova can choos...
instruction
0
97,025
19
194,050
Tags: binary search, math Correct Solution: ``` from sys import stdin input = stdin.readline for _ in range(int(input())): k,n,a,b = list(map(int, input().split())) s = b*n if s >= k: print(-1) else: print(min((k-s-1)//(a-b), n)) ```
output
1
97,025
19
194,051
Provide tags and a correct Python 3 solution for this coding contest problem. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k. During each turn Vova can choos...
instruction
0
97,026
19
194,052
Tags: binary search, math Correct Solution: ``` t=int(input('')) for _ in range(t): n,k,a,b=map(int, input().split()) if (k*a)<n: print(k) continue elif n<= k*b: print(-1) continue else: a-=b l=n-(b*k) if l%a==0: print((l//a)-1) else: print(l//a) ```
output
1
97,026
19
194,053
Provide tags and a correct Python 3 solution for this coding contest problem. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k. During each turn Vova can choos...
instruction
0
97,027
19
194,054
Tags: binary search, math Correct Solution: ``` #Anuneet Anand q=int(input()) while q: k,n,a,b=map(int,input().split()) c=0 if k-n*b<=0: c=-1 elif k-n*a>0: c=n else: c=(k-n*b)/(a-b) if int(c)==c: c=int(c)-1 else: c=int(c) print(c) q=q-1 ```
output
1
97,027
19
194,055
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,028
19
194,056
Yes
output
1
97,028
19
194,057
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,029
19
194,058
Yes
output
1
97,029
19
194,059
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,030
19
194,060
Yes
output
1
97,030
19
194,061
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,031
19
194,062
Yes
output
1
97,031
19
194,063
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,032
19
194,064
No
output
1
97,032
19
194,065
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,033
19
194,066
No
output
1
97,033
19
194,067
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,034
19
194,068
No
output
1
97,034
19
194,069
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of t...
instruction
0
97,035
19
194,070
No
output
1
97,035
19
194,071
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The programmers from the R2 company love playing 2048. One day, they decided to invent their own simplified version of this game — 2k on a stripe. Imagine an infinite in one direction stripe, c...
instruction
0
97,327
19
194,654
No
output
1
97,327
19
194,655
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The programmers from the R2 company love playing 2048. One day, they decided to invent their own simplified version of this game — 2k on a stripe. Imagine an infinite in one direction stripe, c...
instruction
0
97,328
19
194,656
No
output
1
97,328
19
194,657
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,345
19
194,690
Tags: greedy, sortings Correct Solution: ``` # -*- coding: utf-8 -*- import sys from heapq import heappush, heappop, heapify def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4...
output
1
97,345
19
194,691
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,346
19
194,692
Tags: greedy, sortings Correct Solution: ``` N = int(input()) ints = list(map(int, input().split())) ints = sorted(ints) cum_sum = [0] * (N+1) for i in range(N): cum_sum[i+1] = cum_sum[i] + ints[i] res = sum(ints) for i in range(1,N): res += ints[i-1] + (cum_sum[-1]-cum_sum[i]) print(res) ```
output
1
97,346
19
194,693
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,347
19
194,694
Tags: greedy, sortings Correct Solution: ``` from collections import Counter import string import bisect #import random import math import sys # sys.setrecursionlimit(10**6) from fractions import Fraction def array_int(): return [int(i) for i in sys.stdin.readline().split()] def vary(arrber_of_variables): if a...
output
1
97,347
19
194,695
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,348
19
194,696
Tags: greedy, sortings Correct Solution: ``` import itertools input() a = list(map(int, str.split(input()))) a.sort(reverse=True) print(sum(itertools.accumulate(a)) + sum(a) - max(a)) ```
output
1
97,348
19
194,697
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,349
19
194,698
Tags: greedy, sortings Correct Solution: ``` import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) a.sort() ans = n*a[-1] for i in range(n-1): ans += (i+2)*a[i] print(ans) ```
output
1
97,349
19
194,699
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,350
19
194,700
Tags: greedy, sortings Correct Solution: ``` n = int(input()) num = list(map(int, input().split())) num.sort(reverse=True) psum = [0]*n psum[0] = num[0] for i in range(1, n): psum[i] = psum[i-1]+num[i] print(sum(psum[1:])+psum[n-1]) ```
output
1
97,350
19
194,701
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,351
19
194,702
Tags: greedy, sortings Correct Solution: ``` def main(): n = int(input()) seq = [int(c) for c in input().split()] if n == 1: print(seq[0]) return seq.sort() s = sum(seq) ans = 2 * s for i in range(n-2): s -= seq[i] ans += s print(ans) if __name__ =...
output
1
97,351
19
194,703
Provide tags and a correct Python 3 solution for this coding contest problem. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this su...
instruction
0
97,352
19
194,704
Tags: greedy, sortings Correct Solution: ``` from heapq import * def main(): n = int(input()) s = [int(a) for a in map(int, input().split())] heapify(s) res = sum(s) ans = res for i in range(n - 1): x = heappop(s) res -= x ans += x + res print(ans) if __name__ == '__...
output
1
97,352
19
194,705
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,353
19
194,706
Yes
output
1
97,353
19
194,707
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,354
19
194,708
Yes
output
1
97,354
19
194,709
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,355
19
194,710
Yes
output
1
97,355
19
194,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,356
19
194,712
Yes
output
1
97,356
19
194,713
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,357
19
194,714
No
output
1
97,357
19
194,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,358
19
194,716
No
output
1
97,358
19
194,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,359
19
194,718
No
output
1
97,359
19
194,719
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks: * Each time Toastman gets a group of numbe...
instruction
0
97,360
19
194,720
No
output
1
97,360
19
194,721
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,377
19
194,754
Tags: greedy, math Correct Solution: ``` m, n = list(map(int, input().split())) print((m * n) // 2) # S_of_deck / S_of_domino ```
output
1
97,377
19
194,755
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,378
19
194,756
Tags: greedy, math Correct Solution: ``` a,b=map(int,input().split()) c=(int(a*b)) d=2 maximum1=(int(c/d)) print(round(maximum1)) ```
output
1
97,378
19
194,757
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,379
19
194,758
Tags: greedy, math Correct Solution: ``` m,n=[int(x) for x in input().split()] if(m%2==0 or n%2==0): if(m%2==0): ans=n*(int(m/2)) else: ans=m*(int(n/2)) else: ans=int((m*n)/2) print(ans) ```
output
1
97,379
19
194,759
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,380
19
194,760
Tags: greedy, math Correct Solution: ``` s= input().split(' ') m = int(s[0]) n = int(s[1]) if m == n == 1: print(0) elif m == 1 or n == 1: print(int(round(m*n/2-0.2))) else: if m%2 == 0 or n%2 == 0: print(int(m*n/2)) else: #m,n le if m>n: m=m-1 print(int(m*n/2+ r...
output
1
97,380
19
194,761
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,381
19
194,762
Tags: greedy, math Correct Solution: ``` def domino(): m,n=map(int,input().split()) return m*n//2 print (domino()) ```
output
1
97,381
19
194,763
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,382
19
194,764
Tags: greedy, math Correct Solution: ``` a = map(int, input().split()) result = 1 for x in a: result *= x print(int(result/2)) ```
output
1
97,382
19
194,765
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,383
19
194,766
Tags: greedy, math Correct Solution: ``` m,n=map(int,input().split()) if n*m %2==0: x=n*m/2 elif m*n%2==1: x=((n*m)-1)/2 print(int(x)) ```
output
1
97,383
19
194,767
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so ...
instruction
0
97,384
19
194,768
Tags: greedy, math Correct Solution: ``` m, n = [int(x) for x in input().strip().split(' ')] print(m * n // 2) ```
output
1
97,384
19
194,769
Provide tags and a correct Python 3 solution for this coding contest problem. The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As one of them loses, his place is taken by the next ra...
instruction
0
97,472
19
194,944
Tags: bitmasks, dp, math, probabilities Correct Solution: ``` import sys n = int(input()) prob = [list(map(float, input().split())) for _ in range(n)] dp = [[0.0]*n for _ in range(1 << n)] dp[1][0] = 1.0 for mask in range(3, 1 << n): for i in range(n): if not (mask & (1 << i)): continue ...
output
1
97,472
19
194,945
Provide tags and a correct Python 3 solution for this coding contest problem. The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As one of them loses, his place is taken by the next ra...
instruction
0
97,474
19
194,948
Tags: bitmasks, dp, math, probabilities Correct Solution: ``` import sys n = int(input()) prob = [list(map(float, input().split())) for _ in range(n)] dp = [[0.0]*(1 << n) for _ in range(n)] dp[0][1] = 1.0 for mask in range(3, 1 << n): for i in range(n): if not (mask & (1 << i)): continue ...
output
1
97,474
19
194,949
Provide tags and a correct Python 3 solution for this coding contest problem. The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As one of them loses, his place is taken by the next ra...
instruction
0
97,475
19
194,950
Tags: bitmasks, dp, math, probabilities Correct Solution: ``` import sys import bisect from bisect import bisect_left as lb input_=lambda: sys.stdin.readline().strip("\r\n") from math import log from math import gcd from math import atan2,acos from random import randint sa=lambda :input_() sb=lambda:int(input_()) sc=la...
output
1
97,475
19
194,951
Provide a correct Python 3 solution for this coding contest problem. 2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As ...
instruction
0
97,623
19
195,246
"Correct Solution: ``` n,a,b=map(int,input().split()) if (b-a-1)%2==1: print((b-a-1)//2+1) else: print(min(a-1,n-b)+1+(b-a-2)//2+1) ```
output
1
97,623
19
195,247
Provide a correct Python 3 solution for this coding contest problem. 2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As ...
instruction
0
97,624
19
195,248
"Correct Solution: ``` n,a,b=map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: print(min(a-1+1+(b-a-1)//2,n-b+1+(n-(a+n-b+1))//2)) ```
output
1
97,624
19
195,249
Provide a correct Python 3 solution for this coding contest problem. 2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As ...
instruction
0
97,625
19
195,250
"Correct Solution: ``` n,a,b = map(int,input().split()) if (b-a)%2==0: print(int((b-a)//2)) else: print(int(min(a-1,n-b)+1+(b-1-a)//2)) ```
output
1
97,625
19
195,251
Provide a correct Python 3 solution for this coding contest problem. 2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As ...
instruction
0
97,626
19
195,252
"Correct Solution: ``` n, a, b = map(int, input().split()) dif = b-a if dif%2 == 0: print(dif//2) else: print(min(a-1, n-b)+1+(b-a-1)//2) ```
output
1
97,626
19
195,253
Provide a correct Python 3 solution for this coding contest problem. 2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As ...
instruction
0
97,627
19
195,254
"Correct Solution: ``` n, a, b = map(int, input().split()) d = b - a print((d % 2 and min(a, n - b + 1)) + d // 2) ```
output
1
97,627
19
195,255
Provide a correct Python 3 solution for this coding contest problem. 2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As ...
instruction
0
97,628
19
195,256
"Correct Solution: ``` n,a,b=map(int,input().split()) print((b-a)//2 if (b-a)%2==0 else min(a-1,n-b)+(b-a)//2+1) ```
output
1
97,628
19
195,257