message
stringlengths
2
59.7k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
37
108k
cluster
float64
20
20
__index_level_0__
int64
74
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,600
20
189,200
Tags: brute force, implementation Correct Solution: ``` a, b = list(map(int, input().split())) while True: a += 1 sta = str(a) m = "" n = 0 for i in range(len(sta)): if sta[i] == '4' or sta[i] == '7': m += sta[i] if len(m) > 0: n = int(m) if n == b: print(a) break ```
output
1
94,600
20
189,201
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,601
20
189,202
Tags: brute force, implementation Correct Solution: ``` a,b=map(str,input().split()) def mask(x): st='' for i in str(x): if i=='7' or i=='4': st+=i return(st) for i in range(int(a)+1,177778): if mask(i)!=b: pass else: print(i) quit() ```
output
1
94,601
20
189,203
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,602
20
189,204
Tags: brute force, implementation Correct Solution: ``` a,b=map(str,input().split()) def check(x): st='' for i in str(x): if i=='7' or i=='4': st+=i return(st) for i in range(int(a)+1,177778): if check(i)!=b: pass else: print(i) quit() ```
output
1
94,602
20
189,205
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,603
20
189,206
Tags: brute force, implementation Correct Solution: ``` a=input() list1 = a.split(' ') num1=list1[0] num2=list1[1] def mask(num): num=str(num) str1="" for i in range(0,len(num)): if (ord(num[i])-48)==7 or (ord(num[i])-48)==4: str1=str1+num[i] return str1 for i in range(int(num1)+1,1000000): if mask(i)==num2: print(i) quit() ```
output
1
94,603
20
189,207
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,604
20
189,208
Tags: brute force, implementation Correct Solution: ``` target,lucky=map(int,input().split()) if lucky>target: print(lucky) else: checkarr=list(map(int,str(lucky))) while True: target+=1 i=0 check=False tmp=list(map(int,str(target))) for val in tmp: if val==checkarr[i]: i+=1 if i==len(checkarr): check=True break if check: tmpstr=[] for val in tmp: if val==7: tmpstr.append(7) elif val==4: tmpstr.append(4) if tmpstr==checkarr: print(target) break ```
output
1
94,604
20
189,209
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,605
20
189,210
Tags: brute force, implementation Correct Solution: ``` import math def mask(x): tmp,res=0,0 while(x): if(x%10==4 or x%10==7): tmp=tmp*10+(x%10) x//=10 while(tmp): res=res*10+(tmp%10) tmp//=10 return res try: t=1 while(t): t-=1 a,b=map(int,input().split()) a+=1 while(mask(a)!=b): a+=1 print(a) except: pass ```
output
1
94,605
20
189,211
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,606
20
189,212
Tags: brute force, implementation Correct Solution: ``` s = input() a = int(s.split()[0]) b = int(s.split()[1]) def getMask(num): s = str(num) l = [c for c in s if c=='4' or c=='7'] if len(l) == 0: return 0 return int(''.join(l)) ans = a + 1 while not getMask(ans) == b: ans = ans + 1 print(ans) ```
output
1
94,606
20
189,213
Provide tags and a correct Python 3 solution for this coding contest problem. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147
instruction
0
94,607
20
189,214
Tags: brute force, implementation Correct Solution: ``` def mask(x,k): t="" for i in x: if i in "47":t+=i return t!=k a,b=map(int,input().split()) z=a while mask(str(a),str(b)) or a<=z:a+=1 print(a) ```
output
1
94,607
20
189,215
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` def f(x): s="0" for c in str(x): if c=='7' or c=='4': s+=c return int(s) a,b=map(int,input().split()) x=a+1 while f(x)!=b: x+=1 print(x) ```
instruction
0
94,608
20
189,216
Yes
output
1
94,608
20
189,217
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` a, b = input().split() for i in range(max(int(a) + 1, int(b)), 999999): if ''.join(c for c in str(i) if c in ('4,7')) == b: print(i);exit() ```
instruction
0
94,609
20
189,218
Yes
output
1
94,609
20
189,219
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` def mask(x): s = 0 n = str(x) for i in range(len(n)): if n[i] == '7' or n[i] == '4': s = s * 10 + int(n[i]) return s a , b = (input().split()) a= int(a) a= a + 1 b= int(b) while mask(a) != b: a = a + 1 print(a) ```
instruction
0
94,610
20
189,220
Yes
output
1
94,610
20
189,221
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` a = [int(x) for x in input().split()] b=str(a[0]+1) c=str(a[1]) def getmask(q): s="" for i in q: if i in ["4","7"]: s+=i return s while getmask(b)!=c : b=str(int(b)+1) print(b) ```
instruction
0
94,611
20
189,222
Yes
output
1
94,611
20
189,223
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` a = [int(x) for x in input().split()] b=str(a[0]) c=str(a[1]) while c not in b: b=str(int(b)+1) print(b) ```
instruction
0
94,612
20
189,224
No
output
1
94,612
20
189,225
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` def f(a, b): j = 0 for i in b: j = a.find(i, j) if j < 0: return False return True a, b = input().split() if len(a) < len(b): ans = b else: u, v = len(a) - 1, len(b) - 1 for i in range(len(b)): x, y = u - i, v - i if a[x:] > b[y:]: t = str(int(a[:x]) + 1) if f(t, b[:y]): ans = t + b[y:] break elif f(a[:x], b[:y]): ans = a[:x] + b[y:] break print(ans) ```
instruction
0
94,613
20
189,226
No
output
1
94,613
20
189,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` #from dust i have come dust i will be import sys a,b=map(int,input().split()) sa=str(a) sb=str(b) if len(sa)==len(sb): if b>a: print(b) else: sys.stdout.write("1"+sb) else: if b>a: print(b) else: #extract the same len of b from a sc="" l=len(sa)-len(sb) for i in range(l,len(sa)): sc+=sa[i] c=int(sc) #if c<b then write first l chars if c<b: for i in range(l): sys.stdout.write(sa[i]) sys.stdout.write(sb) # otherwise from l-1 to 0 try increasing 1 else: sc="" for i in range(l): sc+=sa[i] c=int(sc) c+=1 sys.stdout.write(str(c)+sb) ```
instruction
0
94,614
20
189,228
No
output
1
94,614
20
189,229
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number. Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b. Input The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky. Output In the only line print a single number — the number c that is sought by Petya. Examples Input 1 7 Output 7 Input 100 47 Output 147 Submitted Solution: ``` ''' Created on Feb 11, 2015 @author: mohamed265 ''' def fun (a, b): #print(a ,b) lenA = len(a) o = 0 for i in range(lenA): if b[o] == a[i]: o += 1 if o == len(b): return False return True # for i in range(o , l temp = input().split() a = int(temp[0]) +1 b = temp[1] while fun(str(a), b): a +=1 print(a) ```
instruction
0
94,615
20
189,230
No
output
1
94,615
20
189,231
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where k is some integer number in range [1, a]. By <image> we denote the quotient of integer division of x and y. By <image> we denote the remainder of integer division of x and y. You can read more about these operations here: http://goo.gl/AcsXhT. The answer may be large, so please print its remainder modulo 1 000 000 007 (109 + 7). Can you compute it faster than Dreamoon? Input The single line of the input contains two integers a, b (1 ≤ a, b ≤ 107). Output Print a single integer representing the answer modulo 1 000 000 007 (109 + 7). Examples Input 1 1 Output 0 Input 2 2 Output 8 Note For the first sample, there are no nice integers because <image> is always zero. For the second sample, the set of nice integers is {3, 5}. Submitted Solution: ``` from sys import stdin from sys import stdout def get(): return stdin.readline().strip() def getf(): return [int(i) for i in get().split()] def put(a, end = "\n"): stdout.write(str(a) + end) def putf(a): stdout.write(" ".join([str(i) for i in a]) + "\n") def main(): a, b = getf() m = 1000000007 ans = (b * (b - 1) // 2) * a * (1 + b * (a + 1) // 2) % m put(ans) main() ```
instruction
0
94,780
20
189,560
No
output
1
94,780
20
189,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where k is some integer number in range [1, a]. By <image> we denote the quotient of integer division of x and y. By <image> we denote the remainder of integer division of x and y. You can read more about these operations here: http://goo.gl/AcsXhT. The answer may be large, so please print its remainder modulo 1 000 000 007 (109 + 7). Can you compute it faster than Dreamoon? Input The single line of the input contains two integers a, b (1 ≤ a, b ≤ 107). Output Print a single integer representing the answer modulo 1 000 000 007 (109 + 7). Examples Input 1 1 Output 0 Input 2 2 Output 8 Note For the first sample, there are no nice integers because <image> is always zero. For the second sample, the set of nice integers is {3, 5}. Submitted Solution: ``` import sys import math MAXNUM = math.inf MINNUM = -1 * math.inf ASCIILOWER = 97 ASCIIUPPER = 65 MODMAX = 1000000007 def getInt(): return int(sys.stdin.readline().rstrip()) def getInts(): return map(int, sys.stdin.readline().rstrip().split(" ")) def getString(): return sys.stdin.readline().rstrip() def printOutput(ans): sys.stdout.write() pass def termadd(n): return (n * (n + 1)) // 2 def solve(a, b): multtotal = 0 addtotal = 0 divadd = 1 while divadd < b and a // divadd != 0: multtotal += (termadd(a // divadd) * divadd) % MODMAX addtotal += ((a // divadd) * divadd) % MODMAX divadd += 1 multtotal *= b return (addtotal + multtotal) % MODMAX def readinput(): a, b = getInts() print(solve(a, b)) readinput() ```
instruction
0
94,781
20
189,562
No
output
1
94,781
20
189,563
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,822
20
189,644
Tags: implementation Correct Solution: ``` def proc( x , nums ): res = 0 while x != 0: #print(x) res += nums[x%10] x //= 10 return res if __name__ == "__main__": nums = [6,2,5,5,4,5,6,3,7,6] a , b = [int(x) for x in input().split()] res = 0 s = str(list(range(a,b+1))) #print(s) for i in range(10): res += nums[i] * s.count(str(i)) print(res) ```
output
1
94,822
20
189,645
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,823
20
189,646
Tags: implementation Correct Solution: ``` segment = {'0':6,'1':2,'2':5,'3':5,'4':4,'5':5,'6':6,'7':3,'8':7,'9':6} a,b = map(int,input().split()) ans = 0 s = str([i for i in range(a,b+1)]) for i in s: try: ans+=segment[i] except: pass print(ans) ```
output
1
94,823
20
189,647
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,824
20
189,648
Tags: implementation Correct Solution: ``` a,b=list(input().split()) t={'0':6,'1':2,'2':5,'3':5,'4':4,'5':5,'6':6,'7':3,'8':7,'9':6} v=0 for k in range(int(a),int(b)+1): s=str(k) for i in s: v+=t[i] print(v) ```
output
1
94,824
20
189,649
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,825
20
189,650
Tags: implementation Correct Solution: ``` import sys,math ''' def construct(a,seg,low,high,pos): try: if low == high: seg[pos] = a[low] mid = (low+high)//2 construct(a,seg,low,mid,2*pos+1) construct(a,seg,mid,high,2*pos+2) seg[pos] = min(seg[2*pos+1],seg[2*pos+2]) except: pass a = [-1,2,4,0] c = 1 while c<len(a): c = 2*c seg = [10000]*(2*c-1) print(construct(a,seg,0,3,0)) def matrix(a,b): c = [[a[0][0]*b[0][0]+a[0][1]*b[1][0],a[0][0]*b[0][1]+a[0][1]*b[1][1]],\ [a[1][0]*b[0][0]+a[1][1]*b[1][0],a[1][0]*b[1][0]+a[1][1]*b[1][1]]] return c def power(a,n): if n == 0: return [[1,1],[1,0]] else: if n%2 == 0: return matrix(power(a,n//2),power(a,n//2)) else: return matrix(matrix(a,a),power(a,n-1)) a = [[1,1],[1,0]] for i in range(10): print(power(a,i)) a = [[1,1],[1,0]] c = a for i in range(10): c = matrix(c,a) print(c) t = int(input()) for _ in range(t): n, w = map(int,input().split()) a = list(map(int,input().split())) a.sort() x = 0 s = 0 while x<n and s+a[x]<=w: s+=a[x] x+=1 if x == 0: print(-1) else: print(x) print(a[0:x+1]) ''' def cal(a,b): seg = {0:6,1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6} ans = 0 for i in range(a,b+1): for c in str(i): ans += seg[int(c)] return ans a, b = map(int,input().split()) print(cal(a,b)) ```
output
1
94,825
20
189,651
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,826
20
189,652
Tags: implementation Correct Solution: ``` arr = [6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6] ans = 0 a , b = map(int , input().split()) for i in range(a , b+1): x = list(str(i)) for j in x: ans += arr[int(j)] print(ans) ```
output
1
94,826
20
189,653
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,827
20
189,654
Tags: implementation Correct Solution: ``` a,b=map(int,input().split()) z={"1":2,"2":5,"3":5,"4":4,"5":5,"6":6,"7":3,"8":7,"9":6,"0":6} z1={"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"0":0} s=0 for i in range(a,b+1): k=str(i) for i in k:z1[i]+=1 for i in z:s+=z1[i]*z[i] print(s) ```
output
1
94,827
20
189,655
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,828
20
189,656
Tags: implementation Correct Solution: ``` a,b=map(int,input().split()) i=str(list(range(a,b+1))) seg={'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6} print(seg['0']*i.count('0')+seg['1']*i.count('1')+seg['2']*i.count('2')+seg['3']*i.count('3')+seg['4']*i.count('4')+seg['5']*i.count('5')+seg['6']*i.count('6')+seg['7']*i.count('7')+seg['8']*i.count('8')+seg['9']*i.count('9') ) ```
output
1
94,828
20
189,657
Provide tags and a correct Python 3 solution for this coding contest problem. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
instruction
0
94,829
20
189,658
Tags: implementation Correct Solution: ``` a, b = map(int, input().split()) sum = 0 t = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6] for i in range(a, b+1): s = str(i) for j in range(0, len(str(i))): sum+=t[int(s[j])] print(sum) ```
output
1
94,829
20
189,659
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` a,b = list(map(int, input().split(" "))) i=a segment=[6,2,5,5,4,5,6,3,7,6] sum=0 s=str([i for i in range(a,b+1)]) for i in range(10): sum+=s.count(str(i))*segment[i] print(sum) ```
instruction
0
94,830
20
189,660
Yes
output
1
94,830
20
189,661
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` a, b = map(int, input().split()) d = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6} ans = 0 for i in range(a, b+1): s = str(i) for j in s: ans += d[j] #print(ans, j) print(ans) ```
instruction
0
94,831
20
189,662
Yes
output
1
94,831
20
189,663
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` dic = { '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6, '0': 6, } l, r = (map (int, input().strip().split())) ans = 0 for i in range(l, r+1): s = str(i) for x in range(0, len(s)): ans += dic[s[x]] print(ans) ```
instruction
0
94,832
20
189,664
Yes
output
1
94,832
20
189,665
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` seg = [6,2,5,5,4,5,6,3,7,6] a,b = map(int,input().split()) num = str(list(range(a,b+1))) ans = 0 for i in range(len(seg)): ans += seg[i]*num.count(str(i)) print (ans) ```
instruction
0
94,833
20
189,666
Yes
output
1
94,833
20
189,667
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` cnt = [6, 2, 5, 5, 4, 5, 6, 4, 7, 6] def f(n): ans = 0 while n != 0: ans += cnt[n % 10] n //= 10 return ans a, b = map(int, input().split()) ans = 0 for i in range(a, b + 1): ans += f(i) print(ans) ```
instruction
0
94,834
20
189,668
No
output
1
94,834
20
189,669
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` a,b = list(map(int, input().split(" "))) i=a segment=[6,2,5,5,4,5,6,3,7,6] sum=0 s=[str(i) for i in range(a,b+1)] for i in range(10): sum+=s.count(str(i))*segment[i] print(sum) ```
instruction
0
94,835
20
189,670
No
output
1
94,835
20
189,671
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` def f(x): return 49*int(x)*10**(int(x)-1) def g(y): segs = [6,2,5,5,4,5,6,3,7,6] return sum(segs[1:int(y)]) def g_v(y,c): segs = [6,2,5,5,4,5,6,3,7,6] return sum(segs[0:int(y)+c]) def h(z): segs = [6,2,5,5,4,5,6,3,7,6] return segs[int(z)] def seg_sum(n,c): total = 0 for i in range(0,len(n)): if len(n)-1-i > 0: total += int(n[i])*f(len(n)-1-i)+g(n[i])*10**(len(n)-1-i)+h(n[i])*int(n[i+1:len(n)]) elif len(n)-1-i == 0: total += g_v(int(n[len(n)-1]),c) return total def runner(): [a,b] = input().split() print(seg_sum(b,1) - seg_sum(a,0)) runner() ```
instruction
0
94,836
20
189,672
No
output
1
94,836
20
189,673
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator. For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12. Input The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max. Output Print the only integer a — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39 Submitted Solution: ``` cnt = [6, 2, 5, 5, 5, 4, 5, 6, 4, 7, 6] def f(n): ans = 0 while n != 0: ans += cnt[n % 10] n //= 10 return ans a, b = map(int, input().split()) ans = 0 for i in range(a, b + 1): ans += f(i) print(ans) ```
instruction
0
94,837
20
189,674
No
output
1
94,837
20
189,675
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,866
20
189,732
Tags: constructive algorithms, math Correct Solution: ``` n = int(input()) now = 2 lvl = 0 ans = [] for i in range(1, n + 1): to = (lvl + 1) * (lvl + 2) ans.append((to * to - now) / (lvl + 1)) now = to lvl = lvl + 1 for i in ans: print(int(i)) ```
output
1
94,866
20
189,733
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,867
20
189,734
Tags: constructive algorithms, math Correct Solution: ``` from math import sqrt m=2 print(2) k=2 n=int(input()) while k<n+1: print((k+1)*(k+1)*k-(k-1)) k+=1 ```
output
1
94,867
20
189,735
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,868
20
189,736
Tags: constructive algorithms, math Correct Solution: ``` def solve(x): return ((((x + 1) ** 2) * (x ** 2)) - (x * x - x)) / x inp = int(input("")) lvl = 1 print ("2") while(inp >= 2): ops = solve(lvl + 1) print (int(ops)) lvl = lvl + 1 inp = inp - 1 ```
output
1
94,868
20
189,737
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,869
20
189,738
Tags: constructive algorithms, math Correct Solution: ``` n = int(input()) nxt = 2 for i in range(1,n+1): temp = (i+1)*2 if(temp%i != 0 or temp%(i+1) != 0): temp = i*(i+1) print(int((temp*temp-nxt)/i)) nxt = temp ```
output
1
94,869
20
189,739
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,870
20
189,740
Tags: constructive algorithms, math Correct Solution: ``` import math n = int(input()) al = 2 for i in range(1,n+1): ai = (i*i+i)**2; res= (ai -al)//i; al = int(math.sqrt(int(ai))) print(int(res)) ```
output
1
94,870
20
189,741
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,871
20
189,742
Tags: constructive algorithms, math Correct Solution: ``` str = input() n = int(str) num = 2; lv = 1; t = 1; while n != 0: t = nlv = lv + 1; t = lv * nlv print(lv * nlv * nlv - int(num / lv)) num = t; lv = nlv; n -= 1 ```
output
1
94,871
20
189,743
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,872
20
189,744
Tags: constructive algorithms, math Correct Solution: ``` n = int(input()) cur = int(2) i = int(1) nxt = int() print(2) while i < n: i = i + 1 nxt = i * (i + 1) print (int(((nxt * nxt) - cur) / i)) cur = nxt; ```
output
1
94,872
20
189,745
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
94,873
20
189,746
Tags: constructive algorithms, math Correct Solution: ``` n=int(input()) num0 = 4 print("14") for i in range(2, n + 1): num1 = i * (i + 1) x = (num1 * num1 - num0)/i print("%d"%x) num0 = num1 ```
output
1
94,873
20
189,747
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n = int(input()) for i in range(1,n+1) : if i == 1 : print(2) else : print((i+1)*(i+1)*i-(i-1)) ```
instruction
0
94,874
20
189,748
Yes
output
1
94,874
20
189,749
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` import bisect from itertools import accumulate, count import os import sys import math from decimal import * from io import BytesIO, IOBase from sys import maxsize 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) def input(): return sys.stdin.readline().rstrip("\r\n") def isPrime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i = i + 6 return True def SieveOfEratosthenes(n): prime = [] primes = [True for i in range(n + 1)] p = 2 while p * p <= n: if primes[p] == True: prime.append(p) for i in range(p * p, n + 1, p): primes[i] = False p += 1 return prime def primefactors(n): fac = [] while n % 2 == 0: fac.append(2) n = n // 2 for i in range(3, int(math.sqrt(n)) + 2): while n % i == 0: fac.append(i) n = n // i if n > 1: fac.append(n) return sorted(fac) def factors(n): fac = set() fac.add(1) fac.add(n) for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: fac.add(i) fac.add(n // i) return list(fac) def modInverse(a, m): m0 = m y = 0 x = 1 if m == 1: return 0 while a > 1: q = a // m t = m m = a % m a = t t = y y = x - q * y x = t if x < 0: x = x + m0 return x # ------------------------------------------------------code n=int(input()) for i in range(1,n+1): if i==1: print(2) else: print((i*(i+1)*(i+1))-(i-1)) ```
instruction
0
94,875
20
189,750
Yes
output
1
94,875
20
189,751
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` a=2 n=0 max = int(input()) for k in range(max+1): if(k==0): continue n = k*(k+1)*(k+1)-a a=k print(n) ```
instruction
0
94,876
20
189,752
Yes
output
1
94,876
20
189,753
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n=int(input()) ccc=2 s=4 for i in range(1,n+1): s=i**2*(i+1)**2 t=int((s-ccc)/i) print(t) ccc=int(s**0.5) ```
instruction
0
94,877
20
189,754
Yes
output
1
94,877
20
189,755
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n = int(input()) print(3) for i in range(2, n + 1): print(i ** 3 + 2 * i ** 2 + 1) ```
instruction
0
94,878
20
189,756
No
output
1
94,878
20
189,757
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n = int(input()) print(2) for k in range(2, n+1): print(k*k*(k+1)*(k+1) - (k-1)*k) ```
instruction
0
94,879
20
189,758
No
output
1
94,879
20
189,759
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n = int(input()) pd = [0]*(n+1); pd[1] = 2 for i in range(2, n+1): k = 1 while True: if ((i*i*k*k - pd[i-1]) % (i-1) == 0): pd[i] = i*k break k += 1 print((pd[i]*pd[i]-pd[i-1])//(i-1)) print(pd[n]) ```
instruction
0
94,880
20
189,760
No
output
1
94,880
20
189,761
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n=int(input()) s=1 for i in range(1,n+1): n2=(i+1)**2 d=0 if s<n2: d=n2-s s=i+1 elif s>n2: c=s%n2 d+=n2-c s=n2*(s//n2+(1 if c else 0)) dx=(s//n2)**0.5 rdx=round(dx) dx=rdx+1 if rdx<dx else rdx dx2=dx**2 d+=dx2*n2-s s=dx*(i+1) print(d) ```
instruction
0
94,881
20
189,762
No
output
1
94,881
20
189,763