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. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1
instruction
0
79,452
20
158,904
Tags: data structures, dp, greedy, implementation Correct Solution: ``` """ for _ in range(int(input())): n,m = map(int,input().split()) l=[] ans=0 for i in range(n): s = input() l.append(s) # print(l) for i in range(n): for j in range(m): if l[i][j]=="C": continue elif i+1==n and l[i][j]=="D": ans+=1 elif j+1==m and l[i][j]=="R": ans+=1 print(ans) """ """ t = int(input()) for _ in range(t): poss=0 cnt=0 cnt1=0 cnt2=0 ans=1000000000 n,e,h,a,b,c = map(int,input().split()) ee = e-min(e,h) hh = h-min(e,h) # ttt=0 poss+=min(e,h) if ee>0: poss+=(ee//2) # ttt+=(ee//2) elif hh>0: poss+=(hh//3) if poss<n: #print(poss) print(-1) else: if n<=0: cnt=0 elif c<=a and c<=b: if min(e,h)>=n: cnt+=n*c else: cnt+=(min(e,h)*c) min1 = min(e,h) n-=min1 e-=min1 h-=min1 if h>0: cnt+=(n)*b elif e>0: cnt+=(n)*a elif c>=a and c>=b: if a<=c and a>=b: pp=h//3 tttt = h%3 if pp>=n: cnt+=n*b else: pp+=e//2 ssss = e%2 if pp>=n: cnt+=(((h//3)*b)+(n-h//3)*a) else: pp+=min(tttt,ssss) # rrrr = n-(h//3+min(ssss,tttt)) # n-=rrrr if pp>=n: cnt+=((((h//3)*b)+(e//2)*a)+((n-(h//3+e//2))*c)) else: if min(e, h) >= n: cnt += n * c else: cnt += (min(e, h) * c) min1 = min(e,h) n -= min1 e -= min1 h -= min1 if h > 0: cnt += (n) * b elif e > 0: cnt += (n) * a elif b<=c and b>=a: # print(poss) pp=e//2 ssss = e%2 if pp>=n: cnt+=n*a else: pp+=h//3 tttt = h%3 # print(ssss,tttt,n) if pp>=n: # print(poss) cnt+=(((e//2)*a)+(n-e//2)*b) else: pp+=min(tttt,ssss) if pp>=n: cnt+=((((e//2)*a)+((h//3)*b))+(n-(h//3+e//2))*c) else: if min(e,h) >= n: cnt += n * c else: cnt += (min(e, h) * c) min1 = min(e,h) n -= min1 e -= min1 h -= min1 if h > 0: cnt += (n) * b elif e > 0: cnt += (n) * a elif a>=c and a>=b: if c<=a and c>=b: pp = h // 3 tttt=h%3 if pp >= n: cnt += n * b else: pp +=min(tttt,e) pppp = tttt-min(tttt,e) ssss = e-min(tttt,e) if pp >= n: cnt += (((h // 3) * b) + (n-h//3) * c) else: if pppp>0: pp+=pppp//3 if pp>=n: cnt+=(((h//3)*b)+(min(tttt,e))*c+(n-(h//3+min(tttt,e)))*b) else: if min(e, h) >= n: cnt += n * c else: cnt += (min(e, h) * c) min1 = min(e,h) n -= min1 e -= min1 h -= min1 if h > 0: cnt += (n) * b elif e > 0: cnt += (n) * a elif ssss>0: pp+=ssss//2 if pp>=n: cnt+=(((h//3)*b)+(min(tttt,e)*c)+(n-(h//3+min(e,tttt)))*a) else: if min(e, h) >= n: cnt += n * c else: cnt += (min(e, h) * c) min1 = min(e,h) n -= min1 e -= min1 h -= min1 if h > 0: cnt += (n) * b elif e > 0: cnt += (n) * a elif b>=c and b>=a: if c<=b and c>=a: pp = e // 2 ssss = e%2 if pp >= n: cnt += n * a else: pp += min(h, ssss) pppp = ssss - min(ssss,h) tttt = h-min(ssss,h) if pp >= n: cnt += (((e//2) * a) + (n - e//2) * c) else: if tttt > 0: pp += tttt // 3 if pp >= n: cnt += (((e//2) * a) + (min(h, ssss)) * c + (n - (e//2 + min(h, ssss))) * b) else: if min(e, h) >= n: cnt += n * c else: cnt += (min(e, h) * c) min1 = min(e,h) n -= min1 e -= min1 h -= min1 if h > 0: cnt += (n) * b elif e > 0: cnt += (n) * a elif pppp > 0: pp += pppp // 2 if pp >= n: cnt += (((e//2) * a) + (min(h, ssss) * c) + (n - (e//2 + min(ssss, h))) * a) else: if min(e, h) >= n: cnt += n * c else: cnt += (min(e, h) * c) min1 = min(e,h) n -= min1 e -= min1 h -= min1 if h > 0: cnt += (n) * b elif e > 0: cnt += (n) * a print(cnt) """ """ n = int(input()) arr = list(map(int,input().split())) if arr.count(0)==0: print(-1) else: five = arr.count(5) five = five-five%9 if five==0: print(0) else: print("5"*five+"0"*arr.count(0)) """ """ def binaryToDecimal(n): return int(n,2) s = input() s=s.replace(">","1000") s=s.replace("<","1001") s=s.replace("+","1010") s=s.replace("-","1011") s=s.replace(".","1100") s=s.replace(",","1101") s=s.replace("[","1110") s=s.replace("]","1111") p = binaryToDecimal(s) ans = p%((10**6) +3) print(ans) """ """ n,m,d = map(int,input().split()) dd=[] for _ in range(n): arr = list(map(int,input().split())) dd+=arr dd=sorted(dd) #print(dd) for i in range(len(dd)): #print((dd[i]-dd[0])%d) if (dd[i]-dd[0])%d!=0: # print(dd[i]) print(-1) break else: ll=[] tt =set(dd) tt = list(tt) sum=0 i=0 while(i<len(tt)): for j in range(len(dd)): sum+=abs(dd[j]-tt[i]) ll.append(sum) sum=0 i+=1 #print(ll) print(min(ll)//d) """ """ n,k = map(int,input().split()) arr = list(map(int,input().split())) min1=100000000000 c=0 for i in range(k): sum1=sum(arr[i::k]) # print(sum1) if sum1<min1: c=i min1= sum1 print(c+1) """ """ n = int(input()) s=n l=[n] i=s-1 while(s>0): if i==0: break if s%i==0: l.append(i) s=i i=s-1 if i==0: break else: i-=1 print(*l) """ """ n,a,b = map(int,input().split()) slope=[] for _ in range(n): x,y = map(int,input().split()) if x-a !=0: slope.append((y-b)/(x-a)) else: slope.append("0") print(len(set(slope))) """ """ s = input() ss = input() t = set(ss) t = list(t) for i in t: if i not in s: print(-1) break else: sum1=0 for i in t: sum1+=min(s.count(i),ss.count(i)) print(sum1) """ """ n,m = map(int,input().split()) l=[0]*(n+1) for _ in range(m): p=[1,2,3] arr = list(map(int,input().split())) for i in arr: if l[i]!=0: p.remove(l[i]) for i in arr: if l[i]==0: l[i]=p.pop() # print(p) for i in range(1,n+1): print(l[i],end=" ") """ """ from itertools import accumulate m, n = map(int, input().split()) t = [] for i in range(m): arr= list(map(int, input().split())) t.append(arr) d = [0] * m for i in range(n): d[0] += t[0][i] for j in range(1, m): d[j] = max(d[j - 1], d[j]) + t[j][i] print(*d) """ """ n = int(input()) s="abcd" t=s*1000001 print(t[:n]) """ """ d={} def f(n): if n in d.keys(): return d[n] a=n//2 b=n//3 c=n//4 if a+b+c>n: t= f(a)+f(b)+f(c) d[n]=t return t else: d[n]=n return n for i in range(10): try: n=int(input()) print(f(n)) except: break """ """ def C(n, k): k = min(n - k, k) answer = 1 for i in range(k): answer *= (n - i) for i in range(k, 1, -1): answer = answer // i return answer numTest = int(input()) for i in range(numTest): N, k = [int(j) for j in input().split(' ')] print(C(N - 1, k - 1)) """ """ n= int(input()) arr = list(map(int,input().split())) r=0 #cnt=0 for i in range(n): j=i while j+1<n and arr[j+1]>=arr[j]: j+=1 #j=i #print(j) while j+1<n and arr[j]>=arr[j+1]: j+=1 # print(j,i) r = max(r,j-i+1) print(r) """ """ a,b,c,d = map(int,input().split()) x=a/b y=c/d xx = 1-x yy = 1-y f = x/(1-(xx*yy)) print(f) """ """ import math n,k,l,m = map(int,input().split()) k=k*l m=m*n a=abs(k-m) b=max(k,m) x=math.gcd(a,b) a//=x b//=x print(str(a)+"/"+str(b)) """ v = int(input()) arr = list(map(int,input().split())) min1 = min(arr) #index1 = arr.index(min1) if v==0: print("-1") else: if min1>v: print(-1) else: rem = v//min1 for i in range(rem, 0, -1): for j in range(9, 0, -1): if v - arr[j - 1] >= min1 * (i - 1): print(j, end="") v -= arr[j - 1] break print() ```
output
1
79,452
20
158,905
Provide tags and a correct Python 3 solution for this coding contest problem. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1
instruction
0
79,453
20
158,906
Tags: data structures, dp, greedy, implementation Correct Solution: ``` v = int(input()) a = list(map(int, input().split())) m = min(a) if v < m: print(-1) else: a = [0] + a d = [0] * 10 k = 9 - a[::-1].index(m) n = v // m d[k] = n v -= n * m for i in range(0, n): for j in range(9, k, -1): if v >= a[j]-a[k]: v -= a[j] - m d[j] += 1 d[k] -= 1 break if v <= 0: break for i in range(9, k-1, -1): print(str(i)*d[i], end='') print() ```
output
1
79,453
20
158,907
Provide tags and a correct Python 3 solution for this coding contest problem. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1
instruction
0
79,454
20
158,908
Tags: data structures, dp, greedy, implementation Correct Solution: ``` n = int(input()) l = list(map(int,input().split())) c = 0 x = len(l) w = "" zzz = 0 q = 0 mi = min(l) q = l.index(min(l)) if n//min(l) == 0: print(-1) else: l1 = [0]*(n//min(l)) aa = n//mi - 1 cc = 0 for i in range(len(l1)): for j in range(8,q-2,-1): if aa*mi + l[j] + cc<=n: aa-=1 cc+=l[j] l1[i] = str(j+1) break k = "".join(l1) print(k) ```
output
1
79,454
20
158,909
Provide tags and a correct Python 3 solution for this coding contest problem. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1
instruction
0
79,455
20
158,910
Tags: data structures, dp, greedy, implementation Correct Solution: ``` if __name__=='__main__': n = (int)(input()) l = list(map(int, input().split())) m = min(l) if n<m: print("-1") elif n%m == 0: s = -1 for i in range(8,-1,-1): if l[i] == m: s = i+1 break print(str(s)*((int)(n/m))) else: s = -1 for i in range(8,-1,-1): if l[i] == m: s=i+1 break st = str(s)*((int)(n/m)) st = list(st) n-=(len(st)*m) j = 8 index = 0 while n!=0 and j>=0 and index<len(st): if l[j]<=(m+n): st[index]=str(j+1) index+=1 n=n+m-l[j] else: j-=1 print("".join(st)) ```
output
1
79,455
20
158,911
Provide tags and a correct Python 3 solution for this coding contest problem. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1
instruction
0
79,456
20
158,912
Tags: data structures, dp, greedy, implementation Correct Solution: ``` n = int(input()) lis=list(map(int,input().split())) aa=lis.index(min(lis))+1 a = min(lis) no = list(str(aa)*(n//a)) if len(no)==0: print(-1) exit() dig = n//a n-=(dig*a) #print(dig,no,n,a,aa) for i in range(dig): ss=0 for j in range(8,aa-1,-1): # print(j,i,lis[int(no[i])-1],lis[j],n,lis[int(no[i])-1]-lis[j]) if n+lis[int(no[i])-1]-lis[j]>=0: # no[i]=str(j+1) n+=(lis[int(no[i])-1]-lis[j]) no[i]=str(j+1) # print(lis[int(no[i])],lis[j]) ss=1 break # print(n) if ss==0: break print(''.join(no)) ```
output
1
79,456
20
158,913
Provide tags and a correct Python 3 solution for this coding contest problem. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1
instruction
0
79,457
20
158,914
Tags: data structures, dp, greedy, implementation Correct Solution: ``` # Author : nitish420 -------------------------------------------------------------------- import os import sys from io import BytesIO, IOBase mod=10**9+7 # sys.setrecursionlimit(10**6) from math import inf def main(): w=int(input()) a=list(map(int,input().split())) mm = min(a) n = w//mm if n == 0: print(-1) exit() if w%mm==0: mi=9 for item in a[::-1]: if item==mm: break mi-=1 print(f"{mi}"*(w//mm)) exit() else: for i in range(n, 0, -1): for j in range(8, -1, -1): if w - a[j] >= mm * (i-1): print(j+1, end = "") w -= a[j] break print() # 62800 # 867 936 2 888 474 530 287 822 220 # 50 # 5 3 10 2 2 4 3 6 5 # 5555555555555555555555557 #---------------------------------------------------------------------------------------- def nouse0(): # This is to save my code from plag due to use of FAST IO template in it. a=420 b=420 print(f'i am nitish{(a+b)//2}') def nouse1(): # This is to save my code from plag due to use of FAST IO template in it. a=420 b=420 print(f'i am nitish{(a+b)//2}') def nouse2(): # This is to save my code from plag due to use of FAST IO template in it. a=420 b=420 print(f'i am nitish{(a+b)//2}') # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = 'x' in file.mode or 'r' not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b'\n') + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode('ascii')) self.read = lambda: self.buffer.read().decode('ascii') self.readline = lambda: self.buffer.readline().decode('ascii') sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip('\r\n') def nouse3(): # This is to save my code from plag due to use of FAST IO template in it. a=420 b=420 print(f'i am nitish{(a+b)//2}') def nouse4(): # This is to save my code from plag due to use of FAST IO template in it. a=420 b=420 print(f'i am nitish{(a+b)//2}') def nouse5(): # This is to save my code from plag due to use of FAST IO template in it. a=420 b=420 print(f'i am nitish{(a+b)//2}') # endregion if __name__ == '__main__': main() ```
output
1
79,457
20
158,915
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1 Submitted Solution: ``` n=int(input()) S=list(map(int,input().split())) K=[0]*9 m=min(S) d=0 di=0 len = n//m for i in range(8,-1,-1): if S[i]==m: d=i+1 break n-=((n//m)*m-m) for i in range(8,-1,-1): if S[i]<=n: di=i+1 break if len: print(str(di)+str(d)*(len-1)) else: print(-1) ```
instruction
0
79,464
20
158,928
No
output
1
79,464
20
158,929
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence. Input The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105). Output Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1. Examples Input 5 5 4 3 2 1 2 3 4 5 Output 55555 Input 2 9 11 1 12 5 8 9 10 6 Output 33 Input 0 1 1 1 1 1 1 1 1 1 Output -1 Submitted Solution: ``` v = int(input()) a = list(map(int, input().split())) def f(m): for i,x in enumerate(reversed(a)): if m // x != 0: return str(9-i)*(m // x) + f(m%x) return "" ans = -1 if min(a) > v: print("-1") else: for i,(d,m) in enumerate(reversed([divmod(v, x) for x in a])): ans = max(ans, int(str(9 - i)*d + f(m))) print(ans) ```
instruction
0
79,465
20
158,930
No
output
1
79,465
20
158,931
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,620
20
159,240
Tags: *special, implementation, math Correct Solution: ``` number = input() drop = False d8 = False dropIndex = 0 for i in range(1,len(number)): if number[i]=='9' and d8 == False: dropIndex = i if number[i]>='0' and number[i]<='7': drop = True break if number[i]=='8' and d8 == True: drop = True break if number[i]=='8' and d8 == False: d8 = True if drop: out = '' if dropIndex > 0: out = number out = out[:dropIndex] + str(int(out[dropIndex])-1) else: if int(number[dropIndex])>1: out += str(int(number[dropIndex])-1) for i in range(dropIndex+1,len(number)): out += '9' print(out) else: print(number) ```
output
1
79,620
20
159,241
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,621
20
159,242
Tags: *special, implementation, math Correct Solution: ``` def get(s): ans = 0 for i in s: ans += (ord(i) - ord('0')) return ans def solve1(): x = input() n = len(x) best_ans = x best_val = get(x) ans = str('' if int(x[0]) - 1 == 0 else int(x[0]) - 1) + '9' * (n - 1) if get(ans) > best_val or (get(ans) >= best_val and int(ans) > int(best_ans)): best_ans = ans best_val = get(ans) for i in range(1, n): #print(ans) ans = x[:i] + str(int(x[i]) - 1) + '9' * (n - i - 1) if get(ans) > best_val or (get(ans) >= best_val and int(ans) > int(best_ans)): best_ans = ans best_val = get(ans) return best_ans best = [0] * 10000 def solve2(): global best was = 0 for i in range(1, 10000): if get(str(i)) >= was: best[i] = i was = get(str(i)) else: best[i] = best[i - 1] def stress(): solve2() for i in range(1, 10000): if int(solve1(str(i))) != best[i]: print(i, best[i], solve1(str(i))) #stress() print(solve1()) ```
output
1
79,621
20
159,243
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,622
20
159,244
Tags: *special, implementation, math Correct Solution: ``` x = input() xlen = len(x) - 1 x0 = x[0] x00 = str(int(x0) - 1) sum = int(x00) + 9*xlen if x00 == '0': x00 = '' ans = x00 + '9'*xlen if int(x0 + '9'*xlen) <= int(x): ans = int(x0 + '9'*xlen) print(ans) else: for i in range(xlen, 0, -1): a = x0 + '9'*(xlen - i) + '8' + '9'*(i-1) if int(a) <= int(x): oldsum = sum sum = 0 for i in range(len(a)): sum += int(a[i]) if sum >= oldsum: ans = a else: sum = oldsum print(ans) ```
output
1
79,622
20
159,245
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,623
20
159,246
Tags: *special, implementation, math Correct Solution: ``` s = input() a = list(map(int, s)) ans = a for i in range(len(a) - 1, -1, -1): b = a.copy() if b[i] != 0: b[i] = int(a[i]) - 1 b[i + 1:] = map(lambda x: 9, b[i + 1:]) if sum(b) > sum(ans): ans = b print(int(''.join(map(str, ans)))) ```
output
1
79,623
20
159,247
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,624
20
159,248
Tags: *special, implementation, math Correct Solution: ``` def sum(A): sum = 0 for k in A: sum += k return sum x = input() numbers = [] for a in x: numbers.append(int(a)) len = numbers.__len__()-1 max = numbers.copy() for i in range(len): numbers[len - i] = 9 numbers[len - i - 1] -= 1 if (sum(numbers) > sum(max)): max = numbers.copy() answ = 0 for i in range(len+1): answ += max[len - i] * 10**i print(answ) ```
output
1
79,624
20
159,249
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,625
20
159,250
Tags: *special, implementation, math Correct Solution: ``` a=[1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 19, 28, 29, 38, 39, 48, 49, 58, 59, 68, 69, 78, 79, 88, 89, 98, 99, 189, 198, 199, 289, 298, 299, 389, 398, 399, 489, 498, 499, 589, 598, 599, 689, 698, 699, 789, 798, 799, 889, 898, 899, 989, 998, 999, 1899, 1989, 1998, 1999, 2899, 2989, 2998, 2999, 3899, 3989, 3998, 3999, 4899, 4989, 4998, 4999, 5899, 5989, 5998, 5999, 6899, 6989, 6998, 6999, 7899, 7989, 7998, 7999, 8899, 8989, 8998, 8999, 9899, 9989, 9998, 9999, 18999, 19899, 19989, 19998, 19999, 28999, 29899, 29989, 29998, 29999, 38999, 39899, 39989, 39998, 39999, 48999, 49899, 49989, 49998, 49999, 58999, 59899, 59989, 59998, 59999, 68999, 69899, 69989, 69998, 69999, 78999, 79899, 79989, 79998, 79999, 88999, 89899, 89989, 89998, 89999, 98999, 99899, 99989, 99998, 99999, 189999, 198999, 199899, 199989, 199998, 199999, 289999, 298999, 299899, 299989, 299998, 299999, 389999, 398999, 399899, 399989, 399998, 399999, 489999, 498999, 499899, 499989, 499998, 499999, 589999, 598999, 599899, 599989, 599998, 599999, 689999, 698999, 699899, 699989, 699998, 699999, 789999, 798999, 799899, 799989, 799998, 799999, 889999, 898999, 899899, 899989, 899998, 899999, 989999, 998999, 999899, 999989, 999998, 999999, 1899999, 1989999, 1998999, 1999899, 1999989, 1999998, 1999999, 2899999, 2989999, 2998999, 2999899, 2999989, 2999998, 2999999, 3899999, 3989999, 3998999, 3999899, 3999989, 3999998, 3999999, 4899999, 4989999, 4998999, 4999899, 4999989, 4999998, 4999999, 5899999, 5989999, 5998999, 5999899, 5999989, 5999998, 5999999, 6899999, 6989999, 6998999, 6999899, 6999989, 6999998, 6999999, 7899999, 7989999, 7998999, 7999899, 7999989, 7999998, 7999999, 8899999, 8989999, 8998999, 8999899, 8999989, 8999998, 8999999, 9899999, 9989999, 9998999, 9999899, 9999989, 9999998, 9999999, 18999999, 19899999, 19989999, 19998999, 19999899, 19999989, 19999998, 19999999, 28999999, 29899999, 29989999, 29998999, 29999899, 29999989, 29999998, 29999999, 38999999, 39899999, 39989999, 39998999, 39999899, 39999989, 39999998, 39999999, 48999999, 49899999, 49989999, 49998999, 49999899, 49999989, 49999998, 49999999, 58999999, 59899999, 59989999, 59998999, 59999899, 59999989, 59999998, 59999999, 68999999, 69899999, 69989999, 69998999, 69999899, 69999989, 69999998, 69999999, 78999999, 79899999, 79989999, 79998999, 79999899, 79999989, 79999998, 79999999, 88999999, 89899999, 89989999, 89998999, 89999899, 89999989, 89999998, 89999999, 98999999, 99899999, 99989999, 99998999, 99999899, 99999989, 99999998, 99999999, 189999999, 198999999, 199899999, 199989999, 199998999, 199999899, 199999989, 199999998, 199999999, 289999999, 298999999, 299899999, 299989999, 299998999, 299999899, 299999989, 299999998, 299999999, 389999999, 398999999, 399899999, 399989999, 399998999, 399999899, 399999989, 399999998, 399999999, 489999999, 498999999, 499899999, 499989999, 499998999, 499999899, 499999989, 499999998, 499999999, 589999999, 598999999, 599899999, 599989999, 599998999, 599999899, 599999989, 599999998, 599999999, 689999999, 698999999, 699899999, 699989999, 699998999, 699999899, 699999989, 699999998, 699999999, 789999999, 798999999, 799899999, 799989999, 799998999, 799999899, 799999989, 799999998, 799999999, 889999999, 898999999, 899899999, 899989999, 899998999, 899999899, 899999989, 899999998, 899999999, 989999999, 998999999, 999899999, 999989999, 999998999, 999999899, 999999989, 999999998, 999999999, 1899999999, 1989999999, 1998999999, 1999899999, 1999989999, 1999998999, 1999999899, 1999999989, 1999999998, 1999999999, 2899999999, 2989999999, 2998999999, 2999899999, 2999989999, 2999998999, 2999999899, 2999999989, 2999999998, 2999999999, 3899999999, 3989999999, 3998999999, 3999899999, 3999989999, 3999998999, 3999999899, 3999999989, 3999999998, 3999999999, 4899999999, 4989999999, 4998999999, 4999899999, 4999989999, 4999998999, 4999999899, 4999999989, 4999999998, 4999999999, 5899999999, 5989999999, 5998999999, 5999899999, 5999989999, 5999998999, 5999999899, 5999999989, 5999999998, 5999999999, 6899999999, 6989999999, 6998999999, 6999899999, 6999989999, 6999998999, 6999999899, 6999999989, 6999999998, 6999999999, 7899999999, 7989999999, 7998999999, 7999899999, 7999989999, 7999998999, 7999999899, 7999999989, 7999999998, 7999999999, 8899999999, 8989999999, 8998999999, 8999899999, 8999989999, 8999998999, 8999999899, 8999999989, 8999999998, 8999999999, 9899999999, 9989999999, 9998999999, 9999899999, 9999989999, 9999998999, 9999999899, 9999999989, 9999999998, 9999999999, 18999999999, 19899999999, 19989999999, 19998999999, 19999899999, 19999989999, 19999998999, 19999999899, 19999999989, 19999999998, 19999999999, 28999999999, 29899999999, 29989999999, 29998999999, 29999899999, 29999989999, 29999998999, 29999999899, 29999999989, 29999999998, 29999999999, 38999999999, 39899999999, 39989999999, 39998999999, 39999899999, 39999989999, 39999998999, 39999999899, 39999999989, 39999999998, 39999999999, 48999999999, 49899999999, 49989999999, 49998999999, 49999899999, 49999989999, 49999998999, 49999999899, 49999999989, 49999999998, 49999999999, 58999999999, 59899999999, 59989999999, 59998999999, 59999899999, 59999989999, 59999998999, 59999999899, 59999999989, 59999999998, 59999999999, 68999999999, 69899999999, 69989999999, 69998999999, 69999899999, 69999989999, 69999998999, 69999999899, 69999999989, 69999999998, 69999999999, 78999999999, 79899999999, 79989999999, 79998999999, 79999899999, 79999989999, 79999998999, 79999999899, 79999999989, 79999999998, 79999999999, 88999999999, 89899999999, 89989999999, 89998999999, 89999899999, 89999989999, 89999998999, 89999999899, 89999999989, 89999999998, 89999999999, 98999999999, 99899999999, 99989999999, 99998999999, 99999899999, 99999989999, 99999998999, 99999999899, 99999999989, 99999999998, 99999999999, 189999999999, 198999999999, 199899999999, 199989999999, 199998999999, 199999899999, 199999989999, 199999998999, 199999999899, 199999999989, 199999999998, 199999999999, 289999999999, 298999999999, 299899999999, 299989999999, 299998999999, 299999899999, 299999989999, 299999998999, 299999999899, 299999999989, 299999999998, 299999999999, 389999999999, 398999999999, 399899999999, 399989999999, 399998999999, 399999899999, 399999989999, 399999998999, 399999999899, 399999999989, 399999999998, 399999999999, 489999999999, 498999999999, 499899999999, 499989999999, 499998999999, 499999899999, 499999989999, 499999998999, 499999999899, 499999999989, 499999999998, 499999999999, 589999999999, 598999999999, 599899999999, 599989999999, 599998999999, 599999899999, 599999989999, 599999998999, 599999999899, 599999999989, 599999999998, 599999999999, 689999999999, 698999999999, 699899999999, 699989999999, 699998999999, 699999899999, 699999989999, 699999998999, 699999999899, 699999999989, 699999999998, 699999999999, 789999999999, 798999999999, 799899999999, 799989999999, 799998999999, 799999899999, 799999989999, 799999998999, 799999999899, 799999999989, 799999999998, 799999999999, 889999999999, 898999999999, 899899999999, 899989999999, 899998999999, 899999899999, 899999989999, 899999998999, 899999999899, 899999999989, 899999999998, 899999999999, 989999999999, 998999999999, 999899999999, 999989999999, 999998999999, 999999899999, 999999989999, 999999998999, 999999999899, 999999999989, 999999999998, 999999999999, 1899999999999, 1989999999999, 1998999999999, 1999899999999, 1999989999999, 1999998999999, 1999999899999, 1999999989999, 1999999998999, 1999999999899, 1999999999989, 1999999999998, 1999999999999, 2899999999999, 2989999999999, 2998999999999, 2999899999999, 2999989999999, 2999998999999, 2999999899999, 2999999989999, 2999999998999, 2999999999899, 2999999999989, 2999999999998, 2999999999999, 3899999999999, 3989999999999, 3998999999999, 3999899999999, 3999989999999, 3999998999999, 3999999899999, 3999999989999, 3999999998999, 3999999999899, 3999999999989, 3999999999998, 3999999999999, 4899999999999, 4989999999999, 4998999999999, 4999899999999, 4999989999999, 4999998999999, 4999999899999, 4999999989999, 4999999998999, 4999999999899, 4999999999989, 4999999999998, 4999999999999, 5899999999999, 5989999999999, 5998999999999, 5999899999999, 5999989999999, 5999998999999, 5999999899999, 5999999989999, 5999999998999, 5999999999899, 5999999999989, 5999999999998, 5999999999999, 6899999999999, 6989999999999, 6998999999999, 6999899999999, 6999989999999, 6999998999999, 6999999899999, 6999999989999, 6999999998999, 6999999999899, 6999999999989, 6999999999998, 6999999999999, 7899999999999, 7989999999999, 7998999999999, 7999899999999, 7999989999999, 7999998999999, 7999999899999, 7999999989999, 7999999998999, 7999999999899, 7999999999989, 7999999999998, 7999999999999, 8899999999999, 8989999999999, 8998999999999, 8999899999999, 8999989999999, 8999998999999, 8999999899999, 8999999989999, 8999999998999, 8999999999899, 8999999999989, 8999999999998, 8999999999999, 9899999999999, 9989999999999, 9998999999999, 9999899999999, 9999989999999, 9999998999999, 9999999899999, 9999999989999, 9999999998999, 9999999999899, 9999999999989, 9999999999998, 9999999999999, 18999999999999, 19899999999999, 19989999999999, 19998999999999, 19999899999999, 19999989999999, 19999998999999, 19999999899999, 19999999989999, 19999999998999, 19999999999899, 19999999999989, 19999999999998, 19999999999999, 28999999999999, 29899999999999, 29989999999999, 29998999999999, 29999899999999, 29999989999999, 29999998999999, 29999999899999, 29999999989999, 29999999998999, 29999999999899, 29999999999989, 29999999999998, 29999999999999, 38999999999999, 39899999999999, 39989999999999, 39998999999999, 39999899999999, 39999989999999, 39999998999999, 39999999899999, 39999999989999, 39999999998999, 39999999999899, 39999999999989, 39999999999998, 39999999999999, 48999999999999, 49899999999999, 49989999999999, 49998999999999, 49999899999999, 49999989999999, 49999998999999, 49999999899999, 49999999989999, 49999999998999, 49999999999899, 49999999999989, 49999999999998, 49999999999999, 58999999999999, 59899999999999, 59989999999999, 59998999999999, 59999899999999, 59999989999999, 59999998999999, 59999999899999, 59999999989999, 59999999998999, 59999999999899, 59999999999989, 59999999999998, 59999999999999, 68999999999999, 69899999999999, 69989999999999, 69998999999999, 69999899999999, 69999989999999, 69999998999999, 69999999899999, 69999999989999, 69999999998999, 69999999999899, 69999999999989, 69999999999998, 69999999999999, 78999999999999, 79899999999999, 79989999999999, 79998999999999, 79999899999999, 79999989999999, 79999998999999, 79999999899999, 79999999989999, 79999999998999, 79999999999899, 79999999999989, 79999999999998, 79999999999999, 88999999999999, 89899999999999, 89989999999999, 89998999999999, 89999899999999, 89999989999999, 89999998999999, 89999999899999, 89999999989999, 89999999998999, 89999999999899, 89999999999989, 89999999999998, 89999999999999, 98999999999999, 99899999999999, 99989999999999, 99998999999999, 99999899999999, 99999989999999, 99999998999999, 99999999899999, 99999999989999, 99999999998999, 99999999999899, 99999999999989, 99999999999998, 99999999999999, 189999999999999, 198999999999999, 199899999999999, 199989999999999, 199998999999999, 199999899999999, 199999989999999, 199999998999999, 199999999899999, 199999999989999, 199999999998999, 199999999999899, 199999999999989, 199999999999998, 199999999999999, 289999999999999, 298999999999999, 299899999999999, 299989999999999, 299998999999999, 299999899999999, 299999989999999, 299999998999999, 299999999899999, 299999999989999, 299999999998999, 299999999999899, 299999999999989, 299999999999998, 299999999999999, 389999999999999, 398999999999999, 399899999999999, 399989999999999, 399998999999999, 399999899999999, 399999989999999, 399999998999999, 399999999899999, 399999999989999, 399999999998999, 399999999999899, 399999999999989, 399999999999998, 399999999999999, 489999999999999, 498999999999999, 499899999999999, 499989999999999, 499998999999999, 499999899999999, 499999989999999, 499999998999999, 499999999899999, 499999999989999, 499999999998999, 499999999999899, 499999999999989, 499999999999998, 499999999999999, 589999999999999, 598999999999999, 599899999999999, 599989999999999, 599998999999999, 599999899999999, 599999989999999, 599999998999999, 599999999899999, 599999999989999, 599999999998999, 599999999999899, 599999999999989, 599999999999998, 599999999999999, 689999999999999, 698999999999999, 699899999999999, 699989999999999, 699998999999999, 699999899999999, 699999989999999, 699999998999999, 699999999899999, 699999999989999, 699999999998999, 699999999999899, 699999999999989, 699999999999998, 699999999999999, 789999999999999, 798999999999999, 799899999999999, 799989999999999, 799998999999999, 799999899999999, 799999989999999, 799999998999999, 799999999899999, 799999999989999, 799999999998999, 799999999999899, 799999999999989, 799999999999998, 799999999999999, 889999999999999, 898999999999999, 899899999999999, 899989999999999, 899998999999999, 899999899999999, 899999989999999, 899999998999999, 899999999899999, 899999999989999, 899999999998999, 899999999999899, 899999999999989, 899999999999998, 899999999999999, 989999999999999, 998999999999999, 999899999999999, 999989999999999, 999998999999999, 999999899999999, 999999989999999, 999999998999999, 999999999899999, 999999999989999, 999999999998999, 999999999999899, 999999999999989, 999999999999998, 999999999999999, 1899999999999999, 1989999999999999, 1998999999999999, 1999899999999999, 1999989999999999, 1999998999999999, 1999999899999999, 1999999989999999, 1999999998999999, 1999999999899999, 1999999999989999, 1999999999998999, 1999999999999899, 1999999999999989, 1999999999999998, 1999999999999999, 2899999999999999, 2989999999999999, 2998999999999999, 2999899999999999, 2999989999999999, 2999998999999999, 2999999899999999, 2999999989999999, 2999999998999999, 2999999999899999, 2999999999989999, 2999999999998999, 2999999999999899, 2999999999999989, 2999999999999998, 2999999999999999, 3899999999999999, 3989999999999999, 3998999999999999, 3999899999999999, 3999989999999999, 3999998999999999, 3999999899999999, 3999999989999999, 3999999998999999, 3999999999899999, 3999999999989999, 3999999999998999, 3999999999999899, 3999999999999989, 3999999999999998, 3999999999999999, 4899999999999999, 4989999999999999, 4998999999999999, 4999899999999999, 4999989999999999, 4999998999999999, 4999999899999999, 4999999989999999, 4999999998999999, 4999999999899999, 4999999999989999, 4999999999998999, 4999999999999899, 4999999999999989, 4999999999999998, 4999999999999999, 5899999999999999, 5989999999999999, 5998999999999999, 5999899999999999, 5999989999999999, 5999998999999999, 5999999899999999, 5999999989999999, 5999999998999999, 5999999999899999, 5999999999989999, 5999999999998999, 5999999999999899, 5999999999999989, 5999999999999998, 5999999999999999, 6899999999999999, 6989999999999999, 6998999999999999, 6999899999999999, 6999989999999999, 6999998999999999, 6999999899999999, 6999999989999999, 6999999998999999, 6999999999899999, 6999999999989999, 6999999999998999, 6999999999999899, 6999999999999989, 6999999999999998, 6999999999999999, 7899999999999999, 7989999999999999, 7998999999999999, 7999899999999999, 7999989999999999, 7999998999999999, 7999999899999999, 7999999989999999, 7999999998999999, 7999999999899999, 7999999999989999, 7999999999998999, 7999999999999899, 7999999999999989, 7999999999999998, 7999999999999999, 8899999999999999, 8989999999999999, 8998999999999999, 8999899999999999, 8999989999999999, 8999998999999999, 8999999899999999, 8999999989999999, 8999999998999999, 8999999999899999, 8999999999989999, 8999999999998999, 8999999999999899, 8999999999999989, 8999999999999998, 8999999999999999, 9899999999999999, 9989999999999999, 9998999999999999, 9999899999999999, 9999989999999999, 9999998999999999, 9999999899999999, 9999999989999999, 9999999998999999, 9999999999899999, 9999999999989999, 9999999999998999, 9999999999999899, 9999999999999989, 9999999999999998, 9999999999999999, 18999999999999999, 19899999999999999, 19989999999999999, 19998999999999999, 19999899999999999, 19999989999999999, 19999998999999999, 19999999899999999, 19999999989999999, 19999999998999999, 19999999999899999, 19999999999989999, 19999999999998999, 19999999999999899, 19999999999999989, 19999999999999998, 19999999999999999, 28999999999999999, 29899999999999999, 29989999999999999, 29998999999999999, 29999899999999999, 29999989999999999, 29999998999999999, 29999999899999999, 29999999989999999, 29999999998999999, 29999999999899999, 29999999999989999, 29999999999998999, 29999999999999899, 29999999999999989, 29999999999999998, 29999999999999999, 38999999999999999, 39899999999999999, 39989999999999999, 39998999999999999, 39999899999999999, 39999989999999999, 39999998999999999, 39999999899999999, 39999999989999999, 39999999998999999, 39999999999899999, 39999999999989999, 39999999999998999, 39999999999999899, 39999999999999989, 39999999999999998, 39999999999999999, 48999999999999999, 49899999999999999, 49989999999999999, 49998999999999999, 49999899999999999, 49999989999999999, 49999998999999999, 49999999899999999, 49999999989999999, 49999999998999999, 49999999999899999, 49999999999989999, 49999999999998999, 49999999999999899, 49999999999999989, 49999999999999998, 49999999999999999, 58999999999999999, 59899999999999999, 59989999999999999, 59998999999999999, 59999899999999999, 59999989999999999, 59999998999999999, 59999999899999999, 59999999989999999, 59999999998999999, 59999999999899999, 59999999999989999, 59999999999998999, 59999999999999899, 59999999999999989, 59999999999999998, 59999999999999999, 68999999999999999, 69899999999999999, 69989999999999999, 69998999999999999, 69999899999999999, 69999989999999999, 69999998999999999, 69999999899999999, 69999999989999999, 69999999998999999, 69999999999899999, 69999999999989999, 69999999999998999, 69999999999999899, 69999999999999989, 69999999999999998, 69999999999999999, 78999999999999999, 79899999999999999, 79989999999999999, 79998999999999999, 79999899999999999, 79999989999999999, 79999998999999999, 79999999899999999, 79999999989999999, 79999999998999999, 79999999999899999, 79999999999989999, 79999999999998999, 79999999999999899, 79999999999999989, 79999999999999998, 79999999999999999, 88999999999999999, 89899999999999999, 89989999999999999, 89998999999999999, 89999899999999999, 89999989999999999, 89999998999999999, 89999999899999999, 89999999989999999, 89999999998999999, 89999999999899999, 89999999999989999, 89999999999998999, 89999999999999899, 89999999999999989, 89999999999999998, 89999999999999999, 98999999999999999, 99899999999999999, 99989999999999999, 99998999999999999, 99999899999999999, 99999989999999999, 99999998999999999, 99999999899999999, 99999999989999999, 99999999998999999, 99999999999899999, 99999999999989999, 99999999999998999, 99999999999999899, 99999999999999989, 99999999999999998, 99999999999999999, 189999999999999999, 198999999999999999, 199899999999999999, 199989999999999999, 199998999999999999, 199999899999999999, 199999989999999999, 199999998999999999, 199999999899999999, 199999999989999999, 199999999998999999, 199999999999899999, 199999999999989999, 199999999999998999, 199999999999999899, 199999999999999989, 199999999999999998, 199999999999999999, 289999999999999999, 298999999999999999, 299899999999999999, 299989999999999999, 299998999999999999, 299999899999999999, 299999989999999999, 299999998999999999, 299999999899999999, 299999999989999999, 299999999998999999, 299999999999899999, 299999999999989999, 299999999999998999, 299999999999999899, 299999999999999989, 299999999999999998, 299999999999999999, 389999999999999999, 398999999999999999, 399899999999999999, 399989999999999999, 399998999999999999, 399999899999999999, 399999989999999999, 399999998999999999, 399999999899999999, 399999999989999999, 399999999998999999, 399999999999899999, 399999999999989999, 399999999999998999, 399999999999999899, 399999999999999989, 399999999999999998, 399999999999999999, 489999999999999999, 498999999999999999, 499899999999999999, 499989999999999999, 499998999999999999, 499999899999999999, 499999989999999999, 499999998999999999, 499999999899999999, 499999999989999999, 499999999998999999, 499999999999899999, 499999999999989999, 499999999999998999, 499999999999999899, 499999999999999989, 499999999999999998, 499999999999999999, 589999999999999999, 598999999999999999, 599899999999999999, 599989999999999999, 599998999999999999, 599999899999999999, 599999989999999999, 599999998999999999, 599999999899999999, 599999999989999999, 599999999998999999, 599999999999899999, 599999999999989999, 599999999999998999, 599999999999999899, 599999999999999989, 599999999999999998, 599999999999999999, 689999999999999999, 698999999999999999, 699899999999999999, 699989999999999999, 699998999999999999, 699999899999999999, 699999989999999999, 699999998999999999, 699999999899999999, 699999999989999999, 699999999998999999, 699999999999899999, 699999999999989999, 699999999999998999, 699999999999999899, 699999999999999989, 699999999999999998, 699999999999999999, 789999999999999999, 798999999999999999, 799899999999999999, 799989999999999999, 799998999999999999, 799999899999999999, 799999989999999999, 799999998999999999, 799999999899999999, 799999999989999999, 799999999998999999, 799999999999899999, 799999999999989999, 799999999999998999, 799999999999999899, 799999999999999989, 799999999999999998, 799999999999999999, 889999999999999999, 898999999999999999, 899899999999999999, 899989999999999999, 899998999999999999, 899999899999999999, 899999989999999999, 899999998999999999, 899999999899999999, 899999999989999999, 899999999998999999, 899999999999899999, 899999999999989999, 899999999999998999, 899999999999999899, 899999999999999989, 899999999999999998, 899999999999999999, 989999999999999999, 998999999999999999, 999899999999999999, 999989999999999999, 999998999999999999, 999999899999999999, 999999989999999999, 999999998999999999, 999999999899999999, 999999999989999999, 999999999998999999, 999999999999899999, 999999999999989999, 999999999999998999, 999999999999999899, 999999999999999989, 999999999999999998, 999999999999999999] n=int(input()) res=1 for z in a: if n>=z: res=z else: break print(res) ```
output
1
79,625
20
159,251
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,626
20
159,252
Tags: *special, implementation, math Correct Solution: ``` def main(): x = input() y = int(x) s = sum(int(d) for d in x) for i in range(len(x)): if x[i] == '0': continue z = x[:i] + str(int(x[i]) - 1) + '9' * (len(x) - i - 1) zi = int(z) t = sum(int(d) for d in z) if t > s or t == s and zi > y: y = zi s = t print(y) if __name__ == '__main__': # import sys # sys.stdin = open("B.txt") main() ```
output
1
79,626
20
159,253
Provide tags and a correct Python 3 solution for this coding contest problem. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499
instruction
0
79,627
20
159,254
Tags: *special, implementation, math Correct Solution: ``` t = input() p = [t] + [int(t) - int(t[-k:]) - 1 for k in range(1, len(t))] print(max(p, key=lambda q: sum(map(int, str(q))))) ```
output
1
79,627
20
159,255
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` num = list(input()) orgnum = num.copy() if len(num) == 1: print(num[0]) elif num[1:] != list("9"*(len(num)-1)): if num[1:] == list("8"+"9"*(len(num)-2)): print(int("".join(num))) elif "9" in num: finished = False did = False for i in range(len(num)): if num[i] != "9" and not finished and i != 0 and i != 1 and orgnum[i-1] == "9": num[i-1] = "8" num[i] = "9" finished = True did = True elif i != 0: num[i] = "9" if orgnum[i-1] != "9" and i != 0 and i != 1 and not did: finished = True did = False for i in range(2, 13): if num[-i:] == ["8"] + ["9"]*(i-1): num[-i:] = num[-i:][::-1] if int("".join(orgnum)) < int("".join(num)): num[-i:] = num[-i:][::-1] if not did: num[0] = str(int(num[0])-1) if sum([int(x) for x in num]) <= sum([int(x) for x in orgnum]): num = orgnum.copy() print(int("".join(num))) else: print(int(str(int(num[0])-1)+"9"*(len(num)-1))) else: print(int("".join(num))) ```
instruction
0
79,628
20
159,256
Yes
output
1
79,628
20
159,257
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` from sys import exit s = input() i = int(s) n = 0 k = i while k > 0: n += 1 k //= 10 if n == 1: print(s) exit() k = 1 l = int(s[0])*10**(n-1) while s[k] == '9': k += 1 l += 9*10**(n-k) if k == n: print(s) exit() l -= 1 if '0' in s[k:] or '1' in s[k:] or '2' in s[k:] or '3' in s[k:] or '4' in s[k:] or '5' in s[k:] or '6' in s[k:] or '7' in s[k:]: print(l) elif '8' in s[1:]: p = s.find('8', 1) if '8' in s[p+1:]: print(l) else: print(s) ```
instruction
0
79,629
20
159,258
Yes
output
1
79,629
20
159,259
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` #!/usr/bin/python3 # Copyright (C) Sayutin Dmitry, 2k17 def sslow(x): ans = -1, -1 for i in range(1, x + 1): this = sum([int(ch) for ch in str(i)]) ans = max(ans, (this, i)) return ans[1] def sfast(x): ans = -1, -1 for i in range(x, x + 1): this = sum([int(ch) for ch in str(i)]) ans = max(ans, (this, i)) sx = str(x) csum = 0 for com in range(0, len(sx) - 1): csum += int(sx[com]) if sx[com] != '0': ch = str(int(sx[com]) - 1) ans = max(ans, (csum - 1 + 9 * (len(sx) - 1 - com), int(sx[:com] + ch + '9' * (len(sx) - 1 - com)))) return ans[1] print(sfast(int(input()))) import sys sys.exit(0) for x in range(1, 1000): if sslow(x) != sfast(x): print(x, sslow(x), sfast(x)) break ```
instruction
0
79,630
20
159,260
Yes
output
1
79,630
20
159,261
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` def f(n, k): n = str(n) if n[k] == "0": return f(n, k - 1) a = [] for i in n: a.append(int(i)) n = a n[k] = int(n[k]) - 1 n[k + 1::] = [9] * (len(n) - k - 1) return n a = input() n = len(a) ans = [int(x) for x in a] ms = sum(ans) for i in range(0, n): ca = f(a, i) cs = sum(ca) if cs> ms: ans = ca ms = cs elif cs == ms: if int(''.join([str(_) for _ in ca])) > int(''.join([str(_) for _ in ans])): ans = ca print(int(''.join([str(_) for _ in ans]))) ```
instruction
0
79,631
20
159,262
Yes
output
1
79,631
20
159,263
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` x = input() if x=='0': print(0) exit() if x<='9': print(int(x)) exit() if int(x)%10==0: print(int(x)-1) exit() if int(x[1:])<=int('9'*(len(x)-1)) and x[-1]!='8': print(int(str(int(x[0])-1)+'9'*(len(x)-1))) exit() if x[-1]=='8': print(x) exit() ```
instruction
0
79,632
20
159,264
No
output
1
79,632
20
159,265
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` #This code is dedicated to Olya S. def e(x): s=0 while x>0: s+=x%10 x//=10 return s def down(x): l=len(x)-1 return str(int(x[0])-1)+'9'*l n=input() if e(int(n))>=e(int(down(n))): print(n) else: print(int(down(n))) ```
instruction
0
79,633
20
159,266
No
output
1
79,633
20
159,267
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` #This code is dedicated to Olya S. def e(x): s=0 while x>0: s+=x%10 x//=10 return s def down(x): l=len(x)-1 return str(int(x[0])-1)+'9'*l n=input() while len(n)>1 and n[0]=='9' and n[1]=='9': print('9',end='') n=n[1:] if e(int(n))>=e(int(down(n))): print(n) else: print(int(down(n))) ```
instruction
0
79,634
20
159,268
No
output
1
79,634
20
159,269
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. Input The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. Output Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Examples Input 100 Output 99 Input 48 Output 48 Input 521 Output 499 Submitted Solution: ``` def g(sn): n = int(sn) edge = (len(sn)-1)*9 res = [0] * len(sn) if n == 18: return n if n < 10: return n if sn[0] == "1" and sn[1] < "8": return "9"*(len(sn)-1) if sn[1] < "8": return str(int(sn[0])-1)+ "9"*(len(sn)-1) is8 = -1 for s in range(len(sn)-1): if sn[s+1] != "9": if is8 != -1: if is8 == 0: if sn[1] < "8": return "9"*(len(sn)-1) else: return str(int(sn[0])-1)+ "9"*(len(sn)-1) else: return sn[:is8] + "8" + "9"*(len(sn) - is8-1) if sn[s+1] == "8": is8 = s continue if sn[s+1] < "8": return sn[:s] + "8" + "9"*(len(sn) - s-1) if(sn == '0'): return sn for i, item in enumerate(sn): if item != '0': return sn[i:] print(g(input())) ```
instruction
0
79,635
20
159,270
No
output
1
79,635
20
159,271
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,765
20
159,530
"Correct Solution: ``` A,B=map(int,input().split()) c=0 for i in range(A,B+1): s=str(i) if s[0]==s[4] and s[1]==s[3]: c+=1 print(c) ```
output
1
79,765
20
159,531
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,766
20
159,532
"Correct Solution: ``` print(sum(s[0]==s[4]and s[1]==s[3]for s in map(str,range(*map(sum,enumerate(map(int,input().split()))))))) ```
output
1
79,766
20
159,533
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,767
20
159,534
"Correct Solution: ``` n,m=map(int,input().split()) c=0 for i in range(n,m+1): s=str(i) if(s==s[::-1]): c=c+1 print(c) ```
output
1
79,767
20
159,535
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,768
20
159,536
"Correct Solution: ``` A, B = map(int, input().split()) cnt = 0 for i in range(A, B+1): s = str(i) if s == s[-1::-1]: cnt += 1 print (cnt) ```
output
1
79,768
20
159,537
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,769
20
159,538
"Correct Solution: ``` A,B = map(int,input().split()) n=0 for i in range(A,B+1): if i == int(str(i)[::-1]): n+=1 print(n) ```
output
1
79,769
20
159,539
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,770
20
159,540
"Correct Solution: ``` A, B = map(int, input().split()) print([True for i in range(A, B + 1) if str(i) == str(i)[::-1]].count(True)) ```
output
1
79,770
20
159,541
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,771
20
159,542
"Correct Solution: ``` a, b = map(int, input().split()) print(sum(map(lambda x: 1 if str(x) == str(x)[::-1] else 0, range(a, b+1)))) ```
output
1
79,771
20
159,543
Provide a correct Python 3 solution for this coding contest problem. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612
instruction
0
79,772
20
159,544
"Correct Solution: ``` a,b=map(int,input().split()) print(len([j for j in [str(i) for i in range(a,b+1)] if j[0]==j[4]and j[1]==j[3]])) ```
output
1
79,772
20
159,545
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612 Submitted Solution: ``` a,b=map(int,input().split()) res=0 for i in range(a,b+1): c=str(i) if c[::-1]==c:res+=1 print(res) ```
instruction
0
79,776
20
159,552
Yes
output
1
79,776
20
159,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612 Submitted Solution: ``` def kai(n): a="" for i in reversed(range(len(n))): a+=(n[i]) if n==a: return True a,b=input().split() cnt=0 for i in range(1,int(b)-int(a)+1): if kai(str(int(a)+i)): cnt+=1 print(cnt) ```
instruction
0
79,777
20
159,554
No
output
1
79,777
20
159,555
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612 Submitted Solution: ``` a,b = (int(i) for i in input().split()) ct= 0 for i in range(a,b+1): judge = str(i+1) if judge == judge[4]+judge[3]+judge[2]+judge[1]+judge[0]: ct += 1 print(ct) ```
instruction
0
79,778
20
159,556
No
output
1
79,778
20
159,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Input Input is given from Standard Input in the following format: A B Output Print the number of palindromic numbers among the integers between A and B (inclusive). Examples Input 11009 11332 Output 4 Input 31415 92653 Output 612 Submitted Solution: ``` a,s=map(int,input().split()) A=0 for i in range(a,b+1): if str(i)==str(i)[::-1]:A+=1 print(A) ```
instruction
0
79,780
20
159,560
No
output
1
79,780
20
159,561
Provide tags and a correct Python 3 solution for this coding contest problem. <image> Input The input contains two integers row, col (0 ≤ row, col ≤ 63), separated by a single space. Output Output "IN" or "OUT". Examples Input 0 0 Output OUT Input 27 0 Output IN Input 0 27 Output OUT Input 27 27 Output IN
instruction
0
80,076
20
160,152
Tags: *special, dfs and similar, geometry, implementation Correct Solution: ``` s = ["1111111111111111111111111101010000001011111111111111111111111111", "1111111111111111111111010001010101101000001111111111111111111111", "1111111111111111111100010111011100101111011011111111111111111111", "1111111111111111100001010100000111100001010001011111111111111111", "1111111111111111001111110101111100001111010101001111111111111111", "1111111111111101100100000100010001011010011101101011111111111111", "1111111111111000110110111111010111000011001001001001111111111111", "1111111111100000010010010001000100011110011011011100011111111111", "1111111111000000000000111101111101110100110010010110001111111111", "1111111110000000000000000000010000000110000110000000000111111111", "1111111100000000000000000000000000000000000000000000000011111111", "1111111000000000000000000000000000000000000000000000000001111111", "1111111000000000000000000000000000000000000000000000000001111111", "1111110000000000000000000000000000000000000000000000000000111111", "1111100000000000000000000000000000000000000000000000000000011111", "1111100000000000000000000000000000000000000000000000000000011111", "1111000000000000000000000000000000000000000000000000000000001111", "1110000000000000000000000000000000000000000000000000000000000111", "1111100000000000000000000000000000000000000000000000000000000111", "1111111000000000000111011000000000000001110101000000000000011111", "1100111110000000001101110000000000000001011111110000000011111111", "1100001111100000111001011100000000000000010010011010011111110011", "1000000011111011100011000110000000000010110111001111111110000001", "1000000000111110110110010011100000000010010000011011110000000001", "1000000000000100100011111000110000000111011011110001000000000001", "1000000000111110111000100011100000000101000001011101101000000001", "0000000000001000101101101110110000001101101111001000111000000000", "0000000000011101101001000100010000101000100001100011101000000000", "0000000000010000001000011110110101111010110100001110001000000000", "0000000000011111011011000100011101010010010110111011011000000000", "0000000000001001000010010001110100011111000010100000010000000000", "0000000000011100011011011100010110001000011010001110111000000000", "0000000000000111110010001001000100111110110010011011101000000000", "0000000000000010010111101011110101101010010111001001000000000000", "0000000000001111000010101010100001001011010001100011100000000000", "0000000000000101101110001110000111011001111011001110000000000000", "0000000000000000111000111010010010010011010001011011000000000000", "0000000000000000001110100000011111000000011101110000000000000000", "1000000000000000011011110000010100000000000111011000000000000001", "1000000000000000000000000000000111100000000000000000000000000001", "1000000000000000000000000000101101000000000000000000000000000001", "1000000000000000000000000010111000000000000000000000000000000001", "1100000000000000000000000011101110000000000000000000000000000011", "1100000001100000000000000000001000000000000000000000000000000011", "1110000000101000000000000000011100000000000000000000010000000111", "1110000000111011100000000000110100000000000100000101111000000111", "1110000000101010110101110010100110101101001110011111010000000111", "1111000000001110011111011111110011100111111010110001000000001111", "1111100000001011000010000100011000111100010000010100000000011111", "1111100000000001011011011101000010001001011111011100000000011111", "1111110000000011110010010111101110101111000101110000000000111111", "1111111000000000100111000001001010111010011100000000000001111111", "1111111000000000110001101011100011101000110111000000000001111111", "1111111100000000011100001110001001000010000100000000000011111111", "1111111110000000001001111010111111011110100000000000000111111111", "1111111111000000000000101000010010010100110000000000001111111111", "1111111111100000000000001111000011110111100000000000011111111111", "1111111111111000000000000000000001000000000000000001111111111111", "1111111111111100000000000000000000000000000000000011111111111111", "1111111111111111000000000000000000000000000000001111111111111111", "1111111111111111100000000000000000000000000000011111111111111111", "1111111111111111111100000000000000000000000011111111111111111111", "1111111111111111111111000000000000000000001111111111111111111111", "1111111111111111111111111100000000000011111111111111111111111111"] x,y = [int(n) for n in input().split()] if s[x][y] == '1': print('OUT') else: print('IN') ```
output
1
80,076
20
160,153
Provide tags and a correct Python 3 solution for this coding contest problem. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012
instruction
0
80,281
20
160,562
Tags: expression parsing, implementation Correct Solution: ``` st=input() i=0 ans=[] while(i<len(st)-1): if st[i]=='-' and st[i+1]=='.': ans.append(1) i+=1 elif st[i]=='.': ans.append(0) #print('x') elif st[i]=='-' and st[i+1]=='-': ans.append(2) i+=1 i+=1 if st[len(st)-1]=='.' and st[len(st)-2]!='-': ans.append(0) if st[len(st)-1]=='.' and st[len(st)-2]=='-' and st[len(st)-3]=='-': ans.append(0) print(*ans,sep='') ```
output
1
80,281
20
160,563
Provide tags and a correct Python 3 solution for this coding contest problem. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012
instruction
0
80,282
20
160,564
Tags: expression parsing, implementation Correct Solution: ``` codigo = input() codigo = codigo.replace('--', '2') codigo = codigo.replace('-.', '1') codigo = codigo.replace('.', '0') print(codigo) ```
output
1
80,282
20
160,565
Provide tags and a correct Python 3 solution for this coding contest problem. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012
instruction
0
80,283
20
160,566
Tags: expression parsing, implementation Correct Solution: ``` t = input() t = t.replace("--","2") t = t.replace("-.","1") t = t.replace(".","0") print(t) ```
output
1
80,283
20
160,567
Provide tags and a correct Python 3 solution for this coding contest problem. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012
instruction
0
80,284
20
160,568
Tags: expression parsing, implementation Correct Solution: ``` code = {".": "0", "-.": "1", "--": "2"} line = input() answer = "" while len(line) != 0: if line[0] == ".": answer = answer + code["."] line = line[1:] else: answer = answer + code[line[0:2]] line = line[2:] print(answer) ```
output
1
80,284
20
160,569
Provide tags and a correct Python 3 solution for this coding contest problem. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012
instruction
0
80,285
20
160,570
Tags: expression parsing, implementation Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Fri Feb 21 19:52:42 2020 @author: Lenovo """ #https://codeforces.com/problemset/problem/32/B def borze_code(): string = input() output = '' if len(string) == 1: print(0) return i = 0 while True: if string[i] == '.': output = output + str(0) i += 1 if i >= len(string): break elif string[i] == '-': if string[i+1] == '.': output = output + str(1) i += 2 if i >= len(string): break elif string[i+1] == '-': output = output + str(2) i += 2 if i >= len(string): break print(output) return borze_code() ```
output
1
80,285
20
160,571
Provide tags and a correct Python 3 solution for this coding contest problem. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012
instruction
0
80,286
20
160,572
Tags: expression parsing, implementation Correct Solution: ``` d={"-.":1,".":0,"--":2} f=input() b="" w='' n="" for i in range(len(f)): if (n+f[i]) in d.keys(): b=n+f[i] w=str(w)+str((d[b])) b='' n='' else: n=f[i] print(w) ```
output
1
80,286
20
160,573
Provide tags and a correct Python 3 solution for this coding contest problem. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012
instruction
0
80,288
20
160,576
Tags: expression parsing, implementation Correct Solution: ``` n = input() s = [] r = 20392309 for i in range(len(n)): if i != r: if n[i] == '.' or i == len(n)-1: s.append(0) elif n[i] == '-' and n[i+1] == '.': s.append(1) r = i+1 elif n[i] == '-' and n[i+1] == '-': s.append(2) r = i+1 for k in s: print(k,end = "") ```
output
1
80,288
20
160,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012 Submitted Solution: ``` s=input() i=0 a=[] while(i<=len(s)-1): if(s[i]=="."): a.append("0") i=i+1 else: if(s[i]=="-" and s[i+1]=="."): a.append("1") i=i+2 else: a.append("2") i=i+2 s="" s="".join(a) print(s) ```
instruction
0
80,289
20
160,578
Yes
output
1
80,289
20
160,579
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012 Submitted Solution: ``` t = input() i = 0 ans = "" while i < len(t): if t[i] =='.': ans = ans +"0" else: i+=1 if t[i] == '.': ans = ans + "1" else: ans = ans +"2" i+=1 print(ans) ```
instruction
0
80,290
20
160,580
Yes
output
1
80,290
20
160,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012 Submitted Solution: ``` import sys import decimal import collections import math import itertools as it def readArray(type= int): line = input() return [type(x) for x in line.split()] def solve(): digits= [] s = input() dash_began = False for x in s: if dash_began: dash_began = False digits.append('1' if x == '.' else '2') else: if x == '-': dash_began= True else: # Single . found digits.append('0') print(''.join(digits)) if __name__ == '__main__': # sys.stdin = open('input.txt') solve() ```
instruction
0
80,291
20
160,582
Yes
output
1
80,291
20
160,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012 Submitted Solution: ``` borze= str(input()) def value(borze): if(borze == ""): return "" else: if(borze[0]== "."): return("0"+value(borze[1:])) elif(borze[1]== "-"): return("2"+value(borze[2:])) else: return("1"+value(borze[2:])) print(value(borze)) ```
instruction
0
80,292
20
160,584
Yes
output
1
80,292
20
160,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012 Submitted Solution: ``` #!/usr/bin/env python # coding: utf-8 # In[27]: ## Inputs # n = int(input()) code = str(input()) stack = '' ans = [] for sym in code: stack += sym if stack == '.': ans.append(0) stack = '' elif stack == '-.': ans.append(1) stack = '' elif stack == '--': ans.append(2) stack = '' for i in ans: print(i) # In[ ]: ```
instruction
0
80,293
20
160,586
No
output
1
80,293
20
160,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. Input The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). Output Output the decoded ternary number. It can have leading zeroes. Examples Input .-.-- Output 012 Input --. Output 20 Input -..-.-- Output 1012 Submitted Solution: ``` ls = list(input()) d = {".": 0, "-.": 1, "--": 2} ans = [] i = 0 buff = "" while i < len(ls): if ls[i] == "." and not buff: ans.append("0") else: buff += ls[i] if buff == "-.": ans.append("1") else: ans.append("2") buff = "" i += 1 print("".join(ans)) ```
instruction
0
80,294
20
160,588
No
output
1
80,294
20
160,589