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.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To combine their tastes, they invented p-binar... | instruction | 0 | 87,658 | 20 | 175,316 |
Tags: bitmasks, brute force, math
Correct Solution:
```
n, p = map(int, input().split())
ans = -1
m = 1
if p == 0:
s = bin(n)[2:]
for i in range(len(s)):
if s[i] == '1':
ans += 1
ans += 1
while n - m * p > 0 and p != 0:
k = n - m * p
left, right = 0, 0
s = bin(k)[2:]
for ... | output | 1 | 87,658 | 20 | 175,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To combine their tastes, they invented p-binar... | instruction | 0 | 87,659 | 20 | 175,318 |
Tags: bitmasks, brute force, math
Correct Solution:
```
n, p = map(int, input().split())
c = 1
while n:
n -= p
if n < c:
print(-1)
break
if bin(n).count('1') <= c:
print(c)
break
c += 1
``` | output | 1 | 87,659 | 20 | 175,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To combine their tastes, they invented p-binar... | instruction | 0 | 87,660 | 20 | 175,320 |
Tags: bitmasks, brute force, math
Correct Solution:
```
n,p = [int(x) for x in input().split()]
from math import log
f = 0
def check(x,i):
t = list(bin(x))[2:]
if (t.count('1')<=i):
return True
return False
i = 0
for i in range(0,100):
if check((n-i*p),i) and n-i*p>=i:
print(... | output | 1 | 87,660 | 20 | 175,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,661 | 20 | 175,322 |
Yes | output | 1 | 87,661 | 20 | 175,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,662 | 20 | 175,324 |
Yes | output | 1 | 87,662 | 20 | 175,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,663 | 20 | 175,326 |
Yes | output | 1 | 87,663 | 20 | 175,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,664 | 20 | 175,328 |
Yes | output | 1 | 87,664 | 20 | 175,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,665 | 20 | 175,330 |
No | output | 1 | 87,665 | 20 | 175,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,666 | 20 | 175,332 |
No | output | 1 | 87,666 | 20 | 175,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,667 | 20 | 175,334 |
No | output | 1 | 87,667 | 20 | 175,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero).... | instruction | 0 | 87,668 | 20 | 175,336 |
No | output | 1 | 87,668 | 20 | 175,337 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the elemen... | instruction | 0 | 87,932 | 20 | 175,864 |
Tags: binary search, brute force
Correct Solution:
```
import math
def good(x):
# Returns true if there are at least k table members <= x
c = 0
for i in range(1, n + 1):
c += min(m, math.floor(x / i))
if c >= k:
return True
return False
n, m, k = [int(x) for x in input().s... | output | 1 | 87,932 | 20 | 175,865 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the elemen... | instruction | 0 | 87,933 | 20 | 175,866 |
Tags: binary search, brute force
Correct Solution:
```
def works(X,N,M,K):
#in each row, how many numbers are < X
res = 0
n = 1
div = X/M
while n < div:
res += M
n += 1
while n < N+1:
res += (X-1)//n
n += 1
return res
def solve():
N, M, K = [int(s) for s... | output | 1 | 87,933 | 20 | 175,867 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the elemen... | instruction | 0 | 87,934 | 20 | 175,868 |
Tags: binary search, brute force
Correct Solution:
```
# import sys
# from functools import lru_cache, cmp_to_key
# from heapq import merge, heapify, heappop, heappush
# from math import *
# from collections import defaultdict as dd, deque, Counter as C
# from itertools import combinations as comb, permutations as perm... | output | 1 | 87,934 | 20 | 175,869 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the elemen... | instruction | 0 | 87,935 | 20 | 175,870 |
Tags: binary search, brute force
Correct Solution:
```
def main():
from math import sqrt
m, n, k = map(int, input().split())
if n < m:
n, m = m, n
lo, hi = 1, k + 1
while lo + 1 < hi:
mid = (lo + hi) // 2
t = mid - 1
v = min(int(sqrt(t)), m)
tn, tm = (t - 1) /... | output | 1 | 87,935 | 20 | 175,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted ... | instruction | 0 | 87,936 | 20 | 175,872 |
No | output | 1 | 87,936 | 20 | 175,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted ... | instruction | 0 | 87,937 | 20 | 175,874 |
No | output | 1 | 87,937 | 20 | 175,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted ... | instruction | 0 | 87,938 | 20 | 175,876 |
No | output | 1 | 87,938 | 20 | 175,877 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted ... | instruction | 0 | 87,939 | 20 | 175,878 |
No | output | 1 | 87,939 | 20 | 175,879 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,279 | 20 | 176,558 |
"Correct Solution:
```
import sys
import math
def koratsu(n,i):
if(n==1):
return i
elif(n%2==0):
n=n//2
i=i+1
return koratsu(n,i)
else:
n=3*n+1
i=i+1
return koratsu(n,i)
i=0
while i<50:
n=int(input())
if(n==0):
break
kaisu=koratsu(n... | output | 1 | 88,279 | 20 | 176,559 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,280 | 20 | 176,560 |
"Correct Solution:
```
while True:
n = int(input());
if n == 0:
break;
i = 0;
while n != 1:
i += 1;
if n % 2 == 0:
n = n / 2;
else:
n = n * 3 + 1;
print(i);
``` | output | 1 | 88,280 | 20 | 176,561 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,281 | 20 | 176,562 |
"Correct Solution:
```
while True:
n=int(input())
s=0
if n==0:
break
while n!=1:
if n!=0:
if n%2==0:
n=n/2
s+=1
else:
n=n*3+1
s+=1
print(s)
``` | output | 1 | 88,281 | 20 | 176,563 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,282 | 20 | 176,564 |
"Correct Solution:
```
while True:
num = int(input())
if num == 0:
break
count = 0
while num != 1:
if num % 2 == 0:
num >>= 1
count += 1
else:
num += num // 2 + 1
count += 2
print(count)
``` | output | 1 | 88,282 | 20 | 176,565 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,283 | 20 | 176,566 |
"Correct Solution:
```
while True:
n = int(input())
if n == 0:
break
cnt = 0
while n != 1:
n = 3*n+1 if n % 2 else n//2
cnt += 1
print(cnt)
``` | output | 1 | 88,283 | 20 | 176,567 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,284 | 20 | 176,568 |
"Correct Solution:
```
while True:
x = int(input())
if x == 0:
break
c=0
while True:
if x==1:
break
elif x%2==0:
x = x//2
else:
x = x*3 +1
c += 1
print(c)
``` | output | 1 | 88,284 | 20 | 176,569 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,285 | 20 | 176,570 |
"Correct Solution:
```
while True:
n=int(input())
if n==0:
break
else:
a=0
while True:
if n==1:
print(a)
break
elif n%2==0:
n/=2
a+=1
else:
n*=3
n+=1
... | output | 1 | 88,285 | 20 | 176,571 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer ... | instruction | 0 | 88,286 | 20 | 176,572 |
"Correct Solution:
```
for i in range(50):
n = int(input())
if n == 0: break
i = 0
while 1:
if n == 1: break
if n % 2 == 0:
n = n / 2
else:
n = n*3 + 1
i += 1
print(i)
``` | output | 1 | 88,286 | 20 | 176,573 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is... | instruction | 0 | 88,287 | 20 | 176,574 |
Yes | output | 1 | 88,287 | 20 | 176,575 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is... | instruction | 0 | 88,288 | 20 | 176,576 |
Yes | output | 1 | 88,288 | 20 | 176,577 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is... | instruction | 0 | 88,289 | 20 | 176,578 |
Yes | output | 1 | 88,289 | 20 | 176,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is... | instruction | 0 | 88,290 | 20 | 176,580 |
Yes | output | 1 | 88,290 | 20 | 176,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is... | instruction | 0 | 88,291 | 20 | 176,582 |
No | output | 1 | 88,291 | 20 | 176,583 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is... | instruction | 0 | 88,292 | 20 | 176,584 |
No | output | 1 | 88,292 | 20 | 176,585 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,483 | 20 | 176,966 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
n = int(input())
d = [int(i) for i in input().split()]
# [print(bin(ff)) for ff in d]
l1 = [[1] * n for i in range(15)]
l2 = [[1] * n for i in range(15)]
vec_const1 = [0]*n
vec_const2 = [0]*n
for j in range(n):
dd = d[j]
for i in ran... | output | 1 | 88,483 | 20 | 176,967 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,484 | 20 | 176,968 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
H = 15
n = int(input())
a = list(map(int, input().split()))
def pc(v):
v = v - ((v >> 1) & 0x55555555)
v = (v & 0x33333333) + ((v >> 2) & 0x33333333)
return (((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) & 0xFFFFFFFF) >> 24
mask = ... | output | 1 | 88,484 | 20 | 176,969 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,485 | 20 | 176,970 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
def main():
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
dic1 = {}
dic2 = {}
A1 = [0] * N
for i, a in enumerate(A):
A1[i] = a>>15
for i in range(2**1... | output | 1 | 88,485 | 20 | 176,971 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,486 | 20 | 176,972 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = ... | output | 1 | 88,486 | 20 | 176,973 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,487 | 20 | 176,974 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
def bitcount(x):
return (
0 if x == 0 else
x%2 + bitcount(x//2)
)
###
def core():
_ = int(input()) # n
A = [int(v) for v in input().split()]
# 222222222211111111110000000000
# 987654321098765432109876543210
H... | output | 1 | 88,487 | 20 | 176,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,488 | 20 | 176,976 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
H = 15
MASK = (1 << H) - 1
n = int(input())
a = list(map(int, input().split()))
rec = {}
for x in range(1 << H):
r = [bin(ai & MASK ^ x).count('1') for ai in a]
d = tuple(r[-1] - ri for ri in r[:-1])
rec.setdefault(d, x)
ans =... | output | 1 | 88,488 | 20 | 176,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,489 | 20 | 176,978 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
import sys
from array import array # noqa: F401
import typing as Tp # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
def popcnt_32(x):
x = (x & 0x55555555) + ((x >> 1) & 0x55555555)
x = (x & 0x33... | output | 1 | 88,489 | 20 | 176,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1337 and 4213 are similar (binary representation... | instruction | 0 | 88,490 | 20 | 176,980 |
Tags: bitmasks, brute force, hashing, meet-in-the-middle
Correct Solution:
```
n = int(input())
arr = list(map(int, input().split()))
msbs_achieved_by = {tuple(
bin((num>>15) ^ x).count("1")
for num in arr
) : x
for x in range(1<<... | output | 1 | 88,490 | 20 | 176,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1... | instruction | 0 | 88,491 | 20 | 176,982 |
No | output | 1 | 88,491 | 20 | 176,983 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1... | instruction | 0 | 88,492 | 20 | 176,984 |
No | output | 1 | 88,492 | 20 | 176,985 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1... | instruction | 0 | 88,493 | 20 | 176,986 |
No | output | 1 | 88,493 | 20 | 176,987 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:
* 2 and 4 are similar (binary representations are 10 and 100);
* 1... | instruction | 0 | 88,494 | 20 | 176,988 |
No | output | 1 | 88,494 | 20 | 176,989 |
Provide a correct Python 3 solution for this coding contest problem.
C: Canisal cryptography
problem
Ebi-chan was given the string C obtained by encrypting a non-negative integer D with "canisal cipher". This cipher replaces each number in decimal notation with a fixed number (not necessarily different from the orig... | instruction | 0 | 89,217 | 20 | 178,434 |
"Correct Solution:
```
# 半分全列挙
from itertools import permutations, combinations
M = int(input())
C = list(map(int, input()))
if len(C)==1 and M==0:
print(0)
exit()
mod = 10**9 + 7
L = [0] * 10
b = 1
for c in C[::-1]:
L[c] += b
b = b * 10 % mod
for t_half1 in combinations(range(10), 5):
L1, L2 = L[:... | output | 1 | 89,217 | 20 | 178,435 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're sti... | instruction | 0 | 89,390 | 20 | 178,780 |
Tags: greedy, math, strings
Correct Solution:
```
def ans(s):
ans = 0
for i in s:
ans = ans * 10 + i
return ans
def f(s, a):
if len(s) == 1:
return -1
elif s[-1] % 2 != 0 and a % 2 == 0:
return ans(s)
elif s[-1] % 2 == 0:
while s[-1] % 2 == 0 and len(s) > 1:
... | output | 1 | 89,390 | 20 | 178,781 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're sti... | instruction | 0 | 89,391 | 20 | 178,782 |
Tags: greedy, math, strings
Correct Solution:
```
#Ashish Sagar
q=int(input())
for _ in range(q):
n=int(input())
#l=list(map(int,input().split()))
l=list(input())
for i in range(n):
l[i]=int(l[i])
x=[]
for i in range(n):
if l[i]%2!=0 and len(x)<2:
x.append(l[i])
... | output | 1 | 89,391 | 20 | 178,783 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're sti... | instruction | 0 | 89,392 | 20 | 178,784 |
Tags: greedy, math, strings
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
s = input()
sm = 0
l = []
count = 0
for i in range(n):
sm += int(s[i])
if(int(s[i])%2==1):
l.append(i)
count += 1
ans = -1
if(sm %2 == 0):
if... | output | 1 | 89,392 | 20 | 178,785 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're sti... | instruction | 0 | 89,393 | 20 | 178,786 |
Tags: greedy, math, strings
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
s = input()
odd=0;total=0;flag='waiting'
for i in range(n):
total+=int(s[i])
if int(s[i])%2==1:
odd+=1
if total%2==0 and total>0 and odd%2==0 and int(s[i])%2==1:
... | output | 1 | 89,393 | 20 | 178,787 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.