├── ProjectEuler+ ├── p33.py ├── p13.py ├── p28.py ├── p6.py ├── p42.py ├── p1.py ├── p20.py ├── p48.py ├── p63.py ├── p5.py ├── p15.py ├── p34.py ├── p18.py ├── p8.py ├── p31.py ├── p53.py ├── p21.py ├── p22.py ├── p2.py ├── p7.py ├── p3.py ├── p24.py ├── p12.py ├── p36.py ├── p1.java ├── p44.py ├── p57.py ├── p30.py ├── p32.py ├── p19.py ├── p40.py ├── p65.py ├── p14.py ├── p43.py ├── p11.py ├── p17.py ├── p27.py ├── p10.py ├── p35.py ├── p4.py ├── p41.py ├── p37.py ├── p26.py ├── p9.py ├── p25.py ├── p23.py └── p16.py ├── README.md ├── Algorithm ├── Find Median.py ├── Sherlock and Squares.py ├── Handshakes.py ├── Reverse Game.py ├── Easy Sum.py ├── Hackerrank Tweet.py ├── Lonely Integer.py ├── Flowers.py ├── Dancing in Pairs.py ├── Gem Stones.py ├── Die Hard 3.py ├── Sherlock and permutation.py ├── Counter Game.py ├── Stepping Stone Games.py ├── Find Point.py ├── Correctness and Loop Invariant.py ├── Triangle Number.py ├── ACM ICPC Team.py ├── Sherlock and Divisors.py ├── Sherlock and Watson.py ├── Missing Numbers.py ├── Sherlock and GCD.py ├── The Love Letter.py ├── Make it Anagram.py ├── Summing up to N series.java ├── B'day Gift.java ├── Encryption.java ├── Hackerrank Language.py ├── Special Multiples.java ├── Game of Thrones-I.py ├── Triangle Number.java ├── Mark and Toys.java ├── Even Odd Query.py ├── is Fibo.py ├── Angry Children.java ├── Diwali Lights.java ├── Pairs.java ├── Maximizing XOR.java ├── Connecting Town.java ├── Filling Jars.java ├── Halloween Party.java ├── Chocolate Fiesta.java ├── Manasa and Stones.java ├── Closest Number.java ├── Ice Creame Parlor.java ├── A Chocolate Fiesta.java ├── Insertion Sort part2.java ├── Volleyball Match.java └── Sherlock and The Beast.py ├── Regular Expresstion ├── Find Digits.py ├── Utopian Identification.py ├── Split Phone Number.py ├── The British and American Style of Spelling.py ├── Valid PAN Format.py ├── Utopian Tree.py ├── Detect Email Address.py ├── Find Hackerrank.java ├── Building a Smart IDE.java └── IP Address Validation.java ├── .gitattributes ├── Artificial Inteligence ├── BotClean Stochastic.py ├── Bot Save Princess.java └── Bot Save Princess2.java └── .gitignore /ProjectEuler+/p33.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HackerRank-Solution 2 | Solutions of problems from HackerRank 3 | -------------------------------------------------------------------------------- /ProjectEuler+/p13.py: -------------------------------------------------------------------------------- 1 | s = 0 2 | for i in xrange(input()): 3 | s += input() 4 | print str(s)[:10] -------------------------------------------------------------------------------- /Algorithm/Find Median.py: -------------------------------------------------------------------------------- 1 | n = input() 2 | w = raw_input() 3 | w = w.split() 4 | w = map(int,w) 5 | w = sorted(w) 6 | m = w[n/2 ] 7 | print m -------------------------------------------------------------------------------- /ProjectEuler+/p28.py: -------------------------------------------------------------------------------- 1 | mod = 10**9+7 2 | def s(L): 3 | n = (L-1)//2 4 | return ((16*n**3 + 30*n**2 + 26*n + 3) // 3)%mod 5 | for _ in xrange(input()): 6 | print s(input()) -------------------------------------------------------------------------------- /ProjectEuler+/p6.py: -------------------------------------------------------------------------------- 1 | def diff(n): 2 | return (n*(n*n-1)*(3*n+2))/12 3 | a = [] 4 | for i in range(input()): 5 | a.append(input()) 6 | for i in a: 7 | print diff(i) -------------------------------------------------------------------------------- /ProjectEuler+/p42.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | def root(tn): 3 | s = sqrt(1+8*tn) 4 | if s%1 == 0: 5 | return int((s-1)/2) 6 | else: 7 | return -1 8 | for i in xrange(input()): 9 | print root(input()) -------------------------------------------------------------------------------- /Algorithm/Sherlock and Squares.py: -------------------------------------------------------------------------------- 1 | from math import ceil, sqrt, floor 2 | def c(a,b): 3 | return int(floor(sqrt(b)) - ceil(sqrt(a)) + 1) 4 | for i in xrange(input()): 5 | a,b = map(int,raw_input().split()) 6 | print c(a,b) -------------------------------------------------------------------------------- /Algorithm/Handshakes.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | oup = {} 4 | for i in range(t): 5 | w = input() 6 | oup[i] = (w*(w-1))/2 7 | for i in oup.values(): 8 | print i 9 | 10 | if __name__ == '__main__': 11 | main() 12 | -------------------------------------------------------------------------------- /ProjectEuler+/p1.py: -------------------------------------------------------------------------------- 1 | def s(l): 2 | n3 = l/3 3 | n5 = l/5 4 | n15 = l/15 5 | su = 0 6 | su += 3*(n3*(n3+1))/2 7 | su += 5*(n5*(n5+1))/2 8 | su -= 15*(n15*(n15+1))/2 9 | print su 10 | for i in xrange(input()): 11 | s(input()-1) -------------------------------------------------------------------------------- /ProjectEuler+/p20.py: -------------------------------------------------------------------------------- 1 | from math import factorial 2 | def cnt_fac(n): 3 | sm = 0 4 | s = str(factorial(n)) 5 | l = len(s) 6 | for i in xrange(l): 7 | sm += int(s[i]) 8 | return sm 9 | for i in xrange(input()): 10 | print cnt_fac(input()) -------------------------------------------------------------------------------- /Algorithm/Reverse Game.py: -------------------------------------------------------------------------------- 1 | def find(n,k): 2 | if k == n/2: 3 | return n 4 | elif k< n/2: 5 | return ((k+1)*2 - 1) 6 | else: 7 | return ((n-k)*2) 8 | for i in xrange(input()): 9 | n,k = map(int,raw_input().split()) 10 | print find(n-1,k) -------------------------------------------------------------------------------- /ProjectEuler+/p48.py: -------------------------------------------------------------------------------- 1 | def solve(n): 2 | mod = pow(10,10) 3 | c = 0 4 | s = 1 5 | if n > 100000: 6 | c = 3031782500L 7 | s = 100001 8 | for i in xrange(s,n+1): 9 | c += pow(i,i,mod) 10 | c %= mod 11 | return c 12 | print solve(input()) -------------------------------------------------------------------------------- /Algorithm/Easy Sum.py: -------------------------------------------------------------------------------- 1 | def e_sum(n,m): 2 | s = 0 3 | sn = (m*(m-1))/2 4 | s += sn*(n/m) 5 | r = n%m 6 | s += ((r+1)*(r))/2 7 | return s 8 | for i in xrange(input()): 9 | n,m = map(int,raw_input().split()) 10 | print e_sum(n,m) -------------------------------------------------------------------------------- /ProjectEuler+/p63.py: -------------------------------------------------------------------------------- 1 | from math import floor,ceil 2 | def getfir(n): 3 | a = pow(10,n-1) 4 | return (int(ceil(pow(a,1/float(n)))),int(floor(pow(a*10 -1,1/float(n))))) 5 | n = input() 6 | fir,las = getfir(n) 7 | while fir <= las: 8 | print pow(fir,n) 9 | fir += 1 -------------------------------------------------------------------------------- /Algorithm/Hackerrank Tweet.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | count = 0 4 | for i in range(t): 5 | w = raw_input() 6 | w = w.lower() 7 | if 'hackerrank' in w: 8 | count += 1 9 | print count 10 | 11 | if __name__ == '__main__': 12 | main() 13 | -------------------------------------------------------------------------------- /ProjectEuler+/p5.py: -------------------------------------------------------------------------------- 1 | def lcm(a,b): 2 | gcd, tmp = a,b 3 | while tmp != 0: 4 | gcd,tmp = tmp, gcd % tmp 5 | return a*b/gcd 6 | n = [] 7 | for i in range(input()): 8 | n.append(input()) 9 | for i in n: 10 | print reduce(lcm,range(1,i+1)) -------------------------------------------------------------------------------- /Algorithm/Lonely Integer.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | if t%2 == 1: 4 | w = raw_input() 5 | w = w.split() 6 | p = list(set(w)) 7 | for i in p: 8 | if w.count(i) == 1: 9 | print i 10 | break 11 | 12 | if __name__ == '__main__': 13 | main() 14 | -------------------------------------------------------------------------------- /Algorithm/Flowers.py: -------------------------------------------------------------------------------- 1 | n,k = map(int,raw_input().split()) 2 | a = map(int,raw_input().split()) 3 | a = sorted(a,reverse=True) 4 | s = 0 5 | p = 0 6 | l = 1 7 | for i in a: 8 | if p==k: 9 | p=0 10 | l += 1 11 | s += i*l 12 | #print i*l 13 | p += 1 14 | print s -------------------------------------------------------------------------------- /Algorithm/Dancing in Pairs.py: -------------------------------------------------------------------------------- 1 | import math 2 | t = input() 3 | i = [] 4 | for x in xrange(t): 5 | i.append(input()) 6 | for x in i: 7 | d = 4*(x+1) 8 | n = math.ceil((math.sqrt(d) - 2)/2) 9 | if(int(n)%2 == 0): 10 | print 'even' 11 | else: 12 | print 'odd' 13 | -------------------------------------------------------------------------------- /Algorithm/Gem Stones.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | w = [] 4 | for i in range(t): 5 | w.append(raw_input()) 6 | l = set(w[0]) 7 | for i in range(1,len(w)): 8 | l = l.intersection(w[i]) 9 | print len(l) 10 | 11 | if __name__ == '__main__': 12 | main() -------------------------------------------------------------------------------- /Algorithm/Die Hard 3.py: -------------------------------------------------------------------------------- 1 | from fractions import gcd 2 | out = [] 3 | for i in range(input()): 4 | a,b,c = [int(i) for i in raw_input().strip().split()] 5 | if c%gcd(a,b) == 0 and (c<=a or c<=b): 6 | out.append("YES") 7 | else: 8 | out.append("NO") 9 | for i in out: 10 | print i -------------------------------------------------------------------------------- /Algorithm/Sherlock and permutation.py: -------------------------------------------------------------------------------- 1 | mod = 10**9+7 2 | def ncr(n,r): 3 | s = 1 4 | if r> n-r: 5 | r = n-r 6 | for i in xrange(r): 7 | s = ((s*(n-i))/(i+1)) 8 | return s%mod 9 | 10 | for i in xrange(input()): 11 | n,m = map(int,raw_input().split()) 12 | print ncr(n+m-1,m-1) -------------------------------------------------------------------------------- /ProjectEuler+/p15.py: -------------------------------------------------------------------------------- 1 | mod = 10**9+7 2 | def mcn(m,n): 3 | r = m 4 | if m>n: 5 | r = n 6 | p = 1 7 | for i in xrange(r): 8 | p *= (m+n) - i 9 | p /= i+1 10 | return p%mod 11 | n = [] 12 | for i in xrange(input()): 13 | n.append(map(int,raw_input().split())) 14 | for i in n: 15 | print mcn(i[0],i[1]) -------------------------------------------------------------------------------- /ProjectEuler+/p34.py: -------------------------------------------------------------------------------- 1 | l = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880] 2 | def is_fac(n): 3 | s = str(n) 4 | sm = 0 5 | for i in s: 6 | sm += l[int(i)] 7 | if sm%n == 0: 8 | return True 9 | return False 10 | i = 10 11 | end = input() 12 | c = 0 13 | while i<= end: 14 | if is_fac(i): c+= i 15 | i += 1 16 | print c -------------------------------------------------------------------------------- /Regular Expresstion/Find Digits.py: -------------------------------------------------------------------------------- 1 | t = input() 2 | n = [] 3 | for i in range(t): 4 | n.append(input()) 5 | for i in n: 6 | st = str(i) 7 | s = list(set(str(i))) 8 | cnt = 0 9 | for j in s: 10 | if j != '0': 11 | if i%int(j)==0: 12 | cnt += st.count(j) 13 | print cnt -------------------------------------------------------------------------------- /ProjectEuler+/p18.py: -------------------------------------------------------------------------------- 1 | def maxx(table): 2 | for row in range(len(table)-1, 0, -1): 3 | for col in range(0, row): 4 | table[row-1][col] += max(table[row][col], table[row][col+1]) 5 | return table[0][0] 6 | for i in xrange(input()): 7 | n = [] 8 | for j in xrange(input()): 9 | n.append(map(int,raw_input().split())) 10 | print maxx(n) -------------------------------------------------------------------------------- /ProjectEuler+/p8.py: -------------------------------------------------------------------------------- 1 | def num_prod(n,k): 2 | print max([reduce(lambda accum, x : accum * x, [int(x) for x in n[i:i+k]]) for i in range(len(n) - k)]) 3 | n = [] 4 | num = [] 5 | t = input() 6 | for i in range(t): 7 | n.append(map(int,raw_input().split())) 8 | num.append(raw_input()) 9 | for i in range(t): 10 | num_prod(num[i],n[i][1]) -------------------------------------------------------------------------------- /Algorithm/Counter Game.py: -------------------------------------------------------------------------------- 1 | import math 2 | def c(n): 3 | cn = 0 4 | while n!=1: 5 | if (n&(n-1)==0 and n!=0): 6 | n /= 2 7 | else: 8 | i= n.bit_length()-1 9 | n -= int(math.pow(2,i)) 10 | cn += 1 11 | return cn 12 | for i in xrange(input()): 13 | n = c(input()) 14 | if n%2==0: 15 | print 'Richard' 16 | else: 17 | print 'Louise' -------------------------------------------------------------------------------- /Algorithm/Stepping Stone Games.py: -------------------------------------------------------------------------------- 1 | t = "Go On Bob" 2 | f = "Better Luck Next Time" 3 | from math import sqrt 4 | def check(x): 5 | s = sqrt(8*x+1) 6 | if s%1 ==0: 7 | n = (s-1)/2.0 8 | if (s-1)/2.0 %1 == 0: 9 | return t + ' ' + str(int(n)) 10 | else: 11 | return f 12 | else: 13 | return f 14 | 15 | for i in xrange(input()): 16 | print check(input()) -------------------------------------------------------------------------------- /ProjectEuler+/p31.py: -------------------------------------------------------------------------------- 1 | mod = 10**9+7 2 | coins = [1, 2, 5, 10, 20, 50, 100, 200] 3 | def c(target): 4 | ways = [1] + [0]*target 5 | for coin in coins: 6 | for i in range(coin, target+1): 7 | ways[i] += ways[i-coin]%mod 8 | return ways 9 | n =[] 10 | for i in xrange(input()): 11 | n.append(input()) 12 | way = c(max(n)) 13 | for i in n: 14 | print way[i]%mod -------------------------------------------------------------------------------- /ProjectEuler+/p53.py: -------------------------------------------------------------------------------- 1 | def scan(op, seq, it): 2 | a = [] 3 | result = it 4 | a.append(it) 5 | for x in seq: 6 | result = op(result, x) 7 | a.append(result) 8 | return a 9 | def pascal(n): 10 | def nextrow(row, x): 11 | return [l+r for l,r in zip(row+[0,],[0,]+row)] 12 | 13 | return scan(nextrow, range(n-1), [1,]) 14 | for row in pascal(400): 15 | print(row) -------------------------------------------------------------------------------- /Algorithm/Find Point.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | w = {} 4 | p = {} 5 | for i in range(t): 6 | w[i] = raw_input() 7 | w[i] = w[i].split() 8 | w[i] = map(int,w[i]) 9 | x = w[i][2] + w[i][2] - w[i][0] 10 | y = w[i][3] + w[i][3] - w[i][1] 11 | p[i] = (str)(x) + ' '+ (str)(y) 12 | for i in p.values(): 13 | print i 14 | 15 | if __name__ == '__main__': 16 | main() -------------------------------------------------------------------------------- /ProjectEuler+/p21.py: -------------------------------------------------------------------------------- 1 | am = [220, 284, 1184, 1210, 2620, 2924, 5020, 5564, 6232, 6368, 10744, 10856, 12285, 14595, 17296, 18416, 63020, 66928, 66992, 67095, 69615, 71145, 76084, 79750, 87633, 88730] 2 | for i in xrange(input()): 3 | s = 0 4 | n = input() 5 | if n>88730: 6 | print sum(am) 7 | else: 8 | for j in am: 9 | if j < n: 10 | s+=j 11 | else:break 12 | print s 13 | -------------------------------------------------------------------------------- /Regular Expresstion/Utopian Identification.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def main(): 4 | p = input() 5 | t = 'VALID' 6 | f = 'INVALID' 7 | oup = [] 8 | for i in range(p): 9 | w = raw_input() 10 | if re.match('[a-z]{0,3}\d{2,8}[A-z]{3,}',w): 11 | oup.append(t) 12 | else: 13 | oup.append(f) 14 | for i in oup: 15 | print i 16 | 17 | if __name__ == '__main__': 18 | main() 19 | -------------------------------------------------------------------------------- /Regular Expresstion/Split Phone Number.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | w = {} 4 | for i in range(t): 5 | w[i] = raw_input() 6 | if '-' in w[i]: 7 | w[i] = w[i].split('-') 8 | else: 9 | w[i] = w[i].split() 10 | for i in range(t): 11 | print 'CountryCode='+w[i][0]+',LocalAreaCode='+w[i][1]+',Number='+w[i][2] 12 | 13 | 14 | if __name__ == '__main__': 15 | main() 16 | -------------------------------------------------------------------------------- /Regular Expresstion/The British and American Style of Spelling.py: -------------------------------------------------------------------------------- 1 | import re 2 | n = input() 3 | w = '' 4 | for i in range(n): 5 | w += raw_input().strip() 6 | t = input() 7 | wr = [] 8 | for i in range(t): 9 | wr.append(raw_input().strip()) 10 | for i in wr: 11 | j = i[:-2] 12 | if i[-2] =='z': 13 | j+='se' 14 | else: 15 | j+='ze' 16 | print w.count(i)+w.count(j) -------------------------------------------------------------------------------- /Algorithm/Correctness and Loop Invariant.py: -------------------------------------------------------------------------------- 1 | def insertion_sort(l): 2 | for i in xrange(1, len(l)): 3 | j = i-1 4 | key = l[i] 5 | while (l[j] > key) and (j >= 0): 6 | l[j+1] = l[j] 7 | j -= 1 8 | l[j+1] = key 9 | 10 | 11 | m = input() 12 | ar = [int(i) for i in raw_input().strip().split()] 13 | insertion_sort(ar) 14 | print " ".join(map(str,ar)) -------------------------------------------------------------------------------- /Algorithm/Triangle Number.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | oup = [] 4 | for i in range(t): 5 | w = input() 6 | if w <= 2: 7 | oup.append(-1) 8 | elif w % 2 == 1: 9 | oup.append(2) 10 | elif w % 2 == 0: 11 | p = w/2 12 | if p % 2 == 0: 13 | oup.append(3) 14 | else: 15 | oup.append(4) 16 | for i in oup: 17 | print i 18 | 19 | if __name__ == '__main__': 20 | main() 21 | -------------------------------------------------------------------------------- /ProjectEuler+/p22.py: -------------------------------------------------------------------------------- 1 | names = [] 2 | for i in xrange(input()): 3 | names.append(raw_input().strip()) 4 | names = sorted(names) 5 | for i in xrange(input()): 6 | out = 0 7 | s = raw_input().strip() 8 | for j in xrange(len(s)): 9 | if ord(s[j])-64 > 27: 10 | out += ord(s[j]) - 96 11 | else: 12 | out += ord(s[j]) - 64 13 | print s*(names.index(s)+1) 14 | -------------------------------------------------------------------------------- /ProjectEuler+/p2.py: -------------------------------------------------------------------------------- 1 | def fib(): 2 | x,y = 0,1 3 | while True: 4 | yield x 5 | x,y = y, x+y 6 | def even(seq): 7 | for number in seq: 8 | if not number % 2: 9 | yield number 10 | def sumofev(seq,k): 11 | for number in seq: 12 | if number > k: 13 | break 14 | yield number 15 | for i in range(input()): 16 | print sum(even(sumofev(fib(),input()))) -------------------------------------------------------------------------------- /Regular Expresstion/Valid PAN Format.py: -------------------------------------------------------------------------------- 1 | import re 2 | def main(): 3 | p = input() 4 | t = 'YES' 5 | f = 'NO' 6 | oup = [] 7 | for i in range(p): 8 | w = raw_input() 9 | if len(w) == 10: 10 | if re.match('[A-Z]{5}[0-9]{4}[A-Z]',w): 11 | oup.append(t) 12 | else: 13 | oup.append(f) 14 | else: 15 | oup.append(f) 16 | for i in oup: 17 | print i 18 | 19 | if __name__ =='__main__': 20 | main() 21 | -------------------------------------------------------------------------------- /Algorithm/ACM ICPC Team.py: -------------------------------------------------------------------------------- 1 | def c(): 2 | n,m = map(int,raw_input().split()) 3 | l = [] 4 | mx = 0 5 | for _ in xrange(n): 6 | w = int('0b' + raw_input(),2) 7 | l.append(w) 8 | cnt = 0 9 | for i in xrange(n): 10 | for j in xrange(i+1,n): 11 | p = bin(l[i]|l[j]).count('1') 12 | if p > mx: 13 | mx = p 14 | cnt = 1 15 | elif p == mx: 16 | cnt += 1 17 | return mx,cnt 18 | a,b = c() 19 | print a 20 | print b -------------------------------------------------------------------------------- /Regular Expresstion/Utopian Tree.py: -------------------------------------------------------------------------------- 1 | def calc(cycle): 2 | ht = 1 3 | ses = 'mon' 4 | while cycle > 0: 5 | if ses == 'mon': 6 | ht = 2*ht 7 | ses = 'somm' 8 | else: 9 | ht += 1 10 | ses = 'mon' 11 | cycle -= 1 12 | print ht 13 | 14 | def main(): 15 | t = input() 16 | no = [] 17 | for i in range(t): 18 | w = input() 19 | no.append(w) 20 | for i in no: 21 | calc(i) 22 | 23 | if __name__ == '__main__': 24 | main() -------------------------------------------------------------------------------- /Algorithm/Sherlock and Divisors.py: -------------------------------------------------------------------------------- 1 | for cas in xrange(input()): 2 | n = input() 3 | if n % 2: # odd 4 | print 0 5 | else: 6 | n /= 2 7 | ans = 1 8 | p = 2 9 | while p <= n: 10 | if p * p > n: p = n 11 | e = 0 12 | while n % p == 0: 13 | e += 1 14 | n /= p 15 | ans *= e + 1 16 | p += 1 17 | print ans -------------------------------------------------------------------------------- /Algorithm/Sherlock and Watson.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | w = map(int,raw_input().split()) 3 | n = w[0] 4 | k = w[1] 5 | q = w[2] 6 | arr = map(int,raw_input().split()) 7 | for i in range(k): 8 | w = arr.pop() 9 | arr.insert(0,w) 10 | oup = [] 11 | for i in range(q): 12 | oup.append(arr[input()]) 13 | for i in oup: 14 | print i 15 | 16 | 17 | if __name__ == '__main__': 18 | main() 19 | -------------------------------------------------------------------------------- /ProjectEuler+/p7.py: -------------------------------------------------------------------------------- 1 | import math 2 | def is_prime(n): 3 | if n == 2: 4 | return True 5 | if n == 3: 6 | return True 7 | if n%2==0: 8 | return False 9 | for i in range(3,int(math.sqrt(n))+1,2): 10 | if n%i == 0: 11 | return False 12 | return True 13 | n = [] 14 | for i in range(input()): 15 | n.append(input()) 16 | l = max(n) 17 | a = [] 18 | i = 2 19 | while len(a) < l: 20 | if is_prime(i): 21 | a.append(i) 22 | i += 1 23 | for i in n: 24 | print a[i-1] -------------------------------------------------------------------------------- /Algorithm/Missing Numbers.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | i = 0 3 | j = 0 4 | oup = [] 5 | size1 = input() 6 | inp1 = raw_input() 7 | inp1 = inp1.split() 8 | size2 = input() 9 | inp2 = raw_input() 10 | inp2 = inp2.split() 11 | p = list(set(inp1)) 12 | for i in p: 13 | if inp1.count(i) != inp2.count(i): 14 | oup.append(i) 15 | oup = map(int,oup) 16 | oup = list(set(oup)) 17 | oup = sorted(oup) 18 | for i in oup: 19 | print i, 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /Algorithm/Sherlock and GCD.py: -------------------------------------------------------------------------------- 1 | from fractions import gcd 2 | t = input() 3 | a = [] 4 | n = [] 5 | for i in range(t): 6 | n.append(input()) 7 | a.append(map(int,raw_input().split())) 8 | for i in a: 9 | l = len(i) 10 | if l >1: 11 | g = gcd(i[0],i[1]) 12 | else: 13 | g = i[0] 14 | for j in range(2,l): 15 | if g==1: 16 | break 17 | g = gcd(g,i[j]) 18 | if g==1: 19 | print 'YES' 20 | else: 21 | print 'NO' -------------------------------------------------------------------------------- /ProjectEuler+/p3.py: -------------------------------------------------------------------------------- 1 | from itertools import chain 2 | def first(gen): 3 | try: 4 | return gen.next() 5 | except StopIteration : 6 | return None 7 | def prime_factors(n): 8 | while n > 1 : 9 | ff = first(val for val in chain( 10 | xrange(2,int(n**0.5+1.0)),[n]) if n % val == 0) 11 | yield ff 12 | n = n / ff 13 | n = [] 14 | for i in range(input()): 15 | n.append(input()) 16 | for i in n: 17 | print max(prime_factors(i)) -------------------------------------------------------------------------------- /ProjectEuler+/p24.py: -------------------------------------------------------------------------------- 1 | facs = [479001600, 39916800, 3628800, 362880, 40320, 5040, 720, 120, 24, 6, 2, 1] 2 | def pr(n): 3 | s = ['a','b','c','d','e','f','g','h','i','j','k','l','m'] 4 | out = '' 5 | for i in facs: 6 | if n/i>0: 7 | j = n/i 8 | n = n%i 9 | if n == 0: 10 | j-=1 11 | n+= i 12 | #print j 13 | out += str(s[j]) 14 | del(s[j]) 15 | else: 16 | #print 0 17 | out += s[0] 18 | del(s[0]) 19 | return out + s[0] 20 | for i in xrange(input()): 21 | print pr(input()) -------------------------------------------------------------------------------- /ProjectEuler+/p12.py: -------------------------------------------------------------------------------- 1 | li = {128: 157080, 1: 1, 2: 3, 4: 6, 6: 28, 648: 103672800, 9: 36, 144: 437580, 18: 300, 20: 528, 24: 630, 768: 236215980, 112: 73920, 162: 749700, 36: 2016, 1024: 842161320, 40: 3240, 1280: 3090906000L, 48: 5460, 192: 1493856, 320: 2162160, 90: 25200, 480: 17907120, 16: 120, 240: 2031120, 168: 1385280, 1344: 4819214400L, 576: 76576500} 2 | keys = sorted(li.keys()) 3 | n = [] 4 | for i in xrange(input()): 5 | n.append(input()) 6 | for i in n: 7 | for j in keys: 8 | if j>i: 9 | print li[j] 10 | break -------------------------------------------------------------------------------- /Algorithm/The Love Letter.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = input() 3 | s = [] 4 | for i in range(t): 5 | s.append(raw_input()) 6 | for i in range(t): 7 | l = s[i] 8 | out = 0 9 | j = 0 10 | k = len(l) - 1 11 | while(jq): 17 | out += p-q 18 | j += 1 19 | k -= 1 20 | print out 21 | 22 | 23 | if __name__ == '__main__': 24 | main() -------------------------------------------------------------------------------- /ProjectEuler+/p36.py: -------------------------------------------------------------------------------- 1 | import time 2 | digits = "0123456789abcdefghijklmnopqrstuvwxyz" 3 | def baseN(num,b): 4 | if num == 0: return "0" 5 | result = "" 6 | while num != 0: 7 | num, d = divmod(num, b) 8 | result += digits[d] 9 | return result[::-1] 10 | def getRev(n): 11 | return str(n)[::-1] 12 | 13 | def c(n,k): 14 | i=s=0 15 | while i<=n: 16 | j = str(i) 17 | b = baseN(i,k) 18 | #print j,b,getRev(j),getRev(b) 19 | if j == getRev(j) and str(b) == getRev(b): 20 | s+= i 21 | i += 1 22 | return s 23 | n,k = map(int,raw_input().split()) 24 | print c(n,k) -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /ProjectEuler+/p1.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | class Solution{ 4 | public static void main(String args[]){ 5 | Scanner in = new Scanner(System.in); 6 | int t = in.nextInt(); 7 | for(int i=0;i ca[i]: 12 | count += cb[i] - ca[i] 13 | else: 14 | count += ca[i] - cb[i] 15 | del(cb[i]) 16 | else: 17 | count += ca[i] 18 | for i in cb.keys(): 19 | count += cb[i] 20 | print count 21 | 22 | if __name__ == '__main__': 23 | main() 24 | -------------------------------------------------------------------------------- /ProjectEuler+/p44.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | def init(n,k): 3 | a = [0] 4 | for i in xrange(1,n): 5 | a.append((i*((3*i)-1))/2) 6 | for i in xrange(n,10**6+1): 7 | a.append(0) 8 | return a 9 | def solve(n,k): 10 | a = init(n,k) 11 | for i in xrange(k+1,n): 12 | p3 = a[i]- a[i-k] 13 | p4 = a[i] + a[i-k] 14 | p1 = int((1+sqrt(1+24*p3))/6) 15 | p2 = int((1+sqrt(1+24*p4))/6) 16 | if p1<=10**6: 17 | if a[p1] == p3: 18 | print a[i] 19 | elif p2<=10**6: 20 | if a[p2] == p4: 21 | print a[i] 22 | elif p2<=10**6: 23 | if a[p2] == p4: 24 | print a[i] 25 | n,k = map(int,raw_input().split()) 26 | solve(n,k) -------------------------------------------------------------------------------- /Regular Expresstion/Detect Email Address.py: -------------------------------------------------------------------------------- 1 | import re 2 | def main(): 3 | t = input() 4 | w = {} 5 | oup = [] 6 | for i in range(t): 7 | w[i] = raw_input() 8 | if re.findall('\w+\.\w+@\w+\.\w+\.\w+',w[i]): 9 | oup += re.findall('\w+\.\w+@\w+\.\w+\.\w+',w[i]) 10 | elif re.findall('\w+@\w+\.\w+\.\w+\.\w+',w[i]): 11 | oup += re.findall('\w+@\w+\.\w+\.\w+\.\w+',w[i]) 12 | elif re.findall('\w+@\w+\.\w+\.\w+',w[i]): 13 | oup += re.findall('\w+@\w+\.\w+\.\w+',w[i]) 14 | elif re.findall('\w+@\w+\.\w+',w[i]): 15 | oup += re.findall('\w+@\w+\.\w+',w[i]) 16 | oup = list(set(oup)) 17 | oup.sort() 18 | p = ';'.join(oup) 19 | print p 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /Algorithm/Summing up to N series.java: -------------------------------------------------------------------------------- 1 | import java.math.BigInteger; 2 | import java.util.Scanner; 3 | 4 | 5 | public class Solution { 6 | 7 | /** 8 | * @param args 9 | */ 10 | public static void main(String[] args) { 11 | // TODO Auto-generated method stub 12 | Scanner in = new Scanner(System.in); 13 | int t = in.nextInt(); 14 | BigInteger n[] = new BigInteger[t]; 15 | BigInteger s[] = new BigInteger[t]; 16 | for (int i=0;i len(str(f.den)) and i+1 <= n: 26 | print i+1 -------------------------------------------------------------------------------- /Algorithm/Encryption.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) { 10 | // TODO Auto-generated method stub 11 | Scanner in = new Scanner(System.in); 12 | String s = in.nextLine(); 13 | Double a = Math.sqrt(s.length()); 14 | int h = (int) Math.floor(a); 15 | int w = (int) Math.ceil(a); 16 | int count = 0; 17 | char ar[] = s.toCharArray(); 18 | 19 | for(int i=0;i di: 10 | print 'UP' 11 | elif posr < di: 12 | print 'DOWN' 13 | else: 14 | if posc > dj: 15 | print 'LEFT' 16 | elif posc < dj: 17 | print 'RIGHT' 18 | else: 19 | print 'CLEAN' 20 | if __name__ == "__main__": 21 | pos = [int(i) for i in raw_input().strip().split()] 22 | board = [[j for j in raw_input().strip()] for i in xrange(5)] 23 | nextMove(pos[0], pos[1], board) 24 | -------------------------------------------------------------------------------- /Algorithm/Special Multiples.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) throws Exception { 10 | 11 | //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 12 | Scanner inr = new Scanner (System.in); 13 | int t = inr.nextInt(); 14 | int n[] = new int[t]; 15 | for(int i=0;i=2: 18 | flag = False 19 | break 20 | if(flag == True): 21 | print 'YES' 22 | else: 23 | print 'NO' 24 | if __name__ == '__main__': 25 | main() -------------------------------------------------------------------------------- /Algorithm/Triangle Number.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) throws Exception { 10 | 11 | //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 12 | Scanner inr = new Scanner (System.in); 13 | int t = inr.nextInt(); 14 | int n[] = new int[t]; 15 | for(int i=0;ik){ 25 | break; 26 | } 27 | total++; 28 | } 29 | System.out.println(total); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Algorithm/Even Odd Query.py: -------------------------------------------------------------------------------- 1 | def cal(a): 2 | if a%2==0: 3 | return True 4 | else: 5 | return False 6 | n = input() 7 | a = map(int,raw_input().split()) 8 | q = input() 9 | qr = [] 10 | o = 'Odd' 11 | e = 'Even' 12 | for i in range(q): 13 | qr.append(map(int,raw_input().split())) 14 | for i in range(q): 15 | x = qr[i][0] 16 | y = qr[i][1] 17 | if x>y: 18 | print o 19 | else: 20 | if cal(a[x-1]): 21 | if y!=x and x 10: y -= 1 7 | #print m,y 8 | if (1 + int(math.floor(2.6*m - 0.2)) + 5*(y%4) + 4*(y%100) + 6*(y%400))%7 == 0: 9 | #print m,y 10 | return True 11 | else: 12 | return False 13 | def iter(yr1,yr2): 14 | d1,m1,y1 = yr1[2],yr1[1],yr1[0] 15 | d2,m2,y2 = yr2[2],yr2[1],yr2[0] 16 | cnt = 0 17 | if d1 > 1: 18 | if m1 != 12: m1 += 1 19 | else: 20 | m1 = 1 21 | y1 += 1 22 | for y in xrange(y1,y2+1): 23 | mn = 1 24 | mj = 13 25 | if y == y1: mn = m1 26 | if y == y2: mj = m2 +1 27 | for m in xrange(mn,mj): 28 | if day_sun(m,y): 29 | cnt += 1 30 | return cnt 31 | for i in xrange(input()): 32 | y1 = map(int,raw_input().split()) 33 | y2 = map(int,raw_input().split()) 34 | print iter(y1,y2) -------------------------------------------------------------------------------- /ProjectEuler+/p40.py: -------------------------------------------------------------------------------- 1 | a = [0, 9, 189, 2889, 38889, 488889, 5888889, 68888889, 788888889, 8888888889L, 98888888889L, 1088888888889L, 11888888888889L, 128888888888889L, 1388888888888889L, 14888888888888889L, 158888888888888889L, 1688888888888888889L] 2 | def get(n): 3 | if n in a: 4 | return [a.index(n)] 5 | else: 6 | pre = 0 7 | for i in xrange(1,len(a)): 8 | nxt = a[i] 9 | if nxt > n and pre k || num[i] - num[j] > k){ 27 | break; 28 | } 29 | } 30 | } 31 | System.out.println(count); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Algorithm/Maximizing XOR.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | /* 9 | * Complete the function below. 10 | */ 11 | public static void main(String[] args) { 12 | // TODO Auto-generated method stub 13 | Scanner in = new Scanner(System.in); 14 | BigInteger l = in.nextBigInteger(); 15 | BigInteger r = in.nextBigInteger(); 16 | int i = l.intValue(); 17 | int last = r.intValue(); 18 | int j = last; 19 | BigInteger max = BigInteger.valueOf(i).xor(BigInteger.valueOf(j)); 20 | for(i=l.intValue();ii;j--){ 22 | if(max.compareTo(BigInteger.valueOf(i).xor(BigInteger.valueOf(j))) ==-1){ 23 | max = BigInteger.valueOf(i).xor(BigInteger.valueOf(j)); 24 | } 25 | } 26 | 27 | } 28 | System.out.println(max); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ProjectEuler+/p65.py: -------------------------------------------------------------------------------- 1 | from fractions import gcd 2 | class frac: 3 | def __init__(self,num,den=1): 4 | self.num = num 5 | self.den = den 6 | def add(self,f): 7 | self.num = self.num*f.den + f.num*self.den 8 | self.den *= f.den 9 | # l = gcd(self.num,self.den) 10 | # self.num /= l 11 | # self.den /= l 12 | def rec(self): 13 | self.num,self.den = self.den,self.num 14 | def getEle(n): 15 | q,r = divmod(n,3) 16 | if r == 0: 17 | return q*2 18 | return 1 19 | n = input() 20 | if n == 1: 21 | print 2 22 | else: 23 | f = frac(getEle(n)) 24 | for i in xrange(n-1,1,-1): 25 | #print f,getEle(i) 26 | f.rec() 27 | f.add(frac(getEle(i))) 28 | # f = 1/f + getEle(i) 29 | f.rec() 30 | f.add(frac(2)) 31 | # f = 1/f + 32 | num = f.num 33 | den = f.den 34 | l = gcd(num,den) 35 | num /= l 36 | st = str(num) 37 | print sum(map(int,st)) 38 | # for i in st: 39 | # s += int(i) 40 | # print s -------------------------------------------------------------------------------- /Regular Expresstion/Find Hackerrank.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) throws Exception{ 10 | /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ 11 | String h = "hackerrank"; 12 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 13 | String inp = br.readLine(); 14 | int n = Integer.parseInt(inp); 15 | for(int i=0;i= 3732423: 10 | print 3732423 11 | break 12 | if i < p[j]: 13 | c = 1 14 | print p[j-1] 15 | break 16 | ''' 17 | import time 18 | def c(n,i): 19 | if n%2==0: 20 | n /= 2 21 | else: 22 | n = 3*n+1 23 | if n==1: 24 | return i 25 | else: return c(n,i+1) 26 | n = [] 27 | t = input() 28 | s = time.time() 29 | for i in xrange(1,t+1): 30 | n.append(c(i,1)) 31 | print len(n) 32 | for i in n: 33 | c(i,1) 34 | print time.time()-s 35 | ''' -------------------------------------------------------------------------------- /ProjectEuler+/p43.py: -------------------------------------------------------------------------------- 1 | from itertools import permutations as P 2 | def gen(n): 3 | val = 0 4 | s = '0123456789' 5 | sn = s[:n+1] 6 | for i in P(sn): 7 | k = ''.join(i) 8 | if ch(k): 9 | val += int(k) 10 | return val 11 | def ch(n): 12 | fl = False 13 | if len(n) >= 4: 14 | if int(n[1:4])%2 == 0: 15 | fl = True 16 | else: return False 17 | if len(n) >= 5: 18 | if int(n[2:5])%3 == 0: 19 | fl = True 20 | else: return False 21 | if len(n) >= 6: 22 | if int(n[3:6])%5 == 0: 23 | fl = True 24 | else: return False 25 | if len(n) >= 7: 26 | if int(n[4:7])%7 == 0: 27 | fl = True 28 | else: return False 29 | if len(n) >= 8: 30 | if int(n[5:8])%11 == 0: 31 | fl = True 32 | else: return False 33 | if len(n) >= 9: 34 | if int(n[6:9])%13 == 0: 35 | fl = True 36 | else: return False 37 | if len(n) >= 10: 38 | if int(n[7:])%17 == 0: 39 | fl = True 40 | else: return False 41 | if fl: 42 | return True 43 | else: 44 | return False 45 | n = input() 46 | print gen(n) -------------------------------------------------------------------------------- /ProjectEuler+/p11.py: -------------------------------------------------------------------------------- 1 | def maxx(x): 2 | max_prod = -1 3 | for i in range(len(x)): 4 | for j in range(len(x[i])-3): 5 | horiz = (x[i][j])*(x[i][j+1])*(x[i][j+2])*(x[i][j+3]) 6 | if horiz > max_prod: 7 | max_prod = horiz 8 | 9 | 10 | for i in range(len(x[i])-3): 11 | for j in range(len(x)): 12 | vert = (x[i][j])*(x[i+1][j])*(x[i+2][j])*(x[i+3][j]) 13 | if vert > max_prod: 14 | max_prod = vert 15 | 16 | 17 | for i in range(len(x[i])-3): 18 | for j in range(len(x[i])-3): 19 | diag_right = (x[i][j])*(x[i+1][j+1])*(x[i+2][j+2])*(x[i+3][j+3]) 20 | if diag_right > max_prod: 21 | max_prod = diag_right 22 | 23 | 24 | for i in range(3,len(x)): 25 | for j in range(len(x[i])-3): 26 | diag_left = (x[i][j])*(x[i-1][j+1])*(x[i-2][j+2])*(x[i-3][j+3]) 27 | if diag_left > max_prod: 28 | max_prod = diag_left 29 | return max_prod 30 | 31 | n = [] 32 | for i in range(20): 33 | n.append(map(int,raw_input().split())) 34 | print maxx(n) 35 | -------------------------------------------------------------------------------- /Algorithm/Filling Jars.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) throws Exception { 10 | 11 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 12 | String s [] = br.readLine().split(" "); 13 | int n = Integer.parseInt(s[0]); 14 | int m = Integer.parseInt(s[1]); 15 | int a[] = new int[m]; 16 | int b[] = new int[m]; 17 | int k[] = new int[m]; 18 | for(int i=0;i=m[i]){ 30 | su += n[i]/m[i]; 31 | n[i] = n[i]/m[i] + n[i]%m[i]; 32 | } 33 | oup[i] = su; 34 | } 35 | for(int i:oup){ 36 | System.out.println(i); 37 | } 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /Algorithm/Manasa and Stones.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | 4 | public class Solution { 5 | 6 | /** 7 | * @param args 8 | */ 9 | public static void main(String[] args) { 10 | // TODO Auto-generated method stub 11 | Scanner in = new Scanner(System.in); 12 | int t = in.nextInt(); 13 | int n[] = new int[t]; 14 | int a[] = new int[t]; 15 | int b[] = new int[t]; 16 | for(int i=0;ib[i]){ 28 | for(int j=0;j0){ 29 | int key = -1;//Arrays.binarySearch(c[i], j+1, n[i]+1, k); 30 | for(int l=j+1;l=0){ 37 | //System.out.print(m[i] + " "); 38 | if(j1){ 36 | s1 = BigInteger.valueOf(2).pow(o-1); 37 | sum = sum.add(s1); 38 | sum = sum.subtract(BigInteger.ONE); 39 | } 40 | } 41 | else{ 42 | s1 = BigInteger.valueOf(2).pow(o-1); 43 | s2 = BigInteger.valueOf(2).pow(e); 44 | s2 = s2.subtract(BigInteger.ONE); 45 | sum = s1.multiply(s2); 46 | sum = sum.add(s1); 47 | sum = sum.subtract(BigInteger.ONE); 48 | } 49 | sum = sum.mod(BigInteger.valueOf(1000000007)); 50 | System.out.println(sum); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Algorithm/Insertion Sort part2.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void insertionSortPart2(int[] ar, int s) 7 | { 8 | // Fill up the code for the required logic here 9 | // Manipulate the array as required 10 | // The code for Input/Output is already provided 11 | for(int i=0;i0){ 14 | if(ar[j]=0){ 26 | int l = line[i].indexOf("/*"); 27 | if (line[i].indexOf("*/")>=0){ 28 | int la = line[i].indexOf("*/"); 29 | System.out.println(line[i].substring(l, la+2)); 30 | }else{ 31 | System.out.println(line[i].substring(l)); 32 | i++; 33 | while(line[i].indexOf("*/")<0){ 34 | System.out.println(line[i]); 35 | i++; 36 | } 37 | int la = line[i].indexOf("*/"); 38 | System.out.println(line[i].substring(0, la+2)); 39 | } 40 | }else if(line[i].indexOf("//")>=0){ 41 | int l = line[i].indexOf("//"); 42 | System.out.println(line[i].substring(l)); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Artificial Inteligence/Bot Save Princess.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | static void displayPathtoPrincess(int n, String [] grid){ 9 | int b_xpos = -1, b_ypos = -1, p_xpos = -1, p_ypos = -1; 10 | for(int i=0;i-1){ 12 | p_ypos = i; 13 | p_xpos = grid[i].indexOf('p'); 14 | } 15 | if(grid[i].indexOf('m')>-1){ 16 | b_ypos = i; 17 | b_xpos = grid[i].indexOf('m'); 18 | } 19 | if(b_xpos >=0 && b_ypos >=0 && p_xpos>=0 && p_ypos>=0){ 20 | break; 21 | } 22 | } 23 | while(b_xpos != p_xpos || b_ypos != p_ypos){ 24 | if(b_xpos > p_xpos){ 25 | b_xpos--; 26 | System.out.println("LEFT"); 27 | }else if(b_xpos < p_xpos){ 28 | b_xpos++; 29 | System.out.println("RIGHT"); 30 | } 31 | if(b_ypos > p_ypos){ 32 | b_ypos--; 33 | System.out.println("UP"); 34 | }else if(b_ypos < p_ypos){ 35 | b_ypos++; 36 | System.out.println("DOWN"); 37 | } 38 | } 39 | 40 | } 41 | public static void main(String[] args) { 42 | Scanner in = new Scanner(System.in); 43 | int m; 44 | m = in.nextInt(); 45 | String grid[] = new String[m]; 46 | for(int i = 0; i < m; i++) { 47 | grid[i] = in.next(); 48 | } 49 | 50 | displayPathtoPrincess(m,grid); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Artificial Inteligence/Bot Save Princess2.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | static void nextMove(int n, int r, int c, String [] grid){ 9 | 10 | int b_xpos = c, b_ypos = r, p_xpos = -1, p_ypos = -1; 11 | for(int i=0;i-1){ 13 | p_ypos = i; 14 | p_xpos = grid[i].indexOf('p'); 15 | } 16 | if(p_xpos>=0 && p_ypos>=0){ 17 | break; 18 | } 19 | } 20 | boolean flag = true; 21 | if(b_xpos > p_xpos){ 22 | b_xpos--; 23 | flag = false; 24 | System.out.println("LEFT"); 25 | }else if(b_xpos < p_xpos){ 26 | b_xpos++; 27 | flag = false; 28 | System.out.println("RIGHT"); 29 | } 30 | if(b_ypos > p_ypos && flag == true){ 31 | b_ypos--; 32 | System.out.println("UP"); 33 | }else if(b_ypos < p_ypos && flag == true){ 34 | b_ypos++; 35 | System.out.println("DOWN"); 36 | } 37 | 38 | } 39 | public static void main(String[] args) { 40 | Scanner in = new Scanner(System.in); 41 | int n,r,c; 42 | n = in.nextInt(); 43 | r = in.nextInt(); 44 | c = in.nextInt(); 45 | in.useDelimiter("\n"); 46 | String grid[] = new String[n]; 47 | 48 | 49 | for(int i = 0; i < n; i++) { 50 | grid[i] = in.next(); 51 | } 52 | 53 | nextMove(n,r,c,grid); 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ProjectEuler+/p17.py: -------------------------------------------------------------------------------- 1 | num = {'1':'One', '2':'Two', '3':'Three','4':'Four','5':'Five','6':'Six','7':'Seven','8':'Eight','9':'Nine','10':'Ten','11':'Eleven','12':'Twelve','13':'Thirteen','14':'Fourteen','15':'Fifteen','16':'Sixteen','17':'Seventeen','18':'Eighteen','19':'Nineteen','20':'Twenty','30':'Thirty','40':'Forty','50':'Fifty','60':'Sixty','70':'Seventy','80':'Eighty','90':'Ninety'} 2 | def n2l(n): 3 | '''t = 'thousand''' 4 | h = 'Hundred' 5 | sn = str(n) 6 | '''if len(sn) == 4: 7 | if sn[1:] == '000': 8 | return num[sn[0]] + ' ' + t 9 | else: 10 | rst = num[sn[0]] + ' ' + t + ' ' 11 | n = int(sn[1:]) 12 | return rst + n2l(n)''' 13 | if len(sn) == 3: 14 | if sn[1:] == '00': 15 | return num[sn[0]] + ' ' + h + ' ' 16 | else: 17 | rst = num[sn[0]] + ' ' + h + ' ' 18 | n = int(sn[1:]) 19 | return rst + n2l(n) 20 | elif len(sn) == 2: 21 | if sn in num: 22 | return num[sn] 23 | else: 24 | j = str(sn[0]) + '0' 25 | rst = num[j] + ' ' 26 | return rst + n2l(n%10) 27 | elif len(sn) == 1 and sn != '0': 28 | return num[sn] 29 | return '' 30 | 31 | def j(n): 32 | s = '' 33 | m = '' 34 | b = '' 35 | t = '' 36 | h = '' 37 | h = n2l(n%1000) 38 | n /= 1000 39 | t = n2l(n%1000) 40 | n /= 1000 41 | if t: t += ' Thousand ' + h 42 | else: t = h 43 | m = n2l(n%1000) 44 | n /= 1000 45 | if m: m += ' Million ' + t 46 | else: m = t 47 | b = n2l(n%1000) 48 | n /= 1000 49 | if b: b += ' Billion ' + m 50 | else: b = m 51 | print b 52 | 53 | for i in xrange(input()): 54 | n = input() 55 | if n == 0: 56 | print 'Zero' 57 | elif n == 1000000000000: 58 | print 'One Trillion' 59 | else: 60 | j(n) -------------------------------------------------------------------------------- /Algorithm/Volleyball Match.java: -------------------------------------------------------------------------------- 1 | import java.math.BigInteger; 2 | import java.util.Scanner; 3 | 4 | 5 | public class Solution { 6 | 7 | static BigInteger tw = BigInteger.ONE; 8 | static BigInteger tl = BigInteger.ONE; 9 | static BigInteger num = BigInteger.ONE; 10 | static BigInteger den = BigInteger.ONE; 11 | static BigInteger v24 = BigInteger.ONE; 12 | 13 | public static void main(String[] args) { 14 | 15 | Scanner in = new Scanner(System.in); 16 | int a = in.nextInt(); 17 | int b = in.nextInt(); 18 | BigInteger mo = BigInteger.valueOf(1000000007); 19 | BigInteger way = BigInteger.ZERO; 20 | if(a ==25 && b==24){ 21 | }else if(a<25 && b<25){ 22 | }else if((a == 25 && b<24) || (b == 25 && a<24)){ 23 | 24 | int c; 25 | if(a == 25){ 26 | tw = BigInteger.valueOf(a-1+b); 27 | tl = BigInteger.valueOf(b); 28 | c = b; 29 | }else{ 30 | tw = BigInteger.valueOf(b-1+a); 31 | tl = BigInteger.valueOf(a); 32 | c = a; 33 | } 34 | 35 | for(int i=1;i<=c;i++){ 36 | num = num.multiply(tw); 37 | tw = tw.subtract(BigInteger.ONE); 38 | den = den.multiply(tl); 39 | tl = tl.subtract(BigInteger.ONE); 40 | } 41 | way = num.divide(den).mod(mo); 42 | 43 | 44 | }else if((a-b==2) || (b-a==2)){ 45 | 46 | v24 = BigInteger.valueOf(801728689); 47 | num = v24; 48 | int c; 49 | if(a>b){ 50 | c = b - 24; 51 | }else{ 52 | c = a - 24; 53 | } 54 | tw = BigInteger.valueOf(2); 55 | tw = tw.modPow(BigInteger.valueOf(c+1), mo); 56 | way = num.multiply(tw).mod(mo); 57 | 58 | } 59 | 60 | System.out.println(way); 61 | } 62 | 63 | } 64 | //32247603683100 65 | -------------------------------------------------------------------------------- /Regular Expresstion/IP Address Validation.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) throws Exception { 10 | 11 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 12 | String s = br.readLine(); 13 | int n = Integer.parseInt(s); 14 | String [] ip = new String[n]; 15 | for(int i = 0;i0){ 40 | pat = Pattern.compile(ipv4); 41 | match = pat.matcher(ip); 42 | if(match.matches()){ 43 | System.out.println(ip4); 44 | }else{ 45 | System.out.println(non); 46 | } 47 | }else if (ip.indexOf(":")>0){ 48 | pat = Pattern.compile(ipv6); 49 | match = pat.matcher(ip); 50 | if(match.matches()){ 51 | System.out.println(ip6); 52 | }else{ 53 | System.out.println(non); 54 | } 55 | }else{ 56 | System.out.println(non); 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /ProjectEuler+/p27.py: -------------------------------------------------------------------------------- 1 | #import time 2 | 3 | def primes_xrange(stop): 4 | primes = [True] * stop 5 | primes[0], primes[1] = [False] * 2 6 | for ind, val in enumerate(primes): 7 | if val is True: 8 | primes[ind*2::ind] = [False] * (((stop - 1)//ind) - 1) 9 | return primes 10 | 11 | #start = time.time() 12 | 13 | P = primes_xrange(6842000) 14 | a_max, b_max, c_max = 0, 0, 0 15 | p = input() 16 | for a in range(-p,p+1): 17 | for b in range(1,p+1): 18 | if P[b] is False: continue 19 | if b < -1600-40*a or b< c_max: continue 20 | c, n = 0, 0 21 | while P[n**2 + a*n + b] is True: 22 | c += 1 23 | n += 1 24 | if c > c_max: 25 | a_max, b_max, c_max = a, b, c 26 | 27 | print a_max, b_max 28 | #print time.time()-start 29 | 30 | ''' 31 | from timeit import default_timer as timer 32 | import math 33 | start = timer() 34 | 35 | def longestPrimeQuadratic(alim, blim): 36 | 37 | def isPrime(k): # checks if a number is prime 38 | if k < 2: return False 39 | elif k == 2: return True 40 | elif k % 2 == 0: return False 41 | else: 42 | for x in range(3, int(math.sqrt(k)+1), 2): 43 | if k % x == 0: return False 44 | 45 | return True 46 | 47 | longest = [0, 0, 0] # length, a, b 48 | for a in range((alim * -1) + 1, alim): 49 | for b in range(2, blim): 50 | if isPrime(b): 51 | count = 0 52 | n = 0 53 | while isPrime((n**2) + (a*n) + b): 54 | count += 1 55 | n += 1 56 | 57 | if count > longest[0]: 58 | longest = [count, a, b] 59 | 60 | return longest 61 | n = input() 62 | ans = longestPrimeQuadratic(n+1, n+1) 63 | print ans 64 | print (timer() - start) 65 | ''' -------------------------------------------------------------------------------- /ProjectEuler+/p10.py: -------------------------------------------------------------------------------- 1 | import math 2 | def pr(n): 3 | lim=n 4 | sqrtlim=math.sqrt(float(lim)) 5 | pp=2 6 | ss=[pp] 7 | ep=[pp] 8 | pp+=1 9 | rss=[ss[0]] 10 | tp=[pp] 11 | i=0 12 | rss.append(rss[i]*tp[0]) 13 | xp=[] 14 | pp+=ss[0] 15 | npp=pp 16 | tp.append(npp) 17 | while nppint(lim): break 23 | if npp<=rss[i]+1: pp=npp 24 | sqrtnpp=math.sqrt(npp) 25 | test=True 26 | for q in tp: 27 | if sqrtnppint(lim): break 35 | if npp>int(lim): break 36 | lrpp=pp 37 | nss=[] 38 | while pp<(rss[i]+1)*2-1: 39 | for n in ss: 40 | npp=pp+n 41 | if npp>int(lim): break 42 | sqrtnpp=math.sqrt(npp) 43 | test=True 44 | for q in tp: 45 | if sqrtnppint(lim): break 57 | if npp>int(lim): break 58 | ss=nss 59 | ep.append(tp[0]) 60 | del tp[0] 61 | rss.append(rss[i]*tp[0]) 62 | npp=lrpp 63 | ep.reverse() 64 | [tp.insert(0,a) for a in ep] 65 | tp.reverse() 66 | [xp.insert(0,a) for a in tp] 67 | return xp 68 | 69 | n = [] 70 | t = input() 71 | for i in xrange(t): 72 | n.append(input()) 73 | a = pr(max(n)) 74 | l = len(a) 75 | m = max(n) 76 | p = {} 77 | s = 0 78 | li = sorted(list(set(n))) 79 | t = len(li) 80 | j = 0 81 | g = -1 82 | i = 0 83 | while ili[j]: 85 | p[li[j]] = s 86 | j += 1 87 | continue 88 | s += a[i] 89 | i += 1 90 | for i in xrange(j,t): 91 | p[li[i]] = s 92 | 93 | for i in n: 94 | print p[i] 95 | -------------------------------------------------------------------------------- /ProjectEuler+/p35.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | def getPrimesBelowN(n=1000000): 5 | """Get all primes below n with the sieve of Eratosthenes. 6 | @return: a list 0..n with boolean values that indicate if 7 | i in 0..n is a prime. 8 | """ 9 | from math import ceil 10 | primes = [True] * n 11 | primes[0] = False 12 | primes[1] = False 13 | primeList = [] 14 | roundUp = lambda n, prime: int(ceil(float(n) / prime)) 15 | for currentPrime in xrange(2, n): 16 | if not primes[currentPrime]: 17 | continue 18 | primeList.append(currentPrime) 19 | for multiplicant in xrange(2, roundUp(n, currentPrime)): 20 | primes[multiplicant * currentPrime] = False 21 | return primes 22 | 23 | def isCircularPrime(primes, number): 24 | """Check if number is a circular prime. 25 | 26 | Keyword arguments: 27 | primes -- a list from 0..n with boolean values that indicate if 28 | i in 0..n is a prime 29 | number -- the integer you want to check 30 | """ 31 | number = str(number) 32 | for i in xrange(0, len(number)): 33 | rotatedNumber = number[i:len(number)] + number[0:i] 34 | if not primes[int(rotatedNumber)]: 35 | return False 36 | return True 37 | 38 | if __name__ == "__main__": 39 | primes = getPrimesBelowN(input()) 40 | sm =7 41 | numberOfPrimes = 2 42 | '''print(2) # I print them now, because I want to skip all primes 43 | print(5) # that contain one of those digits: 0,2,4,5,6,8''' 44 | for prime, isPrime in enumerate(primes): 45 | if (not isPrime) or ("2" in str(prime)) or \ 46 | ("4" in str(prime)) or ("6" in str(prime)) or \ 47 | ("8" in str(prime)) or ("0" in str(prime)) or \ 48 | ("5" in str(prime)): 49 | continue 50 | if isCircularPrime(primes, prime): 51 | #print(prime) 52 | #numberOfPrimes += 1 53 | sm += prime 54 | 55 | print sm -------------------------------------------------------------------------------- /ProjectEuler+/p4.py: -------------------------------------------------------------------------------- 1 | a = [101101, 102201, 105501, 106601, 108801, 110011, 111111, 117711, 119911, 121121, 122221, 123321, 127721, 128821, 129921, 131131, 133331, 135531, 137731, 138831, 140041, 141141, 142241, 143341, 147741, 149941, 154451, 155551, 156651, 159951, 161161, 162261, 165561, 168861, 171171, 174471, 178871, 180081, 182281, 184481, 187781, 188881, 189981, 198891, 201102, 202202, 204402, 209902, 210012, 212212, 213312, 214412, 215512, 216612, 219912, 220022, 221122, 222222, 225522, 227722, 231132, 232232, 234432, 235532, 238832, 239932, 242242, 244442, 246642, 249942, 252252, 255552, 256652, 257752, 258852, 259952, 262262, 266662, 270072, 272272, 273372, 276672, 277772, 279972, 280082, 282282, 284482, 286682, 289982, 290092, 292292, 294492, 296692, 297792, 299992, 301103, 302203, 303303, 306603, 308803, 320023, 321123, 324423, 329923, 330033, 333333, 335533, 343343, 345543, 348843, 354453, 357753, 359953, 363363, 366663, 367763, 369963, 371173, 372273, 374473, 375573, 377773, 378873, 384483, 391193, 393393, 397793, 399993, 401104, 402204, 404404, 405504, 407704, 408804, 409904, 412214, 414414, 416614, 420024, 421124, 424424, 425524, 426624, 428824, 432234, 434434, 436634, 438834, 440044, 441144, 442244, 443344, 444444, 445544, 447744, 452254, 456654, 459954, 461164, 462264, 464464, 468864, 469964, 470074, 471174, 474474, 476674, 477774, 484484, 485584, 487784, 488884, 489984, 491194, 493394, 505505, 506605, 507705, 508805, 509905, 510015, 512215, 513315, 514415, 515515, 519915, 520025, 522225, 523325, 525525, 528825, 531135, 534435, 535535, 536635, 543345, 545545, 548845, 549945, 550055, 551155, 554455, 555555, 560065, 561165, 564465, 565565, 570075, 571175, 573375, 575575, 576675, 577775, 579975, 580085, 585585, 588885, 589985, 592295, 595595, 601106, 602206, 603306, 604406, 606606, 611116, 612216, 616616, 618816, 619916, 623326, 630036, 631136, 636636, 639936, 642246, 648846, 649946, 650056, 652256, 653356, 654456, 656656, 657756, 660066, 661166, 663366, 666666, 672276, 675576, 678876, 689986, 693396, 696696, 698896, 723327, 729927, 737737, 747747, 749947, 770077, 780087, 793397, 801108, 802208, 804408, 807708, 809908, 819918, 821128, 824428, 828828, 840048, 853358, 855558, 861168, 886688, 888888, 906609] 2 | 3 | n = [] 4 | ln = len(a) 5 | for i in range(input()): 6 | n.append(input()) 7 | for i in n: 8 | last = 0 9 | for j in range(ln): 10 | if a[j]<=i: 11 | last = a[j] 12 | if a[j] > i: 13 | break 14 | print last -------------------------------------------------------------------------------- /ProjectEuler+/p41.py: -------------------------------------------------------------------------------- 1 | from itertools import permutations as P 2 | import time 3 | from heapq import heappush as push, heappop as pop,heapify as h 4 | def check_composite(n, s, d, a): 5 | ''' 6 | check compositeness of n with witness a 7 | (n,s,d) should satisfy d*2^s = n-1 and d is odd 8 | ''' 9 | x = pow(a, d, n) 10 | if x == 1 or x == n - 1: 11 | return False 12 | for y in xrange(1, s): 13 | x = x * x % n 14 | if x == 1: 15 | return True 16 | if x == n - 1: 17 | return False 18 | return True 19 | st = time.time() 20 | small_primes = set([3,5,7,11,13,17,19,23,29,31,37]) 21 | small_is_prime = [s in small_primes for s in xrange(38)] 22 | small_is_prime[2] = True 23 | 24 | # witnesses for different bounds (taken from http://miller-rabin.appspot.com/ ) 25 | witnesses_bounds = [ 26 | (341531, [9345883071009581737]), 27 | (716169301, [15, 13393019396194701]), 28 | (154639673381, [15, 176006322, 4221622697]), 29 | (47636622961201, [2, 2570940, 211991001, 3749873356]), 30 | (3770579582154547, [2, 2570940, 880937, 610386380, 4130785767]), 31 | ] 32 | # set of witnesses for < 2^64 (taken from http://miller-rabin.appspot.com/ ) 33 | i64_witnesses = [2, 325, 9375, 28178, 450775, 9780504, 1795265022] 34 | 35 | 36 | def is_prime(n): 37 | ''' 38 | returns True if n is probably prime, and False if n is definitely not prime. 39 | if n < 2^64, then is_prime(n) never returns a wrong answer. 40 | ''' 41 | # if too small, check small_is_prime 42 | if n < 38: 43 | return small_is_prime[n] 44 | # check divisibility with small primes 45 | for s in small_primes: 46 | if n % s == 0: 47 | return False 48 | # find (d,s) such that d*2^s = n-1 with d odd 49 | d = n - 1 50 | s = 0 51 | while not d & 1: 52 | d >>= 1 53 | s += 1 54 | # find the best set of witnesses 55 | best_witnesses = i64_witnesses 56 | for bound, bound_ws in witnesses_bounds: 57 | if n < bound: 58 | best_witnesses = bound_ws 59 | break 60 | # check compositeness with the witnesses 61 | for a in best_witnesses: 62 | a %= n 63 | if a and check_composite(n, s, d, a): 64 | return False 65 | return True 66 | s = '123456789' 67 | l = [] 68 | for i in xrange(1,11): 69 | a = P(s[:i]) 70 | for j in a: 71 | c = int(''.join(j)) 72 | if is_prime(c): 73 | push(l,c) 74 | h(l) 75 | for i in xrange(input()): 76 | a = True 77 | n = input() 78 | ln = len(l) 79 | for j in xrange(ln): 80 | if l[ln -j-1] < n: 81 | a = False 82 | print l[ln - j-1] 83 | break 84 | if a: 85 | print -1 86 | # print l[-1] -------------------------------------------------------------------------------- /ProjectEuler+/p37.py: -------------------------------------------------------------------------------- 1 | #import time 2 | 3 | ######################################################### 4 | ''' 5 | Miller-rabin primality test 6 | Valid for all 64-bit unsigned integers 7 | Sometimes wrong for numbers greater 8 | ''' 9 | def check_composite(n, s, d, a): 10 | ''' 11 | check compositeness of n with witness a 12 | (n,s,d) should satisfy d*2^s = n-1 and d is odd 13 | ''' 14 | x = pow(a, d, n) 15 | if x == 1 or x == n - 1: 16 | return False 17 | for y in xrange(1, s): 18 | x = x * x % n 19 | if x == 1: 20 | return True 21 | if x == n - 1: 22 | return False 23 | return True 24 | 25 | small_primes = set([3,5,7,11,13,17,19,23,29,31,37]) 26 | small_is_prime = [s in small_primes for s in xrange(38)] 27 | small_is_prime[2] = True 28 | 29 | # witnesses for different bounds (taken from http://miller-rabin.appspot.com/ ) 30 | witnesses_bounds = [ 31 | (341531, [9345883071009581737]), 32 | (716169301, [15, 13393019396194701]), 33 | (154639673381, [15, 176006322, 4221622697]), 34 | (47636622961201, [2, 2570940, 211991001, 3749873356]), 35 | (3770579582154547, [2, 2570940, 880937, 610386380, 4130785767]), 36 | ] 37 | # set of witnesses for < 2^64 (taken from http://miller-rabin.appspot.com/ ) 38 | i64_witnesses = [2, 325, 9375, 28178, 450775, 9780504, 1795265022] 39 | 40 | 41 | def is_prime(n): 42 | ''' 43 | returns True if n is probably prime, and False if n is definitely not prime. 44 | if n < 2^64, then is_prime(n) never returns a wrong answer. 45 | ''' 46 | # if too small, check small_is_prime 47 | if n < 38: 48 | return small_is_prime[n] 49 | # check divisibility with small primes 50 | for s in small_primes: 51 | if n % s == 0: 52 | return False 53 | # find (d,s) such that d*2^s = n-1 with d odd 54 | d = n - 1 55 | s = 0 56 | while not d & 1: 57 | d >>= 1 58 | s += 1 59 | # find the best set of witnesses 60 | best_witnesses = i64_witnesses 61 | for bound, bound_ws in witnesses_bounds: 62 | if n < bound: 63 | best_witnesses = bound_ws 64 | break 65 | # check compositeness with the witnesses 66 | for a in best_witnesses: 67 | a %= n 68 | if a and check_composite(n, s, d, a): 69 | return False 70 | return True 71 | def getL(n): 72 | s = str(n)[1:] 73 | while len(s) != 0: 74 | if is_prime(int(s)):s = s[1:] 75 | else:return False 76 | return True 77 | def getR(n): 78 | s = str(n)[:-1] 79 | while len(s) != 0: 80 | if is_prime(int(s)):s = s[:-1] 81 | else:return False 82 | return True 83 | #st = time.time() 84 | i = 11 85 | end = input() 86 | s = 0 87 | while i< end: 88 | if is_prime(i) and getL(i) and getR(i): 89 | #print i 90 | s+= i 91 | i += 1 92 | print s 93 | #print time.time()-st -------------------------------------------------------------------------------- /ProjectEuler+/p26.py: -------------------------------------------------------------------------------- 1 | l = [1, 3, 7, 17, 19, 23, 29, 47, 59, 61, 97, 109, 113, 131, 149, 167, 179, 181, 193, 223, 229, 233, 257, 263, 269, 289, 313, 337, 361, 367, 379, 383, 389, 419, 433, 461, 487, 491, 499, 503, 509, 541, 571, 577, 593, 619, 647, 659, 701, 709, 727, 743, 811, 821, 823, 857, 863, 887, 937, 941, 953, 971, 977, 983, 1019, 1021, 1033, 1051, 1063, 1069, 1087, 1091, 1097, 1103, 1109, 1153, 1171, 1181, 1193, 1217, 1223, 1229, 1259, 1291, 1297, 1301, 1303, 1327, 1367, 1381, 1429, 1433, 1447, 1487, 1531, 1543, 1549, 1553, 1567, 1571, 1579, 1583, 1607, 1619, 1621, 1663, 1697, 1709, 1741, 1777, 1783, 1789, 1811, 1823, 1847, 1861, 1873, 1913, 1949, 1979, 2017, 2029, 2063, 2069, 2099, 2113, 2137, 2141, 2143, 2153, 2179, 2207, 2221, 2251, 2269, 2273, 2297, 2309, 2339, 2341, 2371, 2383, 2389, 2411, 2417, 2423, 2447, 2459, 2473, 2539, 2543, 2549, 2579, 2593, 2617, 2621, 2633, 2657, 2663, 2687, 2699, 2713, 2731, 2741, 2753, 2767, 2777, 2789, 2819, 2833, 2851, 2861, 2887, 2897, 2903, 2909, 2927, 2939, 2971, 3011, 3019, 3023, 3137, 3167, 3221, 3251, 3257, 3259, 3299, 3301, 3313, 3331, 3343, 3371, 3389, 3407, 3433, 3461, 3463, 3469, 3527, 3539, 3571, 3581, 3593, 3607, 3617, 3623, 3659, 3673, 3701, 3709, 3727, 3767, 3779, 3821, 3833, 3847, 3863, 3943, 3967, 3989, 4007, 4019, 4051, 4057, 4073, 4091, 4099, 4127, 4139, 4153, 4177, 4211, 4217, 4219, 4229, 4259, 4261, 4327, 4337, 4339, 4349, 4421, 4423, 4447, 4451, 4457, 4463, 4567, 4583, 4651, 4673, 4691, 4703, 4783, 4793, 4817, 4931, 4937, 4943, 4967, 5021, 5059, 5087, 5099, 5153, 5167, 5179, 5189, 5233, 5273, 5297, 5303, 5309, 5381, 5393, 5417, 5419, 5501, 5503, 5527, 5531, 5581, 5623, 5651, 5657, 5659, 5669, 5701, 5737, 5741, 5743, 5749, 5779, 5783, 5807, 5821, 5857, 5861, 5869, 5897, 5903, 5927, 5939, 5981, 6011, 6029, 6047, 6073, 6113, 6131, 6143, 6211, 6217, 6221, 6247, 6257, 6263, 6269, 6287, 6301, 6337, 6343, 6353, 6367, 6389, 6473, 6553, 6571, 6619, 6659, 6661, 6673, 6691, 6701, 6703, 6709, 6737, 6779, 6793, 6823, 6829, 6833, 6857, 6863, 6869, 6899, 6949, 6967, 6971, 6977, 6983, 7019, 7057, 7069, 7103, 7109, 7177, 7193, 7207, 7219, 7229, 7247, 7309, 7349, 7393, 7411, 7433, 7451, 7457, 7459, 7487, 7499, 7541, 7577, 7583, 7607, 7673, 7687, 7691, 7699, 7703, 7727, 7753, 7793, 7817, 7823, 7829, 7873, 7901, 7927, 7937, 7949, 8017, 8059, 8069, 8087, 8171, 8179, 8219, 8233, 8263, 8269, 8273, 8287, 8291, 8297, 8353, 8377, 8389, 8423, 8429, 8447, 8501, 8513, 8537, 8543, 8623, 8647, 8663, 8669, 8699, 8713, 8731, 8741, 8753, 8783, 8807, 8819, 8821, 8861, 8863, 8887, 8971, 9011, 9029, 9059, 9103, 9109, 9137, 9221, 9257, 9341, 9343, 9371, 9377, 9421, 9461, 9473, 9491, 9497, 9539, 9623, 9629, 9697, 9739, 9743, 9749, 9767, 9781, 9811, 9817, 9829, 9833, 9851, 9857, 9887, 9931, 9949, 9967] 2 | ln = len(l) 3 | for i in xrange(input()): 4 | n = input() 5 | if n >= 9967: 6 | print 9967 7 | else: 8 | for j in xrange(ln): 9 | if l[j] > n: 10 | print l[j-1] 11 | break 12 | -------------------------------------------------------------------------------- /Algorithm/Sherlock and The Beast.py: -------------------------------------------------------------------------------- 1 | def cal(num): 2 | f = 5 3 | t = num - 5 4 | while t >= 3: 5 | if f % 5 == 0 and t % 3 == 0: 6 | a = (t,f) 7 | return a 8 | else: 9 | t -= 5 10 | f += 5 11 | return False 12 | 13 | def evil(num): 14 | oup = 0 15 | if num > 2 and num % 3 == 0: 16 | q = num/3 17 | if q >= 10: 18 | p = q/10 19 | r = q%10 20 | oup = 555555555555555555555555555555 21 | for i in range(1,p): 22 | oup = oup*1000000000000000000000000000000 + 555555555555555555555555555555 23 | for i in range(r): 24 | oup = oup*1000 + 555 25 | elif q >= 5: 26 | p = q/5 27 | r = q%5 28 | oup = 555555555555555 29 | for i in range(1,p): 30 | oup = oup*1000000000000000 + 555555555555555 31 | for i in range(r): 32 | oup = oup*1000 + 555 33 | else: 34 | oup = 555 35 | for i in range(1,q): 36 | oup = oup*1000 + 555 37 | elif num < 20 and num % 5 == 0: 38 | q = num/5 39 | if q >= 10: 40 | p = q/10 41 | r = q%10 42 | oup = 33333333333333333333333333333333333333333333333333 43 | for i in range(1,p): 44 | oup = oup*100000000000000000000000000000000000000000000000000 + 33333333333333333333333333333333333333333333333333 45 | for i in range(r): 46 | oup = oup*100000 + 33333 47 | elif q>=5: 48 | p = q/5 49 | r = q%5 50 | oup = 3333333333333333333333333 51 | for i in range(1,p): 52 | oup = oup*10000000000000000000000000 + 3333333333333333333333333 53 | for i in range(r): 54 | oup = oup*100000 + 33333 55 | else: 56 | oup = 33333 57 | for i in range(1,q): 58 | oup = oup*100000 + 33333 59 | elif num > 2: 60 | b = cal(num) 61 | if b: 62 | q1 = b[0]/3 63 | q2 = b[1]/5 64 | if q1 >= 10: 65 | p1 = q1/10 66 | r1 = q1%10 67 | oup = 555555555555555555555555555555 68 | for i in range(1,p1): 69 | oup = oup*1000000000000000000000000000000 + 555555555555555555555555555555 70 | for i in range(r1): 71 | oup = oup*1000 + 555 72 | elif q1>=5: 73 | p1 = q1/5 74 | r1 = q1%5 75 | oup = 555555555555555 76 | for i in range(1,p1): 77 | oup = oup*1000000000000000 + 555555555555555 78 | for i in range(r1): 79 | oup = oup*1000 + 555 80 | else: 81 | oup = 555 82 | for i in range(1,q1): 83 | oup = oup*1000 + 555 84 | if q2 >= 10: 85 | p2 = q2/10 86 | r2 = q2%10 87 | for i in range(p2): 88 | oup = oup*100000000000000000000000000000000000000000000000000 + 33333333333333333333333333333333333333333333333333 89 | for i in range(r2): 90 | oup = oup*100000 + 33333 91 | elif q2>=5: 92 | p2 = q2/5 93 | r2 = q2%5 94 | for i in range(p2): 95 | oup = oup*10000000000000000000000000 + 3333333333333333333333333 96 | for i in range(r2): 97 | oup = oup*100000 + 33333 98 | else: 99 | for i in range(q2): 100 | oup = oup*100000 + 33333 101 | else: 102 | oup = -1 103 | else: 104 | oup = -1 105 | print oup 106 | 107 | def main(): 108 | t = input() 109 | inp = [] 110 | for i in range(t): 111 | w = input() 112 | inp.append(w) 113 | for i in range(t): 114 | evil(inp[i]) 115 | 116 | if __name__ == '__main__': 117 | main() -------------------------------------------------------------------------------- /ProjectEuler+/p9.py: -------------------------------------------------------------------------------- 1 | ptr = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,60,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,480,-1,-1,-1,-1,-1,780,-1,-1,-1,-1,-1,1620,-1,-1,-1,2040,-1,-1,-1,-1,-1,-1,-1,3840,-1,-1,-1,-1,-1,-1,-1,4200,-1,-1,-1,7500,-1,-1,-1,-1,-1,-1,-1,-1,-1,12180,-1,12960,-1,-1,-1,-1,-1,-1,-1,16320,-1,-1,-1,20580,-1,-1,-1,-1,-1,21060,-1,-1,-1,-1,-1,30720,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,43740,-1,-1,-1,33600,-1,-1,-1,-1,-1,-1,-1,60000,-1,-1,-1,-1,-1,66780,-1,-1,-1,-1,-1,79860,-1,-1,-1,-1,-1,-1,-1,97440,-1,-1,-1,103680,-1,-1,-1,-1,-1,97500,-1,-1,-1,120120,-1,131820,-1,-1,-1,130560,-1,-1,-1,-1,-1,-1,-1,164640,-1,-1,-1,-1,-1,-1,-1,192720,-1,-1,-1,202500,-1,92820,-1,-1,-1,-1,-1,-1,-1,-1,-1,245760,-1,-1,-1,-1,-1,235620,-1,255000,-1,-1,-1,294780,-1,-1,-1,277680,-1,328860,-1,-1,-1,-1,-1,349920,-1,-1,-1,199980,-1,-1,-1,268800,-1,-1,-1,411540,-1,-1,-1,-1,-1,453960,-1,-1,-1,-1,-1,480000,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,555660,-1,-1,-1,-1,-1,-1,-1,595140,-1,-1,-1,638880,-1,-1,-1,-1,-1,568620,-1,-1,-1,-1,-1,730020,-1,-1,-1,779520,-1,-1,-1,-1,-1,643500,-1,829440,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,937500,-1,-1,-1,-1,-1,354960,-1,960960,-1,-1,-1,1054560,-1,-1,-1,-1,-1,-1,-1,1044480,-1,-1,-1,1180980,-1,-1,-1,-1,-1,1265880,-1,-1,-1,-1,-1,1317120,-1,-1,-1,1063860,-1,-1,-1,-1,-1,-1,-1,1463340,-1,1522500,-1,1541760,-1,-1,-1,-1,-1,-1,-1,1620000,-1,-1,-1,742560,-1,-1,-1,-1,-1,-1,-1,1787460,-1,1761540,-1,-1,-1,1803060,-1,619020,-1,-1,-1,1966080,-1,-1,-1,-1,-1,1713660,-1,1440600,-1,-1,-1,2156220,-1,-1,-1,2040000,-1,-1,-1,-1,-1,-1,-1,2413320,-1,-1,-1,-1,-1,-1,-1,2221440,-1,1855920,-1,2630880,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2799360,-1,-1,-1,-1,-1,-1,-1,2715240,-1,2943720,-1,3039180,-1,-1,-1,2150400,-1,2632500,-1,-1,-1,-1,-1,3292320,-1,-1,-1,-1,-1,3243240,-1,-1,-1,-1,-1,3631680,-1,-1,-1,-1,-1,-1,-1,3220140,-1,-1,-1,3840000,-1,-1,-1,-1,-1,-1,-1,-1,-1,4177740,-1,4135260,-1,4253340,-1,-1,-1,-1,-1,-1,-1,-1,-1,4445280,-1,-1,-1,-1,-1,3832140,-1,-1,-1,-1,-1,4770420,-1,-1,-1,4761120,-1,-1,-1,-1,-1,-1,-1,5203440,-1,-1,-1,5290740,-1,-1,-1,-1,-1,-1,-1,5467500,-1,-1,-1,2097120,-1,5088720,-1,-1,-1,-1,-1,5840160,-1,-1,-1,-1,-1,-1,-1,6236160,-1,-1,-1,6229380,-1,-1,-1,-1,-1,6044280,-1,5148000,-1,-1,-1,6635520,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7058940,-1,-1,-1,-1,-1,6361740,-1,-1,-1,4825860,-1,7500000,-1,-1,-1,-1,-1,-1,-1,6283680,-1,-1,-1,7959060,-1,-1,-1,7687680,-1,-1,-1,-1,-1,-1,-1,8436480,-1,-1,-1,-1,-1,8879220,-1,-1,-1,-1,-1,8932620,-1,-1,-1,8355840,-1,-1,-1,8027460,-1,5678340,-1,9447840,-1,2441400,-1,-1,-1,-1,-1,-1,-1,-1,-1,10127040,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10536960,-1,-1,-1,-1,-1,-1,-1,10022520,-1,-1,-1,11111580,-1,-1,-1,-1,-1,11166960,-1,-1,-1,-1,-1,11706720,-1,-1,-1,12180000,-1,12256920,-1,12334080,-1,-1,-1,12322740,-1,-1,-1,-1,-1,11324040,-1,-1,-1,-1,-1,12960000,-1,-1,-1,-1,-1,-1,-1,9227400,-1,-1,-1,13618860,-1,-1,-1,14142240,-1,-1,-1,-1,-1,-1,-1,14299680,-1,-1,-1,14092320,-1,12187500,-1,-1,-1,-1,-1,15002820,-1,-1,-1,13992360,-1,-1,-1,-1,-1,-1,-1,15728640,-1,16211580,-1,-1,-1,-1,-1,-1,-1,-1,-1,16477500,-1,16773900,-1,11524800,-1,-1,-1,-1,-1,-1,-1,17249760,-1,-1,-1,-1,-1,9903180,-1,16984800,-1,-1,-1,18045780,-1,-1,-1,-1,-1,15352740,-1,-1,-1,-1,-1,19306560,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19710540,-1,-1,-1,17771520,-1,-1,-1,14847360,-1,-1,-1,21047040,-1,-1,-1,-1,-1,-1,-1,-1,-1,21603600,-1,21474660,-1,-1,-1,-1,-1,17374500,-1,-1,-1,-1,-1,22394880,-1,-1,-1,-1,-1,19023420,-1,-1,-1,19769880,-1,23341020,-1,-1,-1,24090000,-1,22905540,-1,23549760,-1,-1,-1,24313440,-1,-1,-1,-1,-1,-1,-1,17203200,-1,-1,-1,25848900,-1,-1,-1,-1,-1,-1,-1,-1,-1,26759460,-1,26338560,-1,-1,-1,-1,-1,24997140,-1,24820680,-1,-1,-1,27391980,-1,-1,-1,15381600,-1,23236980,-1,-1,-1,-1,-1,29053440,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,29582340,-1,29417700,-1,25761120,-1,-1,-1,-1,-1,-1,-1,30720000,-1,-1,-1,-1,-1,16335060,-1,-1,-1,-1,-1,31886460,-1,-1,-1,-1,-1,-1,-1,33421920,-1,-1,-1,33082080,-1,25616280,-1,34026720,-1,34178760,-1,7157280,-1,-1,-1,34307220,-1,-1,-1,31875000,-1,-1,-1,-1,-1,-1,-1,35562240,-1,-1,-1,10307220,-1,-1,-1,-1,-1,-1,-1,36847500,-1,-1,-1,-1,-1,38372400,-1,-1,-1,-1,-1,38163360,-1,-1,-1,-1,-1,-1,-1,38088960,-1,-1,-1,39510180,-1,-1,-1,-1,-1,41107500,-1,-1,-1,21469980,-1,41627520,-1,-1,-1,-1,-1,-1,-1,42325920,-1,-1,-1,42298140,-1,-1,-1,-1,-1,-1,-1,-1,-1,41201160,-1,44127720,-1,-1,-1,-1,-1,-1,-1,16776960,-1,-1,-1,45214260,-1,-1,-1,-1,-1,-1,-1,30911100,-1,45721980,-1,46721280,-1,-1,-1,-1,-1,39509340,-1,-1,-1,-1,-1,48261420,-1,-1,-1,49889280,-1,47561580,-1,-1,-1,-1,-1,49835040,-1,-1,-1,-1,-1,48682620,-1,-1,-1,-1,-1,51442500,-1,-1,-1,41184000,-1,-1,-1,-1,-1,25743900,-1,53084160,-1,-1,-1,-1,-1,-1,-1,55238040,-1,-1,-1,54760380,-1,-1,-1,-1,-1,56745000,-1,-1,-1,-1,-1,56471520,-1,49970760,-1,-1,-1,-1,-1,-1,-1,-1,-1,58217940,-1,59840340,-1,-1,-1,-1,-1,38606880,-1,-1,-1,60000000,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,61818060,-1,-1,-1,50269440,-1,63969360,-1,-1,-1,-1,-1,65159640,-1,-1,-1,-1,-1,53758380,-1,66102960,-1,-1,-1,65563620,-1,-1,-1,63957960,-1,51443640,-1,-1,-1,-1,-1,67491840,-1,-1,-1,-1,-1,50109840,-1,-1,-1,-1,-1,71033760,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,71460960,-1,31837260,-1,71411340,-1,-1,-1,66846720,-1,-1,-1,73502580,-1,-1,-1,64219680,-1,62015460,-1,45426720,-1,-1,-1,75582720,-1,-1,-1,74392500,-1,77482020,-1,-1,-1,-1,-1,77701740,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,81016320,-1,-1,-1,-1,-1,79480440,-1,-1,-1,83542620,-1,82057860,-1,76878420,-1,-1,-1,-1,-1,-1,-1,-1,-1,84295680,-1,-1,-1,-1,-1,71077500,-1,-1,-1,-1,-1,86573820,-1,-1,-1,80180160,-1,-1,-1,90167220,-1,-1,-1,88892640,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,91252500,-1,-1,-1,-1,-1,88884180,-1,-1,-1,-1,-1,93653760,-1,-1,-1,-1,-1,-1,-1,97440000,-1,-1,-1,98055360,-1,17335980,-1,98672640,-1,80981940,-1,-1,-1,-1,-1,98581920,-1,-1,-1,-1,-1,-1,-1,-1,-1,101474160,-1,101109540,-1,80437500,-1,-1,-1,-1,-1,-1,-1,-1,-1,103680000,-1,-1,-1,-1,-1,-1,-1,-1,-1,78073800,-1,106293660,-1,-1,-1,95244240,-1,-1,-1,-1,-1,-1,-1,108950880,-1,-1,-1,-1,-1,112798980,-1,113137920,-1,-1,-1,111652020,-1,-1,-1,103332120,-1,114840180,-1,-1,-1,-1,-1,114397440,-1,-1,-1,-1,-1,-1,-1,112738560,-1,-1,-1,117187500,-1,-1,-1,-1,-1,-1,-1,71275620,-1,-1,-1,120022560,-1,-1,-1,-1,-1,124126860,-1,111938880,-1,-1,-1,122902980,-1,-1,-1,-1,-1,103467780,-1,-1,-1,-1,-1,125829120,-1,-1,-1,129692640,-1,-1,-1,-1,-1,-1,-1,128801340,-1,116798700,-1,-1,-1,86651040,-1,-1,-1,-1,-1,131820000,-1,-1,-1,134191200,-1,57393900,-1,92198400,-1,-1,-1,134885460,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,140492880,-1,-1,-1,-1,-1,116124060,-1,-1,-1,-1,-1,142849980,-1,-1,-1,135878400,-1,-1,-1,-1,-1,-1,-1,144366240,-1,148194060,-1,118651260,-1,-1,-1,-1,-1,-1,-1,147622500,-1,-1,-1,102433800,-1,-1,-1,121196460,-1,-1,-1,154452480,-1,-1,-1,-1,-1,155708280,-1,140598840,-1,-1,-1,154281180,-1,-1,-1,-1,-1,158235000,-1,-1,-1,-1,-1,157684320,-1,-1,-1,-1,-1,-1,-1,142172160,-1,-1,-1,161137140,-1,-1,-1,118778880,-1,114735960,-1,-1,-1,-1,-1,168376320,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,168193260,-1,159879720,-1,-1,-1,-1,-1,172828800,-1,155477700,-1,171797280,-1,-1,-1,-1,-1,163195560,-1,-1,-1,-1,-1,175452420,-1,-1,-1,162194280,-1,28964040,-1,-1,-1,-1,-1,179159040,-1,-1,-1,-1,-1,-1,-1,125122200,-1,-1,-1,182917500,-1,-1,-1,-1,-1,-1,-1,158159040,-1,190312500,-1,186728160,-1,-1,-1,-1,-1,-1,-1,192720000,-1,-1,-1,190591380,-1,-1,-1,188398080,-1,160195620,-1,-1,-1,-1,-1,194507520,-1,-1,-1,-1,-1,171766980,-1,-1,-1,-1,-1,198476940,-1,-1,-1,137625600,-1,157728480,-1,-1,-1,82042740,-1,206791200,-1,-1,-1,86889660,-1,-1,-1,-1,-1,-1,-1,206577060,-1,-1,-1,-1,-1,-1,-1,214075680,-1,-1,-1,210708480,-1,-1,-1,-1,-1,177045180,-1,-1,-1,-1,-1,214894620,-1,-1,-1,198565440,-1,-1,-1,-1,-1,-1,-1,219135840,-1,221933400,-1,-1,-1,-1,-1,123052800,-1,-1,-1,223432500,-1,-1,-1,-1,-1,-1,-1,-1,-1,220192500,-1,232427520,-1,-1,-1,-1,-1,-1,-1,211798920,-1,-1,-1,232193580,-1,144788220,-1,-1,-1,239738940,-1,36752100,-1,-1,-1,236658720,-1,-1,-1,235341600,-1,-1,-1,206088960,-1,-1,-1,241180740,-1,-1,-1,-1,-1,164029800,-1,-1,-1,-1,-1,245760000,-1,-1,-1,253015620,-1,-1,-1,-1,-1,-1,-1,250396860,-1,-1,-1,256510320,-1,153315180,-1,-1,-1,-1,-1,255091680,-1,-1,-1,-1,-1,246546300,-1,-1,-1,-1,-1,259844820,-1,-1,-1,267375360,-1,-1,-1,-1,-1,-1,-1,264656640,-1,-1,-1,204930240,-1,-1,-1,272213760,-1,110253720,-1,273430080,-1,-1,-1,57258240,-1,-1,-1,-1,-1,-1,-1,274457760,-1,-1,-1,-1,-1,281578140,-1,255000000,-1,263903640,-1,279447780,-1,-1,-1,-1,-1,234595140,-1,-1,-1,-1,-1,284497920,-1,-1,-1,-1,-1,-1,-1,82457760,-1,-1,-1,289608540,-1,297058020,-1,-1,-1,-1,-1,-1,-1,-1,-1,301665000,-1,-1,-1,-1,-1,114514620,-1,-1,-1,260071200,-1,306979200,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,305306880,-1,-1,-1,-1,-1,301507920,-1,306479880,-1,-1,-1,310663020,-1,-1,-1,304711680,-1,-1,-1,-1,-1,-1,-1,316081440,-1,231990000,-1,-1,-1,-1,-1,-1,-1,-1,-1,328860000,-1,-1,-1,-1,-1,330936840,-1,171759840,-1,-1,-1,333020160,-1,-1,-1,-1,-1,-1,-1,303709080,-1,-1,-1,332713980,-1,-1,-1,338607360,-1,279170580,-1,316953780,-1,-1,-1,338385120,-1,-1,-1,-1,-1,328090140,-1,-1,-1,326277840,-1,344120340,-1,257084100,-1,-1,-1,-1,-1,329609280,-1,-1,-1,353021760,-1,-1,-1,-1,-1,-1,-1,-1,-1,362854380,-1,355784460,-1,-1,-1,134215680,-1,313610220,-1,-1,-1,-1,-1,369609240,-1,-1,-1,-1,-1,303433260,-1,-1,-1,-1,-1,367709220,-1,-1,-1,339405000,-1,-1,-1,365775840,-1,-1,-1,381840480,-1,367965000,-1,-1,-1,372726900,-1,-1,-1,-1,-1,379897500,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,386091360,-1,-1,-1,330134220,-1,-1,-1,399114240,-1,-1,-1,392352180,-1,-1,-1,-1,-1,329062500,-1,-1,-1,-1,-1,398680320,-1,-1,-1,-1,-1,404422980,-1,-1,-1,-1,-1,405076140,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,411540000,-1,-1,-1,-1,-1,-1,-1,423405840,-1,-1,-1,418072260,-1,343067700,-1,426677160,-1,-1,-1,205951200,-1,-1,-1,424673280,-1,-1,-1,-1,-1,437712660,-1,-1,-1,-1,-1,431343420,-1,-1,-1,441904320,-1,402541920,-1,-1,-1,-1,-1,438083040,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,453960000,-1,-1,-1,-1,-1,452895300,-1,-1,-1,172005900,-1,451772160,-1,-1,-1,399766080,-1,-1,-1,418973160,-1,-1,-1,458722380,-1,203925540,-1,335344320,-1,384570420,-1,-1,-1,-1,-1,465743520,-1,477835320,-1,478722720,-1,-1,-1,-1,-1,-1,-1,472835940,-1,-1,-1,308855040,-1,458044020,-1,-1,-1,-1,-1,480000000,-1,-1,-1,-1,-1,-1,-1,473786040,-1,-1,-1,487236060,-1,-1,-1,-1,-1,456034800,-1,266173380,-1,-1,-1,494544480,-1,-1,-1,-1,-1,414523980,-1,402155520,-1,-1,-1,511754880,-1,-1,-1,463041240,-1,313015560,-1,286644540,-1,-1,-1,521277120,-1,522217500,-1,-1,-1,-1,-1,-1,-1,-1,-1,524936940,-1,-1,-1,528823680,-1,-1,-1,-1,-1,531667500,-1,524508960,-1,-1,-1,-1,-1,-1,-1,511663680,-1,-1,-1,532184580,-1,-1,-1,-1,-1,445993860,-1,-1,-1,543118380,-1,539934720,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,547759740,-1,-1,-1,-1,-1,-1,-1,272596020,-1,-1,-1,568270080,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,563635860,-1,-1,-1,-1,-1,401156280,-1,-1,-1,566383020,-1,571687680,-1,-1,-1,254698080,-1,583297200,-1,571290720,-1,-1,-1,579815820,-1,-1,-1,534773760,-1,-1,-1,-1,-1,-1,-1,588020640,-1,-1,-1,-1,-1,604220760,-1,513757440,-1,-1,-1,609522420,-1,-1,-1,363413760,-1,-1,-1,-1,-1,616953540,-1,604661760,-1,-1,-1,-1,-1,-1,-1,595140000,-1,-1,-1,619856160,-1,-1,-1,-1,-1,595539360,-1,-1,-1,-1,-1,621613920,-1,604208220,-1,-1,-1,533786760,-1,600200640,-1,-1,-1,630207540,-1,-1,-1,515332440,-1,-1,-1,-1,-1,-1,-1,650430000,-1,-1,-1,-1,-1,618449580,-1,-1,-1,-1,-1,647631660,-1,-1,-1,-1,-1,-1,-1,668340960,-1,-1,-1,656462880,-1,671672040,-1,615027360,-1,549875820,-1,-1,-1,-1,-1,665374020,-1,-1,-1,613556520,-1,-1,-1,-1,-1,-1,-1,674365440,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,697920300,-1,-1,-1,610062960,-1,624003600,-1,-1,-1,-1,-1,692590560,-1,-1,-1,-1,-1,-1,-1,641441280,-1,-1,-1,701824980,-1,628806420,-1,721337760,-1,722505420,-1,-1,-1,-1,-1,711141120,-1,-1,-1,-1,-1,-1,-1,494125800,-1,-1,-1,720539340,-1,-1,-1,727890240,-1,674922780,-1,-1,-1,-1,-1,730020000,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,739583460,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,749230080,-1,-1,-1,634953060,-1,768271140,-1,-1,-1,-1,-1,758960220,-1,-1,-1,779520000,-1,-1,-1,-1,-1,-1,-1,784442880,-1,-1,-1,138687840,-1,-1,-1,789381120,-1,-1,-1,778672500,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,788655360,-1,-1,-1,-1,-1,776107860,-1,730138440,-1,634845960,-1,798723180,-1,-1,-1,-1,-1,794277900,-1,811793280,-1,-1,-1,827768760,-1,-1,-1,792131340,-1,104548860,-1,-1,-1,-1,-1,819115140,-1,839457780,-1,-1,-1,-1,-1,-1,-1,-1,-1,848652480,-1,-1,-1,-1,-1,277373460,-1,-1,-1,-1,-1,839851260,-1,-1,-1,-1,-1,812512260,-1,624590400,-1,-1,-1,850349280,-1,-1,-1,-1,-1,711884940,-1,761953920,-1,851121120,-1,860934420,-1,-1,-1,793594680,-1,-1,-1,813822300,-1,823903080,-1,871607040,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,902391840,-1,-1,-1,905103360,-1,-1,-1,-1,-1,-1,-1,893216160,-1,-1,-1,-1,-1,691639560,-1,826656960,-1,-1,-1,918721440,-1,-1,-1,625283400,-1,922826520,-1,-1,-1,-1,-1,915179520,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,926294940,-1,603232500,-1,946833360,-1,-1,-1,-1,-1,-1,-1,937500000] 2 | n = [] 3 | for i in xrange(input()): 4 | n.append(input()) 5 | for i in n: 6 | print ptr[i-1] -------------------------------------------------------------------------------- /ProjectEuler+/p25.py: -------------------------------------------------------------------------------- 1 | l = [0,7,12,17,21,26,31,36,40,45,50,55,60,64,69,74,79,84,88,93,98,103,107,112,117,122,127,131,136,141,146,151,155,160,165,170,174,179,184,189,194,198,203,208,213,217,222,227,232,237,241,246,251,256,261,265,270,275,280,284,289,294,299,304,308,313,318,323,328,332,337,342,347,351,356,361,366,371,375,380,385,390,395,399,404,409,414,418,423,428,433,438,442,447,452,457,462,466,471,476,481,485,490,495,500,505,509,514,519,524,529,533,538,543,548,552,557,562,567,572,576,581,586,591,596,600,605,610,615,619,624,629,634,639,643,648,653,658,662,667,672,677,682,686,691,696,701,706,710,715,720,725,729,734,739,744,749,753,758,763,768,773,777,782,787,792,796,801,806,811,816,820,825,830,835,840,844,849,854,859,863,868,873,878,883,887,892,897,902,907,911,916,921,926,930,935,940,945,950,954,959,964,969,974,978,983,988,993,997,1002,1007,1012,1017,1021,1026,1031,1036,1041,1045,1050,1055,1060,1064,1069,1074,1079,1084,1088,1093,1098,1103,1108,1112,1117,1122,1127,1131,1136,1141,1146,1151,1155,1160,1165,1170,1174,1179,1184,1189,1194,1198,1203,1208,1213,1218,1222,1227,1232,1237,1241,1246,1251,1256,1261,1265,1270,1275,1280,1285,1289,1294,1299,1304,1308,1313,1318,1323,1328,1332,1337,1342,1347,1352,1356,1361,1366,1371,1375,1380,1385,1390,1395,1399,1404,1409,1414,1419,1423,1428,1433,1438,1442,1447,1452,1457,1462,1466,1471,1476,1481,1486,1490,1495,1500,1505,1509,1514,1519,1524,1529,1533,1538,1543,1548,1553,1557,1562,1567,1572,1576,1581,1586,1591,1596,1600,1605,1610,1615,1619,1624,1629,1634,1639,1643,1648,1653,1658,1663,1667,1672,1677,1682,1686,1691,1696,1701,1706,1710,1715,1720,1725,1730,1734,1739,1744,1749,1753,1758,1763,1768,1773,1777,1782,1787,1792,1797,1801,1806,1811,1816,1820,1825,1830,1835,1840,1844,1849,1854,1859,1864,1868,1873,1878,1883,1887,1892,1897,1902,1907,1911,1916,1921,1926,1931,1935,1940,1945,1950,1954,1959,1964,1969,1974,1978,1983,1988,1993,1998,2002,2007,2012,2017,2021,2026,2031,2036,2041,2045,2050,2055,2060,2064,2069,2074,2079,2084,2088,2093,2098,2103,2108,2112,2117,2122,2127,2131,2136,2141,2146,2151,2155,2160,2165,2170,2175,2179,2184,2189,2194,2198,2203,2208,2213,2218,2222,2227,2232,2237,2242,2246,2251,2256,2261,2265,2270,2275,2280,2285,2289,2294,2299,2304,2309,2313,2318,2323,2328,2332,2337,2342,2347,2352,2356,2361,2366,2371,2376,2380,2385,2390,2395,2399,2404,2409,2414,2419,2423,2428,2433,2438,2443,2447,2452,2457,2462,2466,2471,2476,2481,2486,2490,2495,2500,2505,2509,2514,2519,2524,2529,2533,2538,2543,2548,2553,2557,2562,2567,2572,2576,2581,2586,2591,2596,2600,2605,2610,2615,2620,2624,2629,2634,2639,2643,2648,2653,2658,2663,2667,2672,2677,2682,2687,2691,2696,2701,2706,2710,2715,2720,2725,2730,2734,2739,2744,2749,2754,2758,2763,2768,2773,2777,2782,2787,2792,2797,2801,2806,2811,2816,2821,2825,2830,2835,2840,2844,2849,2854,2859,2864,2868,2873,2878,2883,2888,2892,2897,2902,2907,2911,2916,2921,2926,2931,2935,2940,2945,2950,2954,2959,2964,2969,2974,2978,2983,2988,2993,2998,3002,3007,3012,3017,3021,3026,3031,3036,3041,3045,3050,3055,3060,3065,3069,3074,3079,3084,3088,3093,3098,3103,3108,3112,3117,3122,3127,3132,3136,3141,3146,3151,3155,3160,3165,3170,3175,3179,3184,3189,3194,3199,3203,3208,3213,3218,3222,3227,3232,3237,3242,3246,3251,3256,3261,3266,3270,3275,3280,3285,3289,3294,3299,3304,3309,3313,3318,3323,3328,3333,3337,3342,3347,3352,3356,3361,3366,3371,3376,3380,3385,3390,3395,3400,3404,3409,3414,3419,3423,3428,3433,3438,3443,3447,3452,3457,3462,3466,3471,3476,3481,3486,3490,3495,3500,3505,3510,3514,3519,3524,3529,3533,3538,3543,3548,3553,3557,3562,3567,3572,3577,3581,3586,3591,3596,3600,3605,3610,3615,3620,3624,3629,3634,3639,3644,3648,3653,3658,3663,3667,3672,3677,3682,3687,3691,3696,3701,3706,3711,3715,3720,3725,3730,3734,3739,3744,3749,3754,3758,3763,3768,3773,3778,3782,3787,3792,3797,3801,3806,3811,3816,3821,3825,3830,3835,3840,3845,3849,3854,3859,3864,3868,3873,3878,3883,3888,3892,3897,3902,3907,3911,3916,3921,3926,3931,3935,3940,3945,3950,3955,3959,3964,3969,3974,3978,3983,3988,3993,3998,4002,4007,4012,4017,4022,4026,4031,4036,4041,4045,4050,4055,4060,4065,4069,4074,4079,4084,4089,4093,4098,4103,4108,4112,4117,4122,4127,4132,4136,4141,4146,4151,4156,4160,4165,4170,4175,4179,4184,4189,4194,4199,4203,4208,4213,4218,4223,4227,4232,4237,4242,4246,4251,4256,4261,4266,4270,4275,4280,4285,4290,4294,4299,4304,4309,4313,4318,4323,4328,4333,4337,4342,4347,4352,4356,4361,4366,4371,4376,4380,4385,4390,4395,4400,4404,4409,4414,4419,4423,4428,4433,4438,4443,4447,4452,4457,4462,4467,4471,4476,4481,4486,4490,4495,4500,4505,4510,4514,4519,4524,4529,4534,4538,4543,4548,4553,4557,4562,4567,4572,4577,4581,4586,4591,4596,4601,4605,4610,4615,4620,4624,4629,4634,4639,4644,4648,4653,4658,4663,4668,4672,4677,4682,4687,4691,4696,4701,4706,4711,4715,4720,4725,4730,4735,4739,4744,4749,4754,4758,4763,4768,4773,4778,4782,4787,4792,4797,4801,4806,4811,4816,4821,4825,4830,4835,4840,4845,4849,4854,4859,4864,4868,4873,4878,4883,4888,4892,4897,4902,4907,4912,4916,4921,4926,4931,4935,4940,4945,4950,4955,4959,4964,4969,4974,4979,4983,4988,4993,4998,5002,5007,5012,5017,5022,5026,5031,5036,5041,5046,5050,5055,5060,5065,5069,5074,5079,5084,5089,5093,5098,5103,5108,5113,5117,5122,5127,5132,5136,5141,5146,5151,5156,5160,5165,5170,5175,5180,5184,5189,5194,5199,5203,5208,5213,5218,5223,5227,5232,5237,5242,5247,5251,5256,5261,5266,5270,5275,5280,5285,5290,5294,5299,5304,5309,5313,5318,5323,5328,5333,5337,5342,5347,5352,5357,5361,5366,5371,5376,5380,5385,5390,5395,5400,5404,5409,5414,5419,5424,5428,5433,5438,5443,5447,5452,5457,5462,5467,5471,5476,5481,5486,5491,5495,5500,5505,5510,5514,5519,5524,5529,5534,5538,5543,5548,5553,5558,5562,5567,5572,5577,5581,5586,5591,5596,5601,5605,5610,5615,5620,5625,5629,5634,5639,5644,5648,5653,5658,5663,5668,5672,5677,5682,5687,5692,5696,5701,5706,5711,5715,5720,5725,5730,5735,5739,5744,5749,5754,5758,5763,5768,5773,5778,5782,5787,5792,5797,5802,5806,5811,5816,5821,5825,5830,5835,5840,5845,5849,5854,5859,5864,5869,5873,5878,5883,5888,5892,5897,5902,5907,5912,5916,5921,5926,5931,5936,5940,5945,5950,5955,5959,5964,5969,5974,5979,5983,5988,5993,5998,6003,6007,6012,6017,6022,6026,6031,6036,6041,6046,6050,6055,6060,6065,6070,6074,6079,6084,6089,6093,6098,6103,6108,6113,6117,6122,6127,6132,6137,6141,6146,6151,6156,6160,6165,6170,6175,6180,6184,6189,6194,6199,6203,6208,6213,6218,6223,6227,6232,6237,6242,6247,6251,6256,6261,6266,6270,6275,6280,6285,6290,6294,6299,6304,6309,6314,6318,6323,6328,6333,6337,6342,6347,6352,6357,6361,6366,6371,6376,6381,6385,6390,6395,6400,6404,6409,6414,6419,6424,6428,6433,6438,6443,6448,6452,6457,6462,6467,6471,6476,6481,6486,6491,6495,6500,6505,6510,6515,6519,6524,6529,6534,6538,6543,6548,6553,6558,6562,6567,6572,6577,6582,6586,6591,6596,6601,6605,6610,6615,6620,6625,6629,6634,6639,6644,6648,6653,6658,6663,6668,6672,6677,6682,6687,6692,6696,6701,6706,6711,6715,6720,6725,6730,6735,6739,6744,6749,6754,6759,6763,6768,6773,6778,6782,6787,6792,6797,6802,6806,6811,6816,6821,6826,6830,6835,6840,6845,6849,6854,6859,6864,6869,6873,6878,6883,6888,6893,6897,6902,6907,6912,6916,6921,6926,6931,6936,6940,6945,6950,6955,6960,6964,6969,6974,6979,6983,6988,6993,6998,7003,7007,7012,7017,7022,7027,7031,7036,7041,7046,7050,7055,7060,7065,7070,7074,7079,7084,7089,7094,7098,7103,7108,7113,7117,7122,7127,7132,7137,7141,7146,7151,7156,7160,7165,7170,7175,7180,7184,7189,7194,7199,7204,7208,7213,7218,7223,7227,7232,7237,7242,7247,7251,7256,7261,7266,7271,7275,7280,7285,7290,7294,7299,7304,7309,7314,7318,7323,7328,7333,7338,7342,7347,7352,7357,7361,7366,7371,7376,7381,7385,7390,7395,7400,7405,7409,7414,7419,7424,7428,7433,7438,7443,7448,7452,7457,7462,7467,7472,7476,7481,7486,7491,7495,7500,7505,7510,7515,7519,7524,7529,7534,7539,7543,7548,7553,7558,7562,7567,7572,7577,7582,7586,7591,7596,7601,7605,7610,7615,7620,7625,7629,7634,7639,7644,7649,7653,7658,7663,7668,7672,7677,7682,7687,7692,7696,7701,7706,7711,7716,7720,7725,7730,7735,7739,7744,7749,7754,7759,7763,7768,7773,7778,7783,7787,7792,7797,7802,7806,7811,7816,7821,7826,7830,7835,7840,7845,7850,7854,7859,7864,7869,7873,7878,7883,7888,7893,7897,7902,7907,7912,7917,7921,7926,7931,7936,7940,7945,7950,7955,7960,7964,7969,7974,7979,7984,7988,7993,7998,8003,8007,8012,8017,8022,8027,8031,8036,8041,8046,8050,8055,8060,8065,8070,8074,8079,8084,8089,8094,8098,8103,8108,8113,8117,8122,8127,8132,8137,8141,8146,8151,8156,8161,8165,8170,8175,8180,8184,8189,8194,8199,8204,8208,8213,8218,8223,8228,8232,8237,8242,8247,8251,8256,8261,8266,8271,8275,8280,8285,8290,8295,8299,8304,8309,8314,8318,8323,8328,8333,8338,8342,8347,8352,8357,8362,8366,8371,8376,8381,8385,8390,8395,8400,8405,8409,8414,8419,8424,8429,8433,8438,8443,8448,8452,8457,8462,8467,8472,8476,8481,8486,8491,8495,8500,8505,8510,8515,8519,8524,8529,8534,8539,8543,8548,8553,8558,8562,8567,8572,8577,8582,8586,8591,8596,8601,8606,8610,8615,8620,8625,8629,8634,8639,8644,8649,8653,8658,8663,8668,8673,8677,8682,8687,8692,8696,8701,8706,8711,8716,8720,8725,8730,8735,8740,8744,8749,8754,8759,8763,8768,8773,8778,8783,8787,8792,8797,8802,8807,8811,8816,8821,8826,8830,8835,8840,8845,8850,8854,8859,8864,8869,8874,8878,8883,8888,8893,8897,8902,8907,8912,8917,8921,8926,8931,8936,8940,8945,8950,8955,8960,8964,8969,8974,8979,8984,8988,8993,8998,9003,9007,9012,9017,9022,9027,9031,9036,9041,9046,9051,9055,9060,9065,9070,9074,9079,9084,9089,9094,9098,9103,9108,9113,9118,9122,9127,9132,9137,9141,9146,9151,9156,9161,9165,9170,9175,9180,9185,9189,9194,9199,9204,9208,9213,9218,9223,9228,9232,9237,9242,9247,9252,9256,9261,9266,9271,9275,9280,9285,9290,9295,9299,9304,9309,9314,9319,9323,9328,9333,9338,9342,9347,9352,9357,9362,9366,9371,9376,9381,9386,9390,9395,9400,9405,9409,9414,9419,9424,9429,9433,9438,9443,9448,9452,9457,9462,9467,9472,9476,9481,9486,9491,9496,9500,9505,9510,9515,9519,9524,9529,9534,9539,9543,9548,9553,9558,9563,9567,9572,9577,9582,9586,9591,9596,9601,9606,9610,9615,9620,9625,9630,9634,9639,9644,9649,9653,9658,9663,9668,9673,9677,9682,9687,9692,9697,9701,9706,9711,9716,9720,9725,9730,9735,9740,9744,9749,9754,9759,9764,9768,9773,9778,9783,9787,9792,9797,9802,9807,9811,9816,9821,9826,9831,9835,9840,9845,9850,9854,9859,9864,9869,9874,9878,9883,9888,9893,9897,9902,9907,9912,9917,9921,9926,9931,9936,9941,9945,9950,9955,9960,9964,9969,9974,9979,9984,9988,9993,9998,10003,10008,10012,10017,10022,10027,10031,10036,10041,10046,10051,10055,10060,10065,10070,10075,10079,10084,10089,10094,10098,10103,10108,10113,10118,10122,10127,10132,10137,10142,10146,10151,10156,10161,10165,10170,10175,10180,10185,10189,10194,10199,10204,10209,10213,10218,10223,10228,10232,10237,10242,10247,10252,10256,10261,10266,10271,10276,10280,10285,10290,10295,10299,10304,10309,10314,10319,10323,10328,10333,10338,10342,10347,10352,10357,10362,10366,10371,10376,10381,10386,10390,10395,10400,10405,10409,10414,10419,10424,10429,10433,10438,10443,10448,10453,10457,10462,10467,10472,10476,10481,10486,10491,10496,10500,10505,10510,10515,10520,10524,10529,10534,10539,10543,10548,10553,10558,10563,10567,10572,10577,10582,10587,10591,10596,10601,10606,10610,10615,10620,10625,10630,10634,10639,10644,10649,10654,10658,10663,10668,10673,10677,10682,10687,10692,10697,10701,10706,10711,10716,10721,10725,10730,10735,10740,10744,10749,10754,10759,10764,10768,10773,10778,10783,10787,10792,10797,10802,10807,10811,10816,10821,10826,10831,10835,10840,10845,10850,10854,10859,10864,10869,10874,10878,10883,10888,10893,10898,10902,10907,10912,10917,10921,10926,10931,10936,10941,10945,10950,10955,10960,10965,10969,10974,10979,10984,10988,10993,10998,11003,11008,11012,11017,11022,11027,11032,11036,11041,11046,11051,11055,11060,11065,11070,11075,11079,11084,11089,11094,11099,11103,11108,11113,11118,11122,11127,11132,11137,11142,11146,11151,11156,11161,11166,11170,11175,11180,11185,11189,11194,11199,11204,11209,11213,11218,11223,11228,11233,11237,11242,11247,11252,11256,11261,11266,11271,11276,11280,11285,11290,11295,11299,11304,11309,11314,11319,11323,11328,11333,11338,11343,11347,11352,11357,11362,11366,11371,11376,11381,11386,11390,11395,11400,11405,11410,11414,11419,11424,11429,11433,11438,11443,11448,11453,11457,11462,11467,11472,11477,11481,11486,11491,11496,11500,11505,11510,11515,11520,11524,11529,11534,11539,11544,11548,11553,11558,11563,11567,11572,11577,11582,11587,11591,11596,11601,11606,11611,11615,11620,11625,11630,11634,11639,11644,11649,11654,11658,11663,11668,11673,11678,11682,11687,11692,11697,11701,11706,11711,11716,11721,11725,11730,11735,11740,11744,11749,11754,11759,11764,11768,11773,11778,11783,11788,11792,11797,11802,11807,11811,11816,11821,11826,11831,11835,11840,11845,11850,11855,11859,11864,11869,11874,11878,11883,11888,11893,11898,11902,11907,11912,11917,11922,11926,11931,11936,11941,11945,11950,11955,11960,11965,11969,11974,11979,11984,11989,11993,11998,12003,12008,12012,12017,12022,12027,12032,12036,12041,12046,12051,12056,12060,12065,12070,12075,12079,12084,12089,12094,12099,12103,12108,12113,12118,12123,12127,12132,12137,12142,12146,12151,12156,12161,12166,12170,12175,12180,12185,12189,12194,12199,12204,12209,12213,12218,12223,12228,12233,12237,12242,12247,12252,12256,12261,12266,12271,12276,12280,12285,12290,12295,12300,12304,12309,12314,12319,12323,12328,12333,12338,12343,12347,12352,12357,12362,12367,12371,12376,12381,12386,12390,12395,12400,12405,12410,12414,12419,12424,12429,12434,12438,12443,12448,12453,12457,12462,12467,12472,12477,12481,12486,12491,12496,12501,12505,12510,12515,12520,12524,12529,12534,12539,12544,12548,12553,12558,12563,12568,12572,12577,12582,12587,12591,12596,12601,12606,12611,12615,12620,12625,12630,12634,12639,12644,12649,12654,12658,12663,12668,12673,12678,12682,12687,12692,12697,12701,12706,12711,12716,12721,12725,12730,12735,12740,12745,12749,12754,12759,12764,12768,12773,12778,12783,12788,12792,12797,12802,12807,12812,12816,12821,12826,12831,12835,12840,12845,12850,12855,12859,12864,12869,12874,12879,12883,12888,12893,12898,12902,12907,12912,12917,12922,12926,12931,12936,12941,12946,12950,12955,12960,12965,12969,12974,12979,12984,12989,12993,12998,13003,13008,13013,13017,13022,13027,13032,13036,13041,13046,13051,13056,13060,13065,13070,13075,13080,13084,13089,13094,13099,13103,13108,13113,13118,13123,13127,13132,13137,13142,13146,13151,13156,13161,13166,13170,13175,13180,13185,13190,13194,13199,13204,13209,13213,13218,13223,13228,13233,13237,13242,13247,13252,13257,13261,13266,13271,13276,13280,13285,13290,13295,13300,13304,13309,13314,13319,13324,13328,13333,13338,13343,13347,13352,13357,13362,13367,13371,13376,13381,13386,13391,13395,13400,13405,13410,13414,13419,13424,13429,13434,13438,13443,13448,13453,13458,13462,13467,13472,13477,13481,13486,13491,13496,13501,13505,13510,13515,13520,13525,13529,13534,13539,13544,13548,13553,13558,13563,13568,13572,13577,13582,13587,13591,13596,13601,13606,13611,13615,13620,13625,13630,13635,13639,13644,13649,13654,13658,13663,13668,13673,13678,13682,13687,13692,13697,13702,13706,13711,13716,13721,13725,13730,13735,13740,13745,13749,13754,13759,13764,13769,13773,13778,13783,13788,13792,13797,13802,13807,13812,13816,13821,13826,13831,13836,13840,13845,13850,13855,13859,13864,13869,13874,13879,13883,13888,13893,13898,13903,13907,13912,13917,13922,13926,13931,13936,13941,13946,13950,13955,13960,13965,13970,13974,13979,13984,13989,13993,13998,14003,14008,14013,14017,14022,14027,14032,14036,14041,14046,14051,14056,14060,14065,14070,14075,14080,14084,14089,14094,14099,14103,14108,14113,14118,14123,14127,14132,14137,14142,14147,14151,14156,14161,14166,14170,14175,14180,14185,14190,14194,14199,14204,14209,14214,14218,14223,14228,14233,14237,14242,14247,14252,14257,14261,14266,14271,14276,14281,14285,14290,14295,14300,14304,14309,14314,14319,14324,14328,14333,14338,14343,14348,14352,14357,14362,14367,14371,14376,14381,14386,14391,14395,14400,14405,14410,14415,14419,14424,14429,14434,14438,14443,14448,14453,14458,14462,14467,14472,14477,14481,14486,14491,14496,14501,14505,14510,14515,14520,14525,14529,14534,14539,14544,14548,14553,14558,14563,14568,14572,14577,14582,14587,14592,14596,14601,14606,14611,14615,14620,14625,14630,14635,14639,14644,14649,14654,14659,14663,14668,14673,14678,14682,14687,14692,14697,14702,14706,14711,14716,14721,14726,14730,14735,14740,14745,14749,14754,14759,14764,14769,14773,14778,14783,14788,14793,14797,14802,14807,14812,14816,14821,14826,14831,14836,14840,14845,14850,14855,14860,14864,14869,14874,14879,14883,14888,14893,14898,14903,14907,14912,14917,14922,14926,14931,14936,14941,14946,14950,14955,14960,14965,14970,14974,14979,14984,14989,14993,14998,15003,15008,15013,15017,15022,15027,15032,15037,15041,15046,15051,15056,15060,15065,15070,15075,15080,15084,15089,15094,15099,15104,15108,15113,15118,15123,15127,15132,15137,15142,15147,15151,15156,15161,15166,15171,15175,15180,15185,15190,15194,15199,15204,15209,15214,15218,15223,15228,15233,15238,15242,15247,15252,15257,15261,15266,15271,15276,15281,15285,15290,15295,15300,15305,15309,15314,15319,15324,15328,15333,15338,15343,15348,15352,15357,15362,15367,15372,15376,15381,15386,15391,15395,15400,15405,15410,15415,15419,15424,15429,15434,15438,15443,15448,15453,15458,15462,15467,15472,15477,15482,15486,15491,15496,15501,15505,15510,15515,15520,15525,15529,15534,15539,15544,15549,15553,15558,15563,15568,15572,15577,15582,15587,15592,15596,15601,15606,15611,15616,15620,15625,15630,15635,15639,15644,15649,15654,15659,15663,15668,15673,15678,15683,15687,15692,15697,15702,15706,15711,15716,15721,15726,15730,15735,15740,15745,15750,15754,15759,15764,15769,15773,15778,15783,15788,15793,15797,15802,15807,15812,15817,15821,15826,15831,15836,15840,15845,15850,15855,15860,15864,15869,15874,15879,15883,15888,15893,15898,15903,15907,15912,15917,15922,15927,15931,15936,15941,15946,15950,15955,15960,15965,15970,15974,15979,15984,15989,15994,15998,16003,16008,16013,16017,16022,16027,16032,16037,16041,16046,16051,16056,16061,16065,16070,16075,16080,16084,16089,16094,16099,16104,16108,16113,16118,16123,16128,16132,16137,16142,16147,16151,16156,16161,16166,16171,16175,16180,16185,16190,16195,16199,16204,16209,16214,16218,16223,16228,16233,16238,16242,16247,16252,16257,16262,16266,16271,16276,16281,16285,16290,16295,16300,16305,16309,16314,16319,16324,16328,16333,16338,16343,16348,16352,16357,16362,16367,16372,16376,16381,16386,16391,16395,16400,16405,16410,16415,16419,16424,16429,16434,16439,16443,16448,16453,16458,16462,16467,16472,16477,16482,16486,16491,16496,16501,16506,16510,16515,16520,16525,16529,16534,16539,16544,16549,16553,16558,16563,16568,16573,16577,16582,16587,16592,16596,16601,16606,16611,16616,16620,16625,16630,16635,16640,16644,16649,16654,16659,16663,16668,16673,16678,16683,16687,16692,16697,16702,16707,16711,16716,16721,16726,16730,16735,16740,16745,16750,16754,16759,16764,16769,16773,16778,16783,16788,16793,16797,16802,16807,16812,16817,16821,16826,16831,16836,16840,16845,16850,16855,16860,16864,16869,16874,16879,16884,16888,16893,16898,16903,16907,16912,16917,16922,16927,16931,16936,16941,16946,16951,16955,16960,16965,16970,16974,16979,16984,16989,16994,16998,17003,17008,17013,17018,17022,17027,17032,17037,17041,17046,17051,17056,17061,17065,17070,17075,17080,17085,17089,17094,17099,17104,17108,17113,17118,17123,17128,17132,17137,17142,17147,17152,17156,17161,17166,17171,17175,17180,17185,17190,17195,17199,17204,17209,17214,17219,17223,17228,17233,17238,17242,17247,17252,17257,17262,17266,17271,17276,17281,17285,17290,17295,17300,17305,17309,17314,17319,17324,17329,17333,17338,17343,17348,17352,17357,17362,17367,17372,17376,17381,17386,17391,17396,17400,17405,17410,17415,17419,17424,17429,17434,17439,17443,17448,17453,17458,17463,17467,17472,17477,17482,17486,17491,17496,17501,17506,17510,17515,17520,17525,17530,17534,17539,17544,17549,17553,17558,17563,17568,17573,17577,17582,17587,17592,17597,17601,17606,17611,17616,17620,17625,17630,17635,17640,17644,17649,17654,17659,17664,17668,17673,17678,17683,17687,17692,17697,17702,17707,17711,17716,17721,17726,17730,17735,17740,17745,17750,17754,17759,17764,17769,17774,17778,17783,17788,17793,17797,17802,17807,17812,17817,17821,17826,17831,17836,17841,17845,17850,17855,17860,17864,17869,17874,17879,17884,17888,17893,17898,17903,17908,17912,17917,17922,17927,17931,17936,17941,17946,17951,17955,17960,17965,17970,17975,17979,17984,17989,17994,17998,18003,18008,18013,18018,18022,18027,18032,18037,18042,18046,18051,18056,18061,18065,18070,18075,18080,18085,18089,18094,18099,18104,18109,18113,18118,18123,18128,18132,18137,18142,18147,18152,18156,18161,18166,18171,18175,18180,18185,18190,18195,18199,18204,18209,18214,18219,18223,18228,18233,18238,18242,18247,18252,18257,18262,18266,18271,18276,18281,18286,18290,18295,18300,18305,18309,18314,18319,18324,18329,18333,18338,18343,18348,18353,18357,18362,18367,18372,18376,18381,18386,18391,18396,18400,18405,18410,18415,18420,18424,18429,18434,18439,18443,18448,18453,18458,18463,18467,18472,18477,18482,18487,18491,18496,18501,18506,18510,18515,18520,18525,18530,18534,18539,18544,18549,18554,18558,18563,18568,18573,18577,18582,18587,18592,18597,18601,18606,18611,18616,18620,18625,18630,18635,18640,18644,18649,18654,18659,18664,18668,18673,18678,18683,18687,18692,18697,18702,18707,18711,18716,18721,18726,18731,18735,18740,18745,18750,18754,18759,18764,18769,18774,18778,18783,18788,18793,18798,18802,18807,18812,18817,18821,18826,18831,18836,18841,18845,18850,18855,18860,18865,18869,18874,18879,18884,18888,18893,18898,18903,18908,18912,18917,18922,18927,18932,18936,18941,18946,18951,18955,18960,18965,18970,18975,18979,18984,18989,18994,18999,19003,19008,19013,19018,19022,19027,19032,19037,19042,19046,19051,19056,19061,19066,19070,19075,19080,19085,19089,19094,19099,19104,19109,19113,19118,19123,19128,19132,19137,19142,19147,19152,19156,19161,19166,19171,19176,19180,19185,19190,19195,19199,19204,19209,19214,19219,19223,19228,19233,19238,19243,19247,19252,19257,19262,19266,19271,19276,19281,19286,19290,19295,19300,19305,19310,19314,19319,19324,19329,19333,19338,19343,19348,19353,19357,19362,19367,19372,19377,19381,19386,19391,19396,19400,19405,19410,19415,19420,19424,19429,19434,19439,19444,19448,19453,19458,19463,19467,19472,19477,19482,19487,19491,19496,19501,19506,19511,19515,19520,19525,19530,19534,19539,19544,19549,19554,19558,19563,19568,19573,19577,19582,19587,19592,19597,19601,19606,19611,19616,19621,19625,19630,19635,19640,19644,19649,19654,19659,19664,19668,19673,19678,19683,19688,19692,19697,19702,19707,19711,19716,19721,19726,19731,19735,19740,19745,19750,19755,19759,19764,19769,19774,19778,19783,19788,19793,19798,19802,19807,19812,19817,19822,19826,19831,19836,19841,19845,19850,19855,19860,19865,19869,19874,19879,19884,19889,19893,19898,19903,19908,19912,19917,19922,19927,19932,19936,19941,19946,19951,19956,19960,19965,19970,19975,19979,19984,19989,19994,19999,20003,20008,20013,20018,20022,20027,20032,20037,20042,20046,20051,20056,20061,20066,20070,20075,20080,20085,20089,20094,20099,20104,20109,20113,20118,20123,20128,20133,20137,20142,20147,20152,20156,20161,20166,20171,20176,20180,20185,20190,20195,20200,20204,20209,20214,20219,20223,20228,20233,20238,20243,20247,20252,20257,20262,20267,20271,20276,20281,20286,20290,20295,20300,20305,20310,20314,20319,20324,20329,20334,20338,20343,20348,20353,20357,20362,20367,20372,20377,20381,20386,20391,20396,20401,20405,20410,20415,20420,20424,20429,20434,20439,20444,20448,20453,20458,20463,20467,20472,20477,20482,20487,20491,20496,20501,20506,20511,20515,20520,20525,20530,20534,20539,20544,20549,20554,20558,20563,20568,20573,20578,20582,20587,20592,20597,20601,20606,20611,20616,20621,20625,20630,20635,20640,20645,20649,20654,20659,20664,20668,20673,20678,20683,20688,20692,20697,20702,20707,20712,20716,20721,20726,20731,20735,20740,20745,20750,20755,20759,20764,20769,20774,20779,20783,20788,20793,20798,20802,20807,20812,20817,20822,20826,20831,20836,20841,20846,20850,20855,20860,20865,20869,20874,20879,20884,20889,20893,20898,20903,20908,20912,20917,20922,20927,20932,20936,20941,20946,20951,20956,20960,20965,20970,20975,20979,20984,20989,20994,20999,21003,21008,21013,21018,21023,21027,21032,21037,21042,21046,21051,21056,21061,21066,21070,21075,21080,21085,21090,21094,21099,21104,21109,21113,21118,21123,21128,21133,21137,21142,21147,21152,21157,21161,21166,21171,21176,21180,21185,21190,21195,21200,21204,21209,21214,21219,21224,21228,21233,21238,21243,21247,21252,21257,21262,21267,21271,21276,21281,21286,21291,21295,21300,21305,21310,21314,21319,21324,21329,21334,21338,21343,21348,21353,21358,21362,21367,21372,21377,21381,21386,21391,21396,21401,21405,21410,21415,21420,21424,21429,21434,21439,21444,21448,21453,21458,21463,21468,21472,21477,21482,21487,21491,21496,21501,21506,21511,21515,21520,21525,21530,21535,21539,21544,21549,21554,21558,21563,21568,21573,21578,21582,21587,21592,21597,21602,21606,21611,21616,21621,21625,21630,21635,21640,21645,21649,21654,21659,21664,21669,21673,21678,21683,21688,21692,21697,21702,21707,21712,21716,21721,21726,21731,21736,21740,21745,21750,21755,21759,21764,21769,21774,21779,21783,21788,21793,21798,21803,21807,21812,21817,21822,21826,21831,21836,21841,21846,21850,21855,21860,21865,21869,21874,21879,21884,21889,21893,21898,21903,21908,21913,21917,21922,21927,21932,21936,21941,21946,21951,21956,21960,21965,21970,21975,21980,21984,21989,21994,21999,22003,22008,22013,22018,22023,22027,22032,22037,22042,22047,22051,22056,22061,22066,22070,22075,22080,22085,22090,22094,22099,22104,22109,22114,22118,22123,22128,22133,22137,22142,22147,22152,22157,22161,22166,22171,22176,22181,22185,22190,22195,22200,22204,22209,22214,22219,22224,22228,22233,22238,22243,22248,22252,22257,22262,22267,22271,22276,22281,22286,22291,22295,22300,22305,22310,22314,22319,22324,22329,22334,22338,22343,22348,22353,22358,22362,22367,22372,22377,22381,22386,22391,22396,22401,22405,22410,22415,22420,22425,22429,22434,22439,22444,22448,22453,22458,22463,22468,22472,22477,22482,22487,22492,22496,22501,22506,22511,22515,22520,22525,22530,22535,22539,22544,22549,22554,22559,22563,22568,22573,22578,22582,22587,22592,22597,22602,22606,22611,22616,22621,22626,22630,22635,22640,22645,22649,22654,22659,22664,22669,22673,22678,22683,22688,22693,22697,22702,22707,22712,22716,22721,22726,22731,22736,22740,22745,22750,22755,22759,22764,22769,22774,22779,22783,22788,22793,22798,22803,22807,22812,22817,22822,22826,22831,22836,22841,22846,22850,22855,22860,22865,22870,22874,22879,22884,22889,22893,22898,22903,22908,22913,22917,22922,22927,22932,22937,22941,22946,22951,22956,22960,22965,22970,22975,22980,22984,22989,22994,22999,23004,23008,23013,23018,23023,23027,23032,23037,23042,23047,23051,23056,23061,23066,23071,23075,23080,23085,23090,23094,23099,23104,23109,23114,23118,23123,23128,23133,23138,23142,23147,23152,23157,23161,23166,23171,23176,23181,23185,23190,23195,23200,23205,23209,23214,23219,23224,23228,23233,23238,23243,23248,23252,23257,23262,23267,23271,23276,23281,23286,23291,23295,23300,23305,23310,23315,23319,23324,23329,23334,23338,23343,23348,23353,23358,23362,23367,23372,23377,23382,23386,23391,23396,23401,23405,23410,23415,23420,23425,23429,23434,23439,23444,23449,23453,23458,23463,23468,23472,23477,23482,23487,23492,23496,23501,23506,23511,23516,23520,23525,23530,23535,23539,23544,23549,23554,23559,23563,23568,23573,23578,23583,23587,23592,23597,23602,23606,23611,23616,23621,23626,23630,23635,23640,23645,23650,23654,23659,23664,23669,23673,23678,23683,23688,23693,23697,23702,23707,23712,23716,23721,23726,23731,23736,23740,23745,23750,23755,23760,23764,23769,23774,23779,23783,23788,23793,23798,23803,23807,23812,23817,23822,23827,23831,23836,23841,23846,23850,23855,23860,23865,23870,23874,23879,23884,23889,23894,23898,23903,23908,23913,23917,23922,23927] 2 | for i in xrange(input()): 3 | print l[input()-1] -------------------------------------------------------------------------------- /ProjectEuler+/p23.py: -------------------------------------------------------------------------------- 1 | num = [24,30,32,36,38,40,42,44,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,604,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,784,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,957,958,960,962,963,964,965,966,968,969,970,972,974,975,976,978,980,981,982,984,985,986,987,988,990,992,993,994,996,998,999,1000,1001,1002,1004,1005,1006,1008,1010,1011,1012,1014,1015,1016,1017,1018,1020,1022,1023,1024,1025,1026,1028,1029,1030,1032,1033,1034,1035,1036,1038,1040,1041,1042,1044,1045,1046,1047,1048,1049,1050,1052,1053,1054,1056,1057,1058,1059,1060,1062,1064,1065,1066,1068,1070,1071,1072,1074,1076,1077,1078,1080,1082,1083,1084,1085,1086,1088,1089,1090,1092,1094,1095,1096,1098,1100,1101,1102,1104,1105,1106,1107,1108,1110,1112,1113,1114,1116,1118,1119,1120,1121,1122,1124,1125,1126,1128,1130,1131,1132,1134,1136,1137,1138,1140,1141,1142,1143,1144,1145,1146,1148,1149,1150,1152,1153,1154,1155,1156,1158,1160,1161,1162,1164,1165,1166,1167,1168,1169,1170,1172,1173,1174,1176,1178,1179,1180,1182,1184,1185,1186,1188,1190,1191,1192,1194,1196,1197,1198,1200,1202,1203,1204,1205,1206,1208,1209,1210,1212,1214,1215,1216,1217,1218,1220,1221,1222,1224,1225,1226,1227,1228,1230,1232,1233,1234,1236,1238,1239,1240,1242,1244,1245,1246,1248,1249,1250,1251,1252,1253,1254,1256,1257,1258,1260,1262,1263,1264,1265,1266,1268,1269,1270,1272,1274,1275,1276,1278,1280,1281,1282,1284,1285,1286,1287,1288,1290,1292,1293,1294,1295,1296,1297,1298,1299,1300,1302,1304,1305,1306,1308,1309,1310,1311,1312,1313,1314,1316,1317,1318,1320,1322,1323,1324,1325,1326,1328,1329,1330,1332,1334,1335,1336,1337,1338,1340,1341,1342,1344,1345,1346,1347,1348,1350,1352,1353,1354,1356,1358,1359,1360,1361,1362,1364,1365,1366,1368,1370,1371,1372,1374,1376,1377,1378,1380,1382,1383,1384,1385,1386,1388,1389,1390,1392,1393,1394,1395,1396,1398,1400,1401,1402,1404,1405,1406,1407,1408,1409,1410,1412,1413,1414,1416,1418,1419,1420,1421,1422,1424,1425,1426,1428,1430,1431,1432,1434,1435,1436,1437,1438,1440,1442,1443,1444,1445,1446,1448,1449,1450,1452,1454,1455,1456,1458,1460,1461,1462,1464,1465,1466,1467,1468,1470,1472,1473,1474,1476,1477,1478,1479,1480,1482,1484,1485,1486,1488,1489,1490,1491,1492,1494,1495,1496,1497,1498,1500,1502,1503,1504,1505,1506,1508,1509,1510,1512,1514,1515,1516,1517,1518,1520,1521,1522,1524,1525,1526,1527,1528,1530,1532,1533,1534,1536,1538,1539,1540,1542,1544,1545,1546,1548,1550,1551,1552,1553,1554,1556,1557,1558,1560,1561,1562,1563,1564,1565,1566,1568,1569,1570,1572,1574,1575,1576,1578,1580,1581,1582,1584,1585,1586,1587,1588,1589,1590,1592,1593,1594,1595,1596,1598,1599,1600,1602,1604,1605,1606,1608,1610,1611,1612,1614,1615,1616,1617,1618,1620,1622,1623,1624,1625,1626,1628,1629,1630,1631,1632,1634,1635,1636,1638,1640,1641,1642,1644,1645,1646,1647,1648,1649,1650,1652,1653,1654,1655,1656,1658,1659,1660,1662,1663,1664,1665,1666,1668,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1692,1693,1694,1695,1696,1698,1700,1701,1702,1704,1705,1706,1707,1708,1710,1712,1713,1714,1715,1716,1718,1719,1720,1722,1724,1725,1726,1728,1729,1730,1731,1732,1734,1735,1736,1737,1738,1740,1742,1743,1744,1745,1746,1748,1749,1750,1751,1752,1754,1755,1756,1757,1758,1760,1761,1762,1764,1765,1766,1767,1768,1770,1771,1772,1773,1774,1775,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,1786,1788,1790,1791,1792,1794,1795,1796,1797,1798,1799,1800,1802,1803,1804,1805,1806,1808,1809,1810,1812,1813,1814,1815,1816,1818,1820,1821,1822,1824,1825,1826,1827,1828,1830,1832,1833,1834,1835,1836,1838,1839,1840,1841,1842,1844,1845,1846,1847,1848,1850,1851,1852,1854,1855,1856,1857,1858,1860,1862,1863,1864,1865,1866,1868,1869,1870,1872,1873,1874,1875,1876,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1890,1892,1893,1894,1895,1896,1897,1898,1899,1900,1902,1904,1905,1906,1908,1910,1911,1912,1913,1914,1915,1916,1917,1918,1920,1922,1923,1924,1925,1926,1927,1928,1929,1930,1932,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1950,1952,1953,1954,1955,1956,1958,1959,1960,1962,1964,1965,1966,1967,1968,1970,1971,1972,1974,1975,1976,1977,1978,1980,1981,1982,1983,1984,1985,1986,1988,1989,1990,1991,1992,1994,1995,1996,1998,2000,2001,2002,2004,2005,2006,2007,2008,2009,2010,2012,2013,2014,2015,2016,2018,2019,2020,2022,2023,2024,2025,2026,2028,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2042,2043,2044,2045,2046,2048,2049,2050,2051,2052,2054,2055,2056,2058,2060,2061,2062,2064,2065,2066,2067,2068,2070,2072,2073,2074,2075,2076,2078,2079,2080,2082,2084,2085,2086,2088,2089,2090,2091,2092,2093,2094,2095,2096,2097,2098,2100,2102,2103,2104,2105,2106,2107,2108,2109,2110,2112,2114,2115,2116,2118,2119,2120,2121,2122,2124,2125,2126,2127,2128,2129,2130,2132,2133,2134,2135,2136,2138,2139,2140,2142,2144,2145,2146,2147,2148,2149,2150,2151,2152,2154,2155,2156,2157,2158,2160,2161,2162,2163,2164,2165,2166,2168,2169,2170,2172,2174,2175,2176,2177,2178,2180,2181,2182,2183,2184,2185,2186,2187,2188,2190,2191,2192,2193,2194,2195,2196,2198,2199,2200,2202,2204,2205,2206,2208,2210,2211,2212,2214,2215,2216,2217,2218,2219,2220,2222,2223,2224,2225,2226,2228,2229,2230,2232,2233,2234,2235,2236,2238,2240,2241,2242,2244,2245,2246,2247,2248,2250,2252,2253,2254,2255,2256,2257,2258,2259,2260,2261,2262,2264,2265,2266,2268,2270,2271,2272,2274,2275,2276,2277,2278,2279,2280,2282,2283,2284,2285,2286,2288,2289,2290,2292,2293,2294,2295,2296,2297,2298,2300,2301,2302,2303,2304,2305,2306,2307,2308,2309,2310,2311,2312,2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2328,2330,2331,2332,2334,2335,2336,2337,2338,2340,2342,2343,2344,2345,2346,2348,2349,2350,2352,2353,2354,2355,2356,2358,2359,2360,2361,2362,2364,2365,2366,2367,2368,2370,2372,2373,2374,2375,2376,2378,2379,2380,2381,2382,2384,2385,2386,2387,2388,2390,2391,2392,2394,2395,2396,2397,2398,2400,2401,2402,2403,2404,2405,2406,2407,2408,2409,2410,2411,2412,2413,2414,2415,2416,2417,2418,2420,2421,2422,2424,2425,2426,2427,2428,2429,2430,2432,2433,2434,2435,2436,2438,2439,2440,2441,2442,2443,2444,2445,2446,2448,2449,2450,2451,2452,2454,2455,2456,2457,2458,2460,2462,2463,2464,2465,2466,2468,2469,2470,2471,2472,2474,2475,2476,2477,2478,2480,2481,2482,2484,2485,2486,2487,2488,2490,2492,2493,2494,2495,2496,2498,2499,2500,2502,2503,2504,2505,2506,2508,2509,2510,2511,2512,2513,2514,2515,2516,2517,2518,2520,2522,2523,2524,2525,2526,2527,2528,2529,2530,2532,2534,2535,2536,2538,2540,2541,2542,2543,2544,2545,2546,2547,2548,2550,2552,2553,2554,2555,2556,2557,2558,2559,2560,2562,2564,2565,2566,2567,2568,2569,2570,2571,2572,2573,2574,2575,2576,2577,2578,2580,2582,2583,2584,2585,2586,2588,2589,2590,2592,2594,2595,2596,2597,2598,2600,2601,2602,2604,2605,2606,2607,2608,2609,2610,2611,2612,2613,2614,2615,2616,2617,2618,2619,2620,2621,2622,2624,2625,2626,2628,2630,2631,2632,2634,2635,2636,2637,2638,2639,2640,2641,2642,2643,2644,2645,2646,2648,2649,2650,2652,2653,2654,2655,2656,2658,2660,2661,2662,2663,2664,2665,2666,2667,2668,2669,2670,2672,2673,2674,2675,2676,2678,2679,2680,2681,2682,2684,2685,2686,2688,2690,2691,2692,2694,2695,2696,2697,2698,2700,2702,2703,2704,2705,2706,2708,2709,2710,2712,2713,2714,2715,2716,2718,2719,2720,2721,2722,2723,2724,2725,2726,2727,2728,2730,2732,2733,2734,2735,2736,2737,2738,2739,2740,2742,2744,2745,2746,2748,2749,2750,2751,2752,2754,2755,2756,2757,2758,2759,2760,2762,2763,2764,2765,2766,2768,2769,2770,2772,2774,2775,2776,2777,2778,2779,2780,2781,2782,2784,2785,2786,2787,2788,2790,2791,2792,2793,2794,2795,2796,2798,2799,2800,2801,2802,2804,2805,2806,2807,2808,2810,2811,2812,2813,2814,2815,2816,2817,2818,2820,2821,2822,2823,2824,2825,2826,2828,2829,2830,2832,2833,2834,2835,2836,2838,2840,2841,2842,2844,2845,2846,2847,2848,2849,2850,2852,2853,2854,2855,2856,2858,2859,2860,2862,2863,2864,2865,2866,2868,2870,2871,2872,2874,2875,2876,2877,2878,2880,2881,2882,2883,2884,2885,2886,2887,2888,2889,2890,2891,2892,2894,2895,2896,2897,2898,2900,2901,2902,2904,2905,2906,2907,2908,2909,2910,2912,2913,2914,2915,2916,2918,2919,2920,2921,2922,2923,2924,2925,2926,2927,2928,2929,2930,2931,2932,2933,2934,2935,2936,2937,2938,2939,2940,2941,2942,2943,2944,2945,2946,2947,2948,2949,2950,2951,2952,2953,2954,2955,2956,2958,2960,2961,2962,2964,2965,2966,2967,2968,2969,2970,2972,2973,2974,2975,2976,2978,2979,2980,2982,2983,2984,2985,2986,2988,2989,2990,2991,2992,2994,2995,2996,2997,2998,3000,3002,3003,3004,3005,3006,3008,3009,3010,3011,3012,3014,3015,3016,3017,3018,3020,3021,3022,3024,3025,3026,3027,3028,3030,3031,3032,3033,3034,3035,3036,3037,3038,3039,3040,3041,3042,3043,3044,3045,3046,3047,3048,3050,3051,3052,3054,3055,3056,3057,3058,3059,3060,3062,3063,3064,3065,3066,3068,3069,3070,3071,3072,3073,3074,3075,3076,3078,3079,3080,3081,3082,3084,3085,3086,3087,3088,3090,3092,3093,3094,3095,3096,3098,3099,3100,3101,3102,3104,3105,3106,3107,3108,3110,3111,3112,3114,3115,3116,3117,3118,3120,3121,3122,3123,3124,3125,3126,3128,3129,3130,3132,3133,3134,3135,3136,3138,3139,3140,3141,3142,3143,3144,3145,3146,3147,3148,3150,3152,3153,3154,3155,3156,3157,3158,3159,3160,3162,3164,3165,3166,3168,3170,3171,3172,3173,3174,3175,3176,3177,3178,3180,3182,3183,3184,3185,3186,3187,3188,3189,3190,3192,3194,3195,3196,3197,3198,3199,3200,3201,3202,3203,3204,3205,3206,3207,3208,3210,3212,3213,3214,3215,3216,3218,3219,3220,3222,3224,3225,3226,3227,3228,3230,3231,3232,3233,3234,3235,3236,3237,3238,3239,3240,3241,3242,3243,3244,3245,3246,3247,3248,3249,3250,3251,3252,3254,3255,3256,3258,3260,3261,3262,3264,3265,3266,3267,3268,3269,3270,3271,3272,3273,3274,3275,3276,3278,3279,3280,3282,3283,3284,3285,3286,3288,3290,3291,3292,3293,3294,3295,3296,3297,3298,3299,3300,3302,3303,3304,3305,3306,3308,3309,3310,3311,3312,3313,3314,3315,3316,3318,3320,3321,3322,3324,3325,3326,3327,3328,3330,3332,3333,3334,3335,3336,3337,3338,3339,3340,3342,3343,3344,3345,3346,3348,3349,3350,3351,3352,3353,3354,3355,3356,3357,3358,3360,3362,3363,3364,3365,3366,3367,3368,3369,3370,3372,3374,3375,3376,3377,3378,3379,3380,3381,3382,3384,3385,3386,3387,3388,3389,3390,3392,3393,3394,3395,3396,3398,3399,3400,3402,3404,3405,3406,3407,3408,3409,3410,3411,3412,3414,3415,3416,3417,3418,3420,3421,3422,3423,3424,3425,3426,3428,3429,3430,3431,3432,3434,3435,3436,3437,3438,3440,3441,3442,3443,3444,3445,3446,3447,3448,3450,3451,3452,3453,3454,3455,3456,3458,3459,3460,3462,3463,3464,3465,3466,3468,3470,3471,3472,3474,3475,3476,3477,3478,3479,3480,3482,3483,3484,3485,3486,3488,3489,3490,3492,3493,3494,3495,3496,3497,3498,3500,3501,3502,3504,3505,3506,3507,3508,3510,3511,3512,3513,3514,3515,3516,3517,3518,3519,3520,3521,3522,3524,3525,3526,3527,3528,3529,3530,3531,3532,3534,3535,3536,3537,3538,3539,3540,3542,3543,3544,3545,3546,3548,3549,3550,3551,3552,3553,3554,3555,3556,3557,3558,3559,3560,3561,3562,3563,3564,3565,3566,3567,3568,3569,3570,3571,3572,3573,3574,3575,3576,3577,3578,3579,3580,3581,3582,3583,3584,3585,3586,3588,3590,3591,3592,3594,3595,3596,3597,3598,3599,3600,3602,3603,3604,3605,3606,3608,3609,3610,3612,3613,3614,3615,3616,3618,3619,3620,3621,3622,3624,3625,3626,3627,3628,3630,3632,3633,3634,3635,3636,3638,3639,3640,3641,3642,3644,3645,3646,3647,3648,3649,3650,3651,3652,3654,3655,3656,3657,3658,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,3676,3677,3678,3680,3681,3682,3684,3685,3686,3687,3688,3689,3690,3692,3693,3694,3695,3696,3697,3698,3699,3700,3701,3702,3703,3704,3705,3706,3708,3709,3710,3711,3712,3714,3715,3716,3717,3718,3720,3722,3723,3724,3725,3726,3728,3729,3730,3731,3732,3734,3735,3736,3737,3738,3740,3741,3742,3744,3745,3746,3747,3748,3750,3751,3752,3753,3754,3755,3756,3758,3759,3760,3761,3762,3763,3764,3765,3766,3768,3769,3770,3771,3772,3773,3774,3775,3776,3777,3778,3780,3782,3783,3784,3785,3786,3787,3788,3789,3790,3792,3794,3795,3796,3798,3800,3801,3802,3803,3804,3805,3806,3807,3808,3810,3812,3813,3814,3815,3816,3817,3818,3819,3820,3822,3824,3825,3826,3827,3828,3829,3830,3831,3832,3833,3834,3835,3836,3837,3838,3840,3842,3843,3844,3845,3846,3848,3849,3850,3852,3854,3855,3856,3857,3858,3860,3861,3862,3863,3864,3865,3866,3867,3868,3869,3870,3871,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3882,3884,3885,3886,3888,3889,3890,3891,3892,3894,3895,3896,3897,3898,3899,3900,3901,3902,3903,3904,3905,3906,3908,3909,3910,3912,3913,3914,3915,3916,3918,3920,3921,3922,3923,3924,3925,3926,3927,3928,3929,3930,3932,3933,3934,3935,3936,3937,3938,3939,3940,3941,3942,3943,3944,3945,3946,3948,3950,3951,3952,3953,3954,3955,3956,3957,3958,3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3972,3973,3974,3975,3976,3978,3979,3980,3981,3982,3983,3984,3985,3986,3987,3988,3990,3992,3993,3994,3995,3996,3997,3998,3999,4000,4002,4004,4005,4006,4007,4008,4009,4010,4011,4012,4014,4015,4016,4017,4018,4019,4020,4022,4023,4024,4025,4026,4028,4029,4030,4032,4034,4035,4036,4037,4038,4039,4040,4041,4042,4044,4045,4046,4047,4048,4050,4051,4052,4053,4054,4055,4056,4058,4059,4060,4061,4062,4064,4065,4066,4067,4068,4070,4071,4072,4073,4074,4075,4076,4077,4078,4080,4081,4082,4083,4084,4085,4086,4088,4089,4090,4092,4093,4094,4095,4096,4098,4100,4101,4102,4104,4105,4106,4107,4108,4109,4110,4112,4113,4114,4115,4116,4118,4119,4120,4122,4123,4124,4125,4126,4127,4128,4130,4131,4132,4134,4135,4136,4137,4138,4140,4141,4142,4143,4144,4145,4146,4147,4148,4149,4150,4151,4152,4154,4155,4156,4157,4158,4159,4160,4161,4162,4164,4165,4166,4167,4168,4169,4170,4172,4173,4174,4175,4176,4178,4179,4180,4181,4182,4183,4184,4185,4186,4187,4188,4189,4190,4191,4192,4193,4194,4195,4196,4197,4198,4199,4200,4201,4202,4203,4204,4205,4206,4207,4208,4209,4210,4211,4212,4213,4214,4215,4216,4218,4220,4221,4222,4224,4225,4226,4227,4228,4229,4230,4232,4233,4234,4235,4236,4238,4239,4240,4242,4243,4244,4245,4246,4248,4249,4250,4251,4252,4254,4255,4256,4257,4258,4260,4262,4263,4264,4265,4266,4268,4269,4270,4271,4272,4273,4274,4275,4276,4277,4278,4279,4280,4281,4282,4284,4285,4286,4287,4288,4289,4290,4291,4292,4293,4294,4295,4296,4297,4298,4299,4300,4301,4302,4303,4304,4305,4306,4307,4308,4310,4311,4312,4314,4315,4316,4317,4318,4319,4320,4322,4323,4324,4325,4326,4327,4328,4329,4330,4331,4332,4333,4334,4335,4336,4337,4338,4339,4340,4341,4342,4344,4345,4346,4347,4348,4350,4352,4353,4354,4355,4356,4358,4359,4360,4361,4362,4364,4365,4366,4367,4368,4370,4371,4372,4374,4375,4376,4377,4378,4380,4381,4382,4383,4384,4385,4386,4388,4389,4390,4391,4392,4393,4394,4395,4396,4398,4399,4400,4401,4402,4403,4404,4405,4406,4407,4408,4410,4412,4413,4414,4415,4416,4417,4418,4419,4420,4422,4424,4425,4426,4428,4430,4431,4432,4433,4434,4435,4436,4437,4438,4440,4441,4442,4443,4444,4445,4446,4447,4448,4449,4450,4452,4454,4455,4456,4457,4458,4459,4460,4461,4462,4463,4464,4465,4466,4467,4468,4470,4472,4473,4474,4475,4476,4478,4479,4480,4481,4482,4484,4485,4486,4487,4488,4490,4491,4492,4493,4494,4495,4496,4497,4498,4499,4500,4501,4502,4503,4504,4505,4506,4507,4508,4509,4510,4511,4512,4514,4515,4516,4518,4519,4520,4521,4522,4524,4525,4526,4527,4528,4529,4530,4531,4532,4533,4534,4535,4536,4538,4539,4540,4542,4543,4544,4545,4546,4548,4550,4551,4552,4553,4554,4555,4556,4557,4558,4559,4560,4562,4563,4564,4565,4566,4567,4568,4569,4570,4571,4572,4573,4574,4575,4576,4578,4580,4581,4582,4583,4584,4585,4586,4587,4588,4590,4591,4592,4593,4594,4595,4596,4597,4598,4599,4600,4602,4603,4604,4605,4606,4608,4609,4610,4611,4612,4613,4614,4615,4616,4617,4618,4620,4622,4623,4624,4625,4626,4627,4628,4629,4630,4632,4634,4635,4636,4637,4638,4639,4640,4641,4642,4644,4645,4646,4647,4648,4649,4650,4652,4653,4654,4655,4656,4657,4658,4659,4660,4662,4664,4665,4666,4667,4668,4669,4670,4671,4672,4674,4675,4676,4677,4678,4680,4681,4682,4683,4684,4685,4686,4688,4689,4690,4691,4692,4694,4695,4696,4697,4698,4700,4701,4702,4703,4704,4705,4706,4707,4708,4710,4711,4712,4713,4714,4715,4716,4718,4719,4720,4721,4722,4723,4724,4725,4726,4728,4729,4730,4731,4732,4734,4735,4736,4737,4738,4739,4740,4742,4743,4744,4745,4746,4748,4749,4750,4752,4753,4754,4755,4756,4757,4758,4760,4761,4762,4764,4765,4766,4767,4768,4770,4771,4772,4773,4774,4775,4776,4777,4778,4779,4780,4781,4782,4784,4785,4786,4787,4788,4789,4790,4791,4792,4793,4794,4795,4796,4797,4798,4799,4800,4802,4803,4804,4805,4806,4808,4809,4810,4811,4812,4813,4814,4815,4816,4817,4818,4819,4820,4821,4822,4823,4824,4825,4826,4827,4828,4829,4830,4831,4832,4833,4834,4835,4836,4837,4838,4839,4840,4841,4842,4843,4844,4845,4846,4848,4849,4850,4851,4852,4854,4855,4856,4857,4858,4859,4860,4862,4863,4864,4865,4866,4868,4869,4870,4872,4873,4874,4875,4876,4878,4879,4880,4881,4882,4884,4885,4886,4887,4888,4889,4890,4892,4893,4894,4895,4896,4897,4898,4899,4900,4901,4902,4903,4904,4905,4906,4907,4908,4909,4910,4911,4912,4913,4914,4915,4916,4917,4918,4919,4920,4921,4922,4923,4924,4925,4926,4927,4928,4929,4930,4931,4932,4933,4934,4935,4936,4937,4938,4940,4941,4942,4944,4945,4946,4947,4948,4949,4950,4952,4953,4954,4955,4956,4957,4958,4959,4960,4961,4962,4963,4964,4965,4966,4967,4968,4969,4970,4971,4972,4974,4975,4976,4977,4978,4980,4982,4983,4984,4985,4986,4988,4989,4990,4991,4992,4993,4994,4995,4996,4997,4998,5000,5001,5002,5004,5005,5006,5007,5008,5010,5011,5012,5013,5014,5015,5016,5018,5019,5020,5021,5022,5023,5024,5025,5026,5028,5029,5030,5031,5032,5033,5034,5035,5036,5037,5038,5040,5042,5043,5044,5045,5046,5047,5048,5049,5050,5052,5054,5055,5056,5058,5060,5061,5062,5063,5064,5065,5066,5067,5068,5070,5071,5072,5073,5074,5075,5076,5077,5078,5079,5080,5081,5082,5084,5085,5086,5087,5088,5089,5090,5091,5092,5093,5094,5095,5096,5097,5098,5100,5102,5103,5104,5105,5106,5108,5109,5110,5111,5112,5114,5115,5116,5117,5118,5120,5121,5122,5123,5124,5125,5126,5127,5128,5129,5130,5131,5132,5133,5134,5135,5136,5137,5138,5139,5140,5141,5142,5144,5145,5146,5148,5149,5150,5151,5152,5154,5155,5156,5157,5158,5159,5160,5161,5162,5163,5164,5165,5166,5168,5169,5170,5172,5173,5174,5175,5176,5178,5180,5181,5182,5183,5184,5185,5186,5187,5188,5189,5190,5192,5193,5194,5195,5196,5197,5198,5199,5200,5201,5202,5203,5204,5205,5206,5208,5209,5210,5211,5212,5213,5214,5215,5216,5217,5218,5220,5221,5222,5223,5224,5225,5226,5227,5228,5229,5230,5232,5233,5234,5235,5236,5238,5239,5240,5241,5242,5243,5244,5245,5246,5247,5248,5250,5252,5253,5254,5255,5256,5257,5258,5259,5260,5262,5264,5265,5266,5267,5268,5269,5270,5271,5272,5274,5275,5276,5277,5278,5279,5280,5282,5283,5284,5285,5286,5287,5288,5289,5290,5292,5294,5295,5296,5297,5298,5299,5300,5301,5302,5304,5305,5306,5307,5308,5310,5311,5312,5313,5314,5315,5316,5318,5319,5320,5321,5322,5324,5325,5326,5327,5328,5330,5331,5332,5333,5334,5335,5336,5337,5338,5340,5341,5342,5343,5344,5345,5346,5348,5349,5350,5351,5352,5353,5354,5355,5356,5358,5359,5360,5361,5362,5364,5365,5366,5367,5368,5369,5370,5372,5373,5374,5375,5376,5378,5379,5380,5382,5383,5384,5385,5386,5387,5388,5390,5391,5392,5394,5395,5396,5397,5398,5400,5401,5402,5403,5404,5405,5406,5407,5408,5409,5410,5411,5412,5414,5415,5416,5417,5418,5419,5420,5421,5422,5423,5424,5425,5426,5427,5428,5429,5430,5432,5433,5434,5435,5436,5438,5439,5440,5441,5442,5443,5444,5445,5446,5447,5448,5449,5450,5451,5452,5453,5454,5455,5456,5457,5458,5459,5460,5461,5462,5463,5464,5465,5466,5467,5468,5469,5470,5471,5472,5473,5474,5475,5476,5478,5479,5480,5481,5482,5484,5485,5486,5487,5488,5489,5490,5492,5493,5494,5495,5496,5498,5499,5500,5502,5503,5504,5505,5506,5508,5509,5510,5511,5512,5514,5515,5516,5517,5518,5519,5520,5521,5522,5523,5524,5525,5526,5527,5528,5529,5530,5531,5532,5533,5534,5535,5536,5537,5538,5539,5540,5541,5542,5543,5544,5545,5546,5547,5548,5549,5550,5551,5552,5553,5554,5555,5556,5557,5558,5559,5560,5561,5562,5563,5564,5565,5566,5567,5568,5569,5570,5571,5572,5574,5575,5576,5577,5578,5579,5580,5582,5583,5584,5585,5586,5587,5588,5589,5590,5591,5592,5593,5594,5595,5596,5597,5598,5599,5600,5601,5602,5604,5605,5606,5607,5608,5609,5610,5612,5613,5614,5615,5616,5617,5618,5619,5620,5621,5622,5623,5624,5625,5626,5627,5628,5630,5631,5632,5634,5635,5636,5637,5638,5640,5641,5642,5643,5644,5645,5646,5648,5649,5650,5651,5652,5653,5654,5655,5656,5657,5658,5659,5660,5661,5662,5663,5664,5665,5666,5667,5668,5670,5672,5673,5674,5675,5676,5677,5678,5679,5680,5681,5682,5684,5685,5686,5688,5690,5691,5692,5693,5694,5695,5696,5697,5698,5700,5701,5702,5703,5704,5705,5706,5707,5708,5709,5710,5711,5712,5714,5715,5716,5717,5718,5719,5720,5721,5722,5723,5724,5725,5726,5727,5728,5729,5730,5732,5733,5734,5735,5736,5738,5739,5740,5741,5742,5744,5745,5746,5747,5748,5750,5751,5752,5753,5754,5755,5756,5757,5758,5759,5760,5761,5762,5763,5764,5765,5766,5767,5768,5769,5770,5771,5772,5774,5775,5776,5778,5779,5780,5781,5782,5784,5785,5786,5787,5788,5789,5790,5791,5792,5793,5794,5795,5796,5798,5799,5800,5802,5803,5804,5805,5806,5808,5809,5810,5811,5812,5813,5814,5815,5816,5817,5818,5819,5820,5822,5823,5824,5825,5826,5827,5828,5829,5830,5831,5832,5833,5834,5835,5836,5838,5839,5840,5841,5842,5843,5844,5845,5846,5847,5848,5850,5851,5852,5853,5854,5855,5856,5857,5858,5859,5860,5862,5863,5864,5865,5866,5868,5869,5870,5871,5872,5873,5874,5875,5876,5877,5878,5879,5880,5882,5883,5884,5885,5886,5887,5888,5889,5890,5892,5894,5895,5896,5897,5898,5899,5900,5901,5902,5904,5905,5906,5907,5908,5909,5910,5912,5913,5914,5915,5916,5917,5918,5919,5920,5922,5924,5925,5926,5927,5928,5929,5930,5931,5932,5934,5935,5936,5937,5938,5940,5941,5942,5943,5944,5945,5946,5948,5949,5950,5951,5952,5954,5955,5956,5957,5958,5960,5961,5962,5963,5964,5965,5966,5967,5968,5970,5971,5972,5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984,5985,5986,5988,5989,5990,5991,5992,5994,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004,6005,6006,6008,6009,6010,6012,6013,6014,6015,6016,6017,6018,6020,6021,6022,6024,6025,6026,6027,6028,6030,6031,6032,6033,6034,6035,6036,6037,6038,6039,6040,6041,6042,6044,6045,6046,6047,6048,6049,6050,6051,6052,6053,6054,6055,6056,6057,6058,6059,6060,6062,6063,6064,6065,6066,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6108,6109,6110,6111,6112,6113,6114,6115,6116,6117,6118,6119,6120,6122,6123,6124,6125,6126,6127,6128,6129,6130,6132,6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148,6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164,6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179,6180,6181,6182,6183,6184,6185,6186,6187,6188,6189,6190,6191,6192,6193,6194,6195,6196,6197,6198,6199,6200,6201,6202,6204,6205,6206,6207,6208,6209,6210,6212,6213,6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,6224,6225,6226,6227,6228,6229,6230,6231,6232,6234,6235,6236,6237,6238,6239,6240,6242,6243,6244,6245,6246,6247,6248,6249,6250,6251,6252,6253,6254,6255,6256,6257,6258,6260,6261,6262,6264,6265,6266,6267,6268,6270,6271,6272,6273,6274,6275,6276,6278,6279,6280,6281,6282,6283,6284,6285,6286,6287,6288,6289,6290,6291,6292,6293,6294,6295,6296,6297,6298,6300,6302,6303,6304,6305,6306,6307,6308,6309,6310,6311,6312,6313,6314,6315,6316,6318,6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6330,6331,6332,6333,6334,6335,6336,6337,6338,6339,6340,6341,6342,6344,6345,6346,6347,6348,6349,6350,6351,6352,6353,6354,6355,6356,6357,6358,6359,6360,6362,6363,6364,6365,6366,6368,6369,6370,6371,6372,6374,6375,6376,6377,6378,6380,6381,6382,6383,6384,6385,6386,6387,6388,6389,6390,6391,6392,6393,6394,6395,6396,6397,6398,6399,6400,6401,6402,6404,6405,6406,6408,6409,6410,6411,6412,6414,6415,6416,6417,6418,6419,6420,6421,6422,6423,6424,6425,6426,6428,6429,6430,6432,6433,6434,6435,6436,6438,6439,6440,6441,6442,6443,6444,6445,6446,6447,6448,6449,6450,6452,6453,6454,6455,6456,6457,6458,6459,6460,6461,6462,6463,6464,6465,6466,6468,6469,6470,6471,6472,6473,6474,6475,6476,6477,6478,6479,6480,6481,6482,6483,6484,6485,6486,6487,6488,6489,6490,6491,6492,6493,6494,6495,6496,6498,6499,6500,6501,6502,6503,6504,6505,6506,6507,6508,6510,6511,6512,6513,6514,6515,6516,6517,6518,6519,6520,6521,6522,6523,6524,6525,6526,6527,6528,6529,6530,6531,6532,6534,6535,6536,6537,6538,6539,6540,6542,6543,6544,6545,6546,6547,6548,6549,6550,6552,6554,6555,6556,6557,6558,6559,6560,6561,6562,6564,6565,6566,6567,6568,6569,6570,6571,6572,6573,6574,6575,6576,6577,6578,6579,6580,6581,6582,6584,6585,6586,6587,6588,6590,6591,6592,6593,6594,6595,6596,6597,6598,6600,6601,6602,6603,6604,6605,6606,6607,6608,6609,6610,6611,6612,6613,6614,6615,6616,6618,6619,6620,6621,6622,6624,6625,6626,6627,6628,6629,6630,6631,6632,6633,6634,6635,6636,6638,6639,6640,6641,6642,6643,6644,6645,6646,6647,6648,6649,6650,6651,6652,6654,6655,6656,6657,6658,6659,6660,6661,6662,6663,6664,6665,6666,6667,6668,6669,6670,6671,6672,6674,6675,6676,6677,6678,6679,6680,6681,6682,6683,6684,6685,6686,6687,6688,6689,6690,6692,6693,6694,6695,6696,6698,6699,6700,6701,6702,6703,6704,6705,6706,6707,6708,6709,6710,6711,6712,6713,6714,6715,6716,6717,6718,6719,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,6730,6731,6732,6733,6734,6735,6736,6738,6739,6740,6741,6742,6743,6744,6745,6746,6747,6748,6749,6750,6752,6753,6754,6755,6756,6758,6759,6760,6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6774,6775,6776,6777,6778,6779,6780,6781,6782,6783,6784,6785,6786,6787,6788,6789,6790,6791,6792,6793,6794,6795,6796,6797,6798,6799,6800,6801,6802,6803,6804,6805,6806,6807,6808,6809,6810,6811,6812,6813,6814,6815,6816,6817,6818,6819,6820,6821,6822,6823,6824,6825,6826,6827,6828,6829,6830,6831,6832,6833,6834,6835,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6846,6847,6848,6849,6850,6851,6852,6853,6854,6855,6856,6857,6858,6859,6860,6861,6862,6863,6864,6865,6866,6867,6868,6869,6870,6872,6873,6874,6875,6876,6877,6878,6879,6880,6881,6882,6883,6884,6885,6886,6887,6888,6890,6891,6892,6894,6895,6896,6897,6898,6899,6900,6901,6902,6903,6904,6905,6906,6908,6909,6910,6911,6912,6913,6914,6915,6916,6917,6918,6919,6920,6921,6922,6923,6924,6925,6926,6927,6928,6929,6930,6932,6933,6934,6935,6936,6937,6938,6939,6940,6941,6942,6943,6944,6945,6946,6948,6950,6951,6952,6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966,6967,6968,6969,6970,6971,6972,6974,6975,6976,6977,6978,6979,6980,6981,6982,6983,6984,6985,6986,6987,6988,6989,6990,6991,6992,6993,6994,6995,6996,6998,6999,7000,7001,7002,7004,7005,7006,7007,7008,7010,7011,7012,7013,7014,7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027,7028,7029,7030,7031,7032,7033,7034,7035,7036,7038,7039,7040,7041,7042,7043,7044,7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7058,7059,7060,7062,7063,7064,7065,7066,7068,7069,7070,7071,7072,7073,7074,7075,7076,7077,7078,7079,7080,7081,7082,7083,7084,7085,7086,7087,7088,7089,7090,7091,7092,7093,7094,7095,7096,7097,7098,7099,7100,7101,7102,7103,7104,7105,7106,7107,7108,7110,7111,7112,7113,7114,7115,7116,7117,7118,7119,7120,7122,7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,7135,7136,7137,7138,7139,7140,7142,7143,7144,7145,7146,7147,7148,7149,7150,7151,7152,7153,7154,7155,7156,7157,7158,7159,7160,7161,7162,7163,7164,7165,7166,7167,7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7182,7183,7184,7185,7186,7187,7188,7189,7190,7191,7192,7193,7194,7195,7196,7197,7198,7199,7200,7201,7202,7203,7204,7205,7206,7207,7208,7209,7210,7211,7212,7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7224,7225,7226,7227,7228,7230,7231,7232,7233,7234,7235,7236,7237,7238,7239,7240,7241,7242,7243,7244,7245,7246,7247,7248,7249,7250,7251,7252,7254,7255,7256,7257,7258,7259,7260,7261,7262,7263,7264,7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277,7278,7279,7280,7281,7282,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293,7294,7295,7296,7297,7298,7299,7300,7301,7302,7303,7304,7305,7306,7307,7308,7309,7310,7311,7312,7313,7314,7315,7316,7317,7318,7319,7320,7322,7323,7324,7325,7326,7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339,7340,7341,7342,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,7354,7355,7356,7357,7358,7359,7360,7361,7362,7363,7364,7365,7366,7368,7369,7370,7371,7372,7373,7374,7375,7376,7377,7378,7379,7380,7382,7383,7384,7385,7386,7387,7388,7389,7390,7392,7393,7394,7395,7396,7397,7398,7399,7400,7401,7402,7403,7404,7405,7406,7407,7408,7409,7410,7411,7412,7413,7414,7415,7416,7417,7418,7419,7420,7421,7422,7423,7424,7425,7426,7427,7428,7429,7430,7431,7432,7433,7434,7435,7436,7437,7438,7439,7440,7441,7442,7443,7444,7445,7446,7447,7448,7449,7450,7451,7452,7453,7454,7455,7456,7457,7458,7459,7460,7461,7462,7463,7464,7465,7466,7467,7468,7469,7470,7471,7472,7473,7474,7475,7476,7477,7478,7479,7480,7481,7482,7483,7484,7485,7486,7487,7488,7489,7490,7491,7492,7494,7495,7496,7497,7498,7499,7500,7502,7503,7504,7505,7506,7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7520,7521,7522,7523,7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537,7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,7550,7551,7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567,7568,7569,7570,7571,7572,7573,7574,7575,7576,7578,7579,7580,7581,7582,7583,7584,7585,7586,7587,7588,7590,7591,7592,7593,7594,7595,7596,7597,7598,7599,7600,7601,7602,7604,7605,7606,7607,7608,7609,7610,7611,7612,7613,7614,7615,7616,7617,7618,7619,7620,7621,7622,7623,7624,7625,7626,7628,7629,7630,7631,7632,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659,7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,7671,7672,7674,7675,7676,7677,7678,7679,7680,7681,7682,7683,7684,7685,7686,7688,7689,7690,7692,7693,7694,7695,7696,7697,7698,7699,7700,7701,7702,7703,7704,7705,7706,7707,7708,7709,7710,7711,7712,7713,7714,7715,7716,7717,7718,7719,7720,7721,7722,7723,7724,7725,7726,7727,7728,7729,7730,7731,7732,7733,7734,7735,7736,7737,7738,7740,7741,7742,7743,7744,7745,7746,7747,7748,7749,7750,7751,7752,7753,7754,7755,7756,7758,7759,7760,7761,7762,7763,7764,7765,7766,7767,7768,7770,7772,7773,7774,7775,7776,7777,7778,7779,7780,7781,7782,7783,7784,7785,7786,7787,7788,7789,7790,7791,7792,7793,7794,7795,7796,7797,7798,7799,7800,7802,7803,7804,7805,7806,7807,7808,7809,7810,7811,7812] 2 | r_num = [[7814, 7848], [7850, 7858], [7860, 7876], [7878, 7882], [7884, 7932], [7934, 8010], [8012, 8020], [8022, 8122], [8124, 8148], [8150, 8158], [8160, 8190], [8192, 8218], [8220, 8250], [8252, 8268], [8270, 8302], [8304, 8316], [8318, 8400], [8402, 8430], [8432, 8440], [8444, 8472], [8474, 8580], [8582, 8586], [8588, 8626], [8628, 8650], [8652, 8662], [8664, 8836], [8840, 8886], [8888, 8922], [8924, 8932], [8934, 8950], [8952, 8956], [8958, 9016], [9018, 9060], [9062, 9070], [9074, 9108], [9110, 9136], [9138, 9210], [9212, 9390], [9392, 9418], [9420, 9466], [9468, 9516], [9518, 9586], [9588, 9616], [9618, 9700], [9702, 9732], [9734, 10330], [10332, 10362], [10364, 10470], [10472, 10540], [10542, 10678], [10680, 10950], [10952, 10992], [10994, 11590], [11592, 11800], [11802, 12012], [12014, 12360], [12362, 12406], [12408, 12568], [12570, 12618], [12620, 12730], [12732, 12850], [12852, 13036], [13038, 13296], [13298, 13308], [13310, 13620], [13622, 13828], [13830, 13878], [13880, 14142], [14144, 14250], [14252, 14296], [14298, 15370], [15372, 15556], [15558, 16186], [16188, 17260], [17262, 17890], [17892, 18436], [18438, 19066],[19068,20160]] 3 | for i in xrange(input()): 4 | n = input() 5 | if n>20161: 6 | print "YES" 7 | else: 8 | if n in num: 9 | print 'YES' 10 | else: 11 | c = 0 12 | for j in xrange(len(r_num)): 13 | if n>=r_num[j][0] and n<= r_num[j][1]: 14 | c = 1 15 | print 'YES' 16 | break 17 | if c == 0: 18 | print 'NO' -------------------------------------------------------------------------------- /ProjectEuler+/p16.py: -------------------------------------------------------------------------------- 1 | a = [1319,1378,1424,1408,1412,1429,1373,1378,1343,1327,1376,1384,1355,1405,1388,1336,1322,1303,1319,1342,1370,1372,1394,1375,1427,1423,1451,1399,1340,1312,1373,1378,1352,1417,1421,1375,1400,1414,1415,1408,1448,1420,1337,1396,1424,1426,1394,1420,1391,1423,1451,1453,1475,1429,1382,1432,1397,1462,1457,1420,1445,1459,1379,1372,1394,1429,1508,1450,1415,1426,1502,1528,1472,1432,1451,1507,1538,1537,1589,1522,1451,1498,1511,1465,1454,1513,1505,1525,1493,1492,1535,1576,1505,1471,1466,1447,1508,1504,1523,1561,1565,1465,1526,1558,1487,1507,1520,1438,1436,1468,1487,1489,1448,1465,1508,1495,1424,1471,1430,1393,1490,1495,1487,1489,1466,1510,1499,1486,1514,1597,1592,1591,1580,1477,1550,1507,1520,1519,1517,1567,1559,1543,1619,1600,1607,1567,1559,1525,1493,1564,1580,1576,1586,1651,1700,1582,1616,1603,1622,1597,1547,1474,1454,1459,1514,1615,1637,1609,1517,1522,1496,1597,1745,1681,1526,1522,1586,1615,1655,1582,1526,1540,1622,1687,1637,1564,1607,1612,1613,1633,1682,1681,1580,1585,1631,1606,1637,1627,1706,1729,1658,1723,1691,1663,1607,1567,1631,1714,1682,1708,1742,1693,1658,1642,1673,1600,1607,1621,1550,1543,1601,1573,1733,1738,1730,1705,1646,1582,1535,1711,1703,1678,1637,1636,1679,1693,1811,1804,1862,1771,1751,1729,1748,1705,1709,1699,1715,1693,1766,1732,1709,1744,1706,1720,1622,1507,1538,1654,1751,1666,1676,1669,1718,1780,1814,1819,1838,1786,1736,1735,1724,1630,1649,1687,1709,1645,1634,1603,1676,1723,1763,1816,1796,1657,1703,1768,1718,1771,1751,1738,1694,1759,1754,1843,1787,1693,1667,1768,1754,1816,1796,1783,1748,1759,1808,1762,1760,1801,1730,1732,1763,1780,1760,1819,1721,1651,1655,1762,1832,1801,1739,1750,1754,1717,1787,1810,1829,1831,1763,1816,1841,1819,1829,1840,1862,1825,1805,1810,1820,1795,1853,1843,1850,1873,1865,1831,1835,1834,1841,1846,1865,1795,1817,1843,1850,1810,1784,1786,1880,1879,1841,1801,1811,1912,1871,1906,1850,1864,1919,1957,1943,1924,1868,1927,1883,1867,1889,1924,1949,1927,1928,1912,1961,1987,1895,1954,1973,1930,1880,1933,1823,1882,1964,2011,1961,1969,1958,1837,1919,1975,1997,1996,1985,1963,1946,1885,1979,1978,1967,1918,1937,1894,1934,1951,1985,1927,1910,1921,1925,1924,1886,1891,1802,1948,1880,1906,1895,1882,1910,1948,1934,1987,1886,1837,1928,1957,1979,2014,1904,1900,1901,1912,1871,1888,1976,1954,2018,2011,2051,2113,2039,1990,1955,1993,1988,2032,2039,2035,1973,1957,1988,2005,1940,1945,1982,1903,1916,1942,2021,1999,1946,2029,2006,1987,1976,1990,1991,1993,2006,2104,2129,2053,1964,1984,1925,1969,2039,1990,2018,1993,1898,1915,1940,1927,1955,1975,1970,2059,2057,2035,2018,1939,1988,2014,2012,1963,1928,1975,2096,2122,1985,1972,2027,2065,2033,2005,2048,1972,2009,1984,2033,2068,2048,2017,2063,2155,2096,2104,2084,2017,2081,2128,2069,2086,2102,2116,2090,2065,2078,2059,2012,2017,2036,2038,2087,2194,2129,2098,2117,2155,2204,2158,2075,2152,2144,2164,2150,2023,2066,2125,2144,2038,2024,2068,2093,2116,2090,2047,2150,2167,2111,2161,2144,2155,2177,2158,2111,2071,2045,2119,2078,2140,2147,2188,2180,2191,2204,2113,2120,2098,2126,2119,2231,2167,2174,2188,2081,2092,2150,2176,2147,2224,2126,2101,2114,2131,2174,2179,2162,2209,2222,2230,2201,2188,2216,2236,2222,2275,2372,2359,2405,2326,2276,2167,2102,2125,2144,2182,2186,2167,2228,2233,2207,2191,2258,2266,2309,2260,2180,2173,2141,2131,2120,2188,2261,2263,2258,2257,2165,2098,2117,2164,2132,2176,2174,2278,2198,2209,2186,2257,2156,2215,2252,2290,2348,2311,2228,2287,2342,2263,2204,2266,2327,2341,2306,2245,2258,2275,2354,2278,2333,2353,2321,2338,2273,2233,2243,2236,2258,2266,2264,2242,2234,2263,2267,2365,2282,2314,2315,2308,2249,2230,2210,2215,2279,2281,2195,2248,2309,2296,2279,2362,2294,2311,2291,2287,2360,2245,2303,2320,2309,2323,2369,2380,2357,2437,2480,2431,2387,2326,2276,2347,2282,2260,2243,2290,2384,2392,2372,2377,2369,2254,2276,2338,2399,2386,2306,2299,2258,2473,2444,2386,2279,2173,2258,2338,2372,2404,2360,2407,2429,2365,2381,2386,2396,2398,2474,2410,2462,2449,2405,2425,2429,2419,2426,2395,2405,2416,2501,2491,2426,2404,2252,2326,2321,2383,2462,2413,2441,2542,2582,2662,2597,2485,2432,2452,2411,2401,2435,2467,2477,2488,2456,2455,2426,2512,2459,2362,2393,2437,2417,2494,2513,2461,2465,2482,2453,2413,2459,2461,2546,2536,2444,2413,2531,2506,2510,2545,2516,2521,2594,2659,2609,2563,2453,2386,2459,2524,2555,2482,2345,2341,2477,2569,2474,2473,2426,2413,2495,2533,2564,2545,2507,2458,2468,2380,2393,2437,2462,2413,2405,2425,2384,2446,2579,2611,2486,2551,2555,2581,2588,2575,2495,2524,2402,2464,2453,2494,2468,2515,2447,2401,2507,2539,2567,2605,2573,2608,2624,2539,2594,2488,2510,2446,2471,2494,2558,2551,2555,2581,2615,2620,2693,2695,2690,2680,2651,2656,2756,2731,2582,2518,2498,2602,2657,2587,2564,2626,2687,2701,2621,2596,2618,2572,2534,2566,2558,2560,2645,2545,2561,2620,2594,2641,2663,2599,2624,2602,2693,2749,2690,2725,2732,2782,2648,2695,2645,2617,2615,2566,2675,2632,2654,2716,2678,2665,2711,2731,2744,2725,2714,2692,2711,2731,2726,2770,2750,2710,2675,2659,2663,2725,2669,2647,2612,2614,2627,2689,2750,2755,2738,2722,2708,2680,2669,2656,2648,2722,2789,2635,2669,2782,2666,2578,2537,2563,2588,2611,2612,2704,2708,2626,2516,2557,2711,2695,2690,2716,2777,2818,2738,2767,2690,2680,2687,2656,2630,2677,2762,2788,2768,2755,2792,2740,2600,2572,2660,2728,2801,2803,2771,2788,2777,2710,2765,2812,2780,2707,2759,2746,2675,2623,2663,2716,2795,2791,2792,2740,2663,2734,2840,2800,2783,2830,2870,2887,2822,2746,2756,2848,2789,2824,2894,2899,2738,2776,2672,2734,2732,2755,2792,2911,2960,2959,2903,2917,2864,2812,2717,2815,2831,2836,2774,2821,2834,2770,2822,2782,2783,2875,2870,2950,2966,2863,2819,2803,2816,2842,2930,2917,2945,2992,2888,2815,2858,2890,2846,2830,2834,2914,2903,2917,2900,2920,2960,2923,2867,2764,2720,2722,2735,2779,2777,2782,2891,2929,2969,2887,2786,2791,2837,2902,2879,2887,2867,2827,2846,2857,2798,2797,2831,2755,2864,2893,2924,2869,2759,2782,2819,2839,2807,2833,2894,2989,3053,3001,2987,2842,2849,2863,2954,2965,2987,3004,2903,2782,2855,2947,2897,2923,2984,3070,3089,3127,3050,3049,2957,2926,2927,2938,2978,2950,2876,2953,2999,2974,2879,2815,2948,2917,2981,3064,2969,2860,2930,2944,2900,2857,2879,2923,2903,2980,3107,3181,3113,3058,2966,3043,3026,3037,3050,3031,2939,3007,2981,2983,2987,2986,3002,3043,2936,2830,2861,2896,2876,2854,2909,2956,2897,2959,2876,2926,3053,3109,3059,3031,3074,3106,3026,3064,3113,3139,3164,3115,3008,3001,3095,2986,3128,3160,3098,3100,3059,3103,3182,3241,3143,3064,3059,3067,2984,3043,3098,3010,3077,3130,3083,3106,3053,3082,3068,3112,3083,2989,3062,3091,3068,3076,3038,3079,3107,3109,3140,3139,3191,3196,3269,3190,3311,3211,3200,3151,3098,3217,3239,3202,3182,3160,3107,3064,3077,3040,3092,3160,3080,3037,2978,3085,3038,3160,3080,3136,3185,3202,3290,3196,3125,3190,3167,3202,3182,3214,3188,3172,3068,3049,3020,3052,3098,3100,3212,3220,3101,3070,3098,3091,3149,3040,3137,3106,3062,3172,3149,3139,3164,3205,3224,3172,3230,3202,3227,3223,3251,3199,3131,3220,3155,3241,3188,3226,3131,3112,3056,3115,3188,3181,3176,3193,3119,3133,3107,3181,3257,3346,3317,3277,3278,3280,3230,3328,3308,3304,3206,3172,3194,3220,3227,3214,3242,3298,3275,3337,3326,3214,3143,3127,3167,3175,3263,3178,3206,3163,3239,3193,3317,3322,3341,3370,3338,3409,3272,3277,3350,3361,3338,3310,3290,3349,3359,3316,3266,3211,3299,3277,3296,3388,3410,3454,3389,3412,3368,3262,3257,3319,3317,3394,3260,3199,3266,3310,3317,3340,3386,3334,3284,3328,3335,3295,3260,3316,3275,3328,3290,3241,3314,3325,3374,3400,3497,3367,3296,3289,3275,3283,3209,3313,3323,3325,3347,3382,3335,3385,3386,3469,3464,3337,3263,3196,3170,3226,3302,3346,3389,3322,3323,3415,3383,3337,3407,3421,3377,3388,3392,3445,3479,3475,3458,3406,3419,3445,3380,3376,3332,3316,3392,3328,3389,3421,3413,3415,3329,3310,3281,3376,3458,3370,3293,3265,3389,3421,3314,3316,3212,3265,3398,3295,3278,3343,3329,3301,3353,3403,3458,3469,3464,3409,3479,3493,3584,3397,3473,3472,3533,3448,3512,3541,3554,3517,3452,3322,3359,3451,3545,3445,3461,3493,3548,3586,3599,3463,3452,3520,3602,3586,3536,3553,3434,3421,3431,3415,3392,3553,3434,3430,3413,3487,3473,3391,3479,3637,3665,3640,3572,3553,3542,3700,3692,3595,3554,3454,3560,3574,3359,3415,3464,3517,3587,3637,3575,3595,3509,3625,3632,3691,3629,3613,3743,3706,3695,3691,3575,3604,3617,3688,3623,3664,3593,3586,3518,3553,3407,3520,3557,3631,3599,3544,3641,3700,3701,3721,3662,3562,3461,3439,3467,3505,3680,3616,3506,3421,3512,3505,3572,3571,3605,3529,3611,3595,3455,3400,3533,3556,3701,3694,3761,3679,3686,3646,3620,3559,3644,3526,3461,3547,3629,3658,3626,3688,3713,3682,3710,3739,3680,3742,3722,3664,3539,3487,3500,3553,3542,3664,3656,3559,3554,3553,3551,3520,3548,3559,3644,3670,3668,3646,3719,3703,3707,3715,3596,3691,3593,3586,3608,3544,3650,3664,3557,3559,3608,3634,3686,3619,3611,3568,3590,3634,3632,3682,3602,3604,3662,3769,3776,3709,3710,3739,3725,3742,3839,3799,3728,3685,3707,3715,3758,3700,3647,3730,3725,3661,3497,3592,3683,3613,3635,3697,3641,3592,3692,3712,3653,3697,3731,3673,3683,3649,3644,3670,3569,3619,3611,3712,3743,3760,3686,3790,3899,3793,3770,3823,3857,3808,3755,3712,3599,3625,3731,3520,3692,3730,3824,3841,3839,3781,3809,3766,3770,3778,3803,3880,3863,3973,3941,3814,3722,3727,3791,3865,3896,3931,3794,3871,3800,3766,3869,3913,3830,3853,3845,3694,3707,3670,3650,3754,3755,3730,3824,3778,3785,3916,3701,3730,3716,3769,3758,3808,3854,3856,3878,4012,3974,3898,3953,4027,3950,3895,3893,3943,3863,3784,3725,3733,3803,3826,3836,3928,3968,3931,3884,3952,3881,4009,3977,3877,3866,3835,3800,3901,4031,3949,4001,3925,3917,3757,3824,3940,3893,3952,3908,3892,3851,3922,3794,3817,3791,3991,3824,3877,3956,3871,3791,3811,3887,3931,3929,4078,4088,3991,3887,3850,3974,3952,3908,3946,3959,3850,3902,3853,3773,3802,3869,3886,3965,3943,3917,3964,3851,3949,3929,3853,3764,3784,3896,3958,3956,4114,4070,4027,4067,3985,3956,3943,3971,3982,3968,3895,3893,3844,3971,4000,3914,3904,3875,3889,3737,3748,3896,3922,3965,4015,3998,3991,3968,3877,3974,4024,3962,3955,3923,3967,3956,3934,4007,3937,4040,4066,4019,3943,3953,3991,3986,4138,4028,3934,3935,3937,3860,3868,3929,3997,3962,4234,4247,4084,4172,4195,4133,4108,4103,4012,4145,4015,3989,3991,4076,4084,4010,4087,4160,4045,3968,4084,4109,4114,3917,3892,3977,3940,3884,3871,3944,4036,4139,4237,4127,4078,4070,4072,4166,4093,4208,4240,4304,4261,4265,4192,4118,4159,4304,4261,4148,4129,4118,4204,4115,4144,4103,4084,4091,4087,4124,3964,3995,4057,4019,4015,4106,4009,4085,4183,4235,4096,4124,4081,4013,4048,4037,4159,4178,4198,4166,4156,4163,4204,4196,4207,4319,4237,4118,3988,4025,4009,4067,4309,4262,4159,4187,4153,4139,4120,4217,4105,4070,4144,4157,4138,4082,4123,4070,4090,4067,4147,4073,3979,4106,4144,4238,4291,4352,4339,4367,4342,4193,4174,4199,4069,3953,4117,4103,4228,4190,4294,4268,4198,4283,4201,4289,4393,4304,4288,4238,4255,4280,4303,4187,4189,4238,4282,4253,4231,4259,4180,4193,4210,4172,4087,4016,4054,4166,4201,4298,4249,4142,4252,4274,4246,4262,4249,4232,4162,4274,4219,4217,4213,4340,4405,4328,4336,4316,4366,4232,4279,4256,4219,4172,4204,4214,4324,4346,4435,4442,4366,4115,4126,4157,4219,4208,4267,4340,4288,4364,4264,4181,4123,4259,4153,4301,4246,4145,4114,4322,4252,4265,4336,4298,4303,4277,4108,4193,4372,4424,4357,4268,4261,4283,4354,4253,4285,4277,4270,4364,4309,4199,4240,4250,4243,4427,4417,4442,4402,4439,4261,4301,4219,4298,4240,4259,4297,4355,4372,4388,4402,4268,4234,4355,4309,4460,4402,4268,4288,4301,4273,4298,4258,4313,4369,4436,4372,4289,4357,4430,4495,4409,4543,4595,4591,4430,4414,4418,4435,4424,4393,4466,4414,4463,4399,4334,4348,4511,4531,4472,4453,4388,4474,4430,4342,4328,4291,4316,4357,4457,4477,4490,4426,4415,4402,4403,4504,4517,4507,4361,4420,4457,4486,4454,4471,4451,4519,4430,4351,4427,4525,4514,4483,4529,4477,4490,4516,4361,4357,4331,4360,4364,4327,4397,4573,4493,4558,4454,4444,4316,4249,4358,4396,4391,4336,4352,4519,4484,4504,4508,4498,4577,4591,4484,4468,4382,4282,4289,4393,4511,4657,4607,4516,4631,4627,4466,4495,4553,4534,4577,4555,4682,4702,4598,4552,4550,4528,4466,4486,4364,4354,4451,4546,4592,4522,4391,4363,4352,4510,4655,4675,4607,4543,4559,4456,4421,4459,4436,4417,4469,4474,4574,4513,4544,4408,4415,4402,4466,4459,4454,4453,4568,4654,4583,4522,4481,4453,4415,4438,4475,4558,4616,4669,4640,4717,4655,4621,4562,4642,4577,4627,4781,4828,4670,4651,4658,4555,4601,4495,4670,4669,4577,4627,4700,4666,4517,4525,4523,4483,4493,4612,4625,4570,4568,4573,4547,4621,4715,4669,4712,4879,4763,4720,4508,4480,4541,4609,4538,4504,4706,4741,4748,4744,4736,4693,4697,4678,4667,4744,4673,4729,4670,4741,4820,4681,4799,4801,4670,4696,4631,4609,4736,4702,4634,4669,4820,4699,4736,4684,4661,4606,4640,4735,4781,4855,4877,4948,4847,4744,4646,4648,4679,4705,4811,4690,4547,4657,4643,4786,4766,4798,4691,4612,4823,4768,4685,4663,4808,4810,4688,4777,4892,4843,4835,4864,4670,4678,4694,4627,4655,4729,4805,4741,4640,4627,4727,4756,4841,4966,4910,4852,4889,4792,4697,4840,4721,4798,4808,4684,4706,4840,4739,4672,4709,4702,4733,4804,4973,5041,4826,4738,4778,4849,4865,4870,4862,4864,4742,4777,4892,4960,4880,4927,4877,4750,4883,4789,4709,4747,4913,4822,4955,4888,4826,4801,4886,4867,4748,4834,4934,4918,4841,4912,4937,4825,4826,4738,4814,4840,4883,4942,4889,4864,4832,4777,4793,4789,4835,4855,4769,4840,4937,4996,4898,4855,4832,4849,4847,4960,5024,4945,4913,4993,5108,5068,5015,4981,4787,4867,4829,4978,4925,5044,5066,4966,4892,4744,4907,4936,4922,4939,4937,4942,5087,5098,5039,4903,4829,4825,4943,4855,4913,4921,4802,4807,4934,4855,4904,4894,4946,4924,5033,5026,4940,4984,4937,5041,5060,5089,4967,5038,5027,4924,4853,4783,4805,4957,4883,4888,4880,4972,5030,5020,4856,4825,4817,4918,4859,4921,4901,4924,4952,4972,4922,4948,4937,4816,4889,4864,4913,4993,5027,5113,5033,5125,5030,5182,5090,5023,4862,4882,5075,5002,4901,4735,4907,5089,5057,5155,4955,4888,5042,4909,4922,5011,4955,4942,5015,5062,5057,5002,4946,5014,5132,5098,5147,5200,5225,5104,4988,5008,5183,5173,5207,5113,5087,5008,4976,5065,5072,5113,5195,5125,5030,5083,5045,5068,5159,5035,4967,4966,5009,5041,4979,5035,5030,5020,4973,5041,5006,4954,4940,5074,4973,4969,5096,5008,5192,5254,5135,5185,5168,5269,5309,5182,5099,5050,5033,5035,5048,5029,5063,5041,4997,5206,5066,5092,5054,5023,5006,5152,5300,5254,5216,5203,5141,5071,5057,4957,4991,5086,5123,5143,5273,5110,5243,5095,5015,5134,5219,5191,5171,5104,5123,5233,5282,5254,5180,5149,5177,5143,5048,5056,4946,5041,5159,5233,4958,4939,5018,5167,5168,5116,5111,5200,5162,5086,5024,5197,5039,5038,5216,5221,5294,5179,5165,5155,5072,5068,5069,5179,5309,5236,5270,5284,5303,5467,5318,5272,5234,5158,5087,4981,5093,5137,5198,5095,5159,5143,5192,5272,5108,5239,5222,5332,5354,5254,5405,5320,5213,5305,5417,5254,5216,5284,5213,5251,5273,5245,5144,5275,5267,5296,5273,5416,5432,5356,5348,5242,5228,5209,5315,5203,5321,5368,5300,5299,5279,5410,5330,5233,5318,5290,5117,5266,5159,5242,5246,5452,5369,5239,5168,5260,5336,5200,5252,5221,5285,5242,5174,5344,5252,5203,5222,5404,5318,5227,5306,5284,5438,5467,5507,5506,5369,5176,5033,5233,5381,5434,5405,5266,5429,5521,5390,5236,5414,5347,5348,5485,5426,5434,5405,5437,5267,5170,5318,5317,5342,5311,5375,5467,5426,5488,5648,5608,5537,5512,5381,5461,5486,5509,5672,5611,5435,5380,5315,5293,5447,5467,5327,5380,5405,5428,5348,5260,5219,5218,5342,5239,5303,5224,5309,5407,5585,5347,5240,5188,5264,5407,5396,5419,5312,5260,5264,5380,5495,5563,5375,5323,5309,5389,5288,5383,5348,5395,5516,5524,5360,5257,5267,5287,5489,5398,5396,5320,5348,5332,5327,5362,5324,5338,5366,5368,5489,5524,5621,5563,5528,5674,5714,5533,5450,5563,5519,5485,5543,5560,5621,5572,5420,5413,5372,5389,5549,5626,5555,5404,5345,5506,5531,5491,5492,5485,5435,5497,5522,5536,5573,5494,5588,5596,5684,5446,5420,5575,5507,5578,5540,5473,5510,5593,5597,5569,5531,5608,5627,5629,5579,5578,5567,5563,5510,5755,5660,5623,5702,5581,5564,5476,5588,5551,5630,5644,5753,5665,5633,5650,5612,5590,5636,5575,5543,5578,5558,5545,5438,5512,5579,5668,5801,5806,5762,5566,5525,5578,5594,5608,5555,5485,5651,5785,5612,5644,5582,5584,5534,5641,5666,5644,5690,5737,5687,5587,5585,5527,5555,5593,5588,5533,5540,5572,5618,5575,5624,5542,5594,5626,5663,5638,5660,5650,5693,5752,5717,5683,5678,5623,5774,5797,5789,5818,5831,5848,5783,5869,5600,5827,5858,5803,5693,5698,5591,5611,5516,5686,5774,5680,5591,5674,5642,5695,5693,5680,5663,5710,5669,5641,5585,5545,5735,5692,5714,5704,5819,5761,5537,5539,5633,5677,5648,5662,5672,5647,5696,5677,5675,5716,5816,5773,5750,5695,5702,5824,5933,5818,5705,5659,5729,5644,5771,5854,5867,5839,5837,5824,5771,5602,5633,5650,5621,5725,5681,5737,5687,5740,5630,5734,5780,5746,5831,5812,5756,5689,5735,5719,5660,5650,5567,5644,5645,5692,5732,5641,5747,5644,5627,5674,5615,5596,5648,5635,5708,5701,5696,5623,5657,5779,5744,5800,5822,5947,6035,5851,5852,5890,5867,5866,5936,5851,5852,5818,5831,5857,5864,5851,5717,5800,5822,5983,5981,5887,5816,5656,5525,5776,5756,5743,5708,5755,5696,5821,5873,5887,5861,5917,5912,5848,5783,5725,5771,5917,5858,5920,6053,6022,5915,5917,5921,5857,6026,6013,5906,5809,5858,5893,5891,5959,6032,5998,5957,5938,5909,5878,5825,5881,5867,5776,5909,5887,5906,5764,5705,5821,5837,5932,5825,5899,5894,5893,6035,6031,5969,5899,5948,5938,5990,6058,5942,5962,5957,5902,5846,5995,5951,6115,6038,5956,5981,5959,5897,5971,6047,6064,5963,6058,6041,6070,5930,6010,6098,6004,6050,6016,6020,5857,5927,6076,5996,5926,5858,5866,5873,5752,5825,5854,5903,5974,5945,5950,5978,6016,6011,5974,5972,5923,5942,5926,6011,5830,5846,5842,5951,5926,5831,5812,5819,5896,5960,5953,5975,5884,5981,6094,6140,5962,5939,6064,6161,6031,6194,6241,6164,6280,6269,6193,6032,5962,6074,6010,6107,5995,6077,6187,6137,6118,6071,6058,5960,5962,5957,6010,5882,5878,5924,5926,5993,6154,6044,5959,6023,6034,6029,6109,5963,6049,6158,6277,6101,6118,6062,6103,6059,6007,6092,6127,5981,6229,6284,6277,6173,6082,5999,6040,6095,6133,6146,6037,6062,6184,6230,6097,6083,6208,6206,6265,6104,6106,6182,6262,6098,6067,6032,6142,6110,5956,6116,5977,5987,6043,6146,6190,6251,6274,6158,6304,6308,6361,6125,6112,5897,5926,5966,6010,6026,6130,6185,6151,6281,6109,6062,6049,6068,6187,6029,6001,5972,5905,6059,6115,6056,6127,6170,5977,6023,6043,6011,6082,6062,6148,6221,6259,6164,6118,6080,5995,6104,6025,6029,6172,6251,6247,6158,6277,6407,6262,6098,6238,6149,6367,6317,6307,6251,6247,6338,6232,6173,6199,6143,6112,6158,6295,6290,6307,6224,6148,6086,6088,6110,6298,6287,6310,6230,6178,6209,6127,6116,6040,6185,6286,6380,6217,6386,6391,6374,6358,6317,6541,6638,6490,6374,6259,6443,6316,6395,6427,6401,6304,6245,6388,6314,6400,6302,6430,6380,6388,6413,6454,6419,6430,6389,6343,6170,6265,6248,6295,6326,6316,6215,6157,6131,6142,6263,6298,6296,6157,6338,6286,6209,6307,6233,6166,6212,6160,6110,6271,6341,6229,6194,6466,6371,6352,6278,6301,6527,6241,6236,6298,6440,6472,6374,6403,6371,6406,6332,6166,6185,6313,6362,6424,6350,6346,6302,6421,6524,6460,6350,6301,6194,6250,6290,6325,6413,6445,6437,6403,6515,6640,6566,6553,6338,6331,6254,6235,6215,6301,6410,6421,6362,6226,6260,6373,6266,6331,6263,6244,6359,6391,6509,6493,6452,6316,6260,6166,6356,6277,6371,6523,6503,6454,6491,6421,6452,6379,6413,6373,6365,6295,6299,6388,6404,6382,6338,6349,6380,6325,6251,6193,6194,6295,6173,6217,6377,6337,6410,6538,6497,6505,6494,6472,6455,6376,6290,6397,6575,6616,6671,6448,6407,6586,6422,6283,6284,6403,6434,6505,6512,6454,6464,6466,6434,6532,6638,6589,6572,6655,6731,6640,6449,6373,6464,6457,6506,6433,6512,6391,6410,6457,6479,6559,6656,6616,6644,6547,6452,6415,6584,6805,6770,6664,6677,6559,6638,6544,6608,6637,6488,6397,6521,6526,6590,6664,6425,6307,6377,6535,6599,6799,6704,6703,6557,6643,6536,6493,6524,6568,6548,6463,6410,6493,6515,6640,6557,6571,6500,6520,6524,6505,6476,6472,6653,6628,6623,6523,6485,6697,6590,6691,6713,6757,6809,6769,6572,6682,6551,6640,6701,6679,6617,6457,6398,6613,6575,6616,6491,6493,6596,6667,6539,6391,6518,6574,6587,6622,6566,6526,6500,6592,6803,6811,6791,6589,6608,6565,6533,6568,6683,6661,6635,6700,6848,6883,6863,6832,6941,6808,6731,6604,6710,6868,6896,6835,6812,6838,6719,6634,6725,6646,6596,6676,6647,6535,6653,6619,6605,6676,6755,6859,6770,6574,6623,6622,6728,6697,6599,6619,6713,6721,6755,6751,6662,6709,6758,6685,6737,6778,6905,6871,6866,6766,6620,6688,6752,6763,6794,6802,6908,6823,6743,6754,6803,6820,6908,6904,7013,7024,6929,6856,6746,6688,6653,6709,6794,6802,6692,6679,6680,6799,6722,6802,6827,6805,6716,6637,6650,6685,6836,6823,6833,6790,6830,6784,6800,6823,6860,6844,6857,6847,6809,6787,6779,6763,6650,6730,6728,6697,6725,6727,6731,6784,6800,6787,6824,6988,7037,6955,6971,6985,6896,6718,6776,6820,6764,6805,6752,6826,6920,6784,6836,6742,6860,6817,6821,6784,6935,6868,6770,6781,6857,6955,6800,6823,6797,6763,6920,7036,6935,6940,6923,6943,6911,6874,6809,6958,6815,6808,6812,6919,6782,6976,6887,7006,7037,7027,6908,6787,6797,6889,6875,6820,6728,6625,6662,6781,6920,6973,6908,6931,6941,6988,6866,6982,7034,6994,7013,7006,6956,6847,6665,6697,6833,6808,6794,6937,6917,6814,6986,7069,7055,6982,6953,7021,6914,6925,6938,6892,6881,6850,6878,6997,7082,7063,6971,6724,6725,6727,6812,6865,6872,6922,6923,6889,7037,7000,7106,6976,6977,6952,6938,7027,6962,6823,6842,6835,6956,6937,6908,6823,6716,6727,6848,6973,6944,6823,6896,7177,7226,7072,7223,7183,7058,7078,6965,6964,7025,7003,7058,6943,6902,6946,7034,6994,7013,7051,7046,7054,6935,6895,6761,7060,7172,7162,7070,7129,6977,6952,7046,7027,7007,7021,7130,7204,7046,7090,7196,7147,6968,6889,7001,7036,7214,7165,7076,6961,7037,7072,7142,7201,7112,7141,7253,7297,7214,7219,7121,7141,7145,7216,7160,7075,6941,6943,7046,7099,7214,7255,7256,7186,7091,7189,7061,7237,7193,7285,7370,7360,7385,7192,7247,7132,7091,7144,7142,7138,7094,7231,7190,7135,6998,6913,6869,6844,6848,7018,7043,7129,7211,7222,7127,7225,7241,7255,7058,7231,7100,7117,7106,7138,7067,7051,7109,7189,7259,7282,7184,7150,7154,7135,7034,7057,7013,6997,7172,7126,7079,7129,7220,7267,7262,7405,7331,7291,7139,6907,7010,7144,7133,7075,7121,7222,7289,7252,7313,7273,7184,7051,7064,7108,7277,7408,7346,7213,7271,7225,7313,7237,7238,7348,7451,7207,7349,7291,7427,7294,7244,7288,7376,7417,7274,7294,7244,7369,7241,7237,7076,7204,7244,7342,7439,7471,7481,7411,7370,7342,7250,7156,7166,7168,7217,7171,7286,7327,7355,7330,7226,7234,7340,7426,7517,7420,7343,7351,7214,7219,7067,7105,7163,7261,7367,7363,7310,7375,7370,7495,7448,7570,7454,7267,7235,7423,7340,7174,7175,7060,7091,7144,7313,7417,7229,7267,7100,7117,7178,7147,7346,7429,7523,7459,7367,7399,7463,7438,7433,7513,7403,7354,7364,7366,7325,7432,7412,7390,7391,7393,7379,7441,7457,7534,7445,7465,7469,7495,7484,7498,7481,7393,7433,7432,7376,7498,7598,7366,7379,7432,7529,7579,7616,7420,7316,7486,7556,7525,7301,7267,7271,7378,7385,7408,7526,7618,7613,7603,7565,7570,7517,7555,7550,7567,7601,7453,7364,7420,7550,7396,7340,7507,7445,7429,7325,7360,7277,7453,7526,7555,7568,7486,7430,7453,7454,7546,7550,7441,7412,7534,7481,7474,7460,7333,7439,7381,7409,7420,7271,7270,7268,7246,7355,7276,7307,7252,7322,7471,7634,7753,7856,7585,7475,7444,7481,7519,7406,7504,7610,7606,7580,7546,7469,7378,7502,7399,7508,7618,7442,7522,7592,7498,7535,7501,7379,7477,7493,7363,7463,7645,7784,7765,7727,7696,7742,7555,7532,7612,7511,7228,7220,7312,7541,7648,7538,7561,7409,7465,7280,7432,7601,7651,7769,7681,7595,7567,7484,7318,7373,7447,7523,7495,7358,7345,7409,7537,7613,7585,7790,7795,7769,7717,7739,7855,7808,7768,7805,7645,7676,7657,7646,7597,7688,7654,7730,7747,7646,7750,7715,7690,7622,7630,7628,7588,7616,7609,7487,7270,7322,7273,7283,7438,7604,7531,7457,7408,7346,7474,7532,7729,7664,7687,7643,7546,7739,7585,7664,7723,7733,7627,7667,7666,7619,7561,7544,7510,7667,7828,7754,7606,7436,7528,7838,7783,7646,7696,7643,7699,7631,7441,7457,7570,7580,7645,7595,7549,7556,7669,7841,7897,7901,7801,7772,7552,7688,7609,7586,7675,7754,7723,7706,7618,7712,7603,7484,7426,7508,7699,7721,7567,7619,7579,7670,7762,7721,7792,7709,7696,7778,7519,7460,7549,7547,7561,7607,7690,7586,7612,7610,7624,7724,7717,7631,7513,7673,7750,7616,7375,7397,7549,7502,7624,7724,7699,7559,7720,7664,7507,7670,7708,7640,7612,7592,7588,7553,7726,7730,7738,7484,7660,7715,7663,7748,7774,7718,7696,7742,7645,7568,7774,7601,7633,7616,7726,7820,7765,7601,7543,7670,7798,7838,7702,7844,7597,7778,7879,7892,7954,8051,7921,7823,7780,7928,8116,8123,8020,7832,7744,7694,7756,7646,7705,7796,7843,7757,7837,7790,7669,7706,7825,7856,7873,7880,7840,7823,7726,7748,7810,7754,7759,7904,7924,7793,7810,7934,7930,7886,8158,7991,7765,7754,7885,7931,7978,7937,7999,7997,7957,7931,7699,7739,7855,7862,7840,7697,7573,7829,7909,7907,7858,7805,7942,8000,7963,7970,7822,7742,7663,7793,7891,7835,8029,7985,8068,7829,7846,7916,7921,7805,7870,7919,8026,7889,7885,7823,7915,7937,7864,7808,7876,7850,7897,8162,8107,8123,7795,7751,7726,7847,7756,7691,8029,7877,7888,7946,8008,8051,8002,8003,8068,8072,8161,8087,8119,8039,8032,8054,8062,8096,8164,8129,7969,7946,8125,8060,8110,8039,8059,7928,8071,7862,7876,7958,8203,8126,8134,8159,8065,7958,7879,7946,8152,8222,8164,8075,7933,7928,7756,7529,7687,7661,7834,7811,8008,7898,7948,7976,7816,7838,7873,7997,7993,7841,8023,8216,8179,7979,8083,7967,8104,8000,8098,8123,8020,8075,8131,8099,8071,8159,8281,8273,8410,8396,8350,8258,8110,8030,8113,8063,7846,7898,8074,8228,8320,8180,7882,8033,8155,8192,8257,8108,8188,8186,8245,8228,8329,8288,8323,8195,8173,8201,8158,8297,8269,8222,8182,8318,8347,8189,8062,8006,7984,8102,8122,8036,8188,7988,8227,8255,8158,8063,8044,8177,8011,8246,8113,8261,8170,8096,8083,8003,7996,8126,8134,7988,8092,8147,8248,8225,8062,7970,8011,8021,7942,8063,7990,7952,8011,8012,8068,8297,8305,8411,8497,8327,8365,8153,8260,8267,8461,8381,8374,8342,8287,8330,8290,8165,8077,8108,8161,8024,8083,8210,8167,8108,8080,8042,8182,8192,8230,8234,8377,8285,8290,8174,8167,8288,8359,8303,8272,8219,8194,8369,8260,8393,8380,8309,8248,8099,8026,8060,8299,8453,8203,8162,8134,8069,7984,7994,8050,8090,7936,7835,8065,8300,8401,8198,8134,8276,8353,8354,8284,8072,8161,8069,7921,7868,8113,8234,8260,8393,8281,8408,8401,8378,8332,8357,8344,8336,8374,8189,8080,8213,8110,8192,8095,8207,8278,8213,8146,8201,8275,8414,8512,8366,8173,8309,8419,8333,8413,8492,8425,8219,8149,8234,8314,8267,8317,8381,8275,8126,8089,8204,8326,8318,8356,8504,8422,8411,8254,8372,8455,8630,8476,8438,8497,8237,8392,8342,8314,8474,8326,8345,8293,8333,8287,8285,8245,8381,8410,8261,8224,8303,8236,8165,8284,8153,8098,8123,8209,8300,8194,8405,8539,8537,8596,8381,8419,8468,8377,8330,8416,8282,8338,8225,8260,8321,8641,8678,8383,8513,8431,8546,8524,8633,8554,8621,8530,8357,8371,8453,8320,8225,8278,8249,8353,8345,8437,8576,8494,8438,8542,8561,8491,8432,8440,8366,8218,8471,8383,8468,8638,8618,8587,8642,8545,8585,8467,8510,8308,8336,8401,8468,8458,8420,8407,8453,8500,8360,8296,8510,8632,8615,8554,8540,8485,8591,8623,8426,8617,8630,8701,8636,8794,8768,8680,8684,8593,8663,8605,8471,8572,8747,8737,8627,8488,8345,8356,8279,8305,8249,8425,8588,8491,8351,8440,8582,8704,8435,8419,8441,8647,8519,8443,8408,8455,8630,8566,8501,8542,8633,8590,8486,8323,8276,8344,8489,8626,8594,8575,8753,8659,8606,8770,8630,8557,8483,8479,8669,8563,8702,8521,8483,8614,8651,8419,8468,8530,8420,8461,8570,8563,8540,8647,8627,8560,8777,8797,8756,8719,8690,8659,8651,8869,8828,8899,8627,8569,8372,8446,8711,8647,8528,8632,8741,8527,8792,8719,8816,8803,8606,8698,8684,8647,8771,8695,8687,8644,8684,8755,8645,8515,8633,8671,8621,8656,8762,8686,8678,8833,8657,8854,8861,8722,8831,8707,8486,8611,8807,8677,8660,8662,8648,8845,8915,8704,8642,8563,8594,8602,8573,8686,8651,8716,8792,8728,8762,8632,8615,8536,8603,8584,8609,8749,8642,8662,8756,8872,8843,8785,8687,8617,8738,8827,8681,8578,8669,8734,8684,8647,8528,8686,8840,8698,8765,8971,8843,8812,8705,8617,8711,8863,8528,8524,8678,8806,8837,8899,8744,8857,8795,8788,8828,8746,8753,8839,8705,8698,8783,8917,8762,8641,8687,8716,8648,8611,8654,8641,8615,8761,8738,8719,8762,8803,8750,8734,8918,8899,8861,8893,8786,8896,8855,8737,8825,8812,8822,8707,8675,8566,8717,8614,8750,8878,8846,9016,8906,8767,8795,8662,8558,8665,8744,8893,8939,8950,8702,8746,8789,9010,8903,8860,8612,8701,8654,8803,8867,8905,8828,8899,8780,8875,8786,8752,8963,8980,8897,8920,8786,8923,8927,8854,8906,8965,8768,8779,8828,8953,8960,9037,8993,9022,9062,8953,8834,8812,8930,8797,8774,8890,9059,9109,8984,9130,8927,8980,9149,9244,9182,8959,8927,8944,8852,8821,8813,8950,9053,8953,9050,9037,8867,8986,9116,9088,9041,8794,8786,8833,8981,9079,9050,8983,8948,8905,8783,8971,9041,9118,9164,8860,8747,8818,8942,9028,8975,9139,9161,9178,8996,8812,8813,8851,8765,8665,8852,9055,9146,9049,9152,8971,9068,8929,8957,9076,9116,8989,8789,8848,8840,8851,8783,8818,9086,9046,8975,8914,8936,8764,8843,8974,8930,8905,9125,9061,9068,9136,8993,9022,9026,8926,8996,8956,8858,8923,8945,9106,9086,9172,9029,9112,9206,9106,9077,9001,9020,9121,9197,9169,9212,9280,9371,9337,9350,9268,9095,9262,9182,9139,9044,9124,9140,8938,9020,8995,8963,9160,9140,9127,9020,9157,9107,9079,9140,9298,9146,9193,8999,8953,9023,9109,9128,9184,9242,9232,9230,9154,9236,9157,9278,9223,9248,9073,9101,9085,9215,9007,9104,9145,9065,9103,9062,9133,9041,9109,9272,9004,8999,8899,8762,8722,9038,8878,9017,8998,9167,9154,9056,8842,8837,8845,9095,9064,9038,8950,9116,9088,9221,9280,9326,9490,9431,9178,9275,9199,9173,9301,9296,9151,8951,9136,9281,9049,8945,9016,9122,9073,8930,8986,9287,9313,9185,9226,9227,9193,9134,8962,9176,9289,9173,9148,9260,9439,9356,9226,9299,9418,9485,9358,9293,9271,9173,9139,9026,9214,9212,9262,9200,9256,9332,9421,9374,9379,9263,9400,9323,9340,9320,9307,9164,9211,9098,9016,9104,9235,9155,9319,9458,9448,9482,9406,9425,9445,9458,9502,9374,9406,9461,9544,9503,9448,9338,9298,9227,9121,9305,9277,8960,9118,9209,9211,9116,9214,9149,9208,9353,9373,9251,9322,9491,9424,9326,9454,9251,9205,9194,9172,9272,9157,9242,9304,9347,9280,9227,9229,9179,9178,9383,9298,9236,9265,9377,9205,9095,9073,9137,9247,9233,9286,9383,9316,9218,9184,9206,9358,9671,9478,9407,9310,9296,9304,9410,9316,9452,9481,9278,9358,9527,9469,9308,9229,9323,9358,9203,9055,9353,9445,9377,9178,9158,9271,9281,9166,9494,9547,9545,9352,9299,9427,9584,9475,9275,9244,9398,9481,9449,9502,9563,9559,9434,9409,9413,9646,9554,9469,9254,9319,9233,9331,9482,9523,9245,9175,9350,9169,9275,9379,9551,9652,9467,9403,9392,9433,9587,9499,9602,9538,9464,9271,9335,9382,9458,9394,9365,9397,9479,9562,9413,9205,9248,9316,9236,9364,9323,9340,9383,9514,9695,9742,9674,9592,9554,9694,9659,9427,9305,9340,9176,9280,9407,9454,9674,9601,9383,9325,9506,9382,9431,9376,9347,9478,9479,9301,9341,9304,9491,9550,9569,9454,9404,9394,9239,9415,9155,9364,9377,9412,9329,9397,9515,9526,9503,9619,9599,9703,9704,9652,9584,9466,9392,9442,9569,9544,9476,9421,9536,9685,9803,9787,9827,9853,9644,9586,9605,9481,9377,9556,9572,9478,9389,9463,9548,9565,9635,9604,9542,9670,9809,9610,9572,9595,9623,9616,9800,9466,9473,9784,9740,9688,9647,9844,9860,9730,9524,9643,9944,9817,9653,9631,9596,9517,9422,9502,9392,9478,9506,9517,9476,9574,9743,9622,9506,9715,9665,9538,9761,9811,9812,9679,9818,9826,9770,9613,9650,9544,9656,9502,9545,9388,9407,9427,9476,9403,9446,9532,9740,9904,9800,9772,9707,9604,9686,9652,9476,9430,9383,9568,9497,9472,9530,9835,9689,9685,9731,9391,9359,9484,9509,9712,9551,9553,9602,9655,9914,9775,9812,9895,9773,9601,9536,9505,9596,9418,9530,9421,9590,9712,9686,9445,9395,9340,9437,9523,9551,9607,9575,9718,9707,9613,9560,9472,9548,9763,9977,9847,9866,9715,9881,9790,9797,9856,9938,9760,9638,9664,9617,9784,9785,9643,9782,9709,9734,9784,9425,9589,9665,9709,9473,9505,9650,9742,9629,9709,9698,9820,9938,9769,9881,9835,9752,9595,9677,9706,9836,9835,9635,9568,9704,9625,9629,9790,9743,9748,9605,9580,9656,9520,9689,9685,9515,9679,9719,9718,9680,9658,9650,9589,9485,9583,9680,9847,9677,9751,9719,9682,9698,9487,9596,9697,9701,9736,9986,9892,10001,9787,9872,9682,9770,9757,9776,9688,9926,9862,9626,9793,9929,9985,9908,9907,10031,10081,9866,9895,9800,9826,10094,10180,9839,9706,9827,9727,9860,9901,9839,9652,9557,9781,9905,9784,9614,9598,9800,9826,9851,9946,9956,9868,9836,9970,9851,9793,9641,9670,9782,9961,9842,9730,9983,10084,10043,9997,9950,9811,9758,9805,9800,9736,9887,10045,9992,9769,9719,9853,9995,9865,9803,9886,9683,9817,9932,9991,9794,9823,9782,9925,10049,10090,10037,9958,9827,10042,10130,9928,9884,10039,10070,9952,9950,9721,9920,9805,9818,9916,9896,10162,9929,9940,9899,9925,9941,10108,10073,10165,10097,10024,9932,9910,9830,9706,9845,9934,9986,9982,9866,9913,9809,9970,9680,9748,9776,9958,10106,10060,10130,9928,9794,9922,10070,10042,9941,9937,10136,10147,9989,9988,9968,10000,9884,9805,9908,9826,9869,9910,9929,9769,9710,9889,10067,10045,10109,10165,10088,10015,10130,10000,10028,10030,10034,10105,10130,10153,10145,10057,9962,10096,10067,9982,9857,9922,9989,10132,10148,10081,10064,10021,9998,9736,9761,9847,10001,10255,10259,10168,10346,10135,10199,10129,10043,10042,10247,10018,9902,9922,10088,10276,10283,10279,10127,10075,10142,10087,10067,9901,10082,10264,10205,10069,10121,10009,10001,10102,10133,10078,10229,10090,9992,10075,10115,10033,9824,9874,9848,10012,10079,10177,10121,10135,10181,10129,10115,10078,10256,10216,10199,10291,10241,10114,10166,10099,10055,9913,9809,9808,9734,9919,9929,10057,10232,10258,10229,10270,10091,10219,10061,10024,10193,10351,10235,10138,10124,10024,10085,10198,10289,10264,10097,10051,10031,9973,9884,9868,10043,10213,10310,10369,10235,10138,9863,10024,10130,10180,10226,10408,10484,10501,10427,10333,10109,10039,10079,10159,10292,10126,10127,9994,10025,10105,10184,10414,10379,10426,10322,10375,10310,10243,10082,10174,10106,10267,10337,10207,10199,10192,10376,10339,10373,10279,10415,10462,10259,10492,10490,10414,10262,10210,10187,10231,10319,10315,10271,10165,10106,10312,10247,10369,10271,10147,10088,10096,10121,10198,10154,10120,10151,9952,10157,10333,10505,10426,10241,10249,10274,10369,10496,10552,10376,10177,10130,10225,10415,10453,10313,10366,10328,10306,10181,10156,10475,10420,10553,10459,10451,10318,10178,10051,10121,10432,10460,10390,10349,10420,10463,10306,10325,10435,10232,10123,10310,10180,10271,10102,10268,10294,10382,10432,10523,10525,10637,10627,10274,10126,10028,10093,10061,10231,10373,10297,10379,10498,10412,10492,10301,10351,10460,10489,10529,10384,10301,10207,10424,10408,10412,10249,10274,10288,10433,10300,10493,10456,10301,10225,10271,10273,10358,10186,10256,10360,10379,10435,10439,10510,10535,10405,10433,10426,10502,10348,10454,10630,10640,10426,10403,10384,10319,10468,10397,10255,10376,10348,10292,10324,10415,10498,10484,10339,10580,10639,10559,10588,10772,10627,10670,10711,10559,10624,10439,10357,10157,10333,10541,10408,10412,10474,10364,10396,10613,10489,10691,10546,10409,10459,10568,10489,10664,10708,10751,10738,10604,10462,10412,10375,10373,10432,10208,10327,10187,10213,10292,10252,10406,10381,10493,10690,10805,10711,10604,10660,10745,10519,10346,10396,10550,10417,10457,10600,10580,10432,10595,10624,10718,10762,10679,10702,10568,10714,10754,10708,10760,10603,10406,10408,10448,10564,10661,10477,10478,10516,10457,10546,10589,10684,10829,10579,10619,10429,10445,10558,10388,10219,10349,10402,10472,10603,10721,10606,10376,10537,10598,10639,10712,10786,10817,10681,10895,10855,10676,10588,10538,10276,10139,10405,10424,10570,10691,10699,10562,10513,10325,10462,10367,10357,10553,10666,10694,10588,10574,10510,10400,10360,10622,10669,10655,10672,10688,10756,10739,10660,10547,10564,10571,10594,10676,10516,10466,10393,10634,10666,10748,10561,10637,10825,10688,10522,10640,10516,10556,10474,10526,10549,10469,10588,10691,10744,10589,10396,10460,10390,10412,10690,10823,10918,10721,10615,10520,10726,10814,10855,10685,10606,10736,10573,10589,10405,10523,10426,10493,10519,10607,10657,10577,10741,10718,10654,10661,10648,10658,10633,10574,10753,10832,10783,10730,10777,10727,10636,10598,10540,10766,10705,10700,10690,10652,10585,10793,10606,10574,10663,10670,10792,10775,10705,11051,10708,10643,10666,10982,10903,10871,10762,10859,10873,10766,10876,10934,10951,10904,10810,10910,10975,10772,10735,10769,10990,10919,10804,10799,10960,10922,10693,10793,10858,10862,10852,11057,10918,10757,10768,10754,10879,10751,10765,10838,10804,10907,10969,10913,10801,10910,10759,10754,10915,10994,10873,10775,10849,10835,11068,10931,10972,10775,10795,10853,10987,10769,10738,10604,10561,10610,10645,10841,10738,10919,10840,10655,10681,10688,10675,10892,10867,10943,10681,10778,10819,10703,10822,10853,10987,10913,10765,11153,10975,10952,10915,10841,10945,10766,10660,10736,10789,10850,11044,10973,11101,11051,10978,10859,10792,10658,10804,10844,10717,10832,11035,11045,11065,10826,10726,10787,10828,10892,10822,10727,10600,10652,10783,10838,10876,11042,10942,11012,11008,10937,10957,10979,10942,10715,10711,10847,10750,10844,10915,10958,10909,11072,11002,11024,11212,11129,11053,11036,11020,11141,11068,10877,10765,10712,10876,11177,10969,10949,10918,10892,10921,10925,11113,11156,11197,11396,11137,11051,11113,11021,10927,11063,11182,11096,11059,11012,11035,11081,11047,10988,10969,10994,11053,11036,11200,11231,11311,11147,11044,11081,11038,10961,10924,11120,11143,11045,10948,10871,10897,11237,11089,11036,11056,10961,10987,11021,10873,10838,10813,10844,10861,11057,11026,10955,11011,11105,11239,11039,10945,10955,10948,11123,11221,11102,11134,10991,10975,11060,11032,11120,11080,10892,10867,10736,10870,10886,10882,11054,10939,11006,11104,11138,10954,11135,11461,11312,11266,11228,10972,10937,10858,10871,11221,11030,11170,11153,11119,10826,10843,11084,11233,11306,11110,11006,10870,10967,11116,11324,11245,11150,10834,10940,10810,11009,11083,10988,11059,11237,11179,11207,11092,11231,11185,11210,11188,11063,11074,11096,10951,10967,11251,11378,11155,11222,11113,10760,10909,10802,10885,10934,11005,11210,11116,11063,10957,11051,10861,10994,11188,11216,11128,11177,11257,11219,10909,11072,11254,11420,11428,11336,11224,10991,10984,11123,11221,11201,10945,10991,11371,11330,11284,11318,11359,11450,11173,11159,11329,11165,11152,11135,11290,11285,11473,11525,11377,11279,11470,11429,11473,11354,11314,11513,11479,11339,11230,11363,11548,11477,11272,11366,11437,11336,11296,11162,11245,11339,11365,11237,11143,11234,11425,11195,11095,11102,11143,11207,11389,11132,11248,11336,11278,11531,11308,11078,11059,11075,11287,10973,11227,11384,11302,11291,11341,11387,11497,11447,11554,11480,11314,11423,11299,11114,11158,11093,11368,11378,11353,11204,11167,11210,11341,11360,11407,11393,11473,11282,11593,11360,11263,11195,11275,11309,11188,11162,11272,11141,11095,11219,11350,11252,11227,11177,11077,11264,11422,11378,11569,11573,11410,11462,11503,11477,11515,11528,11536,11606,11287,11216,11263,11087,10978,11048,11269,11522,11434,11375,11383,11309,11260,11477,11326,11573,11518,11444,11629,11450,11515,11312,11365,11624,11431,11495,11551,11501,11203,11390,11278,11468,11533,11366,11419,11516,11791,11702,11569,11636,11617,11444,11485,11297,11416,11474,11635,11516,11422,11423,11461,11501,11311,11408,11467,11693,11569,11465,11401,11399,11458,11414,11317,11285,11437,11408,11638,11666,11434,11384,11509,11372,11368,11306,11299,11267,11428,11417,11395,11414,11290,11429,11518,11363,11278,11297,11254,11429,11437,11408,11296,11450,11497,11456,11536,11471,11476,11522,11317,11303,11491,11543,11638,11648,11515,11519,11527,11507,11548,11531,11524,11672,11644,11597,11467,11378,11479,11609,11653,11732,11827,11549,11497,11438,11482,11525,11629,11621,11623,11510,11482,11624,11611,11576,11524,11699,11815,11615,11395,11441,11587,11618,11608,11723,11440,11378,11416,11330,11320,11453,11584,11675,11632,11843,11815,11786,11548,11549,11497,11573,11338,11453,11674,11648,11569,11429,11293,11183,11485,11585,11776,11483,11239,11345,11404,11522,11461,11681,11617,11561,11710,11684,11425,11420,11446,11489,11404,11369,11443,11447,11617,11741,11647,11774,11551,11528,11482,11633,11665,11639,11650,11528,11743,11642,11773,11738,11569,11681,11707,11768,11683,11729,11713,11600,11455,11381,11404,11459,11407,11420,11509,11534,11710,11612,11461,11510,11410,11597,11602,11648,11641,11717,11653,11597,11755,11702,11794,11960,11923,11786,11755,11909,11785,11663,11581,11714,11638,11855,11803,11807,11806,11912,11872,11927,11884,11690,11518,11597,11431,11801,11911,11933,11698,11903,11701,11729,11794,11573,11698,11714,11782,11729,11659,11465,11545,11399,11521,11450,11497,11492,11788,11876,11854,11684,11668,11582,11455,11642,11719,11927,12055,12167,11932,11822,11764,11630,11587,11771,11905,11606,11647,11774,11866,11726,11671,11912,11935,11792,11857,11843,11824,11831,11836,11765,11776,11816,11914,11849,11971,11927,11866,11816,11842,11957,11881,12017,11893,11969,12031,12038,11845,11756,11794,11807,11851,11903,11737,11783,11749,11870,11995,12020,12043,12035,12082,12185,12022,11921,12142,11999,11929,11861,11752,11849,11980,11828,11947,11888,11941,11867,11620,11909,11740,11699,11437,11579,11899,11954,11929,11897,11833,11822,11908,11675,11650,11636,11644,11867,11953,11846,11938,11798,11959,11822,11827,11729,11695,11852,11770,11714,11854,12062,12127,12032,12049,12020,11827,11828,11992,12140,11923,11804,11737,11792,11938,12059,11914,12083,12025,12035,12199,12158,12184,12065,11944,11846,11812,11825,11815,11651,11791,11891,12154,12059,12112,12101,12061,12017,11875,11807,11815,11840,11764,11846,11677,11618,11662,11732,11953,12134,12091,11915,11527,11768,11782,11828,12127,12149,11869,11813,11800,12044,12235,12203,12013,12038,12025,11837,11812,11852,11833,11804,11845,11702,11794,11879,11959,11894,11899,11963,11992,12086,11968,12056,12313,12305,12226,12284,12049,12137,12232,12080,11911,11924,12040,12065,11989,11792,11938,11996,12148,12110,12232,12314,12064,11942,11950,12092,12187,12125,12316,12311,12256,12200,12160,12116,12055,12077,11887,11696,11719,11846,12055,12185,12247,12155,12061,11981,12082,12131,12058,11948,12160,12053,12172,12176,12247,12191,12016,12089,12316,12311,12319,12227,12115,12035,12019,11888,11896,12020,11998,11927,12046,12176,12121,12029,12025,11963,12253,12149,12058,12263,12151,12116,12208,12041,11914,12056,12079,12053,12001,11987,12076,12056,11962,12116,12424,12302,12220,12128,11908,12071,12100,12023,11833,12020,12232,12134,12244,11978,12166,12083,12034,11999,12073,11987,12013,12236,11908,11864,11830,12149,11986,12029,12061,12035,12019,12032,11950,12146,12295,12242,12442,12491,12256,12056,12178,12161,12280,12194,12202,12056,12313,12260,12307,12329,12211,11939,11908,12170,12379,12338,12400,12434,12223,12323,12190,12113,12013,12002,12232,12134,12181,12230,12265,12236,12214,12359,12433,12302,12148,12164,12169,12413,12307,12203,12130,12110,12169,12170,12163,12230,12238,12128,12115,12143,12181,12365,12346,12254,12241,12143,12307,12338,12364,12263,12358,12188,12163,12158,12256,12398,12556,12440,12433,12302,12337,12299,12322,12242,12370,12257,12256,12335,12376,12161,12046,12059,12265,12218,12367,12449,12316,12275,12184,12389,12385,12089,12118,12059,12274,12110,12115,12206,12316,12455,12544,12551,12421,12296,12244,12365,12292,12317,12259,12134,12127,12401,12382,12344,12286,12413,12235,12320,12292,12362,12610,12440,12226,12275,12301,12452,12448,12557,12487,12662,12490,12353,12466,12332,12316,12239,12292,12362,12322,12269,12298,12311,12220,12191,12385,12368,12289,12455,12517,12335,12322,12296,12208,12311,12427,12236,12268,12215,12172,12140,12328,12497,12529,12593,12505,12518,12463,12371,12421,12512,12271,12374,12562,12542,12376,12386,12199,12221,12238,12155,12376,12350,12451,12509,12427,12308,12277,12404,12298,12419,12517,12281,12196,12404,12271,12590,12670,12686,12619,12629,12658,12392,12301,12551,12628,12512,12631,12761,12571,12677,12538,12503,12442,12527,12526,12614,12619,12521,12532,12716,12769,12515,12457,12629,12784,12788,12670,12605,12610,12413,12397,12257,12364,12371,12457,12377,12523,12491,12679,12677,12583,12494,12640,12455,12472,12398,12358,12305,12334,12392,12292,12542,12565,12431,12415,12410,12697,12497,12727,12800,12856,12527,12508,12497,12556,12692,12730,12761,12859,12623,12538,12575,12694,12662,12589,12434,12655,12584,12613,12779,12607,12542,12394,12665,12640,12563,12643,12668,12556,12440,12550,12356,12301,12443,12556,12674,12730,12689,12445,12416,12511,12647,12676,12779,12661,12794,12592,12764,12658,12608,12580,12470,12448,12413,12514,12671,12778,12470,12601,12593,12505,12563,12544,12488,12367,12530,12640,12662,12643,12425,12565,12800,12640,12734,12778,12875,12997,12863,12829,12716,12472,12686,12691,12422,12280,12491,12625,12515,12520,12521,12703,12887,12886,12803,12655,12449,12469,12518,12526,12578,12601,12746,12748,12842,12814,12497,12646,12683,12649,12716,12634,12533,12808,12836,12829,12743,12643,12650,12763,12764,12910,12725,12508,12416,12583,12746,12730,12770,12814,12920,12790,12836,12910,12950,12976,12821,12871,12908,12838,12716,12544,12704,12709,12575,12613,12698,12823,12947,12961,12746,12739,12680,12751,12830,12763,12800,12847,12788,12544,12569,12592,12764,12802,12833,12886,12785,12799,12800,12856,12878,12859,12875,12907,12872,12820,12689,12652,12803,12781,12647,12622,12545,12436,12416,12493,12530,12775,12806,12832,13019,12943,12980,13054,12878,12580,12641,12448,12602,12640,12725,12625,12632,12511,12575,12586,12770,12895,12938,12871,12899,13162,12914,12904,12785,12880,12926,13018,12968,12868,13064,12952,12953,12901,12968,13039,13055,13132,13088,12712,12671,12706,12866,12745,12791,12784,12968,13102,12902,12664,12899,13036,12950,12958,12893,12889,12746,12685,12779,12535,12695,12889,12872,12865,12698,12544,12812,12790,12773,12649,12599,12688,12785,12880,12827,13090,13112,13246,13379,13204,13133,12766,12716,13066,13181,13186,13169,13045,12932,12958,13091,12880,12692,12892,13085,12850,12893,12862,12899,12838,12842,12832,12866,12943,13016,12964,12680,12814,13037,12979,13133,12919,12815,12778,12938,12889,12908,13018,13058,13291,13217,13195,12971,13108,13040,12976,13082,12988,13052,13090,12959,12922,12803,12916,12935,12901,12941,13039,13136,13213,13277,13162,13004,12976,12902,12844,12773,12703,12887,12904,12938,13024,12755,12901,12950,13093,13046,12943,13070,12919,12887,13057,13109,12961,13124,13036,12851,13057,12983,13033,12980,12748,12842,12733,12821,13060,12953,13009,13292,13174,13073,13141,13205,13234,13310,13156,13082,13078,13034,12991,13040,13111,13100,13015,12944,12973,13049,12994,13091,13015,12998,12838,12599,12841,13136,13123,13097,12955,13058,12967,13100,13033,13106,13117,12968,12985,13046,13150,13097,12937,12698,12895,12866,13042,13133,13018,13094,13210,13109,12925,13187,13234,12923,12841,12803,12907,13043,13288,13166,13093,13289,13204,13268,13027,13193,13273,13307,13051,13016,13063,13193,13165,13217,13186,13196,13171,13220,13480,13145,13303,13259,13171,13310,13273,13181,13114,13205,13360,13283,13246,13181,13222,13376,13405,13202,13066,12983,13132,13295,13369,13247,13120,13091,12853,12899,12991,13103,13048,12911,13042,13376,13423,13157,13039,13010,12988,13052,13162,13112,13021,13082,13141,13034,12910,13067,13093,13253,13312,13205,13243,13049,13138,13424,13546,13520,13567,13661,13570,13334,13474,13340,13342,13418,13633,13460,13393,13241,13171,13130,12886,12911,12952,12998,12973,13103,13174,13298,13357,13376,13387,13085,13309,13262,13321,13232,13387,13292,13435,13460,13159,13286,13279,13157,13183,13055,13141,13403,13261,13229,13084,13046,13114,13322,13450,13508,13507,13433,13222,13223,13396,13589,13525,13469,13501,13610,13639,13346,13201,13388,13294,13223,13000,13031,13255,13379,13393,13538,13297,13184,13003,12893,13069,13358,13441,13625,13471,13316,13357,13196,13135,13220,13255,13046,13006,13070,13036,13373,13462,13496,13600,13475,13333,13418,13408,13298,13276,13196,13252,13499,13417,13433,13312,13538,13369,13517,13471,13433,13447,13457,13468,13445,13399,13271,13501,13367,13432,13382,13489,13442,13348,13169,13207,13112,13021,13208,13375,13421,13351,13274,13354,13370,13213,13313,13090,13229,13219,13199,13384,13592,13549,13481,13534,13595,13744,13664,13513,13526,13525,13307,13384,13268,13279,13319,13534,13586,13528,13511,13495,13355,13381,13172,13294,13412,13324,13301,13408,13442,13537,13484,13315,13382,13426,13640,13510,13322,13099,13022,13345,13334,13294,13304,13387,13517,13480,13694,13789,13718,13729,13490,13642,13334,13501,13646,13810,13697,13462,13694,13636,13637,13594,13661,13372,13289,13393,13322,13351,13139,13309,13352,13474,13610,13747,13859,13741,13685,13636,13781,13756,13823,13921,13739,13762,13556,13567,13607,13894,13550,13474,13520,13540,13742,13597,13514,13474,13475,13531,13418,13417,13370,13366,13313,13450,13571,13561] 2 | def d_sum(n): 3 | s = str(2**n) 4 | l = len(s) 5 | su = 0 6 | for i in xrange(l): 7 | su += int(s[i]) 8 | return su 9 | n = [] 10 | for i in xrange(input()): 11 | n.append(input()) 12 | 13 | for i in n: 14 | if i<1001: 15 | print d_sum(i) 16 | else: 17 | print a[i-1001] --------------------------------------------------------------------------------