TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

ans = sys.maxsize
for i in range(1, math.sqrt(n)+1, 1):
    if n % i == 0:
        b = n//i
        tmp_ans = max(len(str(i)), len(str(b)))
        ans = min(ans, tmp_ans)

print(ans)



import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

ans = sys.maxsize
for i in range(1, int(math.sqrt(n))+1, 1):
    if n % i == 0:
        b = n//i
        tmp_ans = max(len(str(i)), len(str(b)))
        ans = min(ans, tmp_ans)

print(ans)



Verdicts: Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
n=int(input())
m=n**(1/2)//1+1
l=[]
for i in range(m+1)[:0:-1]:
  if n%i==0:
    l.append(max(len(str(i)),len(str(n//i))))
  if len(l)==3:
    break
print(min(l))

from math imoprt sqrt
n=int(input())
for i in range(int(sqrt(n)),0,-1):
  if n%i==0:
    print(max(len(str(i)),len(str(n//i))))
    exit()

from math import sqrt
n=int(input())
for i in range(int(sqrt(n)),0,-1):
  if n%i==0:
    print(max(len(str(i)),len(str(n//i))))
    exit()


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import math

N = int(input())

anss = []
for n in range(1,math.ceil(N**0.5)):
	if N % n == 0:
		anss.append(max(len(str(n)),len(str(N//n))))
else:
	anss.append(1)
		
print(min(anss))

import math

N = int(input())

anss = []
for n in range(1,math.ceil(N**0.5)+1):
	if N % n == 0:
		anss.append(max(len(str(n)),len(str(N//n))))

if len(anss) == 0:
	anss.append(1)
		
print(min(anss))

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    return divisors
 
N=int(input()) 
div = make_divisors(N)

A = div[-1]
B = N//A
print(max(len(str(A)),len(str(B))))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    return divisors
 
N=int(input()) 
div = make_divisors(N)

A = div[-1]
B = N//A
print(max(len(str(A)),len(str(B))))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
n=int(input())
ans = []
for i in range(1,int(n**0.5+1)):
  if n%i==0:
    j=n//i
    ans.append(len(str(i))+len(str(j)))
print(max(ans))

n=int(input())
ans = []
for i in range(1,int(n**0.5+1)):
  if n%i==0:
    j=n//i
    ans.append(min(len(str(i)),len(str(j))))
print(min(ans))

n=int(input())
ans = []
for i in range(1,int(n**0.5+1)):
  if n%i==0:
    j=n//i
    ans.append(len(str(i))+len(str(j)))
print(min(ans))

n=int(input())
ans = []
for i in range(1,n**0.5+1):
  if n%i==0:
    j=n//i
    ans.append(len(str(i))+len(str(j)))
print(max(ans))

n=int(input())
ans = []
for i in range(1,int(n**0.5+1)):
  if n%i==0:
    j=n//i
    ans.append(max(len(str(i)),len(str(j))))
print(min(ans))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import math
N = int(input())
c = math.sqrt(N) // 1
while 1:
  if N % c == 0:
    A = int(c)
    B = int(N / c)
    break
  c -= 1
print(A,B)
print(max(len(str(A)),len(str(B)) ))


import math
N = int(input())
c = math.sqrt(N) // 1
while 1:
  if N % c == 0:
    A = int(c)
    B = int(N / c)
    break
  c -= 1
print(max(len(str(A)),len(str(B)) ))


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
from math import sqrt
N = int(input())

div = 1
max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

print(div)
print(max(len(str(div)),len(str(N//div))))

from math import sqrt
N = int(input())

div = 1
max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

#print(div)
print(max(len(str(div)),len(str(N//div))))

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
n = int(input())

ab = []
ans = [1]
for i in range(1, int(n**(0.5))):
	ab.clear()
	if n%i == 0:
		ab.append(i)
		ab.append(int(n/i))
		ans.append(len(str(max(ab))))
			
print(min(ans))


n = int(input())

ab = []
ans = []
for i in range(1, int(n**(0.5))+1):
	ab.clear()
	if n%i == 0:
		ab.append(i)
		ab.append(int(n/i))
		ans.append(len(str(max(ab))))
			
if len(ans) == 0:
	ans.append(1)

print(min(ans))


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):


def findBiggerDigits(n):
    digits = 0
    while n > 0:
        digits += 1
        n //= 10
    return digits 

def main()->None:
    n = int(input())
    sqrt_n = int(n ** (1/2))
    print(sqrt_n)
    range_a = range(1, sqrt_n+1)

    min_value = 1000000
    for a in range_a:
        if n % a != 0: continue
        b = n / a
        a_digits = findBiggerDigits(a)
        b_digits = findBiggerDigits(b)
        max_dig = max(a_digits, b_digits)
        if max_dig < min_value:
            min_value = max_dig

    print(min_value)


if __name__ == "__main__":
    main()



def findBiggerDigits(n):
    digits = 0
    while n > 0:
        digits += 1
        n //= 10
    return digits 

def main()->None:
    n = int(input())
    sqrt_n = int(n ** (1/2))
    range_a = range(1, sqrt_n+1)

    min_value = 1000000
    for a in range_a:
        if n % a != 0: continue
        b = n / a
        a_digits = findBiggerDigits(a)
        b_digits = findBiggerDigits(b)
        max_dig = max(a_digits, b_digits)
        if max_dig < min_value:
            min_value = max_dig

    print(min_value)


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
N = int(input())

def check(a, b):
    return max(len(str(a)), len(str(b)))

n = int(N ** (1/2))
#arr =[]
res = check(1, N)
print('first-res',res,n)
i = 1
while i <= n:
  if N % i == 0:
    res = min(res, check(i,int(N / i)))
#    print(res, i, N/i)
  i += 1

print(res)

N = int(input()) 
n = int(N**.5)
res = len(str(N))
print(n)
for i in range(2,n+1):
    if N % i == 0:
        #print(len(str(i)),len(str(N/i)))
        f = max(len(str(i)),len(str(N//i)))
        res = min(res, f)

print(res)


N = int(input()) 
n = int(N**.5)
res = len(str(N))
for i in range(2,n+1):
    if N % i == 0:
        #print(len(str(i)),len(str(N/i)))
        f = max(len(str(i)),len(str(N//i)))
        res = min(res, f)

print(res)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
n = int(input())
tmp = n
ans = n
y = tmp **0.5
o = int(y // 1)
for i in range(o+1):
    a=i+1
    print("a:"+str(a))
    b=n/(i+1)
    print("b:"+str(b))
    #print("a*b:"+str(a*b))
    if (b.is_integer()==True ):
        kari = max(len(str(a)),len(str(int(b))))
        print("kari:"+str(kari))
        ans = min(ans,kari)
print(ans)

n = int(input())
tmp = n
ans = n
y = tmp **0.5
o = int(y // 1)
for i in range(o+1):
    a=i+1
    #print("a:"+str(a))
    b=n/(i+1)
    #print("b:"+str(b))
    #print("a*b:"+str(a*b))
    if (b.is_integer()==True ):
        kari = max(len(str(a)),len(str(int(b))))
        #print("kari:"+str(kari))
        ans = min(ans,kari)
print(ans)
               

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import sympy
N = int(input())
div_arr = sympy.divisors(N)

if len(div_arr) == 1:
    print(1)
if len(div_arr) == 2:
    ans_num = max(div_arr)
else:
    memo = []
    if len(div_arr) % 2 == 0:
        last_idx = -1
        count = 0
        for i in range(len(div_arr)):
            print(div_arr)
            print(div_arr[i] * div_arr[last_idx])
            count += 1
            if N == div_arr[i] * div_arr[last_idx] and count != len(div_arr) // 2:
                last_idx -= 1
                memo.append(len(str(div_arr[last_idx])))
            else:
                break
    else:
        print(div_arr)
        target_index = len(div_arr) // 2
        memo.append(len(str(div_arr[target_index])))
    print(min(memo))

import sympy
N = int(input())
div_arr = sympy.divisors(N)

if len(div_arr) == 1:
    print(1)
if len(div_arr) == 2:
    ans_num = max(div_arr)
    print(len(str(ans_num)))
else:
    memo = []
    if len(div_arr) % 2 == 0:
        last_idx = -1
        count = 0
        for i in range(len(div_arr)):
            print(div_arr)
            print(div_arr[i] * div_arr[last_idx])
            count += 1
            if N == div_arr[i] * div_arr[last_idx] and count != len(div_arr) // 2:
                last_idx -= 1
                memo.append(len(str(div_arr[last_idx])))
            else:
                break
    else:
        print(div_arr)
        target_index = len(div_arr) // 2
        memo.append(len(str(div_arr[target_index])))
    print(min(memo))

N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
div_arr = make_divisors(N)

if len(div_arr) == 1:
    print(1)
elif len(div_arr) == 2:
    ans_num = max(div_arr)
    print(len(str(ans_num)))
else:
    memo = []
    if len(div_arr) % 2 == 0:
        last_idx = -1
        count = 0
        for i in range(len(div_arr)):
            count += 1
            if N == div_arr[i] * div_arr[last_idx] and count != len(div_arr) // 2:
                last_idx -= 1
                memo.append(len(str(div_arr[last_idx])))
            else:
                break
    else:
        target_index = len(div_arr) // 2
        memo.append(len(str(div_arr[target_index])))
    print(min(memo))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
def f(a,b):
  digit_a = digit_b=0
  
  while a:
    digit_a+=1
    a//=10
    
  while b:
    digit_b+=1
    b//=10
    
  return max(digit_a, digit_b)

n = int(input())

ans = n
for i in range(1, int((n+1)**0.5)):
  for n%i==0:
    n = min(n, f(i, n//i))
    
print(ans)
    

def f(a, b):
    digit_a = digit_b = 0

    while a:
        digit_a += 1
        a //= 10

    while b:
        digit_b += 1
        b //= 10

    return max(digit_a, digit_b)


n = int(input())

ans = n

for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        ans = min(ans, f(i, n // i))

print(ans)



Verdicts: Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import math
n=int(input())
l=math.floor(math.sqrt(n))

for i in range(l,1,-1):
    if n%i==0:
        a,b=i,n//i
        x=max(math.floor(math.log10(a))+1,math.floor(math.log10(b))+1)
        break
print(k)


from sys import exit
import math
n=int(input())
l=math.floor(math.sqrt(n))

for i in range(l+1,0,-1):
    if n%i==0:
        a,b=i,n//i
        h=max(a,b)
        k=math.floor(math.log10(h))+1
        print(k)
        exit()


Verdicts: Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import math

n = int(input())

def f(a,b):
    return len(str(a)) if len(str(a)) > len(str(b)) else len(str(b))

min = 10

for i in range(1,int(math.sqrt(n))):
    if n%i==0 and min > f(i,n//i):
        min = f(i,n//i)

if len(str(n))<10:
    min=1

print(min)

import math

n = int(input())

def f(a,b):
    return len(str(a)) if len(str(a)) > len(str(b)) else len(str(b))

min = 10

for i in range(1,int(math.sqrt(n))+1):
    if n%i==0 and min > f(i,n//i):
        min = f(i,n//i)

if n<10:
    min=1

print(min)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import math

if __name__ == '__main__':
    N = int(input())
    root_N_int = math.floor(math.sqrt(N))
    for A in range(root_N_int, 0, -1):
        if N % A == 0:
            B = int(N / A)
            print(B)
            break
    digit = len(str(B))
    print(digit)

import math

if __name__ == '__main__':
    N = int(input())
    root_N_int = math.floor(math.sqrt(N))
    for A in range(root_N_int, 0, -1):
        if N % A == 0:
            B = int(N / A)
            break
    digit = len(str(B))
    print(digit)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
n = int(input())
ans = float('inf')
temp = 0
for i in range(1,(n/2)+1):
    if n%i == 0:
        temp = max(len(str(i)), len(str(n//i)))
        ans = min(temp, ans)
print(ans)

n = int(input())
ans = float('inf')
temp = 0
for i in range(1,n/2+1):
    if n%i == 0:
        temp = max(len(str(i)), len(str(n//i)))
        ans = min(temp, ans)
print(ans)

n = int(input())
ans = float('inf')
temp = 0
for i in range(1,n**(1/2)):
    if n%i == 0:
        temp = max(i, n//i)
        ans = min(temp, ans)
print(len(str(ans)))

n = int(input())
ans = float('inf')
temp = 0
for i in range(1,int(n**(1/2))+1):
    if n%i == 0:
        temp = max(i, n//i)
        ans = min(temp, ans)
print(len(str(ans)))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given an integer N.   For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.   For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.   Find the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \times B.

Submission attempts (in order):
import math
N=int(input())
a=0
for i in range(1,1+math.ceil(math.sqrt(N))):
    if N%i==0 and i>a:
        a=i
b=int(N/a)
print(max([len(str(a)),len(str(b))]))9876543210

import math
N=int(input())
a=0
for i in range(1,1+math.ceil(math.sqrt(N))):
    if N%i==0 and i>a:
        a=i
b=int(N/a)
print(max([len(str(a)),len(str(b))]))

Verdicts: Runtime Error

Accepted
Problem: You are given N items.   The _value_ of the i-th item (1 \leq i \leq N) is v_i.   Your have to select at least A and at most B of these items.   Under this condition, find the maximum possible arithmetic mean of the values of selected items.   Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.

Submission attempts (in order):
import operator
import functools


def main():
    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    # use list.sort() or sorted(list)
    v.sort(reverse=True)
    # use slice to sum first A elements
    # use '{:f}'.format to format float
    print('{:.6f}'.format((sum(v[:A]) / A)))

    va = v[A - 1]
    # use list.count instead of (sum(list(map(lambda x: 1 if ... else 0, v))))
    pool = v.count(va)
    # ...and for comprehension and boolean sum
    head = sum(x > va for x in v)
    print(pool, head)
    # 5 4 3 3 3 2 1, A = 3, B = 5, pool = 3, pick = 1
    # 5 4 3 3 3 2 1, A = 4, B = 5, pool = 3, pick = 2
    # 3 3 3 3 3 2 1, A = 3, B = 6, pool = 5, pick = 3, 4, 5
    # 3 3 3 3 3 2 1, A = 3, B = 4, pool = 5, pick = 3, 4
    if head == 0:
        # for comprehension again, instead of a for loop that modifies variable
        ans = sum([_nCr(pool, pick) for pick in range(A, min(B, pool) + 1)])
    else:
        pick = A - head
        ans = _nCr(pool, pick)
    print(ans)


def _nCr(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    # reduce and xrange are for python2
    numer = functools.reduce(operator.mul, range(n, n-r, -1))
    denom = functools.reduce(operator.mul, range(1, r+1))
    return numer//denom


if __name__ == '__main__':
    main()


import operator
import functools


def main():
    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    # use list.sort() or sorted(list)
    v.sort(reverse=True)
    # use slice to sum first A elements
    # use '{:f}'.format to format float
    print('{:.6f}'.format((sum(v[:A]) / A)))

    va = v[A - 1]
    # use list.count instead of (sum(list(map(lambda x: 1 if ... else 0, v))))
    pool = v.count(va)
    # ...and for comprehension and boolean sum
    head = sum(x > va for x in v)
    # 5 4 3 3 3 2 1, A = 3, B = 5, pool = 3, pick = 1
    # 5 4 3 3 3 2 1, A = 4, B = 5, pool = 3, pick = 2
    # 3 3 3 3 3 2 1, A = 3, B = 6, pool = 5, pick = 3, 4, 5
    # 3 3 3 3 3 2 1, A = 3, B = 4, pool = 5, pick = 3, 4
    if head == 0:
        # for comprehension again, instead of a for loop that modifies variable
        ans = sum([_nCr(pool, pick) for pick in range(A, min(B, pool) + 1)])
    else:
        pick = A - head
        ans = _nCr(pool, pick)
    print(ans)


def _nCr(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    # reduce and xrange are for python2
    numer = functools.reduce(operator.mul, range(n, n-r, -1))
    denom = functools.reduce(operator.mul, range(1, r+1))
    return numer//denom


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: You are given N items.   The _value_ of the i-th item (1 \leq i \leq N) is v_i.   Your have to select at least A and at most B of these items.   Under this condition, find the maximum possible arithmetic mean of the values of selected items.   Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.

Submission attempts (in order):
from math import factorial


class Frac(object):
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def eq(self, f):
        return self.a * f.b == f.a * self.b

    def lt(self, f):
        return self.a * f.b > f.a * self.b

    def __repr__(self):
        return '%.6f' % (self.a / self.b)


def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)

res = None
for i in range(A, B+1):
    now = Frac(sum(V[:i]), i)
    if res is None or now.lt(res[0]):
        res = [now]
    elif now.eq(res[0]):
        res.append(now)

cnt = 0
for now in res:
    p = V[:now.b]
    n = len(list(filter(lambda x: x == p[-1], V)))
    r = len(list(filter(lambda x: x == p[-1], p)))
    cnt += nCr(n, r)

print(res[0])
print(cnt)
~

class Frac(object):
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def eq(self, f):
        return self.a * f.b == f.a * self.b

    def lt(self, f):
        return self.a * f.b > f.a * self.b

    def __repr__(self):
        return '%.6f' % (self.a / self.b)


def factorial(n):
    res = 1
    for i in range(n):
        res *= i+1
    return res


def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)

res = None
for i in range(A, B+1):
    now = Frac(sum(V[:i]), i)
    if res is None or now.lt(res[0]):
        res = [now]
    elif now.eq(res[0]):
        res.append(now)

cnt = 0
for now in res:
    p = V[:now.b]
    n = len(list(filter(lambda x: x == p[-1], V)))
    r = len(list(filter(lambda x: x == p[-1], p)))
    cnt += nCr(n, r)

print(res[0])
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: You are given N items.   The _value_ of the i-th item (1 \leq i \leq N) is v_i.   Your have to select at least A and at most B of these items.   Under this condition, find the maximum possible arithmetic mean of the values of selected items.   Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.

Submission attempts (in order):
N,A,B=map(int,input().split())
v=[int(x)for x in input().split()]
v.sort(reverse=True)
a=sum(v[:A])/A
m=min(v[:A])
k=v.count(m)
l=v.index(m)
ans=0
import math
for i in range(A,B+1):
    if i==A:
        ans+=(math.factorial(k)/math.factorial(i-l))/math.factorial(k-i+l)
    else:
        if k-i+l>=0 and a==m:
            ans+=(math.factorial(k)//math.factorial(i-l))//math.factorial(k-i+l)
        else:
            break
            
            
print("{:.1f}".format(a))
print(int(ans)) 

N,A,B=map(int,input().split())
v=[int(x)for x in input().split()]
v.sort(reverse=True)
a=sum(v[:A])/A
m=min(v[:A])
k=v.count(m)
l=v.index(m)
ans=0
print(m)
print(v)
print(k)
print(l)
import math
for i in range(A,B+1):
    if i==A:
        ans+=(math.factorial(k)/math.factorial(i-l))/math.factorial(k-i+l)
    else:
        if k-i+l>=0 and a==m:
            ans+=(math.factorial(k)//math.factorial(i-l))//math.factorial(k-i+l)
        else:
            break
            
            
print("{:.6f}".format(a))
print(int(ans))  

N,A,B=map(int,input().split())
v=[int(x)for x in input().split()]
v.sort(reverse=True)
a=sum(v[:A])/A
m=min(v[:A])
k=v.count(m)
l=v.index(m)
ans=0
import math
for i in range(A,B+1):
    if i==A:
        ans+=(math.factorial(k)//math.factorial(i-l))//math.factorial(k-i+l)
    else:
        if k-i+l>=0 and a==m:
            ans+=(math.factorial(k)//math.factorial(i-l))//math.factorial(k-i+l)
        else:
            break
            
            
print("{:.6f}".format(a))
print(int(ans))  

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
n=int(input())
ans=0
for i in range(n+1):
    if i*(i+1)/2>n:
        ans=i
        break
print(ans)


nest = int(input())

max = 0
i = 0

while max < nest:
	i += 1
	max += i

print(i)

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
x=int(input())

jump_count=0
for i in range(x+1):
    if x-i > i+1:
        x-=i
        jump_count+=1
    elif x-i == i+1:
        exit()
        jump_count+=1
print(jump_count)

x=int(input())
dis_sum=0
for i in range(1,x+1):
    dis_sum+=i
    if dis_sum>=x:
        print(i)
        break

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
x = input()
d = 0
for i in range(1, 10 ** 6):
  d += i
  if x <= d:
    print(i)
    break




x = int(input())
d = 0
for i in range(1, 10 ** 6):
    d += i
    if x <= d:
        print(i)
        break


Verdicts: Runtime Error

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
n=int(input())
tmp=0
for i in range(100000):
  tmp+=i
  if tmp>=n:
    print(i)

n=int(input())
tmp=0
for i in range(100000):
  tmp+=i
  if tmp>=n:
    print(i)
    break

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
import sys
[n, k] = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]

a.sort()

if sum(a) < k:
  print(n)
  sys.exit()

s = 0
for i in range(len(a)):
  s += a[i]
  if s >= k:
    break

aa = [x for x in a if x < a[i]]
bb = [x for x in a if x < k]

cc = []
for i in range(len(aa)):
  c = bb[:i] + bb[i+1:]
  t = k - bb[i]
  c.reverse()
  #print(c)
  flg = 0
  j = 0
  s = 0
  f = [0 for x in range(len(c))]
  while True:
    f[j] = 1
    #print(c)
    #print(f)
    s += c[j]
    if s >= t and s < k:
      flg = 1
      #print(c)
      #print(f)
      break
    if s >= k:
      f[j] = 0
      s -= c[j]
    j += 1
    if j == len(c):
      ii = -1
      for jj in range(len(c) - 1):
        if f[jj] == 1:
          ii = jj
      if ii == -1:
        break
      else:
        for l in range(ii, len(c)):
          f[l] = 0
      j = ii + 1
      s = sum([c[l] * f[l] for l in range(len(c))])
  if flg== 0:
    cc.append(bb[i])
#print(cc)
print(len(cc))


x = int(input().strip())

y = 0
i = 0
while y<x:
  i += 1
  y += i

print(i)

Verdicts: Runtime Error

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
import itertools
import numpy as np

X = int(input())
L = np.array(list(range(int(X**.5)+1)),dtype=np.float32)
L = np.array(list(itertools.accumulate(L)),dtype=np.float32)

def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

tmp = getNearestValue(L, X)
tmp1 = abs(X-tmp)
print(int((np.argwhere(L==tmp)+tmp1)[0]))

X=int(input())
res=0
for i in range(X+1):
  if i*(i+1)//2>=X:
    res=i
    break
print(res)

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
x=int(input())
for i in range(100000):
  if i * i+1 >= 2 * x:
    print(i)
    quit()

x=int(input())
for i in range(100000):
  if i * (i+1) >= 2 * x:
    print(i)
    quit()

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
N=int(input())
a=0
i=1
while a<N:
  a+=i
  i+=1
print(i)
  

N=int(input())
a=0
i=0
while a<N:
  i+=1
  a+=i
print(i)

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
x = int(input())

t = (-1 + math.sqrt(1 + 8 * x))
if t % 2 == 0:
  print(t//2)
else:
  print(t//2+1)


import math
x = int(input())

t = (-1 + math.sqrt(1 + 8 * x))
if t % 2 == 0:
  print(int(t)//2)
else:
  print(int(t)//2+1)


Verdicts: Runtime Error

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
n = int(input())
i = 1
while n > 0:
  n -= i
  i += 1
print(i)

n = int(input())
i = 1
while n > 0:
  n -= i
  i += 1
print(i-1)

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
import math
x = int(input())
print(-(-((x*2+1/4)**0.5-1/2)//1))

import math
x = int(input())
print(-int(-((x*2+1/4)**0.5-1/2)//1))

Verdicts: Wrong Answer

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
n=int(input())
i=int(sqrt(n))//2
while(i*(i+1)//2<n):
  i+=1
print(i)

n=int(input())
i=int(n**0.5)//2
while(i*(i+1)//2<n):
  i+=1
print(i)

Verdicts: Runtime Error

Accepted
Problem: There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Submission attempts (in order):
# import sys


n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

prefix = [set() for _ in range(n + 1)]
suffix = [set() for _2 in range(n + 1)]

prefix[0] = {0}
for i in range(n):
    for v in prefix[i]:
        if v + a[i] <= k:
            prefix[i+1].add(v + a[i])

suffix[n] = {0}
for i in range(n - 1, -1, -1):
    suffix[i] = set(suffix[i + 1])
    for v in suffix[i + 1]:
        if v + a[i] <= k:
            suffix[i].add(v + a[i])


c_suffix = [[0] * (k+1) for _3 in range(n + 1)]
for i in range(n + 1):
    for j in range(k):
        c_suffix[i][j + 1] = c_suffix[i][j] + (j in suffix[i])


def find(i):
    if k <= a[i]:
        return 0
    for s in prefix[i]:
        start = max(0, k - a[i] - s)
        stop = k - s
        if c_suffix[i + 1][stop] - c_suffix[i + 1][start] > 0:
            return 0
    return 1


res = 0
for i in range(n):
    res += find(i)
print(res)


import sys
sys.stdin = open('d3.in')

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

prefix = [set() for _ in range(n + 1)]
# suffix = [set() for _2 in range(n + 1)]

prefix[0] = {0}
for i in range(n):
    for v in prefix[i]:
        prefix[i+1].add(v)
        if v + a[i] <= k:
            prefix[i+1].add(v + a[i])

suffix_i = {0}


c_suffix = [[0] * (k+1) for _3 in range(n + 1)]

for j in range(k):
    c_suffix[n][j + 1] = c_suffix[n][j] + (j in suffix_i)

for i in range(n - 1, -1, -1):
    to_add = set()
    for v in suffix_i:
        if v + a[i] <= k:
            to_add.add(v + a[i])
    suffix_i.update(to_add)
    for j in range(k):
        c_suffix[i][j + 1] = c_suffix[i][j] + (j in suffix_i)


def find(i):
    if k <= a[i]:
        return 0
    for s in prefix[i]:
        start = max(0, k - a[i] - s)
        stop = k - s
        if c_suffix[i + 1][stop] - c_suffix[i + 1][start] > 0:
            return 0
    return 1


res = 0
for i in range(n):
    res += find(i)
print(res)


from math import sqrt

x = int(input())
n = int(sqrt(2 * x)) - 10
while not (n - 1) * n // 2 < x <= n * (n + 1) // 2:
    n += 1
print(n)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
N,C,K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
tmp = T[0]
ans = 0
cnt = 1
for i in range(1, N):
    cnt += 1
    if T[i]-tmp>K:
        ans += 1
        cnt = 1
        tmp = T[i]
    elif cnt>C:
        ans += 1
        cnt = 1
        tmp = T[i]
print(ans)

N,C,K = map(int, input().split())
ans = 0
t = [int(input()) for _ in range(N)]
t.sort()
for i in range(N):
    if i==0:
        tmp = t[i]+K
        cnt = 1
    else:
        cnt += 1
        if t[i] > tmp or i==N-1 or cnt==C:
            ans += cnt//C if cnt%C==0 else cnt//C+1
            tmp = t[i]+K
            cnt = 1
    # print(i,cnt, ans)
print(ans)

N,C,K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
tmp = T[0]
ans = 0
cnt = 1
for i in range(1, N):
    cnt += 1
    if T[i]-tmp>K:
        ans += 1
        cnt = 1
        tmp = T[i]
    elif cnt>C:
        ans += 1
        cnt = 1
        tmp = T[i]
print(ans+1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
n, c, k = map(int, input().split())
t = []
for i in range(n):
  t.append(int(input()))
t.sort()
result = 1
j = 0

for i in range(n):
  if (t[j] - t[0]) > k or c == count:
    result += 1
    t = t[j:]
    j = 1
  else:
    j += 1
print(result)

n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()

result = 1
count = 0
f = 0

for i in range(n):
  if (t[i] - t[f]) > k or c == count:
    result += 1
    count = 1
    f = i
  else:
    count += 1
print(result)

Verdicts: Runtime Error

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c <= _idx + 1:
        for _ in range(c):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)

# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c-1 <= _idx:
        for _ in range(c-1):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)

Verdicts: Runtime Error

Accepted