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.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets... | instruction | 0 | 19,658 | 20 | 39,316 |
Tags: implementation
Correct Solution:
```
n=int(input())
a=input().strip()
if sorted(set(a))!=['4','7'] and sorted(set(a))!=['7'] and sorted(set(a))!=['4']:
print("NO")
else:
x=[int(i) for i in a[:n//2]]
y=[int(i) for i in a[n//2:]]
if sum(x)==sum(y):
print("YES")
else:
print("NO")
``` | output | 1 | 19,658 | 20 | 39,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets... | instruction | 0 | 19,659 | 20 | 39,318 |
Tags: implementation
Correct Solution:
```
f='yes'
n=int(input())
a=input()
b='47'
for i in range(n):
if a[i] not in b:
f='no'
if f=='no':
print('NO')
else:
m1=0
m2=0
for i in range(n//2):
m1+=int(a[i])
for i in range(n//2,n):
m2+=int(a[i])
if m1==m2:
print('... | output | 1 | 19,659 | 20 | 39,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets... | instruction | 0 | 19,660 | 20 | 39,320 |
Tags: implementation
Correct Solution:
```
n = int(input().strip())
k = input().strip()
ll = []
o = True
for i in k:
if i in ['4','7']:
ll.append(int(i))
else:
o = False
break
if o == True:
print('YES' if sum(ll[0:n//2]) == sum(ll[n//2:]) else 'NO')
else:
print('NO')
``` | output | 1 | 19,660 | 20 | 39,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets... | instruction | 0 | 19,661 | 20 | 39,322 |
Tags: implementation
Correct Solution:
```
l = int(input())
n = input()
array = list(set([int(x) for x in n]))
array.sort()
n = [int(x) for x in n]
if array == [4, 7] or array == [4] or array == [7]:
s1, s2 = 0, 0
for i in range(int(l/2)):
s1 += n[i]
n.reverse()
for i in range(int(l/2)):
... | output | 1 | 19,661 | 20 | 39,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets... | instruction | 0 | 19,662 | 20 | 39,324 |
Tags: implementation
Correct Solution:
```
import sys
value = int(input())
array = list(str(input()))
firstHalf = 0
secHalf = 0
for i in range(0, int(value/2)):
buffer = int(array[i])
if buffer==4 or buffer==7:
firstHalf += buffer
else:
print("NO")
sys.exit()
for i in range(int(va... | output | 1 | 19,662 | 20 | 39,325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets... | instruction | 0 | 19,663 | 20 | 39,326 |
Tags: implementation
Correct Solution:
```
num=int(input())
a=list(map(int,input()))
l4=l7=0
for i in range(num):
if a[i]==4:
l4+=1
elif a[i]==7:
l7+=1
else:
break
if l4+l7!=num:
print("NO")
else:
h=num//2
s0=sum(a[:h]);s1=sum(a[h:])
if s0!=s1:
print("NO")
else:
print("YES")
``` | output | 1 | 19,663 | 20 | 39,327 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets... | instruction | 0 | 19,664 | 20 | 39,328 |
Tags: implementation
Correct Solution:
```
n=int(input())
s=input()
if s.count("4")+s.count("7")!=n:
print("NO")
else:
if (sum(int(s[i]) for i in range(0,n//2)))==(sum(int(s[j]) for j in range(n//2,n))):
print("YES")
else:print("NO")
``` | output | 1 | 19,664 | 20 | 39,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,665 | 20 | 39,330 |
Yes | output | 1 | 19,665 | 20 | 39,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,666 | 20 | 39,332 |
Yes | output | 1 | 19,666 | 20 | 39,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,667 | 20 | 39,334 |
Yes | output | 1 | 19,667 | 20 | 39,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,668 | 20 | 39,336 |
Yes | output | 1 | 19,668 | 20 | 39,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,669 | 20 | 39,338 |
No | output | 1 | 19,669 | 20 | 39,339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,670 | 20 | 39,340 |
No | output | 1 | 19,670 | 20 | 39,341 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,671 | 20 | 39,342 |
No | output | 1 | 19,671 | 20 | 39,343 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are luc... | instruction | 0 | 19,672 | 20 | 39,344 |
No | output | 1 | 19,672 | 20 | 39,345 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's ... | instruction | 0 | 19,828 | 20 | 39,656 |
Tags: dp, math, probabilities
Correct Solution:
```
def num_ones(a,b):
'''returns how many nums start
with digit 1 in [a,b]'''
if a==0:
if b==0:
return 0
ans=0
b=str(b)
for i in range(1,len(b)):
ans+=10**(i-1)
if b[0]=='1':
x=b[1:]
... | output | 1 | 19,828 | 20 | 39,657 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's ... | instruction | 0 | 19,829 | 20 | 39,658 |
Tags: dp, math, probabilities
Correct Solution:
```
import sys
input=lambda:sys.stdin.readline().strip()
print=lambda s:sys.stdout.write(str(s)+"\n")
nn=int(input())
dp=[1] + [0]*(nn+1)
for _ in range(nn):
l, r = map(int, input().split())
c = 1
n = 0
for _ in range(19):
n += max(0, min(r, 2 * c - 1) - max(l, c) +... | output | 1 | 19,829 | 20 | 39,659 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's ... | instruction | 0 | 19,830 | 20 | 39,660 |
Tags: dp, math, probabilities
Correct Solution:
```
# in = open("input.txt", "r")
# out = open("output.txt", "w")
# long double p[maxn];
# long double dp[maxn][maxn];
#
# int solution() {
#
# int n, k;
# scanf("%d", &n);
# for(int i = 0; i < n; i++) {
# ll l, r;
# scanf("%lld%lld", &l, &r);
# r++;
# ll cn... | output | 1 | 19,830 | 20 | 39,661 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's ... | instruction | 0 | 19,831 | 20 | 39,662 |
Tags: dp, math, probabilities
Correct Solution:
```
def num_ones(a,b):
'''returns how many nums start
with digit 1 in [a,b]'''
if a==0:
if b==0:
return 0
ans=0
b=str(b)
for i in range(1,len(b)):
ans+=10**(i-1)
if b[0]=='1':
x=b[1:]
... | output | 1 | 19,831 | 20 | 39,663 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's ... | instruction | 0 | 19,832 | 20 | 39,664 |
Tags: dp, math, probabilities
Correct Solution:
```
import math
def get_count(x):
if x == 0:
return 0
y = 10 ** (len(str(x)) - 1)
d = x // y
if d == 1:
count = x - y + 1
else:
count = y
#print(x, math.log10(x), int(math.log10(x)), y, d, count)
while y > 1:
y ... | output | 1 | 19,832 | 20 | 39,665 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's ... | instruction | 0 | 19,833 | 20 | 39,666 |
Tags: dp, math, probabilities
Correct Solution:
```
from sys import stdin
tps = [1]
for i in range(20):
tps.append(tps[-1]*10)
def findprob(l, r):
sl = str(l)
sr = str(r)
ans = 0
if (sl[0] == '1' and sr[0] == '1' and len(sl) == len(sr)):
if l == r == 1: ans += 1
else: ans += int(sr... | output | 1 | 19,833 | 20 | 39,667 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's ... | instruction | 0 | 19,834 | 20 | 39,668 |
Tags: dp, math, probabilities
Correct Solution:
```
def f(n):
s=str(n)
l=len(s)
tot=0
tot+=(10**(l-1)-1)//9
tot+=min(n-10**(l-1)+1,10**(l-1))
return tot
n=int(input())
dp=[[0 for i in range(n+1)]for j in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
l,r=map(int,input().split())
tot=f(r)... | output | 1 | 19,834 | 20 | 39,669 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than ... | instruction | 0 | 19,835 | 20 | 39,670 |
No | output | 1 | 19,835 | 20 | 39,671 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than ... | instruction | 0 | 19,836 | 20 | 39,672 |
No | output | 1 | 19,836 | 20 | 39,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than ... | instruction | 0 | 19,837 | 20 | 39,674 |
No | output | 1 | 19,837 | 20 | 39,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than ... | instruction | 0 | 19,838 | 20 | 39,676 |
No | output | 1 | 19,838 | 20 | 39,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not ne... | instruction | 0 | 19,839 | 20 | 39,678 |
Tags: implementation
Correct Solution:
```
import sys
n,m = map(int , input().split())
f = list(map(int , input().split()))
b = list(map(int , input().split()))
cnt = [0 for i in range(n+1)]
indx = [ -1 for i in range(n+1)]
for i in range(n):
cnt[f[i]] += 1
indx[f[i]] = i + 1
ans = []
for num in b:
if cn... | output | 1 | 19,839 | 20 | 39,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not ne... | instruction | 0 | 19,840 | 20 | 39,680 |
Tags: implementation
Correct Solution:
```
import sys
def main():
n, m = map(int, input().split())
f = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
f = [0]+f
b = [0]+b
imf = set()
d = set()
g = [0]*(n+1)
for i in range(1,n+1):
if f[i] in imf:
d.add(f[i])
... | output | 1 | 19,840 | 20 | 39,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not ne... | instruction | 0 | 19,841 | 20 | 39,682 |
Tags: implementation
Correct Solution:
```
n,m=map(int,input().split())
f=list(map(int,input().split()))
b=list(map(int,input().split()))
a=[-1]*100050
for i in range(n):
if a[f[i]]==-1:a[f[i]]=i
else :a[f[i]]=-2
for i in b:
if a[i]==-1:exit(print('Impossible'))
for i in b:
if a[i]==-2:exit(print('Amb... | output | 1 | 19,841 | 20 | 39,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not ne... | instruction | 0 | 19,842 | 20 | 39,684 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/env python3
# 599B_sponge.py - Codeforces.com/problemset/problem/599/B by Sergey 2015
import unittest
import sys
###############################################################################
# Sponge Class (Main Program)
#########################################... | output | 1 | 19,842 | 20 | 39,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not ne... | instruction | 0 | 19,845 | 20 | 39,690 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/env python3
n,m = [int(ii) for ii in input().split(' ')]
f = [int(ii)-1 for ii in input().split(' ')]
b = [int(ii)-1 for ii in input().split(' ')]
mp = dict([])
for i in range(n):
if f[i] in mp:
mp[f[i]].append(i)
else:
mp[f[i]] = [i]
res =... | output | 1 | 19,845 | 20 | 39,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of lengt... | instruction | 0 | 19,848 | 20 | 39,696 |
Yes | output | 1 | 19,848 | 20 | 39,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+... | instruction | 0 | 19,977 | 20 | 39,954 |
Tags: brute force, hashing, math
Correct Solution:
```
def modgroup(M = 10**9+7, invn = 0) :
exec(f'''class mod{M} :
inv = [None] * {invn}
if {invn} >= 2 : inv[1] = 1
for i in range(2, {invn}) : inv[i] = (({M}-{M}//i)*inv[{M}%i])%{M}
def __init__(self, n = 0) : self.n = n % {M}
__repr__ = lambda self : str(self.n... | output | 1 | 19,977 | 20 | 39,955 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+... | instruction | 0 | 19,978 | 20 | 39,956 |
Tags: brute force, hashing, math
Correct Solution:
```
def modgroup(M = 10**9+7, invn = 0) :
exec(f'''class mod{M} :
inv = [None] * {invn+1}
if {invn+1} >= 2 : inv[1] = 1
for i in range(2, {invn+1}) :
inv[i] = (({M} - {M}//i) * inv[{M}%i]) %{M}
def __init__(self, n = 0) : self.n = n % {M}
__repr__ = lambda self... | output | 1 | 19,978 | 20 | 39,957 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+... | instruction | 0 | 19,979 | 20 | 39,958 |
Tags: brute force, hashing, math
Correct Solution:
```
def modgroup(M = 10**9+7, invn = 0) :
exec(f'''class mod{M} :
inv = [None] * {invn}
if {invn} >= 2 : inv[1] = 1
for i in range(2, {invn}) : inv[i] = (({M}-{M}//i)*inv[{M}%i])%{M}
def __init__(self, n = 0) : self.n = n % {M}
__repr__ = lambda self : str(self.n... | output | 1 | 19,979 | 20 | 39,959 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,334 | 20 | 40,668 |
Tags: greedy
Correct Solution:
```
n,x,y=map(int, input().split())
if n>y:
print(-1)
else:
z=y-(n-1)
if z**2 + (n-1)<x:
print(-1)
else:
for i in range(n-1):
print(1)
print(z)
``` | output | 1 | 20,334 | 20 | 40,669 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,335 | 20 | 40,670 |
Tags: greedy
Correct Solution:
```
n,x,y=[int(p) for p in input().split()]
if n>y or (y-n+1)**2 + n - 1<x:
print(-1)
else:
y='\n'.join(map(str,[y-n+1]+[1]*(n-1)))
print(y)
``` | output | 1 | 20,335 | 20 | 40,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,336 | 20 | 40,672 |
Tags: greedy
Correct Solution:
```
n,x,y=map(int,input().split())
if(y<n):
print(-1)
elif((y-n+1)**2+(n-1)>=x):
print(y-n+1)
for i in range(n-1):
print(1)
else:
print(-1)
``` | output | 1 | 20,336 | 20 | 40,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,337 | 20 | 40,674 |
Tags: greedy
Correct Solution:
```
n, x, y = list(map(int, input().split()))
if y >= n and n - 1 + (y - n + 1) ** 2 >= x:
print(' '.join(map(str, [1] * (n - 1) + [y - n + 1])))
else:
print(-1)
``` | output | 1 | 20,337 | 20 | 40,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,338 | 20 | 40,676 |
Tags: greedy
Correct Solution:
```
n,x,y=[int(p) for p in input().split()]
if n>y or (y-n+1)**2 + n - 1<x:
print(-1)
else:
print(y-n+1)
for i in range(1,n):
print(1)
``` | output | 1 | 20,338 | 20 | 40,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,339 | 20 | 40,678 |
Tags: greedy
Correct Solution:
```
n, x, y = map(int, input().split())
if (n - 1 + (y - n + 1) ** 2 >= x and y > n - 1):
print('1 '* (n - 1) + str(y - n + 1))
else:
print(-1)
``` | output | 1 | 20,339 | 20 | 40,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,340 | 20 | 40,680 |
Tags: greedy
Correct Solution:
```
n,x,y=map(int,input().split())
sl=y-(n-1)
sm=n-1+sl**2
if sl<=0 or sm<x:
print(-1)
else:
for i in range(n-1):
print(1)
print(sl)
``` | output | 1 | 20,340 | 20 | 40,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:
* a12 + a22 + ... + an2 β₯ x
* a1 + a2 + ... + an β€ y
Input
The first line contains three space-se... | instruction | 0 | 20,341 | 20 | 40,682 |
Tags: greedy
Correct Solution:
```
n, x, y = map(int, input().split())
if n > y:
print(-1)
else:
left = y - n
left += 1
if left ** 2 + n - 1 >= x:
print(left)
for _ in range(n - 1):
print(1)
else:
print(-1)
``` | output | 1 | 20,341 | 20 | 40,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.
Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel t... | instruction | 0 | 20,484 | 20 | 40,968 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
t = int(input())
def solve():
n = int(input())
if n == 1 :
print(9)
elif n == 2:
print(98)
elif n == 3:
print(989)
else:
x = 0
print(989, end = "")
for _ in range(n-3):
print(x, end = "")
x += 1
if x == 10:
x=0
print("")
... | output | 1 | 20,484 | 20 | 40,969 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.
Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel t... | instruction | 0 | 20,485 | 20 | 40,970 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
if n==1:print(9)
elif n==2:print(98)
elif n==3:print(989)
else:
print(989,end="")
if n<=13:
for i in range(n-3):
print(i,end="")
pri... | output | 1 | 20,485 | 20 | 40,971 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.
Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel t... | instruction | 0 | 20,486 | 20 | 40,972 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import sys
input = sys.stdin.readline
for i in range(int(input())):
n = int(input())
tmp = ['9','8','9']
if n<=3:
tmp = tmp[:n]
tmp = ''.join(tmp)
else:
for i in range(n-3):
tmp.append(str((i)%10))
... | output | 1 | 20,486 | 20 | 40,973 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.
Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel t... | instruction | 0 | 20,487 | 20 | 40,974 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from collections import Counter
import string
import math
import sys
# sys.setrecursionlimit(10**6)
from fractions import Fraction
def array_int():
return [int(i) for i in sys.stdin.readline().split()]
def vary(arrber_of_variables):
if arrber_of... | output | 1 | 20,487 | 20 | 40,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.
Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel t... | instruction | 0 | 20,488 | 20 | 40,976 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
t=int(input())
l=[]
m=0
s1='9890123456789'
s2='0123456789'
for i in range(t):
n=int(input())
if(n==0):
print(0)
elif(n<=13):
print(s1[0:n])
else:
x=n-3
... | output | 1 | 20,488 | 20 | 40,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.
Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel t... | instruction | 0 | 20,489 | 20 | 40,978 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import sys
from functools import reduce
from collections import Counter
import time
import datetime
import math
# def time_t():
# print("Current date and time: " , datetime.datetime.now())
# print("Current year: ", datetime.date.today().strftim... | output | 1 | 20,489 | 20 | 40,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.
Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel t... | instruction | 0 | 20,490 | 20 | 40,980 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
s = '989' + '0123456789' * 20000
T = int(input())
for _ in range(T):
N = int(input())
print(s[:N])
``` | output | 1 | 20,490 | 20 | 40,981 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.