message stringlengths 2 433k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 113 108k | cluster float64 12 12 | __index_level_0__ int64 226 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you b... | instruction | 0 | 108,069 | 12 | 216,138 |
Tags: constructive algorithms, math
Correct Solution:
```
"""
ID: happyn61
LANG: PYTHON3
PROB: loan
"""
#from collections import defaultdict
import sys
import heapq
from collections import deque
#fin = open ('loan.in', 'r')
#fout = open ('loan.out', 'w')
#print(dic["4734"])
def find(parent,i):
if parent[i] != i... | output | 1 | 108,069 | 12 | 216,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you b... | instruction | 0 | 108,070 | 12 | 216,140 |
Tags: constructive algorithms, math
Correct Solution:
```
"""
Code of Ayush Tiwari
Codeforces: servermonk
Codechef: ayush572000
"""
#import sys
#input = sys.stdin.buffer.readline
#Fast IO
import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oc... | output | 1 | 108,070 | 12 | 216,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you b... | instruction | 0 | 108,071 | 12 | 216,142 |
Tags: constructive algorithms, math
Correct Solution:
```
for _ in range(int(input())):
n, k = map(int, input().split())
if n == 1 or n == 2 or n == k:
print(*[i for i in range(1, n+1)])
else:
a = [i+1 for i in range(n-2*(n-k)-1, k)]
a.reverse()
print(*[i+1 for i in range(n-2... | output | 1 | 108,071 | 12 | 216,143 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you b... | instruction | 0 | 108,072 | 12 | 216,144 |
Tags: constructive algorithms, math
Correct Solution:
```
for t in range(int(input())):n,k = map(int,input().split());print(*(list(range(1,k-(n-k))) + list(range(k,k-(n-k)-1,-1))))
``` | output | 1 | 108,072 | 12 | 216,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you b... | instruction | 0 | 108,073 | 12 | 216,146 |
Tags: constructive algorithms, math
Correct Solution:
```
import sys
input = sys.stdin.readline
t=int(input())
for tests in range(t):
n,k=map(int,input().split())
aa=k-(n-k)
#print(aa)
print(*list(range(1,aa))+list(range(k,aa-1,-1)))
``` | output | 1 | 108,073 | 12 | 216,147 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you b... | instruction | 0 | 108,074 | 12 | 216,148 |
Tags: constructive algorithms, math
Correct Solution:
```
import sys
import os
import math
import copy
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permutations,combinations,accumulate
... | output | 1 | 108,074 | 12 | 216,149 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you b... | instruction | 0 | 108,075 | 12 | 216,150 |
Tags: constructive algorithms, math
Correct Solution:
```
T = int(input())
for t in range(T):
n, k = tuple([int(x) for x in input().split()])
last_num = k - (n-k)
result = []
start_reverse = False
cur_num = 1
for i in range(1, k+1):
if i < last_num:
result.append(cur_num)
... | output | 1 | 108,075 | 12 | 216,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,076 | 12 | 216,152 |
Yes | output | 1 | 108,076 | 12 | 216,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,077 | 12 | 216,154 |
Yes | output | 1 | 108,077 | 12 | 216,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,078 | 12 | 216,156 |
Yes | output | 1 | 108,078 | 12 | 216,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,079 | 12 | 216,158 |
Yes | output | 1 | 108,079 | 12 | 216,159 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,080 | 12 | 216,160 |
No | output | 1 | 108,080 | 12 | 216,161 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,081 | 12 | 216,162 |
No | output | 1 | 108,081 | 12 | 216,163 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,082 | 12 | 216,164 |
No | output | 1 | 108,082 | 12 | 216,165 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k β€ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, ... | instruction | 0 | 108,083 | 12 | 216,166 |
No | output | 1 | 108,083 | 12 | 216,167 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is an interactive problem!
Nastia has a hidden permutation p of length n consisting of integers from 1 to n. You, for some reason, want to figure out the permutation. To do that, you can give her an integer t (1 β€ t β€ 2), two different... | instruction | 0 | 108,093 | 12 | 216,186 |
Tags: constructive algorithms, interactive
Correct Solution:
```
import math,sys
## from itertools import permutations, combinations;import heapq,random;
from collections import defaultdict,deque
import bisect as bi
def yes():print('YES')
def no():print('NO')
# sys.stdin=open('input.txt','r');sys.stdout=open('output.tx... | output | 1 | 108,093 | 12 | 216,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,098 | 12 | 216,196 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
def fuk(a):
if a[0]<=a[1]<=a[2]:
return 1
if a[0]>=a[1]>=a[2]:
return 1
return 0
def fukk(a):
if a[0]<=a[1]<=a[2]:
return 1
if a[1]<=a[2]<=a[3]:
return 1
if a[0]<=a[2]<=a[3]:
return ... | output | 1 | 108,098 | 12 | 216,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,099 | 12 | 216,198 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
if i+2 < n:
if a[i] == a[i+1]:
continue
elif a[i] < a[i+1]:
if a[i+1] <= a[i+2]:
... | output | 1 | 108,099 | 12 | 216,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,100 | 12 | 216,200 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq,bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import thre... | output | 1 | 108,100 | 12 | 216,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,101 | 12 | 216,202 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
def is_bad(l):
for i in range(2):
for j in range(i+1,3):
for k in range(j+1,4):
if l[i] >= l[j] >= l[k] or l[i] <= l[j] <= l[k]:
return True
return False
def solve():
n = int(input())
inp = list(map(int,input().split()))
ans =... | output | 1 | 108,101 | 12 | 216,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,102 | 12 | 216,204 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
def is_bad(l):
if l[0]<=l[1]<=l[2] or l[0]>=l[1]>=l[2]:return True
if l[0]<=l[1]<=l[3] or l[0]>=l[1]>=l[3]:return True
if l[0]<=l[2]<=l[3] or l[0]>=l[2]>=l[3]:return True
if l[1]<=l[2]<=l[3] or l[1]>=l[2]>=l[3]:return True
return False
def ... | output | 1 | 108,102 | 12 | 216,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,103 | 12 | 216,206 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.m... | output | 1 | 108,103 | 12 | 216,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,104 | 12 | 216,208 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
import sys
t = int(sys.stdin.readline())
while(t>0):
n = int(sys.stdin.readline())
a = list(map(int, input().split()))
c = 2*n-1
if n<=2:
print(c)
else:
for i in range(n-2):
j = i+1
... | output | 1 | 108,104 | 12 | 216,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
L... | instruction | 0 | 108,105 | 12 | 216,210 |
Tags: brute force, geometry, greedy, implementation
Correct Solution:
```
from collections import *
import os, sys
from io import BytesIO, IOBase
from itertools import combinations
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
... | output | 1 | 108,105 | 12 | 216,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,106 | 12 | 216,212 |
Yes | output | 1 | 108,106 | 12 | 216,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,107 | 12 | 216,214 |
Yes | output | 1 | 108,107 | 12 | 216,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,108 | 12 | 216,216 |
Yes | output | 1 | 108,108 | 12 | 216,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,109 | 12 | 216,218 |
Yes | output | 1 | 108,109 | 12 | 216,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,110 | 12 | 216,220 |
No | output | 1 | 108,110 | 12 | 216,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,111 | 12 | 216,222 |
No | output | 1 | 108,111 | 12 | 216,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,112 | 12 | 216,224 |
No | output | 1 | 108,112 | 12 | 216,225 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form ... | instruction | 0 | 108,113 | 12 | 216,226 |
No | output | 1 | 108,113 | 12 | 216,227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly.
More for... | instruction | 0 | 108,153 | 12 | 216,306 |
Tags: data structures
Correct Solution:
```
import sys
'''
SEGMENT TREE
Assign
'''
class SegmTree():
'''
- modify elements on interval
- get single element
'''
def __init__(self, size):
N = 1
while N < size:
N <<= 1
self.N = N
self.tree = [0] * (2*N)
... | output | 1 | 108,153 | 12 | 216,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a nu... | instruction | 0 | 108,154 | 12 | 216,308 |
No | output | 1 | 108,154 | 12 | 216,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a nu... | instruction | 0 | 108,155 | 12 | 216,310 |
No | output | 1 | 108,155 | 12 | 216,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a nu... | instruction | 0 | 108,156 | 12 | 216,312 |
No | output | 1 | 108,156 | 12 | 216,313 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a nu... | instruction | 0 | 108,157 | 12 | 216,314 |
No | output | 1 | 108,157 | 12 | 216,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,242 | 12 | 216,484 |
Tags: combinatorics, math
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.wri... | output | 1 | 108,242 | 12 | 216,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,243 | 12 | 216,486 |
Tags: combinatorics, math
Correct Solution:
```
def fact(n):
res=1
for i in range(2,n+1):
res=(res*i)%(10**9+7)
return res
def rev(a):
return pow(a,10**9+5,10**9+7)
def c2nn(n):
return (fact(2*n+1)*(rev(fact(n))*rev(fact(n+1))))%(10**9+7)
n=int(input())
print(((c2nn(n-1)*2-n)%(10**9+7... | output | 1 | 108,243 | 12 | 216,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,244 | 12 | 216,488 |
Tags: combinatorics, math
Correct Solution:
```
n,a,b,M,I=int(input()),1,1,1000000007,1000000005
for i in range(1,n):
a=a*i%M
a=pow(a,I,M)
for i in range(n+1,n*2):
b=b*i%M
print(((2*a*b)%M-n)%M)
``` | output | 1 | 108,244 | 12 | 216,489 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,245 | 12 | 216,490 |
Tags: combinatorics, math
Correct Solution:
```
#love python :)
#medo journy to icpc
n = int(input())
m = int(1e9 + 7)
p = 1
for i in range(1, n + 1):
p *= 2 * n - i
p *= pow(i, m - 2, m)
p %= m
print((2 * p - n) % m)
``` | output | 1 | 108,245 | 12 | 216,491 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,246 | 12 | 216,492 |
Tags: combinatorics, math
Correct Solution:
```
def fact(n):
res=1
for i in range(2,n+1):
res=(res*i)%(10**9+7)
return res
def rev(a):
return pow(a,10**9+5,10**9+7)
def c2nn(n):
return fact(2*n)*(rev(fact(n))**2)%(10**9+7)
n=int(input())
print(c2nn(n)-n)
``` | output | 1 | 108,246 | 12 | 216,493 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,247 | 12 | 216,494 |
Tags: combinatorics, math
Correct Solution:
```
MOD=10**9+7
def power(x, a):
if(a==0):
return(1)
z=power(x, a//2)
z=(z*z)%MOD
if(a%2):
z=(z*x)%MOD
return(z)
def fact(n):
factn=1
for i in range(2, n+1):
factn=(factn*i)%MOD
return(factn)
def ncr(n, r):
return((f... | output | 1 | 108,247 | 12 | 216,495 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,248 | 12 | 216,496 |
Tags: combinatorics, math
Correct Solution:
```
prod = 1
n = int(input())
for i in range(n+1, 2*n+1):
prod *= i
prod %= (10**9+7)
for i in range(1,n+1):
prod *= pow(i, 10**9+5, 10**9+7)
prod %= 10**9+7
print((prod-n)%(10**9+7))
``` | output | 1 | 108,248 | 12 | 216,497 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him craz... | instruction | 0 | 108,249 | 12 | 216,498 |
Tags: combinatorics, math
Correct Solution:
```
n = int(input())
m = int(1e9 + 7)
# binom(2n - 1, n)
p = 1
for i in range(1, n + 1):
p *= 2 * n - i
p *= pow(i, m - 2, m)
p %= m
print((2 * p - n) % m)
# Made By Mostafa_Khaled
``` | output | 1 | 108,249 | 12 | 216,499 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at mat... | instruction | 0 | 108,250 | 12 | 216,500 |
Yes | output | 1 | 108,250 | 12 | 216,501 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at mat... | instruction | 0 | 108,251 | 12 | 216,502 |
Yes | output | 1 | 108,251 | 12 | 216,503 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at mat... | instruction | 0 | 108,252 | 12 | 216,504 |
Yes | output | 1 | 108,252 | 12 | 216,505 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at mat... | instruction | 0 | 108,253 | 12 | 216,506 |
Yes | output | 1 | 108,253 | 12 | 216,507 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at mat... | instruction | 0 | 108,254 | 12 | 216,508 |
No | output | 1 | 108,254 | 12 | 216,509 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.