message stringlengths 2 59.7k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 37 108k | cluster float64 20 20 | __index_level_0__ int64 74 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticke... | instruction | 0 | 27,961 | 20 | 55,922 |
Tags: brute force, greedy, implementation
Correct Solution:
```
s = input()
l = list()
l1 = list(map(int, s[:3]))
l2 = list(map(int, s[3:]))
if sum(l1) > sum(l2):
l1, l2 = l2, l1
suml, sumr = sum(l1), sum(l2)
for i, j in zip(l1, l2):
l.append(9 - i)
l.append(j)
l.sort(reverse = True)
ans = 0
for i in l:
... | output | 1 | 27,961 | 20 | 55,923 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticke... | instruction | 0 | 27,962 | 20 | 55,924 |
Tags: brute force, greedy, implementation
Correct Solution:
```
l=list(input())
a=list(map(int,l))
l1=a[0:3]
l2=a[3:6]
if sum(l1)>sum(l2):
b=l2
l2=l1
l1=b
l1.sort()
l2.sort()
d=sum(l2)-sum(l1)
if d==0:
print("0")
else:
i=0
j=2
c=0
while d>0 :
if l1==[]:
d-=l2[j]
... | output | 1 | 27,962 | 20 | 55,925 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticke... | instruction | 0 | 27,963 | 20 | 55,926 |
Tags: brute force, greedy, implementation
Correct Solution:
```
entrada = list(map(int, input()))
l = entrada[:3]
r = entrada[3:]
sl = l[0] + l[1] + l[2]
sr = r[0] + r[1] + r[2]
l.sort()
r.sort()
if sl == sr:
print(0)
elif sl < sr:
dif = abs(sl-sr)
if dif <= r[2] or dif + l[0] <= 9:
print(1)
e... | output | 1 | 27,963 | 20 | 55,927 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticke... | instruction | 0 | 27,964 | 20 | 55,928 |
Tags: brute force, greedy, implementation
Correct Solution:
```
p = [int(x) for x in input()]
ans = []
for a in range(10) :
for b in range(10) :
for c in range(10) :
for d in range(10) :
for e in range(10) :
f = a + b + c - d - e
o = [a, b,... | output | 1 | 27,964 | 20 | 55,929 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticke... | instruction | 0 | 27,965 | 20 | 55,930 |
Tags: brute force, greedy, implementation
Correct Solution:
```
s = str(input())
r = []
for el in s:
r.append(int(el))
l1 = r[0:3]
l2 = r[3:6]
if sum(l1) < sum(l2):
l1, l2 = l2, l1
s = abs(sum(l1) - sum(l2))
if s == 0:
print(0)
else:
usable = []
for e in l1:
usable.append(e)
for e in ... | output | 1 | 27,965 | 20 | 55,931 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticke... | instruction | 0 | 27,966 | 20 | 55,932 |
Tags: brute force, greedy, implementation
Correct Solution:
```
s=input()
a,b = sorted(list(map(int,s[:3:]))), sorted(list(map(int,s[3::])))
sma,smb=sum(a),sum(b)
if sum(a) < sum(b):
mn, mx = a, b[::-1]
else:
mn, mx = b, a[::-1]
k1, k2=0, 0
while (sum(mn) < sum(mx)):
if 9-mn[k1] >= mx[k2]:
mn[k1] = ... | output | 1 | 27,966 | 20 | 55,933 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,967 | 20 | 55,934 |
Yes | output | 1 | 27,967 | 20 | 55,935 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,968 | 20 | 55,936 |
Yes | output | 1 | 27,968 | 20 | 55,937 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,969 | 20 | 55,938 |
Yes | output | 1 | 27,969 | 20 | 55,939 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,970 | 20 | 55,940 |
Yes | output | 1 | 27,970 | 20 | 55,941 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,971 | 20 | 55,942 |
No | output | 1 | 27,971 | 20 | 55,943 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,972 | 20 | 55,944 |
No | output | 1 | 27,972 | 20 | 55,945 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,973 | 20 | 55,946 |
No | output | 1 | 27,973 | 20 | 55,947 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replac... | instruction | 0 | 27,974 | 20 | 55,948 |
No | output | 1 | 27,974 | 20 | 55,949 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,983 | 20 | 55,966 |
Tags: math, number theory
Correct Solution:
```
LEN1 = 31
LEN2 = 50
MOD = 10 ** LEN2
def binpow(a, b, mod):
x = 1
y = a
while b > 0:
if b % 2:
x = x * y % mod
y = y * y % mod
b //= 2
return x
def solve(n):
n = n * 10 ** LEN1
diff = (2 ** LEN2 - n) % 2 ** LEN... | output | 1 | 27,983 | 20 | 55,967 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,984 | 20 | 55,968 |
Tags: math, number theory
Correct Solution:
```
def lift(n, a):
# base: mod 5
x = 0
while pow(2, x, 5) != a % 5:
x += 1
for i in range(2, n + 1):
mod, phi, step = pow(5, i), 4 * pow(5, i - 1), 4 * pow(5, i - 2)
while pow(2, x, mod) != a % mod:
x += step
if... | output | 1 | 27,984 | 20 | 55,969 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,985 | 20 | 55,970 |
Tags: math, number theory
Correct Solution:
```
import time
start = time.time()
mod=5;
G=4
def ModPow(exp):
if exp==0:return 1;
if exp%2==1:return (2*ModPow(exp-1))%mod;
A=ModPow(exp//2);
return (A*A)%mod;
t=int(input());
while t>0:
t=t-1;
x=int(input());
mod=5
G=4
a=(10**12)*x;
k=(2**23)-a;
k%=(2**2... | output | 1 | 27,985 | 20 | 55,971 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,986 | 20 | 55,972 |
Tags: math, number theory
Correct Solution:
```
import sys
#sys.stdout = open('output.txt', 'w')
#sys.stdin = open('input.txt', 'r')
#for line in sys.stdin:
#while 1:
# line = sys.stdin.readline()
# if line:
# print (line,end="")
def phi(p,i):
if i == 0:
return 1
return p**i - p**(i-1)
def pw... | output | 1 | 27,986 | 20 | 55,973 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,987 | 20 | 55,974 |
Tags: math, number theory
Correct Solution:
```
MOD = 10**18
def pow2(n):
if n == 0:
return 1
if n % 2:
return (2 * pow2(n-1)) % MOD
c = pow2(n//2)
return (c*c) % MOD
n = int(input())
start2 = pow2(1000)
p2 = [pow2(4*(5**x)) for x in range(50)]
c2 = [10**x for x in range(50)]
c3 = [4... | output | 1 | 27,987 | 20 | 55,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,988 | 20 | 55,976 |
Tags: math, number theory
Correct Solution:
```
import sys
import math
from decimal import *
line = lambda: list(int(x) for x in input().split())
def pow(a, k, p):
r = 1
t = a
while k > 0:
if k % 2 == 1:
r = r * t % p
t = t * t % p
k >>= 1
return r
test = int(in... | output | 1 | 27,988 | 20 | 55,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,989 | 20 | 55,978 |
Tags: math, number theory
Correct Solution:
```
import sys
import random
N = 20
ntest = int(sys.stdin.readline())
for _ in range(ntest):
target = int(sys.stdin.readline())
# target = random.randint(1, 10 ** 11 - 1)
# savetarget = target
divtarget = 2 ** N
target_min = target
target_max = target + 1
while T... | output | 1 | 27,989 | 20 | 55,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Her... | instruction | 0 | 27,990 | 20 | 55,980 |
Tags: math, number theory
Correct Solution:
```
m10=10000000000
mp=21
p2=2**mp
def qmd(log, md):
ans=1
a=2
while log>0:
if log%2:
ans=ans*a%md
log=log//2
a=a*a%md
return ans
n=int(input())
for nn in range(n):
a=int(input())
#print(a)
x=a*m10//p2*p2+p2
... | output | 1 | 27,990 | 20 | 55,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring a... | instruction | 0 | 27,998 | 20 | 55,996 |
No | output | 1 | 27,998 | 20 | 55,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,596 | 20 | 57,192 |
Tags: implementation, math
Correct Solution:
```
a,b=map(int,input().split())
n=int(input())
ans=[a,b,b-a,-a,-b,a-b]
print(ans[(n-1)%6]%(10**9 + 7))
``` | output | 1 | 28,596 | 20 | 57,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,597 | 20 | 57,194 |
Tags: implementation, math
Correct Solution:
```
x,y = map(int,input().split())
n=int(input())
z=[x,y,y-x,-x,-y,x-y]
print(z[n%6-1]% (10**9+7))
``` | output | 1 | 28,597 | 20 | 57,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,598 | 20 | 57,196 |
Tags: implementation, math
Correct Solution:
```
x, y = list(map(int, input().split()))
n = int(input())
mod = 1000000007
arr = []
arr.append(x)
arr.append(y)
arr.append(y-x)
arr.append(-x)
arr.append(-y)
arr.append(x-y)
a = n % 6
#print(a)
print(arr[a-1] % mod)
#print(arr)
``` | output | 1 | 28,598 | 20 | 57,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,599 | 20 | 57,198 |
Tags: implementation, math
Correct Solution:
```
x,y= map(int, input().split())
n= int(input())
seq=[x , y , y-x , -x ,-y , x-y]
d= n%6
print(seq[d-1]%1000000007 )
``` | output | 1 | 28,599 | 20 | 57,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,600 | 20 | 57,200 |
Tags: implementation, math
Correct Solution:
```
def main():
MOD = 1000000007
(x, y) = map(int, input().split(' '))
n = int(input())
out = [x - y, x, y, y - x, -x, -y]
ret = out[n % 6]
print(ret % MOD)
main()
``` | output | 1 | 28,600 | 20 | 57,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,601 | 20 | 57,202 |
Tags: implementation, math
Correct Solution:
```
mod=1000000007
x,y=map(int,input().split())
n=int(input())
if n%6==0:
ans=x-y
print(ans%mod)
if n%6==1:
ans=x
print(ans%mod)
if n%6==2:
ans=y
if ans>0:
print(ans%mod)
else:
print(mo... | output | 1 | 28,601 | 20 | 57,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,602 | 20 | 57,204 |
Tags: implementation, math
Correct Solution:
```
# Description of the problem can be found at http://codeforces.com/problemset/problem/450/B
x, y = map(int, input().split())
n = int(input())
if n % 6 == 1:
print(x % int(1e9 + 7))
elif n % 6 == 2:
print(y % int(1e9 + 7))
elif n % 6 == 3:
print((y - x) % in... | output | 1 | 28,602 | 20 | 57,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jzzhu has invented a kind of sequences, they meet the following property:
<image>
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second lin... | instruction | 0 | 28,603 | 20 | 57,206 |
Tags: implementation, math
Correct Solution:
```
def discos():
x = int()
y = int
z =int
n = int
ans = list()
x, y = [int(x) for x in input().split()]
n = int(input())
ans = [x-y, x, y, y-x, -x, -y];
z = (ans[n%6]%1000000007 + 1000000007) % 1000000007
print(z)
return
discos()
``` | output | 1 | 28,603 | 20 | 57,207 |
Provide a correct Python 3 solution for this coding contest problem.
Number of tanka
Wishing to die in the spring under the flowers
This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and t... | instruction | 0 | 29,063 | 20 | 58,126 |
"Correct Solution:
```
N = int(input())
while N:
l = 2
N -= 1
while N >= ((1<<(l - 1)) - 1)*81:
N -= ((1<<(l - 1)) - 1)*81
l += 1
s = N // (((1<<(l - 1)) - 1)*9) + 1
N %= ((1<<(l - 1)) - 1)*9
t = -1
ans = str(s)
#print("N = ", N)
while t < 0:
for i in range(s)... | output | 1 | 29,063 | 20 | 58,127 |
Provide a correct Python 3 solution for this coding contest problem.
Number of tanka
Wishing to die in the spring under the flowers
This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and t... | instruction | 0 | 29,064 | 20 | 58,128 |
"Correct Solution:
```
def solve(N):
k = 0
rng = 0
for i in range(54):
if cl[i] < N <= cl[i+1]:
k = i + 2
rng2 = cl[i]
rng = cl[i+1] - cl[i]
# print(k)
posrng = (N-rng2)%(rng//9)
perrng = (N-rng2)//(rng//9)+1
if posrng == 0:
posrng = rng//9... | output | 1 | 29,064 | 20 | 58,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Number of tanka
Wishing to die in the spring under the flowers
This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a ... | instruction | 0 | 29,065 | 20 | 58,130 |
No | output | 1 | 29,065 | 20 | 58,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,271 | 20 | 58,542 |
Tags: brute force, implementation, math
Correct Solution:
```
for _ in range(int(input())):
x, k = map(int, input().split())
for i in range(k - 1):
dg = []
x1 = x
while x1 > 0:
dg.append(x1 % 10)
x1 //= 10
x = x + min(dg) * max(dg)
if 0 in dg:
... | output | 1 | 29,271 | 20 | 58,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,272 | 20 | 58,544 |
Tags: brute force, implementation, math
Correct Solution:
```
def minn(m):
mx = 0
mn = 9
while m>0:
a = m%10
mn = min(a,mn)
mx = max(a,mx)
m//=10
return mn*mx
for lo in range(int(input())):
#n = int(input())
n,k = map(int,input().split())
#ls = [int(x) for x i... | output | 1 | 29,272 | 20 | 58,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,273 | 20 | 58,546 |
Tags: brute force, implementation, math
Correct Solution:
```
import sys
for _ in range(int(input())):
a,k=map(int,input().split())
if k==1:
print(a)
else:
s=str(a)
if '0' in s:
print(a)
else:
flag=1
for i in range(k-1):
... | output | 1 | 29,273 | 20 | 58,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,274 | 20 | 58,548 |
Tags: brute force, implementation, math
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
def I(): return(list(map(int,input().split())))
def sieve(n):
a=[1]*n
for i in range(2,n):
if a[i]:
for j in range(i*i,n,i):
a[j]=0
return a
for __ in range(int(input())):
a,k=I()
... | output | 1 | 29,274 | 20 | 58,549 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,275 | 20 | 58,550 |
Tags: brute force, implementation, math
Correct Solution:
```
for j in range(int(input())):
n,k = map(int,input().split())
for i in range(k-1):
n2 = n
max = n2%10
min = n2%10
while(n2>0):
c = n2%10
if c>max:
max = c
if c<min:
... | output | 1 | 29,275 | 20 | 58,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,276 | 20 | 58,552 |
Tags: brute force, implementation, math
Correct Solution:
```
t = int(input())
ls = [list(map(int, input().split())) for _ in range(t)]
for i in range(t):
n = ls[i][0]
for j in range(1, ls[i][1]):
l = [int(x) for x in list(str(n))]
mnd = min(l)
mxd = max(l)
n = n + mnd * mxd
... | output | 1 | 29,276 | 20 | 58,553 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,277 | 20 | 58,554 |
Tags: brute force, implementation, math
Correct Solution:
```
t = int(input())
def f(n,mx,mn):
temp = list(str(n))
for i in range(0,len(temp)):
temp[i] = int(temp[i])
if(i==0):
t1 = temp[i]
t2 = temp[i]
else:
t1 = max(t1,temp[i])
t2 = min(t... | output | 1 | 29,277 | 20 | 58,555 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples re... | instruction | 0 | 29,278 | 20 | 58,556 |
Tags: brute force, implementation, math
Correct Solution:
```
t = int(input())
for i in range(0, t):
nums = list(map(int, input().split(' ')))
ak = nums[0]
for j in range(1, nums[1]):
min = '9'
max = '0'
for i in str(ak):
if min > i:
min = i
i... | output | 1 | 29,278 | 20 | 58,557 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,509 | 20 | 59,018 |
Tags: implementation
Correct Solution:
```
a='012456','25','02346','02356','1235','01356','013456','025','0123456','012356'
b=[set(a[i])for i in range(10)]
c,d=map(int,input())
f,e=0,0
for i in b:f+=i>=b[c];e+=i>=b[d]
print(f*e)
``` | output | 1 | 29,509 | 20 | 59,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,510 | 20 | 59,020 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
dic = { '0' : 2, '1' : 7, '2' : 2, '3' : 3, '4' : 3, '5' : 4, '6' : 2, '7' : 5, '8' : 1, '9' : 2}
n = input()
start = time.time()
ans = dic[n[0]]*dic[n[1]]
print(ans)
finish = time.time()
#print(finish - start)
`... | output | 1 | 29,510 | 20 | 59,021 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,511 | 20 | 59,022 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/env python3
digit = input()
good_value = {'0': 2, '1': 7, '2': 2, '3': 3, '4': 3, '5': 4, '6': 2, '7': 5, '8': 1, '9': 2}
print(good_value[digit[0]] * good_value[digit[1]])
``` | output | 1 | 29,511 | 20 | 59,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,512 | 20 | 59,024 |
Tags: implementation
Correct Solution:
```
a = [2, 7, 2, 3, 3, 4, 2, 5, 1, 2]
l = int(input())
r = int(l % 10)
l = int(l / 10)
print(a[l] * a[r])
``` | output | 1 | 29,512 | 20 | 59,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,513 | 20 | 59,026 |
Tags: implementation
Correct Solution:
```
data = []
data.extend([2,7,2,3,3,4,2,5,1,2])
line = input()
x = data[int(line[0])]
y = data[int(line[1])]
print(x*y)
``` | output | 1 | 29,513 | 20 | 59,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,514 | 20 | 59,028 |
Tags: implementation
Correct Solution:
```
n=int(input())
a=int(n//10)
b=int(n%10)
if a==0:
x=1
if a==1:
x=6
if a==2:
x=1
if a==3:
x=2
if a==4:
x=2
if a==5:
x=3
if a==6:
x=1
if a==7:
x=4
if a==8:
x=0
if a==9:
x=1
if b==0:
y=1
if b==1:
y=6
if b==2:
y=1
if b==3:
y... | output | 1 | 29,514 | 20 | 59,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,515 | 20 | 59,030 |
Tags: implementation
Correct Solution:
```
def findC(n):
if n == 0:
return [0,8]
elif n == 1:
return [0,1,3,4,7,8,9]
elif n == 2:
return [2,8]
elif n == 3:
return [3,8,9]
elif n == 4:
return [4,8,9]
elif n == 5:
return [5,6,8,9]
elif n == 6:
... | output | 1 | 29,515 | 20 | 59,031 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks ... | instruction | 0 | 29,516 | 20 | 59,032 |
Tags: implementation
Correct Solution:
```
a = [2, 7, 2, 3, 3, 4, 2, 5, 1, 2]
n = input()
print(a[int(n[0])] * a[int(n[1])])
``` | output | 1 | 29,516 | 20 | 59,033 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.