message stringlengths 2 43.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 853 107k | cluster float64 24 24 | __index_level_0__ int64 1.71k 214k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to know answers on q queries. The j-th query is de... | instruction | 0 | 59,721 | 24 | 119,442 |
Tags: greedy
Correct Solution:
```
from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *... | output | 1 | 59,721 | 24 | 119,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to know answers on q queries. The j-th query is de... | instruction | 0 | 59,722 | 24 | 119,444 |
Tags: greedy
Correct Solution:
```
import sys
input=sys.stdin.readline
from collections import defaultdict
n,q=list(map(int,input().split()))
a=list(map(int,input().split()))
b=defaultdict(int)
for i in range(n):
b[a[i]]+=1
c=[]
for i in b:
c.append([i,b[i]])
c.sort(reverse=True)
t=len(c)
for i in range(q):
... | output | 1 | 59,722 | 24 | 119,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to know answers on q queries. The j-th query is de... | instruction | 0 | 59,723 | 24 | 119,446 |
Tags: greedy
Correct Solution:
```
# @oj: codeforces
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-10-14 16:44
# @url:https://codeforc.es/contest/1003/problem/D
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio
BUFSIZE ... | output | 1 | 59,723 | 24 | 119,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to know answers on q queries. The j-th query is de... | instruction | 0 | 59,724 | 24 | 119,448 |
Tags: greedy
Correct Solution:
```
n,q=map(int,input().split())
a=list(map(int,input().split()))
li=[0]*32
for i in a:
li[i.bit_length()-1]+=1
#print(li)
queries=[int(input()) for _ in range(q)]
for k in queries:
ans=0
for i in range(31,-1,-1):
mini=min(k>>i,li[i])
ans+=mini
k-=mini<... | output | 1 | 59,724 | 24 | 119,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to know answers on q queries. The j-th query is de... | instruction | 0 | 59,725 | 24 | 119,450 |
Tags: greedy
Correct Solution:
```
# aadiupadhyay
import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')
def st(): return list(sys.stdin.readline().strip())
def li(): return list(map(int, sys.stdin.readline().split()))
def mp(): return map(int, sys.stdi... | output | 1 | 59,725 | 24 | 119,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,726 | 24 | 119,452 |
Yes | output | 1 | 59,726 | 24 | 119,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,727 | 24 | 119,454 |
Yes | output | 1 | 59,727 | 24 | 119,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,728 | 24 | 119,456 |
Yes | output | 1 | 59,728 | 24 | 119,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,729 | 24 | 119,458 |
Yes | output | 1 | 59,729 | 24 | 119,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,730 | 24 | 119,460 |
No | output | 1 | 59,730 | 24 | 119,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,731 | 24 | 119,462 |
No | output | 1 | 59,731 | 24 | 119,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,732 | 24 | 119,464 |
No | output | 1 | 59,732 | 24 | 119,465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).
Polycarp wants to ... | instruction | 0 | 59,733 | 24 | 119,466 |
No | output | 1 | 59,733 | 24 | 119,467 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,884 | 24 | 119,768 |
Tags: binary search, greedy, math
Correct Solution:
```
t = int( input().strip() )
for _ in range( t ):
s, d = map( int, input().strip().split(' ') )
diff = max(s, d) - min(s, d)
if diff > min(s, d):
ans = min(s, d)
else:
ans = diff
tmp = min(s, d) - diff
ans += (tmp // 3... | output | 1 | 59,884 | 24 | 119,769 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,885 | 24 | 119,770 |
Tags: binary search, greedy, math
Correct Solution:
```
import math
t = int(input())
for j in range(t):
temp = input()
a, b = temp.split(' ')
a = int(a)
b = int(b)
if a==0 or b == 0 :
print(0)
elif a>=2*b or b>=2*a:
print(min(a,b))
else:
print(int((a+b)/3))
``` | output | 1 | 59,885 | 24 | 119,771 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,886 | 24 | 119,772 |
Tags: binary search, greedy, math
Correct Solution:
```
def readintlst():
return list(map(int, input().split(' ')))
def readn():
return int(input())
N = readn()
for _ in range(N):
a, b = readintlst()
allx = min(a//2, b)
ally = min(a, b//2)
ans = max(allx, ally)
if a >= 2 * b or b >= 2 *... | output | 1 | 59,886 | 24 | 119,773 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,887 | 24 | 119,774 |
Tags: binary search, greedy, math
Correct Solution:
```
for _ in range(int(input())):
a, b = list(map(int, input().split()))
m = min(a, b)
M = max(a, b)
if 2*m <= M:
print(m)
else:
print((m+M)//3)
``` | output | 1 | 59,887 | 24 | 119,775 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,888 | 24 | 119,776 |
Tags: binary search, greedy, math
Correct Solution:
```
t=int(input())
for _ in range(t):
a,b=map(int,input().split())
if(a==0 or b==0):
print("0")
else:
c=min(a,b)
c1=(a+b)//3
print(min(c,c1))
``` | output | 1 | 59,888 | 24 | 119,777 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,889 | 24 | 119,778 |
Tags: binary search, greedy, math
Correct Solution:
```
import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
f... | output | 1 | 59,889 | 24 | 119,779 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,890 | 24 | 119,780 |
Tags: binary search, greedy, math
Correct Solution:
```
for _ in range(int(input())):
a, b = map(int, input().split())
r = min(a, b)
if r == 0:
print(0)
else:
print(min(min(a, b), (a + b) // 3))
``` | output | 1 | 59,890 | 24 | 119,781 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two d... | instruction | 0 | 59,891 | 24 | 119,782 |
Tags: binary search, greedy, math
Correct Solution:
```
t = int(input())
for _ in range(t):
a, b = [int(x) for x in input().split()]
if max(a, b) >= 2 * min(a, b):
print(min(a, b))
continue
x = min(a, b)
y = max(a, b)
p = max(2 * x - y, 0)
ans = (p // 3) * 2
x -= 3*(p // 3)
... | output | 1 | 59,891 | 24 | 119,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,892 | 24 | 119,784 |
Yes | output | 1 | 59,892 | 24 | 119,785 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,893 | 24 | 119,786 |
Yes | output | 1 | 59,893 | 24 | 119,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,894 | 24 | 119,788 |
Yes | output | 1 | 59,894 | 24 | 119,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,895 | 24 | 119,790 |
Yes | output | 1 | 59,895 | 24 | 119,791 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,896 | 24 | 119,792 |
No | output | 1 | 59,896 | 24 | 119,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,897 | 24 | 119,794 |
No | output | 1 | 59,897 | 24 | 119,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,898 | 24 | 119,796 |
No | output | 1 | 59,898 | 24 | 119,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one d... | instruction | 0 | 59,899 | 24 | 119,798 |
No | output | 1 | 59,899 | 24 | 119,799 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,948 | 24 | 119,896 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
X = []
Y = []
for a, b ... | output | 1 | 59,948 | 24 | 119,897 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,949 | 24 | 119,898 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
for _ in range(int(input())):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa,bb=[],[]
for i in range(n):
if b[i]==1:
aa.append(a[i])
else:
... | output | 1 | 59,949 | 24 | 119,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,950 | 24 | 119,900 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
from bisect import bisect_left,bisect_right
T=int(input())
for i in range(T):
v1 = []
v2 = []
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(n):
if b[i]==1... | output | 1 | 59,950 | 24 | 119,901 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,951 | 24 | 119,902 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
import sys
input = sys.stdin.readline
t=int(input())
for tests in range(t):
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A1=[]
A2=[]
for i in range(n):
if B[i]==1:
... | output | 1 | 59,951 | 24 | 119,903 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,952 | 24 | 119,904 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
import collections,sys,functools,heapq,bisect
input = sys.stdin.readline
mod = 10**9 +7
# return modular inverse of a with respect to m
def modInverse(a, m):
m0 = m
y = 0
x = 1
if (m == 1):
return 0
while (a > 1):
q = a // m
t = m ... | output | 1 | 59,952 | 24 | 119,905 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,953 | 24 | 119,906 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
def find_convenience_lost(n):
memory = list(map(int, input().split()))[1]
memory_per_app, weight = list(map(int, input().split())), list(map(int, input().split()))
ones = list(reversed(sorted([a for i, a in enumerate(memory_per_app) if ... | output | 1 | 59,953 | 24 | 119,907 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,954 | 24 | 119,908 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
# dp = {}
# inf = [int(1e9+7)]
#
# def solve(list1,num,sum1,index):
# key = str(num)+"-"+str(sum1)+"-"+str(index)
# if key in dp.keys():
# return dp[key]%inf[0]
# if sum1==0:
# return 1
#
# elif index<0:
# retu... | output | 1 | 59,954 | 24 | 119,909 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some a... | instruction | 0 | 59,955 | 24 | 119,910 |
Tags: binary search, dp, sortings, two pointers
Correct Solution:
```
import sys
for _ in range(int(input())):
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cost1 = []
cost2 = []
for i in range(n):
if b[i]==1:
cost1.appen... | output | 1 | 59,955 | 24 | 119,911 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,956 | 24 | 119,912 |
Yes | output | 1 | 59,956 | 24 | 119,913 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,957 | 24 | 119,914 |
Yes | output | 1 | 59,957 | 24 | 119,915 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,958 | 24 | 119,916 |
Yes | output | 1 | 59,958 | 24 | 119,917 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,959 | 24 | 119,918 |
Yes | output | 1 | 59,959 | 24 | 119,919 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,960 | 24 | 119,920 |
No | output | 1 | 59,960 | 24 | 119,921 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,961 | 24 | 119,922 |
No | output | 1 | 59,961 | 24 | 119,923 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,962 | 24 | 119,924 |
No | output | 1 | 59,962 | 24 | 119,925 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by ... | instruction | 0 | 59,963 | 24 | 119,926 |
No | output | 1 | 59,963 | 24 | 119,927 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp!
Polycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of ye... | instruction | 0 | 60,769 | 24 | 121,538 |
Tags: implementation
Correct Solution:
```
import math
t = int(input())
for _ in range(t):
n= int(input())
d = math.floor(math.log10(n))+1
res = 9*(d-1)
for i in range(1,10):
s = str(i)*d
if n>=int(s): res+=1
print(res)
``` | output | 1 | 60,769 | 24 | 121,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp!
Polycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of ye... | instruction | 0 | 60,770 | 24 | 121,540 |
Tags: implementation
Correct Solution:
```
t=int(input())
for i in range(t):
n=input()
l=len(n)
num=[]
for j in range(l):
num.append('1')
n1=''.join(num)
f1=int(n)//int(n1)
print((9*(l-1))+f1)
``` | output | 1 | 60,770 | 24 | 121,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp!
Polycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of ye... | instruction | 0 | 60,771 | 24 | 121,542 |
Tags: implementation
Correct Solution:
```
#!python3
"""
w1ld [dog] inbox dot ru
"""
from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt
import unittest
def read_int():
return int(input().strip())
def read_int_array():
return [int(i) fo... | output | 1 | 60,771 | 24 | 121,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp!
Polycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of ye... | instruction | 0 | 60,772 | 24 | 121,544 |
Tags: implementation
Correct Solution:
```
def func(n):
l=len(str(n))
sum=9*(l-1)
if n>=int("1"*l):
sum+=n//int("1"*l)
return sum
t=int(input())
for _ in range(t):
n=int(input())
print(func(n))
``` | output | 1 | 60,772 | 24 | 121,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp!
Polycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of ye... | instruction | 0 | 60,773 | 24 | 121,546 |
Tags: implementation
Correct Solution:
```
n = int(input())
for t in range(n):
a = str(input())
b = int(a)
s = 0
for j in range(1,10):
for i in range(1,len(a)+1):
if b >= int(str(j)*i):
s += 1
print(s)
``` | output | 1 | 60,773 | 24 | 121,547 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.