message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide a correct Python 3 solution for this coding contest problem. There are N people living on a number line. The i-th person lives at coordinate X_i. You are going to hold a meeting that all N people have to attend. The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordina...
instruction
0
18,312
14
36,624
"Correct Solution: ``` n = int(input()) x = list(map(int, input().split())) print(sum((i-int(sum(x)/n + 0.5))**2 for i in x)) ```
output
1
18,312
14
36,625
Provide a correct Python 3 solution for this coding contest problem. There are N people living on a number line. The i-th person lives at coordinate X_i. You are going to hold a meeting that all N people have to attend. The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordina...
instruction
0
18,313
14
36,626
"Correct Solution: ``` N = int(input()) l = list(map(int, input().split())) ans = 0 ave = round(sum(l)/N) for i in l: ans += (i-ave)**2 print(ans) ```
output
1
18,313
14
36,627
Provide a correct Python 3 solution for this coding contest problem. There are N people living on a number line. The i-th person lives at coordinate X_i. You are going to hold a meeting that all N people have to attend. The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordina...
instruction
0
18,314
14
36,628
"Correct Solution: ``` N = int(input()) X = list(map(int,input().split())) P = int(sum(X)/N+0.5) print(sum(map(lambda x_i: (x_i-P)**2, X))) ```
output
1
18,314
14
36,629
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,688
14
37,376
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` #!/usr/bin/env pypy3 from sys import stdin, stdout import heapq def input(): return stdin.readline().strip() def ans(both, alice_only, bob_only, neither, M, K): both_fc = [b[0] for b in both] nei...
output
1
18,688
14
37,377
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,689
14
37,378
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` import sys input = sys.stdin.readline INF = 10 ** 18 n, m, k = map(int, input().split()) B = [tuple(map(int, input().split())) for _ in range(n)] GB = [] AB = [] BB = [] RB = [] for i, (t, a, b) in enumerate(B...
output
1
18,689
14
37,379
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,690
14
37,380
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` import sys input = sys.stdin.readline INF = 10 ** 18 n, m, k = map(int, input().split()) B = sorted((tuple(map(int, input().split())) + (i,) for i in range(n)), key=lambda v: v[0]) GB, AB, BB, RB = ([] for _ in...
output
1
18,690
14
37,381
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,691
14
37,382
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` import bisect import sys import math input = sys.stdin.readline import functools import heapq from collections import defaultdict ############ ---- Input Functions ---- ############ def inp(): return(int(i...
output
1
18,691
14
37,383
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,692
14
37,384
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` #import math #from functools import lru_cache import heapq #from collections import defaultdict #from collections import Counter #from collections import deque #from sys import stdout #from sys import setrecursio...
output
1
18,692
14
37,385
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,693
14
37,386
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` line = input() n, m, k = [int(i) for i in line.split(' ')] books, allL, aliceL, bobL, other =list(range(1, n + 1)), [], [], [], [] ts = [[] for _ in range(n + 1)] for i in range(n): line = input() t, a, ...
output
1
18,693
14
37,387
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,694
14
37,388
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` import sys input = sys.stdin.readline INF = 10 ** 18 n, m, k = map(int, input().split()) B = [tuple(map(int, input().split())) for _ in range(n)] GB = [] AB = [] BB = [] RB = [] for i, (t, a, b) in enumerate(B...
output
1
18,694
14
37,389
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they h...
instruction
0
18,695
14
37,390
Tags: data structures, greedy, implementation, sortings, ternary search, two pointers Correct Solution: ``` n,m,k = map(int,input().split()) ab = [] a = [] b = [] other = [] l = [list(map(int,input().split())) for i in range(n)] for i in range(n): t,c,d = l[i] if c and d == 0: a.append([t,i+1]) elif...
output
1
18,695
14
37,391
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,696
14
37,392
Yes
output
1
18,696
14
37,393
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,697
14
37,394
Yes
output
1
18,697
14
37,395
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,698
14
37,396
Yes
output
1
18,698
14
37,397
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,699
14
37,398
Yes
output
1
18,699
14
37,399
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,700
14
37,400
No
output
1
18,700
14
37,401
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,701
14
37,402
No
output
1
18,701
14
37,403
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,702
14
37,404
No
output
1
18,702
14
37,405
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Easy and hard versions are actually different problems, so read statements of both problems completely and carefully. Summer vacation has started so Alice and Bob want to play and joy, but... T...
instruction
0
18,703
14
37,406
No
output
1
18,703
14
37,407
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,933
14
37,866
Tags: greedy, implementation, sortings Correct Solution: ``` n = int(input()) a = input().split() for i in range(n): a[i] = int(a[i]) a.sort() s = 0 k = 0 for i in a: if i >= s: k += 1 s = s + i print(k) ```
output
1
18,933
14
37,867
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,934
14
37,868
Tags: greedy, implementation, sortings Correct Solution: ``` n=int(input()) a=sorted(list(map(int,input().split()))) sum=0 c=0 for i in a: if i>=sum: sum+=i c+=1 print(c) ```
output
1
18,934
14
37,869
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,935
14
37,870
Tags: greedy, implementation, sortings Correct Solution: ``` n=int(input()) a=sorted(map(int,input().split())) r,q=0,0 for i in a: if i>=r: q+=1 r+=i print(q) ```
output
1
18,935
14
37,871
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,936
14
37,872
Tags: greedy, implementation, sortings Correct Solution: ``` input() c=ans=0 s=sorted(map(int,input().split())) for i in s: if i>=c:ans+=1;c+=i print(ans) ```
output
1
18,936
14
37,873
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,937
14
37,874
Tags: greedy, implementation, sortings Correct Solution: ``` import sys n = int(input()) t = sorted(list(map(int, sys.stdin.readline().split()))) tmp = 0 ans = 0 for ti in t: if ti >= tmp: ans += 1 tmp += ti print(ans) ```
output
1
18,937
14
37,875
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,938
14
37,876
Tags: greedy, implementation, sortings Correct Solution: ``` import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log, pi, sin from collections import defaultdict as dd, deque, Counter as C from it...
output
1
18,938
14
37,877
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,939
14
37,878
Tags: greedy, implementation, sortings Correct Solution: ``` n = int(input()) c = [int(x) for x in input().split()] c.sort() s = 0 k = 0 for i in c: if s <= i: k += 1 s += i #print(c, d, s) print(k) ```
output
1
18,939
14
37,879
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more ...
instruction
0
18,940
14
37,880
Tags: greedy, implementation, sortings Correct Solution: ``` n = int(input()) list_in = input().split() for i in range(n): list_in[i] = int(list_in[i]) list_in = sorted(list_in) m = 0 sprt = 0 best = 1 sprt += list_in[0]-best list_in.pop(0) m += 1 while list_in != []: if list_in[0] >= best+sprt: ...
output
1
18,940
14
37,881
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,941
14
37,882
Yes
output
1
18,941
14
37,883
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,942
14
37,884
Yes
output
1
18,942
14
37,885
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,943
14
37,886
Yes
output
1
18,943
14
37,887
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,944
14
37,888
Yes
output
1
18,944
14
37,889
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,945
14
37,890
No
output
1
18,945
14
37,891
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,946
14
37,892
No
output
1
18,946
14
37,893
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,947
14
37,894
No
output
1
18,947
14
37,895
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person wil...
instruction
0
18,948
14
37,896
No
output
1
18,948
14
37,897
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,075
14
38,150
Tags: implementation Correct Solution: ``` n,p,l,r = map(int,input().split()) if p>r and l!=1: print(p-l+2) elif p>r: print(p-r+1) elif p<l and r!=n: print(r-p+2) elif p<l: print(l-p+1) elif n-r >0 and l > 1: print(min(r-p,p-l)+r-l+2) elif n-r>0 : print(r-p+1) elif l>1: print(p-l+1) else: ...
output
1
19,075
14
38,151
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,076
14
38,152
Tags: implementation Correct Solution: ``` n,pos,l,r=list(map(int,input().split())) count=0 if l<=pos<=r: if r<n and l>1: x=min(pos-l,r-pos) count+=x count+=(r-l) count+=2 elif r<n and l==1: count+=(r-pos) count+=1 elif r==n and l>1: count+=(pos-l) count+=1 elif pos>r: count+=pos-r count+=1 if ...
output
1
19,076
14
38,153
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,077
14
38,154
Tags: implementation Correct Solution: ``` n,pos,l,r=map(int,input().split()) if l>1: if r<n: if pos>=int((l+r)/2)+((l+r)%2): print(abs(r-pos)+r-l+2) else: print(abs(l-pos)+r-l+2) elif r==n: print(abs(l-pos)+1) elif l==1: if r<n: print(...
output
1
19,077
14
38,155
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,078
14
38,156
Tags: implementation Correct Solution: ``` n,pos,l,r=map(int,input().split()) if l==1 and r==n: ans=0 elif l==1: ans=abs(r-pos)+1 elif r==n: ans=abs(l-pos)+1 else: ans=min(abs(l-pos),abs(r-pos))+r-l+2 print(ans) ```
output
1
19,078
14
38,157
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,079
14
38,158
Tags: implementation Correct Solution: ``` import sys n, pos, l, r = map(int, input().split()) if l == 1 and r == n: print(0) elif l == 1: print(abs(r - pos) + 1) elif r == n: print(abs(l - pos) + 1) else: print(min( abs(l - pos) + abs(r - l) + 2, abs(r - pos) + abs(r - l) + 2 )) ...
output
1
19,079
14
38,159
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,080
14
38,160
Tags: implementation Correct Solution: ``` n, pos, l, r = [int(x) for x in input().split()] cl = l > 1 cr = r < n if not(cl) and not(cr): print(0) elif cl and not(cr): print(abs(pos - l) + 1) elif not(cl) and cr: print(abs(pos - r) + 1) else: if pos <= l: print(abs(pos - r) + 2) elif pos >...
output
1
19,080
14
38,161
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,081
14
38,162
Tags: implementation Correct Solution: ``` n, pos, l, r = map(int, input().split()) if l==1 and r==n: print(0) elif l==1 and r!=n: print(abs(r-pos)+1) elif l!=1 and r==n: print(abs(l-pos)+1) else: print((r-l)+min(abs(l-pos), abs(r-pos))+2) ```
output
1
19,081
14
38,163
Provide tags and a correct Python 3 solution for this coding contest problem. Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) fo...
instruction
0
19,082
14
38,164
Tags: implementation Correct Solution: ``` n, pos, l, r = map(int, input().split()) def solve(n,pos,l,r): if l == 1 and r == n: return 0 elif l == 1: return abs(pos-r)+1 elif r == n: return abs(pos-l)+1 else: if l <= pos and pos <= r: return abs(r-l) + min(ab...
output
1
19,082
14
38,165
Provide tags and a correct Python 3 solution for this coding contest problem. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a...
instruction
0
19,574
14
39,148
Tags: combinatorics, math Correct Solution: ``` import math n,m,t=list(map(int,input().split())) sum1=0 x=4 y=n while t-x>m: x=x+1 for i in range(x,y+1): if t-i<1: break sum1=sum1+(math.factorial(n)*math.factorial(m))//(math.factorial(i)*math.factorial(n-i)*math.factorial(t-i)*math.factorial(m-(t-i))) print(int(su...
output
1
19,574
14
39,149
Provide tags and a correct Python 3 solution for this coding contest problem. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a...
instruction
0
19,575
14
39,150
Tags: combinatorics, math Correct Solution: ``` #precalculations fact = [0]*(101) fact[0]=fact[1]=1 for i in range(2,101): fact[i]=fact[i-1]*i n,m,t = map(int,input().split()) ans = 0 if(n>m): a = t-1 b = 1 while(a>=4 and b<=m): d = fact[n]//(fact[n-a]*fact[a]) e = fact[m]//(fact[m-b]*...
output
1
19,575
14
39,151
Provide tags and a correct Python 3 solution for this coding contest problem. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a...
instruction
0
19,576
14
39,152
Tags: combinatorics, math Correct Solution: ``` fact = [] fact.append(1) fact.append(1) for i in range(2,31): fact.append(fact[i-1]*i) def ncr(n,r): if r>n: return 0 if r==n: return 1 return fact[n]//(fact[n-r]*fact[r]) n,m,t = input().split() n = int(n) m = int(m) t = int(t) if n<4 or m<1 or t<5: print("...
output
1
19,576
14
39,153
Provide tags and a correct Python 3 solution for this coding contest problem. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a...
instruction
0
19,577
14
39,154
Tags: combinatorics, math Correct Solution: ``` n,m,t = map(int,input().split(' ')) result = 0 saida = 0 val = 4 def soma(n, m, result): result = 1 for i in range(m): result *= int((n - i)) result /= int((i + 1)) return int(result) while(val <= t-1): saida += soma(n,val,result) * soma(m,t - val,result...
output
1
19,577
14
39,155
Provide tags and a correct Python 3 solution for this coding contest problem. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a...
instruction
0
19,578
14
39,156
Tags: combinatorics, math Correct Solution: ``` from math import factorial as f def C(x,y): return f(x) // (f(y)*f(max(x-y,0))) n,m,t=map(int, input().split()) print(int(sum(C(n,i)*C(m,t-i) for i in range(4,t)))) ```
output
1
19,578
14
39,157
Provide tags and a correct Python 3 solution for this coding contest problem. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a...
instruction
0
19,579
14
39,158
Tags: combinatorics, math Correct Solution: ``` def fact(n): if n==0: return 1 else: return n*fact(n-1) def comb(k,n): c=fact(n) d=fact(n-k) f=fact(k) f=f*d return int(c/f) n,m,t=map(int,input().split()) t=t-5 if t==0: print(comb(4,n)*comb(1,m)) else: k=4+t s=0 h=1 if k>n...
output
1
19,579
14
39,159
Provide tags and a correct Python 3 solution for this coding contest problem. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a...
instruction
0
19,580
14
39,160
Tags: combinatorics, math Correct Solution: ``` from math import factorial def permut(n,k): s=factorial(n)//(factorial(n-k)*factorial(k)) return s while(1): try: n,m,t=map(int,input().split()) q,summ=0,0 for i in range(4,n+1): for j in range(1,m+1): if i+j...
output
1
19,580
14
39,161