description
stringlengths
38
154k
category
stringclasses
5 values
solutions
stringlengths
13
289k
name
stringlengths
3
179
id
stringlengths
24
24
tags
listlengths
0
13
url
stringlengths
54
54
rank_name
stringclasses
8 values
Hello. Today our job is to find the `N`th Pipi number. Let us define P<sub>n</sub> such that the following expression: `$P_{0}+\sqrt{P_{1}+\sqrt{P{_2}+\sqrt{...\sqrt{P_{n-1}+\sqrt{P_n}}}}}$` is equal to `n`, if P<sub>0</sub> = 0. --- # Examples: ``` pipi(0) == 0 ``` because ```math 0 = 0 ``` --- ``` pipi(1) == 1 ``` because ```math 0 + \sqrt { 1 } = 1 ``` --- ``` pipi(2) == 9 ``` because ```math 0 + \sqrt { 1 + \sqrt { 9 } } = 2 ``` --- ``` pipi(3) == 3025 ``` because ```math 0 + \sqrt { 1 + \sqrt { 9 + \sqrt { 3025 } } } = 3 ``` --- ### Number N range: ```if:java From `0` to `22`. ``` ```if:csharp From `0` to `18`. ``` ```if:python From `0` to `21`. Note: 2000 characters restriction to prevent hard-coding. ``` ```if:haskell `[ 0 .. 24 ]` ``` ~~~if:javascript From `0` to `21`. Note: 2000 characters restriction to prevent hard-coding. ~~~ (Check out my other kata!) <a title="Matrix Diagonal Sort OMG" href="https://www.codewars.com/kata/5ab1f8d38d28f67410000090">Matrix Diagonal Sort OMG</a> <a title="String -> N iterations -> String" href="https://www.codewars.com/kata/5ae43ed6252e666a6b0000a4">String -> N iterations -> String</a> <a title="String -> X iterations -> String" href="https://www.codewars.com/kata/5ae64f28d2ee274164000118">String -> X iterations -> String</a> <a title="ANTISTRING" href="https://www.codewars.com/kata/5ab349e01aaf060cd0000069">ANTISTRING</a> <a title="Array - squareUp b!" href="https://www.codewars.com/kata/5a8bcd980025e99381000099">Array - squareUp b!</a> <a title="Matrix - squareUp b!" href="https://www.codewars.com/kata/5a972f30ba1bb5a2590000a0">Matrix - squareUp b!</a> <a title="Infinitely Nested Radical Expressions" href="https://www.codewars.com/kata/5af2b240d2ee2764420000a2">Infinitely Nested Radical Expressions</a> <a title="pipi Numbers!" href="https://www.codewars.com/kata/5af27e3ed2ee278c2c0000e2">pipi Numbers!</a>
algorithms
from functools import reduce ps = [] for i in range(22): ps . append(reduce(lambda a, p: (a - p) * * 2, ps, i)) def pipi(n): return ps[n]
pipi Numbers!
5af27e3ed2ee278c2c0000e2
[ "Mathematics", "Algorithms", "Performance" ]
https://www.codewars.com/kata/5af27e3ed2ee278c2c0000e2
6 kyu
# Scenario *Now that the competition gets tough it will* **_Sort out the men from the boys_** . **_Men_** are the **_Even numbers_** and **_Boys_** are the **_odd_** ![!alt](https://i.imgur.com/mdX8dJP.png) ![!alt](https://i.imgur.com/mdX8dJP.png) ___ # Task **_Given_** an *array/list [] of n integers* , **_Separate_** *The even numbers from the odds* , or **_Separate_** **_the men from the boys_** ![!alt](https://i.imgur.com/mdX8dJP.png) ![!alt](https://i.imgur.com/mdX8dJP.png) ___ # Notes * **_Return_** *an array/list where* **_Even numbers_** **_come first then odds_** * Since , **_Men are stronger than Boys_** , *Then* **_Even numbers_** in **_ascending order_** While **_odds in descending_** . * **_Array/list_** size is *at least **_4_*** . * **_Array/list_** numbers could be a *mixture of positives , negatives* . * **_Have no fear_** , *It is guaranteed that no Zeroes will exists* . ![!alt](https://i.imgur.com/mdX8dJP.png) * **_Repetition_** of numbers in *the array/list could occur* , So **_(duplications are not included when separating)_**. ____ # Input >> Output Examples: ``` menFromBoys ({7, 3 , 14 , 17}) ==> return ({14, 17, 7, 3}) ``` ## **_Explanation_**: **_Since_** , `{ 14 }` is the **_even number_** here , So it **_came first_** , **_then_** *the odds in descending order* `{17 , 7 , 3}` . ____ ``` menFromBoys ({-94, -99 , -100 , -99 , -96 , -99 }) ==> return ({-100 , -96 , -94 , -99}) ``` ## **_Explanation_**: * **_Since_** , `{ -100, -96 , -94 }` is the **_even numbers_** here , So it **_came first_** in *ascending order *, **_then_** *the odds in descending order* `{ -99 }` * **_Since_** , **_(Duplications are not included when separating)_** , *then* you can see **_only one (-99)_** *was appeared in the final array/list* . ____ ``` menFromBoys ({49 , 818 , -282 , 900 , 928 , 281 , -282 , -1 }) ==> return ({-282 , 818 , 900 , 928 , 281 , 49 , -1}) ``` ## **_Explanation_**: * **_Since_** , `{-282 , 818 , 900 , 928 }` is the **_even numbers_** here , So it **_came first_** in *ascending order* , **_then_** *the odds in descending order* `{ 281 , 49 , -1 }` * **_Since_** , **_(Duplications are not included when separating)_** , *then* you can see **_only one (-282)_** *was appeared in the final array/list* . ____ ____ ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [Bizarre Sorting-katas](https://www.codewars.com/collections/bizarre-sorting-katas) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def men_from_boys(arr): men = [] boys = [] for i in sorted(set(arr)): if i % 2 == 0: men . append(i) else: boys . append(i) return men + boys[:: - 1]
Sort Out The Men From Boys
5af15a37de4c7f223e00012d
[ "Fundamentals", "Algorithms", "Sorting" ]
https://www.codewars.com/kata/5af15a37de4c7f223e00012d
7 kyu
You've purchased a ready-meal from the supermarket. The packaging says that you should microwave it for 4 minutes and 20 seconds, based on a 600W microwave. Oh no, your microwave is 800W! How long should you cook this for?! ___ # Input You'll be given 4 arguments: ## 1. needed power The power of the needed microwave. Example: `"600W"` ## 2. minutes The number of minutes shown on the package. Example: `4` ## 3. seconds The number of seconds shown on the package. Example: `20` ## 4. power The power of your microwave. Example: `"800W"` ___ # Output The amount of time you should cook the meal for formatted as a string. Example: `"3 minutes 15 seconds"` Note: the result should be rounded up. ``` 59.2 sec --> 60 sec --> return "1 minutes 0 seconds" ``` ___ ## All comments/feedback/translations appreciated.
reference
import math def cooking_time(needed_power, minutes, seconds, power): t = math . ceil((60 * minutes + seconds) * int(needed_power[: - 1]) / int(power[: - 1])) return '%d minutes %d seconds' % (t / / 60, t - t / / 60 * 60)
How long should you cook this for?
5aefd0a686d075d5f3000091
[ "Fundamentals" ]
https://www.codewars.com/kata/5aefd0a686d075d5f3000091
7 kyu
This challenge is based on [a kata](https://www.codewars.com/kata/n-smallest-elements-in-original-order) by GiacomoSorbi. Before doing this one it is advisable to complete the non-performance version first. ___ ## Task You will be given an array of integers in a `[1; 50]` range, and a number `n`. You have to extract `n` smallest elements out of the array **preserving their original order**. ### Notes * There will be duplicates in the array, and they have to be returned in the order of their each separate appearence. * This kata is an example of the "know your data" principle. Remember this while searching for the correct approach. ### Examples ``` numbers = [1, 2, 3, 4, 5] n = 3 result = [1, 2, 3] numbers = [5, 4, 3, 2, 1] n = 3 result = [3, 2, 1] numbers = [1, 2, 4, 1, 2] n = 3 result = [1, 2, 1] ```
algorithms
def performant_smallest(xs, n): ys = sorted(xs) del ys[n:] m = ys[- 1] km = ys . count(m) res = [] for x in xs: if x <= m: if x < m: res . append(x) elif km > 0: res . append(x) km -= 1 return res
N smallest elements in original order (performance edition)
5aeed69804a92621a7000077
[ "Algorithms", "Arrays", "Performance" ]
https://www.codewars.com/kata/5aeed69804a92621a7000077
6 kyu
In this kata you will be given an **integer n**, which is the number of times that is thown a coin. You will have to return an array of string for all the possibilities (heads[H] and tails[T]). Examples:<br><br> ```coin(1) should return {"H", "T"}```<br> ```coin(2) should return {"HH", "HT", "TH", "TT"}```<br> ```coin(3) should return {"HHH", "HHT", "HTH", "HTT", "THH", "THT", "TTH", "TTT"}```<br><br> When finished sort them alphabetically.<br> <br> In C and C++ just return a ```char*``` with all elements separated by```,``` (without space):<br> ```coin(2) should return "HH,HT,TH,TT"```<br><br> INPUT:<br> ```0 < n < 18```<br><br> Careful with performance!! You'll have to pass 3 basic test (n = 1, n = 2, n = 3), many medium tests (3 < n <= 10) and many large tests (10 < n < 18)
reference
from itertools import product def coin(n): return list(map('' . join, product(* (["HT"] * n))))
Possibilities of throwing a coin n times
5ad6266b673f2f067b000004
[ "Mathematics", "Statistics", "Permutations", "Performance" ]
https://www.codewars.com/kata/5ad6266b673f2f067b000004
6 kyu
Quadratic equations come in the form `y(x) = ax^2 + bx + c`. Substituting in different values of `x` gives us different coordinates/points on the graph of the given quadratic function. # Task: Your job is to create a function that does the following: 1. Takes in three required parameters: `a`, `b`, and `c`, and two keyword/optional parameters, `start` and `step`. If `start` is not provided, it should be set as default to 0, and if `step` is not provided, its default value should be 1 (all of them will be passed in JS **when needed**). 2. It should return an enumerator/generator which is dynamic and created based on the arguments taken in. # What the enumerator/generator must do: Essentially, the method you write should return an enumerator/generator which, when called, should start by yielding `[start, a(start)^2 + b(start) + c]`, where `a`, `b`, and `c`, are provided when the method was called. Then `start` should be incremented by `step` and continue the sequence. # Examples: ```ruby enum = quadratic_enum(1, 0, 0) # this is the equation of y = x^2 First 10 values: [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]] enum = quadratic_enum(1, 0, 0, start: 2) # different start point First 10 values: [[2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81], [10, 100], [11, 121]] enum = quadratic_enum(1, 0, 0, step: 2) # different step value First 10 values: [[0, 0], [2, 4], [4, 16], [6, 36], [8, 64], [10, 100], [12, 144], [14, 196], [16, 256], [18, 324]] enum = quadratic_enum(1, 0, 0, step: -1) # tracing backwards First 10 values: [[0, 0], [-1, 1], [-2, 4], [-3, 9], [-4, 16], [-5, 25], [-6, 36], [-7, 49], [-8, 64], [-9, 81]] enum = quadratic_enum(1, 0, 0, step: 0.5) # step is a float First 10 values: [[0, 0], [0.5, 0.25], [1.0, 1.0], [1.5, 2.25], [2.0, 4.0], [2.5, 6.25], [3.0, 9.0], [3.5, 12.25], [4.0, 16.0], [4.5, 20.25]] ``` ```python gen = quadratic_gen(1, 0, 0) # this is the equation of y = x^2 First 10 values: [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]] gen = quadratic_gen(1, 0, 0, start = 2) # different start point First 10 values: [[2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81], [10, 100], [11, 121]] gen = quadratic_gen(1, 0, 0, step = 2) # different step value First 10 values: [[0, 0], [2, 4], [4, 16], [6, 36], [8, 64], [10, 100], [12, 144], [14, 196], [16, 256], [18, 324]] gen = quadratic_gen(1, 0, 0, step = -1) # tracing backwards First 10 values: [[0, 0], [-1, 1], [-2, 4], [-3, 9], [-4, 16], [-5, 25], [-6, 36], [-7, 49], [-8, 64], [-9, 81]] gen = quadratic_gen(1, 0, 0, step = 0.5) # step is a float First 10 values: [[0, 0], [0.5, 0.25], [1.0, 1.0], [1.5, 2.25], [2.0, 4.0], [2.5, 6.25], [3.0, 9.0], [3.5, 12.25], [4.0, 16.0], [4.5, 20.25]] ``` ```javascript gen = quadraticGen(1, 0, 0) // this is the equation of y = x^2 First 10 values: [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]] gen = quadraticGen(1, 0, 0, start = 2) // different start point First 10 values: [[2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81], [10, 100], [11, 121]] gen = quadraticGen(1, 0, 0, step = 2) // different step value First 10 values: [[0, 0], [2, 4], [4, 16], [6, 36], [8, 64], [10, 100], [12, 144], [14, 196], [16, 256], [18, 324]] gen = quadraticGen(1, 0, 0, step = -1) // tracing backwards First 10 values: [[0, 0], [-1, 1], [-2, 4], [-3, 9], [-4, 16], [-5, 25], [-6, 36], [-7, 49], [-8, 64], [-9, 81]] gen = quadraticGen(1, 0, 0, step = 0.5) // step is a float First 10 values: [[0, 0], [0.5, 0.25], [1.0, 1.0], [1.5, 2.25], [2.0, 4.0], [2.5, 6.25], [3.0, 9.0], [3.5, 12.25], [4.0, 16.0], [4.5, 20.25]] ``` Solutions are rounded to 6 decimal places during tests to prevent rounding errors from causing problems.
reference
def quadratic_gen(a, b, c, start=0, step=1): x = start while True: yield [x, a * x * * 2 + b * x + c] x += step
Quadratic Enumerator
5aee96e22c5061ee90000024
[ "Fundamentals" ]
https://www.codewars.com/kata/5aee96e22c5061ee90000024
7 kyu
Adapted from <a href="https://www.hackerrank.com/challenges/kangaroo/problem">here</a>, with less terrible instructions and a couple tweaks. Two kangaroos are jumping on a line. They start out at different points on the line, and jump in the same direction at different speeds. Your task is to determine whether or not they'll ever land in the same spot at the same time (you'll just have to suspend disbelief for a moment and accept that two kangaroos, for the purpose of this kata, can occupy the same space at the same time :) Your function is given four arguments `(kanga1, rate1, kanga2, rate2)`; the first kangaroo's starting point, the first kangaroo's speed, the second kangaroo's starting point, and the second kangaroo's speed. Return `true` if the above conditions are met, else `false`. Starting location and speed may vary wildly. The first kangaroo will _usually_ start behind the second one and travel faster, but not always. Starting locations may be negative, but speeds will always be > 0. **Example:** ```javascript kangaroo(kanga1 = 0, speed1 = 3, kanga2 = 4, speed2 = 2)=> true //they meet on their fourth jump ``` ![kangaroo](https://i.imgur.com/hXRgSVg.jpg) **Other examples:** ```javascript kangaroo(0,2,5,3)=> false //the first kangaroo starts behind, moves slower, and never catches up ``` Brute force solutions are possible (and not discouraged), but you'll save yourself a lot of waiting time if you don't go that route :) Good luck!
reference
def kangaroo(k1, r1, k2, r2): if r1 == r2: return k1 == k2 cross, r = divmod(k1 - k2, r2 - r1) return cross >= 0 and not r
Jumping Kangaroos
5ae7e1522c5061beb7000051
[ "Fundamentals" ]
https://www.codewars.com/kata/5ae7e1522c5061beb7000051
7 kyu
Your task is to write a function that does just what the title suggests (so, fair warning, be aware that you are not getting out of it just throwing a lame bas sorting method there) with an array/list/vector of integers and the expected number `n` of smallest elements to return. Also: * the number of elements to be returned cannot be higher than the array/list/vector length; * elements can be duplicated; * in case of duplicates, just return them according to the original order (see third example for more clarity). Same examples and more in the test cases: ```javascript firstNSmallest([1,2,3,4,5],3) === [1,2,3] //well, not technically ===, but you get what I mean firstNSmallest([5,4,3,2,1],3) === [3,2,1] firstNSmallest([1,2,3,4,1],3) === [1,2,1] firstNSmallest([1,2,3,-4,0],3) === [1,-4,0] firstNSmallest([1,2,3,4,5],0) === [] ``` ```cpp firstNSmallest({1,2,3,4,5},3) == {1,2,3} firstNSmallest({5,4,3,2,1},3) == {3,2,1} firstNSmallest({1,2,3,4,1},3) == {1,2,1} firstNSmallest({1,2,3,-4,0},3) == {1,-4,0} firstNSmallest({1,2,3,4,5},0) == {} ``` ```python first_n_smallest([1,2,3,4,5],3) == [1,2,3] first_n_smallest([5,4,3,2,1],3) == [3,2,1] first_n_smallest([1,2,3,4,1],3) == [1,2,1] first_n_smallest([1,2,3,-4,0],3) == [1,-4,0] first_n_smallest([1,2,3,4,5],0) == [] ``` ```ruby first_n_smallest([1,2,3,4,5],3) == [1,2,3] first_n_smallest([5,4,3,2,1],3) == [3,2,1] first_n_smallest([1,2,3,4,1],3) == [1,2,1] first_n_smallest([1,2,3,-4,0],3) == [1,-4,0] first_n_smallest([1,2,3,4,5],0) == [] ``` ```crystal first_n_smallest([1,2,3,4,5],3) == [1,2,3] first_n_smallest([5,4,3,2,1],3) == [3,2,1] first_n_smallest([1,2,3,4,1],3) == [1,2,1] first_n_smallest([1,2,3,-4,0],3) == [1,-4,0] first_n_smallest([1,2,3,4,5],0) == [] ``` ```c first_n_smallest((int[]){1,2,3,4,5},5,3) == {1,2,3} first_n_smallest((int[]){5,4,3,2,1},5,3) == {3,2,1} first_n_smallest((int[]){1,2,3,4,1},5,3) == {1,2,1} first_n_smallest((int[]){1,2,3,-4,0},5,3) == {1,-4,0} first_n_smallest((int[]){1,2,3,4,5},5,0) == {} ``` ```nasm first_n_smallest((int[]){1,2,3,4,5},5,3) == {1,2,3} first_n_smallest((int[]){5,4,3,2,1},5,3) == {3,2,1} first_n_smallest((int[]){1,2,3,4,1},5,3) == {1,2,1} first_n_smallest((int[]){1,2,3,-4,0},5,3) == {1,-4,0} first_n_smallest((int[]){1,2,3,4,5},5,0) == {} ``` ```haskell firstNSmallest [1,2,3,4,5] 3 `shouldBe` [1,2,3] firstNSmallest [5,4,3,2,1] 3 `shouldBe` [3,2,1] firstNSmallest [1,2,3,1,2] 3 `shouldBe` [1,2,1] firstNSmallest [1,2,3,-4,0] 3 `shouldBe` [1,-4,0] firstNSmallest [1,2,3,4,5] 0 `shouldBe` [] ``` ```csharp FirstNSmallest(new []{1,2,3,4,5},3) == new []{1,2,3} FirstNSmallest(new []{5,4,3,2,1},3) == new []{3,2,1} FirstNSmallest(new []{1,2,3,4,1},3) == new []{1,2,1} FirstNSmallest(new []{1,2,3,-4,0},3) == new []{1,-4,0} FirstNSmallest(new []{1,2,3,4,5},0) == new int[0] ``` ```rust assert_eq!(first_n_smallest(&[1,2,3,4,5], 3), [1,2,3]); assert_eq!(first_n_smallest(&[5,4,3,2,1], 3), [3,2,1]); assert_eq!(first_n_smallest(&[1,2,3,4,1], 3), [1,2,1]); assert_eq!(first_n_smallest(&[1,2,3,-4,0], 3), [1,-4,0]); assert_eq!(first_n_smallest(&[1,2,3,4,5], 0), []); ``` [Performance version by FArekkusu](https://www.codewars.com/kata/5aeed69804a92621a7000077) also available.
algorithms
def first_n_smallest(arr, n): lst = sorted(enumerate(arr), key=lambda it: it[1])[: n] lst . sort(key=lambda it: it[0]) return [v for _, v in lst]
N smallest elements in original order
5aec1ed7de4c7f3517000079
[ "Arrays", "Lists", "Data Structures", "Algorithms" ]
https://www.codewars.com/kata/5aec1ed7de4c7f3517000079
6 kyu
My 7th kata, a Python puzzle, define `x` such that `str(x)` raises an exception. Note that `str()` calls rarely raise an exception, for example: print(str(1)) #1 print(str(sum)) #<built-in function sum> print(str(i for i in range(2))) #<generator object <genexpr> at 0x7f5c0b54e798> import sys print(str(sys)) #<module 'sys' (built-in)> You cannot simply define a custom class and overide `__str__` (actually it is possible, but I've forbiden the easiest ways), or redefine `str`, but there are multiple other solutions.
games
x = {} for i in range(1000000): x = {1: x}
Cause str(x) to raise an exception
5ae786ad68e644e861000075
[ "Strings", "Puzzles" ]
https://www.codewars.com/kata/5ae786ad68e644e861000075
6 kyu
Your task is to implement a function that takes one or more dictionaries and combines them in one result dictionary. The keys in the given dictionaries can overlap. In that case you should combine all source values in an array. Duplicate values should be preserved. Here is an example: ```cs var source1 = new Dictionary<string, int>{{"A", 1}, {"B", 2}}; var source2 = new Dictionary<string, int>{{"A", 3}}; Dictionary<string, int[]> result = DictionaryMerger.Merge(source1, source2); // result should have this content: {{"A", [1, 3]}, {"B", [2]}} ``` ```python source1 = {"A": 1, "B": 2} source2 = {"A": 3} result = merge(source1, source2); // result should have this content: {"A": [1, 3]}, "B": [2]} ``` ```swift let source1 = ["A": 1, "B": 2] let source2 = ["A": 3] let result = merge([source1, source2]) // result should have this content: ["A": [1, 3], "B": [2]] ``` You can assume that only valid dictionaries are passed to your function. The number of given dictionaries might be large. So take care about performance.
reference
from collections import defaultdict def merge(* dicts): d = defaultdict(list) for dd in dicts: for k, v in dd . items(): d[k]. append(v) return d
Dictionary Merge
5ae840b8783bb4ef79000094
[ "Fundamentals" ]
https://www.codewars.com/kata/5ae840b8783bb4ef79000094
6 kyu
# Scenario *You're saying good-bye your best friend* , **_See you next happy year_** . **_Happy Year_** *is the year with only distinct digits* , (e.g) **_2018_** ___ # Task **_Given_** a year, **_Find_** **_The next happy year_** or **_The closest year You'll see your best friend_** ![!alt](https://i.imgur.com/mdX8dJP.png) ![!alt](https://i.imgur.com/mdX8dJP.png) ___ # Notes * **_Year_** Of Course always **_Positive_** . * **_Have no fear_** , *It is guaranteed that the answer exists* . * **_It's not necessary_** *that the year passed to the function is Happy one* . * **_Input Year with in range_** *(1000  ≤  y  ≤  9000)* ____ # Input >> Output Examples: ```cpp nextHappyYear (7712) ==> return (7801) ``` ```prolog next_happy_year(7712, 7801). ``` ## **_Explanation_**: As the **_Next closest year with only distinct digits is_** *7801* . ___ ```cpp nextHappyYear (8989) ==> return (9012) ``` ```prolog next_happy_year(8989, 9012). ``` ## **_Explanation_**: As the **_Next closest year with only distinct digits is_** *9012* . ___ ```cpp nextHappyYear (1001) ==> return (1023) ``` ```prolog next_happy_year(1001, 1023). ``` ## **_Explanation_**: As the **_Next closest year with only distinct digits is_** *1023* . ___ ___ ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def next_happy_year(year): year += 1 while len(set(str(year))) != 4: year += 1 return year
See You Next Happy Year
5ae7e3f068e6445bc8000046
[ "Fundamentals" ]
https://www.codewars.com/kata/5ae7e3f068e6445bc8000046
7 kyu
Part 2 version [Find X Ⅱ](https://www.codewars.com/kata/5d339b01496f8d001054887f) We have a function that takes in an integer `n`, and returns a number `x`. Lets call this function `findX(n)`/`find_x(n)` (depending on your language): ```python def find_x(n): x = 0 for i in range(n): for j in range(2*n): x += j + i return x ``` ```javascript function findX(n) { let x = 0; for (let i = 0; i < n; i++) { for (let j = 0; j < 2*n; j++) x += i + j; } return x; } ``` ```c long long find_x(int n) { long long x = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 2*n; j++) x += i + j; } return x; } ``` ```fortran integer(8) pure function findX(n) result(x) integer(8), intent(in) :: n integer(8) :: i, j x = 0 do i = 0, n - 1 do j = 0, 2 * n - 1 x = x + j + i end do end do end function findX ``` ```cobol local-storage section. 01 i pic 9(8). 01 j pic 9(8). linkage section. 01 n pic 9(8). 01 result pic 9(20). procedure division using n result. move 0 to result perform varying i from 0 by 1 until i = n perform varying j from 0 by 1 until j = 2 * n compute result = result + i + j end-perform end-perform goback. end program find-x. ``` ```factor : find-x ( n -- x ) dup 2 * [ [0,b) ] bi@ [ + ] cartesian-map [ sum ] map-sum ; ``` The functions loops throught the number `n` and at every iteration, performs a nested loop on `2*n`, at each iteration of this nested loop it increments `x` with the `(nested loop index + parents loop index)`. This works well when the numbers are reasonably small. ```python find_x(2) #=> 16 find_x(3) #=> 63 find_x(5) #=> 325 ``` ```javascript findX(2) //=> 16 findX(3) //=> 63 findX(5) //=> 325 ``` ```c find_x(2) //=> 16 find_x(3) //=> 63 find_x(5) //=> 325 ``` ```fortran findX(2) ! => 16 findX(3) ! => 63 findX(5) ! => 325 ``` ```factor 2 find-x ! --> 16 3 find-x ! --> 63 5 find-x ! --> 325 ``` But may be slow for numbers > **10<sup>3</sup>** So your task is to optimize the function `findX`/`find_x`, so it works well for large numbers. ### Input Range **1 <= n <= 10<sup>6</sup>** (**10<sup>5</sup>** in JS) *Note: This problem is more about logical reasoning than it is about finding a mathematicial formula, infact there are no complex math formula involved*
games
def findX(n): return n * * 2 * (3 * n - 2)
Find X
5ae71f8c2c5061059e000044
[ "Puzzles" ]
https://www.codewars.com/kata/5ae71f8c2c5061059e000044
6 kyu
You are given an array that of arbitrary depth that needs to be nearly flattened into a 2 dimensional array. The given array's depth is also non-uniform, so some parts may be deeper than others. All of lowest level arrays (most deeply nested) will contain only integers and none of the higher level arrays will contain anything but other arrays. All arrays given will be at least 2 dimensional. All lowest level arrays will contain at least one element. Your solution should be an array containing all of the lowest level arrays and only these. The sub-arrays should be ordered by the smallest element within each, so `[1,2]` should preceed `[3,4,5]`. Note: integers will not be repeated. For example: If you receive `[[[1,2,3],[4,5]],[6,7]]`, your answer should be `[[1,2,3],[4,5],[6,7]]`.
reference
def near_flatten(a): r = [] for x in a: if isinstance(x[0], int): r . append(x) else: r . extend(near_flatten(x)) return sorted(r)
Nearly Flatten a Messy Array
5ae64f86783bb4722c0000d7
[ "Fundamentals" ]
https://www.codewars.com/kata/5ae64f86783bb4722c0000d7
6 kyu
This kata is <del> blatantly copied from </del> inspired by <a title="This Kata" href="https://www.codewars.com/kata/reversing-fun">This Kata</a> <h1>Welcome</h1> this is the second in the series of the string iterations kata! Here we go! --------------------------------------------------------------------------------- We have a string <strong>s</strong> Let's say you start with this: "String" The first thing you do is reverse it: "gnirtS" Then you will take the string from the 1st position and reverse it again: "gStrin" Then you will take the string from the 2nd position and reverse it again: "gSnirt" Then you will take the string from the 3rd position and reverse it again: "gSntri" Continue this pattern until you have done every single position, and then you will return the string you have created. For this particular string, you would return: "gSntir" now, <h1>The Task:</h1> In this kata, we also have a number <strong>x</strong> take that reversal function, and apply it to the string x times. return the result of the string after applying the reversal function to it x times. example where s = "String" and x = 3: after 0 iteration s = "String" after 1 iteration s = "gSntir" after 2 iterations s = "rgiStn" after 3 iterations s = "nrtgSi" so you would return "nrtgSi". <h1> Note </h1> String lengths may exceed 2 million x exceeds a billion be ready to optimize if this is too hard, go here https://www.codewars.com/kata/string-%3E-n-iterations-%3E-string/java
algorithms
def string_func(s, n): l, s = [s], list(s) while True: s[:: 2], s[1:: 2] = s[: len(s) / / 2 - 1: - 1], s[: len(s) / / 2] l . append('' . join(s)) if l[0] == l[- 1]: del l[- 1] break return l[n % len(l)]
String -> X-Iterations -> String
5ae64f28d2ee274164000118
[ "Algorithms", "Puzzles", "Mathematics", "Language Features" ]
https://www.codewars.com/kata/5ae64f28d2ee274164000118
4 kyu
<h1>Welcome</h1> This kata is inspired by <a title="This Kata" href="https://www.codewars.com/kata/odd-even-string-sort">This Kata</a> We have a string <strong>s</strong> We have a number <strong>n</strong> Here is a function that takes your string, concatenates the even-indexed chars to the front, odd-indexed chars to the back. <h1>Examples</h1> s = "Wow Example!" result = "WwEapeo xml!" s = "I'm JomoPipi" result = "ImJm ii' ooPp" <h1>The Task:</h1> return the result of the string after applying the function to it n times. example where s = "qwertyuio" and n = 2: after 1 iteration s = "qetuowryi" after 2 iterations s = "qtorieuwy" return "qtorieuwy" <h1> Note </h1> there's a lot of tests, big strings, and n is greater than a billion so be ready to optimize. after doing this: do it's <a title="best friend" href="https://www.codewars.com/kumite/5b238f2325c2bb040b000086?sel=5b238f2325c2bb040b000086">best friend</a>! # Check out my other kata! <a title="Matrix Diagonal Sort OMG" href="https://www.codewars.com/kata/5ab1f8d38d28f67410000090">Matrix Diagonal Sort OMG</a> <a title="String -> N iterations -> String" href="https://www.codewars.com/kata/5ae43ed6252e666a6b0000a4">String -> N iterations -> String</a> <a title="String -> X iterations -> String" href="https://www.codewars.com/kata/5ae64f28d2ee274164000118">String -> X iterations -> String</a> <a title="ANTISTRING" href="https://www.codewars.com/kata/5ab349e01aaf060cd0000069">ANTISTRING</a> <a title="Array - squareUp b!" href="https://www.codewars.com/kata/5a8bcd980025e99381000099">Array - squareUp b!</a> <a title="Matrix - squareUp b!" href="https://www.codewars.com/kata/5a972f30ba1bb5a2590000a0">Matrix - squareUp b!</a> <a title="Infinitely Nested Radical Expressions" href="https://www.codewars.com/kata/5af2b240d2ee2764420000a2">Infinitely Nested Radical Expressions</a> <a title="pipi Numbers!" href="https://www.codewars.com/kata/5af27e3ed2ee278c2c0000e2">pipi Numbers!</a>
algorithms
def jumbled_string(s, n): iterations = [s] while True: s = s[:: 2] + s[1:: 2] if s == iterations[0]: break iterations . append(s) return iterations[n % len(iterations)]
String -> N iterations -> String
5ae43ed6252e666a6b0000a4
[ "Strings", "Algorithms", "Puzzles" ]
https://www.codewars.com/kata/5ae43ed6252e666a6b0000a4
5 kyu
Given a string that includes alphanumeric characters ("3a4B2d") return the expansion of that string: The numeric values represent the occurrence of each letter preceding that numeric value. There should be no numeric characters in the final string. #### Notes * The first occurrence of a numeric value should be the number of times each character behind it is repeated, until the next numeric value appears * If there are multiple consecutive numeric characters, only the last one should be used (ignore the previous ones) * Empty strings should return an empty string. Your code should be able to work for both lower and capital case letters. ```python "3D2a5d2f" --> "DDDaadddddff" # basic example: 3 * "D" + 2 * "a" + 5 * "d" + 2 * "f" "3abc" --> "aaabbbccc" # not "aaabc", nor "abcabcabc"; 3 * "a" + 3 * "b" + 3 * "c" "3d332f2a" --> "dddffaa" # multiple consecutive digits: 3 * "d" + 2 * "f" + 2 * "a" "abcde" --> "abcde" # no digits "1111" --> "" # no characters to repeat "" --> "" # empty string ```
reference
def string_expansion(s): m, n = '', 1 for j in s: if j . isdigit(): n = int(j) else: m += j * n return m
Simple Simple Simple String Expansion
5ae326342f8cbc72220000d2
[ "Strings", "Regular Expressions", "Fundamentals" ]
https://www.codewars.com/kata/5ae326342f8cbc72220000d2
6 kyu
Define a function that will receive a logarithm function, and returns the base of that logarithm. ``` guessBase(ln) == e ``` Base is a real number (not only integers) guaranteed to be less than `1e6`. Have a fun time coding!
reference
def determine_base(f): return 2 * * f(2) * * - 1
Determine the logarithm base
5ae1dcde9c0e489ae00019fc
[ "Mathematics", "Fundamentals" ]
https://www.codewars.com/kata/5ae1dcde9c0e489ae00019fc
7 kyu
This kata is based on a [variation](https://www.codewars.com/kata/happy-numbers-5) of *Happy Numbers* by TySlothrop. It is advisable to complete it first to grasp the idea and then move on to this one. ___ Hello, my dear friend, and welcome to another *Happy Numbers* kata! What? You're not interested in them anymore? They are all the same? But what if I say that this one is a *performance version*... ___ # Your task: Write a function which takes a number `n` as an argument and returns a list of all "happy numbers" from `1` to `n` inclusive. For example: ``` 10 => [1, 7, 10] 50 => [1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49] 100 => [1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100] ``` # Test suite: * `5000` tests with number `n` being up to `300_000` * you are not allowed to hardcode the sequence - you must to compute it (max length of the code is 1700 characters)
algorithms
sum_dig = lambda n, D = { str(d): d * d for d in range(10)}: sum(map(D . get, str(n))) def is_happy(n): return n > 4 and is_happy(sum_dig(n)) or n == 1 happy_set = set(filter(is_happy, range(100))) for n in range(100, 3 * 10 * * 5): if sum_dig(n) in happy_set: happy_set . add(n) from bisect import bisect def performant_numbers(n, happy_list=sorted( happy_set)): return happy_list[: bisect(happy_list, n)]
Happy Numbers (performance edition)
5adf5b6a2f10c6c4bc000200
[ "Performance", "Algorithms" ]
https://www.codewars.com/kata/5adf5b6a2f10c6c4bc000200
5 kyu
With your birthday coming up soon, your eccentric friend sent you a message to say "happy birthday": hhhappyyyy biirrrrrthddaaaayyyyyyy to youuuu hhapppyyyy biirtttthdaaay too youuu happy birrrthdayy to youuu happpyyyy birrtthdaaay tooooo youu At first it looks like a song, but upon closer investigation, you realize that your friend hid the phrase "happy birthday" thousands of times inside his message. In fact, it contains it more than 2 million times! To thank him, you'd like to reply with exactly how many times it occurs. To count all the occurences, the procedure is as follows: look through the paragraph and find a `'h'`; then find an `'a'` later in the paragraph; then find an `'p'` after that, and so on. Now count the number of ways in which you can choose letters in this way to make the full phrase. More precisely, given a text string, you are to determine how many times the search string appears as a sub-sequence of that string. Write a function called `countSubsequences` that takes two arguments: `needle`, the string to be search for and `haystack`, the string to search in. In our example, `"happy birthday"` is the needle and the birthday message is the haystack. The function should return the number of times `needle` occurs as a sub-sequence of `haystack`. Spaces are also considered part of the needle. Since the answers can be very large, return only the last 8 digits of the answer in case it exceeds 8 digits. The answers to the test cases will all be shorter than 8 digits.
algorithms
def count_subsequences(needle, haystack): count = [1] + [0] * len(needle) for a in haystack: count = [1] + [count[i] + count[i - 1] * (a == b) for i, b in enumerate(needle, 1)] return count[- 1] % 10 * * 8
Counting String Subsequences
52f7892a747862fc9a0009a6
[ "Algorithms", "Dynamic Programming", "Strings" ]
https://www.codewars.com/kata/52f7892a747862fc9a0009a6
4 kyu
# 7 Wonders [7 Wonders](https://en.wikipedia.org/wiki/7_Wonders_(board_game)) is a board game that consists of building your city, gathering resources and fighting your neighbors. One part of the game is also to research science in order to gain points at the end of the game. There are 3 types of science glyphs you can gather: + Compasses + Gears + Tablets The way points are added up works as described here: ### Step 1 Each **distinct set of three different glyphs** is worth 7 points: ``` 1 Compass, 1 Gear and 1 Tablet = 7 points 2 Compasses, 1 Gear and 1 Tablet = 7 points (because it's just one disctinct set) ``` Note that a **distinct set of three different glyphs** means 1 Compass, 1 Gear and 1 Tablet. No more, no less! ### Step 2 The amount of each glyph you own is **squared** and then **summed up**: ``` 1 Compass, 1 Gear and 1 Tablet = 1*1 + 1*1 + 1*1 = 3 points 2 Compasses, 1 Gear and 1 Tablet = 2*2 + 1*1 + 1*1 = 6 points ``` ### Finally The total science points is equal to the sum of the two steps: ``` 1 Compass, 1 Gear and 1 Tablet = 7 + 3 = 10 points 2 Compasses, 1 Gear and 1 Tablet = 7 + 6 = 13 points ``` You will be given 3 inputs corresponding to the amount of each glyph you have acquired in the game. Your task is to output the final score. Take into account that you may have no glyphs at all!
algorithms
def seven_wonders_science(* a): return 7 * min(a) + sum(x * x for x in a)
Count up the points for the 7 Wonders board game! Easy version
5adadcb36edb07df5600092e
[ "Puzzles" ]
https://www.codewars.com/kata/5adadcb36edb07df5600092e
7 kyu
In this kata you must implement the "fizz buzz reloaded function". This function takes the following arguments: * start (integer >= 0). -> this is the point where we start counting (inclusive). * stop (integer >= 1) -> this is the point where we stop counting (inclusive). * step (integer) if step is positive count forwards, if count is negative count backwards. for example: start = 2, end = 10, step = 2 sequence: 2 4 6 8 10 start = 10, end = 1, step = -3 sequence: 10 7 4 1 The final paremeter is a dictionary/Map object of functions *(where the key is the name of the function, and the value is the function itself)*. These functions take the following form: func(x): return bool For each number in the range, your task is to create a string where you combine the name of all functions that equate to true for the number. for example, suppose the dictionary/Map object looks like this: ```python {"fizz": lambda x: x % 3 == 0, "buzz" : lambda x: x % 5 == 0} ``` ```javascript new Map([["flash", x => x % 3 === 0], ["bang", x => x % 5 === 0]]) ``` for the number 3, the string ought to be "fizz", for the number 15 it ought to be "fizzbuzz" (no spaces) because both of the functions are true. **If NO functions equate to true, return the number** OKay, lets show you a concrete example. ```python fizz_buzz_reloaded(15, 3, -4, {"fizz": lambda x: x % 3 == 0, "buzz" lambda x: x % 5 == 0}) ``` ```javascript fizzBuzzReloaded(15, 3, -4, new Map([["flash", x => x % 3 === 0], ["bang", x => x % 5 === 0]])) ``` Our range is starting at 15 and ending at 3, with a step of -4. Thus we need to look at three numbers (15, 11, 7, 3). ``` fizz(15) is true, as is buzz(15). Thus to the results we append "fizzbuzz" fizz(11) is false, buzz(11) is false. Thus to the results we append "11", the same can be said for "7". finally, fizz(3) is true but buzz(3) is false. Thus we append "fizz" to the results. Therefore, our final sequence is: "fizzbuzz 11 7 fizz" ``` NOTES: * Each element in the output should be seperated by a single space. e.g: 1 2 3 4 ... * If multiple functions are true for any given x, return them in same order found in the intial dictionary. (for example, in the case above 15 is "fizzbuzz" not "buzzfizz" because "fizz" appears first) * This kata is designed with Python3.6 in mind. In this version of Python dictionary's are ordered.
reference
def fizz_buzz_reloaded(s, e, step, funcs): return ' ' . join('' . join([n for n, f in funcs . items() if f(x)] or [str(x)]) for x in range(s, e + step / / abs(step), step))
Fizz Buzz Reloaded
5adbc57f0774dbaa5600011b
[ "Fundamentals" ]
https://www.codewars.com/kata/5adbc57f0774dbaa5600011b
6 kyu
*Shamelessly stolen from <a href="https://adventofcode.com/2017/day/6">Here</a> :)* Your server has sixteen memory banks; each memory bank can hold any number of blocks. You must write a routine to balance the blocks between the memory banks. The reallocation routine operates in cycles. In each cycle, it finds the memory bank with the most blocks (ties won by the lowest-numbered memory bank) and redistributes those blocks among the banks. To do this, it removes all of the blocks from the selected bank, then moves to the next (by index) memory bank and inserts one of the blocks. It continues doing this until it runs out of blocks; if it reaches the last memory bank, it wraps around to the first one. We need to know how many redistributions can be done before a blocks-in-banks configuration is produced that has been seen before. For example, imagine a scenario with only four memory banks: * The banks start with 0, 2, 7, and 0 blocks (`[0,2,7,0]`). The third bank has the most blocks (7), so it is chosen for redistribution. * Starting with the next bank (the fourth bank) and then continuing one block at a time, the 7 blocks are spread out over the memory banks. The fourth, first, and second banks get two blocks each, and the third bank gets one back. The final result looks like this: 2 4 1 2. * Next, the second bank is chosen because it contains the most blocks (four). Because there are four memory banks, each gets one block. The result is: 3 1 2 3. * Now, there is a tie between the first and fourth memory banks, both of which have three blocks. The first bank wins the tie, and its three blocks are distributed evenly over the other three banks, leaving it with none: 0 2 3 4. * The fourth bank is chosen, and its four blocks are distributed such that each of the four banks receives one: 1 3 4 1. * The third bank is chosen, and the same thing happens: 2 4 1 2. At this point, we've reached a state we've seen before: 2 4 1 2 was already seen. The infinite loop is detected after the fifth block redistribution cycle, and so the answer in this example is 5. Return the number of redistribution cycles completed before a configuration is produced that has been seen before. People seem to be struggling, so here's a visual walkthrough of the above example: http://oi65.tinypic.com/dmshls.jpg Note: Remember, memory access is very fast. Yours should be too. **Hint for those who are timing out:** Look at the number of cycles happening even in the sample tests. That's a _lot_ of different configurations, and a lot of different times you're going to be searching for a matching sequence. Think of ways to cut down on the time this searching process takes. Please upvote if you enjoyed! :)
reference
def mem_alloc(banks): seen = set() while tuple(banks) not in seen: seen . add(tuple(banks)) number = max(banks) index = banks . index(number) banks[index] = 0 while number: index = (index + 1) % 16 banks[index] += 1 number -= 1 return len(seen)
Memory Reallocation
5ad927c932d79e34fb000091
[ "Arrays", "Fundamentals" ]
https://www.codewars.com/kata/5ad927c932d79e34fb000091
6 kyu
# Relations : The following challenge is partially related to two already existing Kata's. But is differnt in the sense that neither approach will work here and this is a more performance version as well. Links : [number1](https://www.codewars.com/kata/complete-the-pattern-number-9-diamond) , [number2](https://www.codewars.com/kata/give-me-a-diamond). OK last one maybe not. --- # Challenge : You are given an integer `n` as input. Your job is to create a diamond that is 2x the given number `n`. --- # Input : Input is integer `n` and n > 2 ≤ 3000. --- # Output : Output will be a string and it will be in form of a diamond consisting of `+` with an addition line at the start showing `n` using `+` --- # Examples : ``` D(3) : +++ + +++ +++++ +++++ +++ + D(5) : +++++ + +++ +++++ +++++++ +++++++++ +++++++++ +++++++ +++++ +++ + ``` --- # Restrictions : This is **code-golf** so there is a limit. Javascript solutions are limited to less than 111 characters. Python solution are limited to less than 89 characters Ruby solution are limited to less than 82 characters All limits are exlusive
games
def D(n): s = [' ' * i + '+' * (2 * (n - i) - 1) for i in range(n)]; return '\n' . join(['+' * n] + s[:: - 1] + s)
One Line Task: Diamond Creator Pro
5ad86a0fcc0f9614e1000091
[ "Strings", "Arrays", "Mathematics", "Puzzles", "Restricted" ]
https://www.codewars.com/kata/5ad86a0fcc0f9614e1000091
5 kyu
Hello. I hope you know something about <a href='https://en.wikipedia.org/wiki/Graph_theory'>Graph Theory</a>. In this simple task lets implement our own class for future use. <b>Don't be scared of long description!</b> The <code>class Graph</code> represents an undirected graph of vertices named 0 through <em>V</em> - 1. It supports 2 primary operations: <ul><li>add an edge to the graph</li> <li>iterate over all of the vertices adjacent to a vertex.</li> </ul> And provides a way for returning the number of vertices <em>V</em> and the number of edges <em>E</em>. Parallel edges and self-loops are permitted. Self-loop <em>v</em>-<em>v</em> appears in the <a href="https://en.wikipedia.org/wiki/Adjacency_list">adjacency list</a> of <em>v</em> twice. Let's see an example: Construct a graph with 3 vertices and add some edges g = Graph(3) g.add_edge(0, 1) g.add_edge(2, 2) After this you should get: g.V returns 3 g.E returns 2 g.adj returns [ [1], [0], [2, 2] ] g.adj[2] returns [2,2] and so on.. So. basically we have something like this: <img src='http://graphonline.ru/tmp/saved/Em/EmKqmIDTyCPJbMaY.png'/> Be aware that the `self.adj` field should keep track of the order in which the vertices were added. Meaning that, for example: g = Graph(4) g.add_edge(0, 1) g.add_edge(0, 3) g.add_edge(0, 2) should lead to: g.adj == [[1,3,2], [0], [0], [0]] <br> You should raise your <b>own</b> <code>IllegalArgumentError</code> on negative number of vertices in ctor or if add_edge gets incorrect args.
reference
class IllegalArgumentError (Exception): pass # Won't work if we add the same edge but that's not asked class Graph: def __init__(self, v): if v < 0: raise IllegalArgumentError() self . V = v self . E = 0 self . adj = [[] for _ in range(v)] def add_edge(self, v, w): if not (0 <= v < self . V and 0 <= w < self . V): raise IllegalArgumentError() self . adj[v]. append(w) self . adj[w]. append(v) self . E += 1
Construct Graph Class (simple)
58867e2e2d2177547500007f
[ "Object-oriented Programming", "Fundamentals", "Graph Theory" ]
https://www.codewars.com/kata/58867e2e2d2177547500007f
6 kyu
# Description : Given a string consisting entirely of binary digits (0 , 1) seperated using spaces. Find the XOR of all digits and return the answer. # Examples : Given ``` "1 0 0 1 0" --> 0 "1 0 1 1 1 0 0 1 0 0 0 0" --> 1 ``` # How : ``` 1 0 0 1 0 ``` Solving : ``` (1 XOR 0) (0 XOR 1) 0 1 1 0 (1 XOR 1) 0 0 0 0 XOR 0 0 ---> Answer ``` This is **code-golf** so shortest code is winner. The limit of solution is set to 40 chars (exclusive).
games
def X(s): return s . count('1') & 1
XOR string reduction
5ad6e5bdb0e8d46b4500201a
[ "Strings", "Mathematics", "Restricted" ]
https://www.codewars.com/kata/5ad6e5bdb0e8d46b4500201a
6 kyu
<h2>Friends</h2> <p>Andrzej was given a task:</p> <p>There are <code>n</code> jars with pills. In every jar there is a different type of pill and the amount of pills in each jar is infinite. One type of pill makes a person glow about 30 minutes after taking and none of the other types has any effect.</p> <p>His job is to determine, in which jar are the pills that make a person glow. But there is one catch, he only has 35 minutes to do so.(so he can't take a pill, wait for the results and then take another one, because he wouldn't be able to see the results) Fortunetely, he can take any number of friends he needs with him. On completing the task Andrzej receives one million dollars. You know that Andrzej is very honest, so he will split the money equally with his friends.</p> <p>Your job is to determine how many friends does Andrzej need to complete the task.(He also wants to make the highest amount of money.)</p> <p>For example for <code>n = 2</code></p> <p>The answer is <code>0</code> because he doesn't need any friends, he just needs to take a pill from the first jar and wait for the effects.</p> <p>For another example for <code>n = 4</code></p> <p>The answer is <code>1</code> because having pills <code>A B C D</code> Andrzej can take pills <code>A B</code> and the friend can take pills <code>B C</code></p> <p> Note: Andrzej is not able to accurately measure time during the task.</p>
reference
def friends(n): return (n - 1 or 1). bit_length() - 1
Friends
5ad29cd95e8240dd85000b54
[ "Algorithms", "Puzzles", "Fundamentals" ]
https://www.codewars.com/kata/5ad29cd95e8240dd85000b54
7 kyu
In this Kata you have to create a function,named `insertMissingLetters`,that takes in a `string` and outputs the same string processed in a particular way. The function should insert **only after the first occurrence** of each character of the input string, all the **alphabet letters** that: -**are NOT** in the original string -**come after** the letter of the string you are processing Each added letter should be in `uppercase`, the letters of the original string will always be in `lowercase`. Example: `input`: "holly" `missing letters`: "a,b,c,d,e,f,g,i,j,k,m,n,p,q,r,s,t,u,v,w,x,z" `output`: "hIJKMNPQRSTUVWXZoPQRSTUVWXZlMNPQRSTUVWXZlyZ" You don't need to validate input, the input string will always contain a certain amount of lowercase letters (min 1 / max 50).
algorithms
def insert_missing_letters(s): s, lst, found, inside = s . lower(), [], set(), set(s . upper()) for a in s: lst . append(a if a in found else a + '' . join(c for c in map(chr, range(ord(a) - 31, 91)) if c not in inside)) found . add(a) return '' . join(lst)
Missing Alphabet
5ad1e412cc2be1dbfb000016
[ "Strings", "Algorithms", "Games" ]
https://www.codewars.com/kata/5ad1e412cc2be1dbfb000016
6 kyu
Hepellopo! Jeringonza is a Spanish language game, similar to Pig Latin, played by children in Spain and all over Hispanic America. It consists of adding the letter p after each vowel (a, e, i, o or u) of a word, and repeating the vowel. For example, `jeringonza` becomes `jeperipingoponzapa` (or j-**epe**-r-**ipi**-ng-**opo**-nz-**apa**). For the purposes of this kata, the input and output are both strings and no input strings will be empty. Also, the added 'p' should match the case of the vowel. So `opo` for `o` and `EPE` for `E`. (If you're interested - there's a few extra components in jeringonza, such as how to deal with stressed vowels, but for the purposes of this kata we're keeping it simple) Gopoopod lupuck!
reference
def jeringonza(s): for c in 'aeiou': s = s . replace(c, c + 'p' + c) for c in 'AEIOU': s = s . replace(c, c + 'P' + c) return s
Simple Jeringonza
5aba0a08379d20026e0000be
[ "Fundamentals" ]
https://www.codewars.com/kata/5aba0a08379d20026e0000be
7 kyu
Mary wrote a recipe book and is about to publish it, but because of a new European law, she needs to update and include all measures in grams. Given all the measures in tablespoon (`tbsp`) and in teaspoon (`tsp`), considering `1 tbsp = 15g` and `1 tsp = 5g`, append to the end of the measurement the biggest equivalent integer (rounding up). ## Examples ``` "2 tbsp of butter" --> "2 tbsp (30g) of butter" "1/2 tbsp of oregano" --> "1/2 tbsp (8g) of oregano" "1/2 tsp of salt" --> "1/2 tsp (3g) of salt" "Add to the mixing bowl and coat well with 1 tbsp of olive oil & 1/2 tbsp of dried dill" --> "Add to the mixing bowl and coat well with 1 tbsp (15g) of olive oil & 1/2 tbsp (8g) of dried dill" ```
algorithms
import re import math def convert_recipe(recipe): def repl(m): ratio = 15 if m . group(2) == "tbsp" else 5 return m . group(0) + " (%sg)" % math . ceil(eval(m . group(1)) * ratio) return re . sub("([0-9/]+) (tb?sp)", repl, recipe)
Converting Measures
5acfab8d23c81836c90000eb
[ "Regular Expressions", "Algorithms" ]
https://www.codewars.com/kata/5acfab8d23c81836c90000eb
6 kyu
1. You are to write a function that takes a string as its first parameter. This string will be a string of words. 2. You are expected to then use the second parameter, which will be an integer, to find the corresponding word in the given string. The first word would be represented by 0. 3. Once you have the located string you are finally going to multiply by it the third provided parameter, which will also be an integer. You are additionally required to add a hyphen in between each word. Example ``` javascript modifyMultiply ("This is a string", 3, 5) ``` ``` python modify_multiply ("This is a string", 3 ,5) ``` ```C# Modifymultiply("This is a string", 3, 5) Should return ``` "string-string-string-string-string" ``` Since the 3rd word is 'string'(starting from 0 remember) and the third paramater indicates that it should be repeated 5 times. Simple. Good luck.
reference
def modify_multiply(st, loc, num): return '-' . join([st . split()[loc]] * num)
Multiply Word in String
5ace2d9f307eb29430000092
[ "Strings", "Algorithms", "Fundamentals", "Arrays" ]
https://www.codewars.com/kata/5ace2d9f307eb29430000092
7 kyu
In the Deca Forest, grow the Deca Trees. On each Deca Tree, a trunk has 10 branches. On each branch, there are 10 twigs. On each twig, there are 10 leaves. Unfortunately, the Deca Forest is becoming wildly overgrown and is endangering the local wildlife. You must add methods to the tree object so that the woodcutter can remove parts of a tree as follows, where `n` is a positive integer: ```javascript chopTrunk(n) will remove n trunks chopBranch(n) will remove n branches chopTwig(n) will remove n twigs chopLeaf(n) will remove n leaves ``` ```python chop_trunk(n) will remove n trunks chop_branch(n) will remove n branches chop_twig(n) will remove n twigs chop_leaf(n) will remove n leaves ``` Make sure that when you remove any part of the tree, you also remove all the smaller parts attached to it. e.g. if you remove a twig you must also remove 10 leaves from the tree object. The woodcutter's aim is to trim back this forest, so he will try to remove as much of the tree as possible each time he chops. Conversely, when you remove a smaller part, you do not need to remove the larger parts it is attached to - for example you could pick off all the leaves from a tree and the number of twigs, branches and trunks would be unaffected. The tree cannot have a negative number of trunks, branches, leaves or twigs. That would be highly unnatural. You must also add a method 'describe' that allows the Deca Forest tourguides to describe each tree. It should describe the tree in the following format: "This tree has `a` trunks, `b` branches, `c` twigs and `d` leaves." (where `a`, `b`, `c` and `d` are integer values) Your methods will be tested for trees with varying numbers of trunks and for removing random numbers of leaves, twigs, branches and trunks. The test will use only positive integers for these values. For more information on JS objects, take a look <a href="https://www.w3schools.com/js/js_object_definition.asp">here</a>
reference
class Tree (object): def __init__(self, trunks): self . data = [trunks * 10 * * i for i in range(4)] @ property def trunks(self): return self . data[0] @ property def branches(self): return self . data[1] @ property def twigs(self): return self . data[2] @ property def leaves(self): return self . data[3] def chop_trunk(self, n): self . cutcut(n, 0) def chop_branch(self, n): self . cutcut(n, 1) def chop_twig(self, n): self . cutcut(n, 2) def chop_leaf(self, n): self . cutcut(n, 3) def cutcut(self, n, here): self . data = [v if i < here else max(0, v - n * 10 * * (i - here)) for i, v in enumerate(self . data)] def describe(self): return "This tree has {} trunks, {} branches, {} twigs and {} leaves." . format(* self . data)
The Deca Tree
5acf710f46b4cb00810001e2
[ "Fundamentals" ]
https://www.codewars.com/kata/5acf710f46b4cb00810001e2
7 kyu
This is a problem that involves adding numbers to items in a list. In a list you will have to add the item's remainder when divided by a given divisor to each item. For example if the item is 40 and the divisor is 3 you would have to add 1 since 40 minus the closest multiple of 3 which is 39 is 1. So the 40 in the list will become 41. You would have to return the modified list in this problem. For this problem you will receive a divisor called `div` as well as simple list of whole numbers called `nums`. Good luck and happy coding. # Examples ```python nums = [2, 7, 5, 9, 100, 34, 32, 0], div = 3 ==> [4, 8, 7, 9, 101, 35, 34, 0] nums = [1000, 999, 998, 997], div = 5 ==> [1000, 1003, 1001, 999] nums = [], div = 2 ==> [] ``` **Note:** random tests check lists containing up to 10000 elements.
reference
def solve(nums, div): return [x + x % div for x in nums]
Adding remainders to a list
5acc3634c6fde760ec0001f7
[ "Fundamentals" ]
https://www.codewars.com/kata/5acc3634c6fde760ec0001f7
7 kyu
Determine if the poker hand is flush, meaning if the five cards are of the **same suit**. Your function will be passed a list/array of 5 strings, each representing a poker card in the format `"5H"` (5 of hearts), meaning the value of the card followed by the initial of its suit (`H`earts, `S`pades, `D`iamonds or `C`lubs). No jokers included. Your function should return `true` if the hand is a flush, `false` otherwise. The possible card values are `2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A` ## Examples ``` ["AS", "3S", "9S", "KS", "4S"] ==> true ["AD", "4S", "7H", "KS", "10S"] ==> false ```
games
def CheckIfFlush(cards): return len({c[- 1] for c in cards}) == 1
Determine if the poker hand is flush
5acbc3b3481ebb23a400007d
[ "Arrays", "Algorithms", "Logic", "Strings", "Games" ]
https://www.codewars.com/kata/5acbc3b3481ebb23a400007d
7 kyu
Given a number and a binary tree ( _not_ a Binary Search Tree! ): * return `True`/`true` if the given number is in the tree * return `False`/`false` if it isn't ~~~if:javascript Each node in the binary tree is either of this `Node` class or `null`: ```javascript class Node { constructor(value, left = null, right = null) { this.value = value; this.left = left; this.right = right; } } ``` ~~~ ~~~if:lambdacalc #### Encodings `purity: LetRec` `numEncoding: Scott` export constructors `Nil` and `Branch` for your `Tree` encoding export deconstructor `if` for your `Boolean` encoding ~~~
reference
from __future__ import annotations from typing import Optional class Node: def __init__(self, value: int, left: Optional[Node] = None, right: Optional[Node] = None): self . value = value self . left = left self . right = right def search(n: int, root: Optional[Node]) - > bool: if not root: return False if root . value == n: return True return search(n, root . left) or search(n, root . right)
Binary Tree Search (not BST)
5acc79efc6fde7838a0000a0
[ "Binary Trees", "Fundamentals" ]
https://www.codewars.com/kata/5acc79efc6fde7838a0000a0
7 kyu
There are [a](https://www.codewars.com/kata/church-numbers-add-multiply-exponents) [few](https://www.codewars.com/kata/church-numbers-1) [Katas](https://www.codewars.com/kata/church-numbers-ii) about Church Numerals so let's talk about booleans. In lambda calculus, the only primitive are lambdas. No numbers, no strings, and of course no booleans. Everything is reduced to anonymous functions. Booleans are defined thusly (this definition is preloaded for you) : ```javascript const True = T => F => T; const False = T => F => F; ``` ```haskell type Boolean = forall a. a -> a -> a -- this requires RankNTypes false,true :: Boolean false = \ t f -> f true = \ t f -> t ``` ```python true = lambda t: lambda f: t false = lambda t: lambda f: f ``` ```lambdacalc True = \ t f . t False = \ t f . f ``` Your task will be to implement basic operators on booleans (using only lambdas and function application) : `Not`, `And`, `Or` and `Xor`. ~~~if:javascript To help, the function `unchurch` comes preloaded, and returns the native boolean given a church boolean : ```javascript unchurch(True); //true; ``` <i>Note: You should not use the following: * numbers * strings * booleans * boolean operators * objects (curly brackets) or arrays (square brackets) * regexp * "new"</i> ~~~ ~~~if:haskell <i>Note: You should not use the following: * native booleans * native boolean operators</i> ~~~ ~~~if:python To help, the function `unchurch` comes preloaded, and returns the native boolean given a church boolean : ```python unchurch(true) # True ``` <i>Note: You should not use the following: * native booleans * native boolean operators</i> ~~~ ~~~if:lambdacalc See sample tests for a function `unchurch`, for converting your LC booleans to native JS booleans. #### Encodings: Purity: `Let` ~~~
reference
def Not(X): return X(false)(true) def And(X): return lambda Y: X(Y)(false) def Or(X): return lambda Y: X(true)(Y) def Xor(X): return lambda Y: X(Not(Y))(Y)
Church Booleans
5ac739ed3fdf73d3f0000048
[ "Fundamentals" ]
https://www.codewars.com/kata/5ac739ed3fdf73d3f0000048
5 kyu
Given an array of words and a target compound word, your objective is to find the two words which combine into the target word, returning both words *in the order they appear in the array*, and their respective indices *in the order they combine to form the target word*. Words in the array you are given may repeat, but there will only be one unique pair that makes the target compound word. If there is no match found, return `null`/`nil`/`None`. **Note:** Some arrays will be very long and may include duplicates, so keep an eye on efficiency. **Examples:** ``` fn(['super','bow','bowl','tar','get','book','let'], "superbowl") => ['super','bowl', [0,2]] fn(['bow','crystal','organic','ally','rain','line'], "crystalline") => ['crystal','line', [1,5]] fn(['bow','crystal','organic','ally','rain','line'], "rainbow") => ['bow','rain', [4,0]] fn(['bow','crystal','organic','ally','rain','line'], "organically") => ['organic','ally', [2,3]] fn(['top','main','tree','ally','fin','line'], "mainline") => ['main','line', [1,5]] fn(['top','main','tree','ally','fin','line'], "treetop") => ['top','tree', [2,0]] ``` Have fun, and if you enjoyed it don't forget to rank & upvote! :)
algorithms
def compound_match(words, target): for i in range(1, len(target) - 1): t1 = target[: i] t2 = target[i:] if (t1 in words) and (t2 in words): i1 = words . index(t1) i2 = words . index(t2) return ([t1, t2] if i1 < i2 else [t2, t1]) + [[i1, i2]]
Find the Word Pair!
5aaae0f5fd8c069e8c00016e
[ "Arrays", "Performance", "Algorithms" ]
https://www.codewars.com/kata/5aaae0f5fd8c069e8c00016e
5 kyu
In mathematics, a **pandigital number** is a number that in a given base has among its significant digits each digit used in the base at least once. For example, 1234567890 is a pandigital number in base 10. For simplification, in this kata, we will consider pandigital numbers in *base 10* and with all digits used *exactly once*. The challenge is to calculate a sorted sequence of pandigital numbers, starting at a certain `offset` and with a specified `size`. Example: ```ruby > getSequence(0, 5) [1023456789, 1023456798, 1023456879, 1023456897, 1023456978] ``` ```python > get_sequence(0, 5) [1023456789, 1023456798, 1023456879, 1023456897, 1023456978] ``` ```java > Pandigital.getSequence(0, 5) [1023456789, 1023456798, 1023456879, 1023456897, 1023456978] ``` ```elixir > Pandigital.get_sequence(0, 5) [1023456789, 1023456798, 1023456879, 1023456897, 1023456978] ``` Rules: - We are looking for positive pandigital numbers in base 10. - Each digit should occur `exactly once`. - A pandigital number can't start with digit zero. - The offset is an integer (negative, zero or positive number) (long in Java) - The size is a positive integer number (int in Java) - Return the `size` pandigital numbers which are not smaller than the `offset`. If there is not enough `size` pandigital numbers, just return all of them. - Return an empty array if nothing is found.
reference
def get_sequence(o, s, st=1023456789): li = [] for i in range([st, o][o > 0 and o > st], 9876543211): i = str(i) if i[0] != '0' and len(set(i)) == 10: li . append(int(i)) if len(li) == s: break return li
Pandigital Sequence
5ac69d572f317bdfc3000124
[ "Fundamentals", "Algorithms", "Mathematics" ]
https://www.codewars.com/kata/5ac69d572f317bdfc3000124
5 kyu
You have to create a function `calcType`, which receives 3 arguments: 2 numbers, and the result of an unknown operation performed on them (also a number). Based on those 3 values you have to return a string, that describes which operation was used to get the given result. The possible return strings are: `"addition"`, `"subtraction"`, `"multiplication"`, `"division"`. ## Example: ```javascript calcType(1, 2, 3) --> 1 ? 2 = 3 --> "addition" ``` ```python calcT_type(1, 2, 3) --> 1 ? 2 = 3 --> "addition" ``` ```ruby calcT_type(1, 2, 3) --> 1 ? 2 = 3 --> "addition" ``` ## Notes * In case of division you should expect that the result of the operation is obtained by using `/` operator on the input values - no manual data type conversion or rounding should be performed. * Cases with just one possible answers are generated. * Only valid arguments will be passed to the function. Only valid arguments will be passed to the function!
reference
def calc_type(a, b, res): return {a + b: "addition", a - b: "subtraction", a * b: "multiplication", a / b: "division"}[res]
Find the calculation type
5aca48db188ab3558e0030fa
[ "Fundamentals" ]
https://www.codewars.com/kata/5aca48db188ab3558e0030fa
7 kyu
<i><font color="gray">This is the performance edition of [this kata](https://www.codewars.com/kata/ulam-sequences). If you didn't do it yet, you should begin there.</font></i> --- The Ulam sequence U is defined by `u0=u`, `u1=v`, with the general term `u_n` for `n>2` given by the least integer expressible uniquely as the sum of two distinct earlier terms. In other words, the next number is always the smallest, unique sum of any two previous terms. The first 10 terms of the sequence `U(u0=1, u1=2)` are `[1, 2, 3, 4, 6, 8, 11, 13, 16, 18]`. * Here, the first term after the initial `1, 2` is obviously `3` since `3=1+2`. * The next term is `4=1+3` (we don't have to worry about `4=2+2` since it is a sum of a single term instead of two distinct terms) * `5` is not a member of the sequence since it is representable in two ways: `5=1+4=2+3`, but `6=2+4` is a member (since `3+3` isn't a valid calculation). You'll have to write a code that creates an Ulam Sequence starting with `u0`, `u1` and containing `n` terms. --- # ___The pitfall...___ While the passing solutions of the first version could have a time complexity of O(N<sup>3</sup>) (or even O(N<sup>4</sup>)!!), with 20 tests up to 100 terms only, here you'll have to manage generation of sequences up to 1500 terms before time out. ___Inputs:___ * `u0` and `u1`: integers, greater than or equal to 1 * `n`: integer greater than 1, length of the returned list ___Configuration of the tests:___ ```if:python * 6 small fixed tests * 20 random tests on small sequences (10 to 30 terms) * 13 large random tests (1500 terms) ``` ```if:ruby * 6 small fixed tests * 20 random tests on small sequences (10 to 30 terms) * 16 large random tests (1500 terms) ``` ```if:javascript,go * 6 small fixed tests * 40 random tests on small sequences (10 to 30 terms) * 30 large random tests (2450 terms) ``` --- Description Reference: http://mathworld.wolfram.com/UlamSequence.html
refactoring
def ulam_sequence(u, v, n): lst, seq, ex, q = [], 1, 1, 1 << v | 1 << u # Put u and v into queue for _ in range(n): # Repeat n times w = q & - q # Take the smallest candidate l = w . bit_length() - 1 # and its value s = seq << l # Generate its sums with all previous values seq |= w # Append it afterwards to the sequence lst . append(l) # and to the list ex |= s & q # Update excluded values if any is already in queue q |= s # Put previous sums into queue q &= ~ ex # Remove excluded values from queue return lst # Return sequence list
Ulam Sequences (performance edition)
5ac94db76bde60383d000038
[ "Algorithms", "Refactoring" ]
https://www.codewars.com/kata/5ac94db76bde60383d000038
5 kyu
`Description:` Given an input array (`arr`) of positive integers, the objective is to return an output array where each index represents the amount of times an element appeared (frequency) in the input array. More specifically, the element at each index of the output array will be an array (bucket) containing integers that appeared index-amount-of-times. Otherwise, slot nulls (JavaScript, Java), None's (Python) nils (Ruby), or NULL's (C/C++) where appropriate. A valid array will always be provided. If an array of [1,2,3,4,4,5,5,5] is passed in, the expected output should be: [null, [1,2,3], [4], [5], null, null, null, null, null]. `Explanation:` ```javascript // bucketize(arr) ======> outputArray bucketize([1,2,3,4,4,5,5,5]) ======> [null, [1,2,3], [4], [5], null, null, null, null, null] ``` ```java // bucketize(arr) ======> outputArray bucketize({1,2,3,4,4,5,5,5}) ======> {null, {1,2,3}, {4}, {5}, null, null, null, null, null} ``` ```c // bucketize(arr) ======> outputArray bucketize({1,2,3,4,4,5,5,5}) ======> {NULL, {1,2,3}, {4}, {5}, NULL, NULL, NULL, NULL, NULL} ``` ```cpp // bucketize(arr) ======> outputArray bucketize({1,2,3,4,4,5,5,5}) ======> {NULL, {1,2,3}, {4}, {5}, NULL, NULL, NULL, NULL, NULL} ``` ```python # bucketize(arr) ======> outputArray bucketize(1,2,3,4,4,5,5,5) ======> [None, [1, 2, 3], [4], [5], None, None, None, None, None] ``` An element cannot appear 0 times, so a null is placed at outputArray[0]. The elements 1, 2, and 3 appear once. This is why they are located at outputArray[1]. Notice the elements are grouped together in an array and sorted in ascending order. The element 4 appears twice. This is why it is located at outputArray[2]. The element 5 appears three times. This is why it is located at outputArray[3]. Although an integer could have possibly appeared four, five, six, seven, or eight times, this is not the case for this particular example. This is the reason why the elements at outputArray[4], outputArray[5], outputArray[6], outputArray[7], and outputArray[8] are all null values. `Examples:` ```javascript bucketize([2,2,4,4,6,6,9,9,9,9]) ===> [null, null, [2,4,6], null, [9], null, null, null, null, null, null]; bucketize([3,3,3,3,2]) =============> [null, [2], null, null, [3], null]; bucketize([5,5,5,5,5]) =============> [null, null, null, null, null, [5]]; bucketize([77,3,40,40,40]) =========> [null, [3,77], null, [40], null, null]; bucketize([16,7,5,3,6,23]) =========> [null, [3,5,6,7,16,23], null, null, null, null, null]; ``` ```java bucketize({2,2,4,4,6,6,9,9,9,9}) ===> {null, null, {2,4,6}, null, {9}, null, null, null, null, null, null}; bucketize({3,3,3,3,2}) =============> {null, {2}, null, null, {3}, null}; bucketize({5,5,5,5,5}) =============> {null, null, null, null, null, {5}}; bucketize({77,3,40,40,40}) =========> {null, {3,77}, null, {40}, null, null}; bucketize({16,7,5,3,6,23}) =========> {null, {3,5,6,7,16,23}, null, null, null, null, null}; ``` ```c bucketize({2,2,4,4,6,6,9,9,9,9}) ===> {NULL, NULL, {2,4,6}, NULL, {9}, NULL, NULL, NULL, NULL, NULL, NULL}; bucketize({3,3,3,3,2}) =============> {NULL, {2}, NULL, NULL, {3}, NULL}; bucketize({5,5,5,5,5}) =============> {NULL, NULL, NULL, NULL, NULL, {5}}; bucketize({77,3,40,40,40}) =========> {NULL, {3,77}, NULL, {40}, NULL, NULL}; bucketize({16,7,5,3,6,23}) =========> {NULL, {3,5,6,7,16,23}, NULL, NULL, NULL, NULL, NULL}; ``` ```cpp bucketize({2,2,4,4,6,6,9,9,9,9}) ===> {NULL, NULL, {2,4,6}, NULL, {9}, NULL, NULL, NULL, NULL, NULL, NULL}; bucketize({3,3,3,3,2}) =============> {NULL, {2}, NULL, NULL, {3}, NULL}; bucketize({5,5,5,5,5}) =============> {NULL, NULL, NULL, NULL, NULL, {5}}; bucketize({77,3,40,40,40}) =========> {NULL, {3,77}, NULL, {40}, NULL, NULL}; bucketize({16,7,5,3,6,23}) =========> {NULL, {3,5,6,7,16,23}, NULL, NULL, NULL, NULL, NULL}; ``` ```python bucketize(2,2,4,4,6,6,9,9,9,9) ==> [None, None, [2,4,6], None, [9], None, None, None, None, None, None] bucketize(3,3,3,3,2) ============> [None, [2], None, None, [3], None] bucketize(5,5,5,5,5) ============> [None, None, None, None, None, [5]] bucketize(77,3,40,40,40) ========> [None, [3,77], None, [40], None, None] bucketize(16,7,5,3,6,23) ========> [None, [3,5,6,7,16,23], None, None, None, None, None] ```
reference
from collections import Counter def bucketize(* a): D = {} for k, v in Counter(a). items(): D[v] = sorted(D . get(v, []) + [k]) return [D . get(i, None) for i in range(len(a) + 1)]
Frequency Analysis With Buckets
5ac95cb05624bac42e000005
[ "Fundamentals", "Arrays", "Sorting" ]
https://www.codewars.com/kata/5ac95cb05624bac42e000005
6 kyu
In English there are types of words called nouns which are persons, places, or things. There are two main classifications of nouns: common and proper nouns. In the common nouns there is another set of classifications that includes collective, compound, and normal nouns. Today we are focused on classifying compound nouns. For this kata the compound noun would be a noun made by a combination of an **adjective + noun** or a **noun + noun**. ___ You will be given a word(s) string, and you have to build a program that will output `"compound"`, `"common"`, `"adjective"`, or `"neither"` depending on the composition of the string. You will be given a collection¹ of 20 nouns called `"nouns" `and a collection of 20 adjectives called `"adjectives"` that are valid in this program. collection¹ = `set` in Python | `array` in Javascript ___ Examples: ``` "eyebrow" -> compound # noun "eye" + noun "brow" "mushroom" -> neither # not listed "" -> neither # not listed "chocolate" -> adjective # in the adjectives set "man" -> common # in the nouns set ```
reference
compounds = {left + right for right in nouns for left in nouns | adjectives} def part(word): if word in nouns: return "common" if word in adjectives: return "adjective" if word in compounds: return "compound" return "neither"
Compound Nouns, Common Nouns, and Adjectives Test
5ac9662d58b03979d800000d
[ "Fundamentals", "Strings", "Parsing" ]
https://www.codewars.com/kata/5ac9662d58b03979d800000d
6 kyu
Ho ho! So you think you know integers, do you? Well then, young wizard, tell us what the Nth digit of the [Champernowne constant](https://en.wikipedia.org/wiki/Champernowne_constant) is! The constant proceeds like this: `0.12345678910111213141516...` I hope you see the pattern! Conjure a function that will accept an integer, `n`, and return the (one-indexed) `n`th digit of Champernowne's constant. Can you get it to run in _constant_ time? For example: `n = 1` should return `0` (the very first digit) `n = 2` should return `1` (we ignore the period character since it's not a digit!) `n = 20` should return `4` (that's the `4` in the number `14`, 20th in sequence) For any invalid values, such as `0` and below, or non-integers, return... `NaN`! I hope (for your sake) that you've been practicing your mathemagical spells, because a naïve solution will _not_ be fast enough to compete in this championship! Invoke with _precision_, and be wary of rounding errors in the realms of enormity! May the best integer win!
algorithms
from math import log, ceil def champernowne_digit(n): if type(n) != int or n < 1: return float('nan') ln, diff = 0, n - 1 while diff > 9 * (ln + 1) * 10 * * ln: diff -= 9 * (ln + 1) * 10 * * ln ln += 1 return int(str(10 * * (ln) - 1 + ceil(diff / (ln + 1)))[(diff - 1) % (ln + 1)])
Champernowne's Championship
5ac53c71376b11df7e0001a9
[ "Mathematics", "Algorithms" ]
https://www.codewars.com/kata/5ac53c71376b11df7e0001a9
6 kyu
# Task **_Given_** a **_list of digits_**, *return the **_smallest number_** that could be formed from these digits, using the digits only once (ignore duplicates).* ___ # Notes: * Only **_positive integers_** *will be passed to the function (> 0 ), no negatives or zeros.* ___ # Input >> Output Examples ``` minValue ({1, 3, 1}) ==> return (13) ``` ## Explanation: **_(13)_** *is the minimum number could be formed from* **_{1, 3, 1}_** , *Without duplications* ___ ``` minValue({5, 7, 5, 9, 7}) ==> return (579) ``` ## Explanation: **_(579)_** *is the minimum number could be formed from* **_{5, 7, 5, 9, 7}_** , *Without duplications* ___ ``` minValue({1, 9, 3, 1, 7, 4, 6, 6, 7}) return ==> (134679) ``` ## Explanation: **_(134679)_** *is the minimum number could be formed from* **_{1, 9, 3, 1, 7, 4, 6, 6, 7}_** , *Without duplications* ___ ___ ## [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [Bizarre Sorting-katas](https://www.codewars.com/collections/bizarre-sorting-katas) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def min_value(digits): return int("" . join(map(str, sorted(set(digits)))))
Form The Minimum
5ac6932b2f317b96980000ca
[ "Fundamentals" ]
https://www.codewars.com/kata/5ac6932b2f317b96980000ca
7 kyu
Lexicographic permutations are ordered combinations of a set of items ordered in a specific way. For instance, the first 8 permutations of the digits 0123, in lexicographic order, are: ``` 1st 0123 2nd 0132 3rd 0213 4th 0231 5th 0312 6th 0321 7th 1023 8th 1032 ``` Your task is to write a function ```L( n, d )``` that will return a `string` representing the `nth` permutation of the `d` digit, starting with 0 (i.e. d=10 means all digits 0123456789). So for `d = 4`, `L(7,4)` should return `'1023'`, and `L(4,4)` should return `'0231'` . Some things to bear in mind: • The function should return a `string`, otherwise permutations beginning with a 0 will have it removed. • Test cases will not exceed the highest possible valid values for `n` • The function should work for any `d` between `1` and `10`. • A value of 1 for `n` means the 1st permutation, so `n = 0` is not a valid input. • Oh, and no itertools ;)
reference
def nth_perm(n, d): k = n - 1 digits = [str(i) for i in range(d)] for i in [362880, 40320, 5040, 720, 120, 24, 6, 2, 1, 1][- d:]: i, k = divmod(k, i) digits . append(digits . pop(i)) return '' . join(digits)
Lexicographic Permutations
55baa55cf332e67eb000000a
[ "Fundamentals", "Algorithms", "Combinatorics", "Mathematics", "Logic" ]
https://www.codewars.com/kata/55baa55cf332e67eb000000a
6 kyu
Given a string of characters, I want the function `findMiddle()`/`find_middle()` to return the middle number in the product of each digit in the string. Example: 's7d8jd9' -> 7, 8, 9 -> 7\*8\*9=504, thus 0 should be returned as an integer. Not all strings will contain digits. In this case and the case for any non-strings, return -1. If the product has an even number of digits, return the middle two digits Example: 1563 -> 56 NOTE: Remove leading zeros if product is even and the first digit of the two is a zero. Example 2016 -> 1
reference
from operator import mul from functools import reduce def find_middle(s): if not s or not isinstance(s, str): return - 1 lstDig = [int(c) for c in s if c . isnumeric()] if not lstDig: return - 1 prod = str(reduce(mul, lstDig)) i = (len(prod) - 1) / / 2 return int(prod[i: - i or len(prod)])
Find the Middle of the Product
5ac54bcbb925d9b437000001
[ "Fundamentals", "Strings" ]
https://www.codewars.com/kata/5ac54bcbb925d9b437000001
7 kyu
It started as a discussion with a friend, who didn't fully grasp some way of setting defaults, but I thought the idea was cool enough for a beginner kata: binary `OR` each matching element of two given arrays (or lists, if you do it in Python; vectors in c++) of integers and give the resulting ORed array [starts to sound like a tonguetwister, doesn't it?]. If one array is shorter than the other, use the optional third parameter (defaulted to `0`) to `OR` the unmatched elements. For example: ```javascript orArrays([1,2,3],[1,2,3]) === [1,2,3] orArrays([1,2,3],[4,5,6]) === [5,7,7] orArrays([1,2,3],[1,2]) === [1,2,3] orArrays([1,2],[1,2,3]) === [1,2,3] orArrays([1,2,3],[1,2,3],3) === [1,2,3] ``` ```cpp orArrays([1,2,3],[1,2,3]) == [1,2,3] orArrays([1,2,3],[4,5,6]) == [5,7,7] orArrays([1,2,3],[1,2]) == [1,2,3] orArrays([1,2],[1,2,3]) == [1,2,3] orArrays([1,2,3],[1,2,3],3) == [1,2,3] ``` ```python or_arrays([1,2,3],[1,2,3]) == [1,2,3] or_arrays([1,2,3],[4,5,6]) == [5,7,7] or_arrays([1,2,3],[1,2]) == [1,2,3] or_arrays([1,2],[1,2,3]) == [1,2,3] or_arrays([1,2,3],[1,2,3],3) == [1,2,3] ``` ```ruby or_arrays([1,2,3],[1,2,3]) == [1,2,3] or_arrays([1,2,3],[4,5,6]) == [5,7,7] or_arrays([1,2,3],[1,2]) == [1,2,3] or_arrays([1,2],[1,2,3]) == [1,2,3] or_arrays([1,2,3],[1,2,3],3) == [1,2,3] ``` ```crystal or_arrays([1,2,3],[1,2,3]) == [1,2,3] or_arrays([1,2,3],[4,5,6]) == [5,7,7] or_arrays([1,2,3],[1,2]) == [1,2,3] or_arrays([1,2],[1,2,3]) == [1,2,3] or_arrays([1,2,3],[1,2,3],3) == [1,2,3] ``` ```java orArrays([1,2,3],[1,2,3]) == [1,2,3] orArrays([1,2,3],[4,5,6]) == [5,7,7] orArrays([1,2,3],[1,2]) == [1,2,3] orArrays([1,2],[1,2,3]) == [1,2,3] orArrays([1,2,3],[1,2,3],3) == [1,2,3] ```
reference
from itertools import zip_longest def or_arrays(a1, a2, d=0): return [x | y for x, y in zip_longest(a1, a2, fillvalue=d)]
ORing arrays
5ac5e9aa3853da25d9000102
[ "Arrays", "Lists", "Binary", "Fundamentals" ]
https://www.codewars.com/kata/5ac5e9aa3853da25d9000102
7 kyu
Write a function ```python alternate_sort(l) ``` that combines the elements of an array by sorting the elements ascending by their **absolute value** and outputs negative and non-negative integers alternatingly (starting with the negative value, if any). E.g. ```python alternate_sort([5, -42, 2, -3, -4, 8, -9,]) == [-3, 2, -4, 5, -9, 8, -42] alternate_sort([5, -42, 2, -3, -4, 8, 9]) == [-3, 2, -4, 5, -42, 8, 9] alternate_sort([5, 2, -3, -4, 8, -9]) == [-3, 2, -4, 5, -9, 8] alternate_sort([5, 2, 9, 3, 8, 4]) == [2, 3, 4, 5, 8, 9] ```
algorithms
from itertools import chain, zip_longest def alternate_sort(l): l = sorted(l, key=abs) p, n = [n for n in l if n >= 0], [n for n in l if n < 0] return [n for n in chain(* zip_longest(n, p)) if n is not None]
Alternating sort
5ac49156376b11767f00060c
[ "Algorithms", "Arrays", "Sorting" ]
https://www.codewars.com/kata/5ac49156376b11767f00060c
6 kyu
# Scenario **_Several people_** are standing in *a row divided into two teams*. The **_first person_** goes into **_team 1_**, **_the second_** goes into **_team 2_**, **_the third_** goes into **_team 1_**, and so on. ___ # Task **_Given_** *an array of positive integers (the weights of the people)*, **_return_** *a new array/tuple of two integers*, **_where_** **_the first_** one is the **_total weight of team 1_**, and **_the second_** one is the **_total weight of team 2_**. ___ # Notes * **_Array size_** is *at least 1*. * **_All numbers_** will be **positive**. ___ # Input >> Output Examples ```cpp rowWeights([13, 27, 49]) ==> return (62, 27) ``` ```prolog row_weights([13, 27, 49], [62, 27]). ``` ## **_Explanation_**: **_The first element_** `62` is *the total weight of team 1*, and **_the second element_** `27` is *the total weight of team 2*. ___ ```cpp rowWeights([50, 60, 70, 80]) ==> return (120, 140) ``` ```prolog row_weights([50, 60, 70, 80], [120, 140]). ``` ## **_Explanation_**: **_The first element_** `120` is *the total weight of team 1*, and **_the second element_** `140` is *the total weight of team 2*. ___ ```cpp rowWeights([80]) ==> return (80, 0) ``` ```prolog row_weights([80], [80, 0]). ``` ## **_Explanation_**: **_The first element_** `80` is *the total weight of team 1*, and **_the second element_** `0` is *the total weight of team 2*. ___ ___ ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def row_weights(array): return sum(array[:: 2]), sum(array[1:: 2])
Row Weights
5abd66a5ccfd1130b30000a9
[ "Fundamentals", "Arrays" ]
https://www.codewars.com/kata/5abd66a5ccfd1130b30000a9
7 kyu
You are given a string. Your job is to convert that string to upper case, then find the sum of each character converted to its ASCII value, then divide the sum by the string's length and round it down then convert that to its equivalent character in ASCII. ~~~if:python,ruby **Note:** do it in maximum `57` characters ~~~ ## Examples ```python "abc" --> "B" "asd" --> "H" "iamareallyreallylongstringthatiscompletelyworthlessandisheretostophardcoders" --> "L" ```
algorithms
def solution(s): return chr(sum(map(ord, s . upper())) / / len(s))
[Code Golf] String to ASCII Character
5abbb33396194245d5000161
[ "Restricted", "Strings", "Algorithms" ]
https://www.codewars.com/kata/5abbb33396194245d5000161
7 kyu
# Task **_Given_** a **_Divisor and a Bound_** , *Find the largest integer N* , Such That , # Conditions : * **_N_** is *divisible by divisor* * **_N_** is *less than or equal to bound* * **_N_** is *greater than 0*. ___ # Notes * The **_parameters (divisor, bound)_** passed to the function are *only positive values* . * *It's guaranteed that* a **divisor is Found** . ___ # Input >> Output Examples ``` divisor = 2, bound = 7 ==> return (6) ``` ## Explanation: **_(6)_** is divisible by **_(2)_** , **_(6)_** is less than or equal to bound **_(7)_** , and **_(6)_** is > 0 . ___ ``` divisor = 10, bound = 50 ==> return (50) ``` ## Explanation: **_(50)_** *is divisible by* **_(10)_** , **_(50)_** is less than or equal to bound **_(50)_** , and **_(50)_** is > 0 .* ___ ``` divisor = 37, bound = 200 ==> return (185) ``` ## Explanation: **_(185)_** is divisible by **_(37)_** , **_(185)_** is less than or equal to bound **_(200)_** , and **_(185)_** is > 0 . ___ ## [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [Bizarre Sorting-katas](https://www.codewars.com/collections/bizarre-sorting-katas) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou ~~~if:java Java's default return statement can be any `int`, a divisor **will** be found. ~~~ ~~~if:nasm ## NASM-specific notes The function declaration is `int max_multiple(int divisor, int bound)` where the first argument is the divisor and the second one is the bound. ~~~
bug_fixes
def max_multiple(divisor, bound): return bound - (bound % divisor)
Maximum Multiple
5aba780a6a176b029800041c
[ "Fundamentals" ]
https://www.codewars.com/kata/5aba780a6a176b029800041c
7 kyu
Mr Leicester's cheese factory is the pride of the East Midlands, but he's feeling a little blue. It's the time of the year when **the taxman is coming round to take a slice of his cheddar** - and the final thing he has to work out is how much money he's spending on his staff. Poor Mr Leicester can barely sleep he's so stressed. Can you help? - Mr Leicester **employs 4 staff**, who together make **10 wheels of cheese every 6 minutes**. - Worker pay is calculated on **how many wheels of cheese they produce in a day**. - Mr Leicester pays his staff according to the UK living wage, which is currently **£8.75p an hour**. There are **100 pence (p) to the UK pound (£)**. The input for function payCheese will be provided as an array of five integers, one for each amount of cheese wheels produced each day. When the workforce don't work a nice integer number of minutes - much to the chagrin of the company accountant - Mr Leicester very generously **rounds up to the nearest hour** at the end of the week (*not the end of each day*). Which means if the workers make 574 wheels on each day of the week, they're each paid 29 hours for the week (28.699 hours rounded up) and not 30 (6 hours a day rounded up * 5). The return value should be a string (with the £ included) of the **total £ of staff wages for that week.**
reference
from math import ceil def pay_cheese(arr): return f'L { ceil ( sum ( arr ) / 100 ) * 35 } '
Sweet Dreams are Made of Cheese
5ab7ee556a176b1043000047
[ "Fundamentals" ]
https://www.codewars.com/kata/5ab7ee556a176b1043000047
7 kyu
> In computing, a hex dump is a hexadecimal view (on screen or paper) of computer data, from RAM or from a file or storage device. Looking at a hex dump of data is commonly done as a part of debugging, or of reverse engineering. > > In a hex dump, each byte (8-bits) is represented as a two-digit hexadecimal number. Hex dumps are commonly organized into rows of 8 or 16 bytes, sometimes separated by whitespaces. Some hex dumps have the hexadecimal memory address at the beginning and/or a checksum byte at the end of each line. *(source: https://en.wikipedia.org/wiki/Hex_dump)* ## Your Task Your task is to complete the functions `hexdump` and `dehex`: ```if:python `hexdump` takes a binary input (a bytes object) and returns a hex dump (as a string) in the following format: ``` ```if:java `hexdump` takes a byte array and returns a hex dump (as a string) in the following format: ``` ```if:cpp `hexdump` takes a `vector<char>` and returns a hex dump (as a string) in the following format: ``` * the memory address displayed as an 8-digit hexadecimal number (starting from `00000000`), followed by a colon (`:`) and a space, * 16 bytes displayed as 2-digit hexadecimal numbers, separated by a space, * two spaces, * the ASCII translation of the bytes if the ASCII values are between 32 and 126 (both included), otherwise a full stop (`.`) **Note:** all hexadecimal values (data and addresses) should be presented in lowercase If the last line is shorter than 16 bytes, then replace the byte values with spaces, but trim the trailing spaces from the end of the line. For example: ``` 00000000: 1d c4 15 25 91 e6 09 59 04 99 15 29 0a 45 21 29 ...%...Y...).E!) 00000010: 26 8e 74 a0 1a be 75 68 06 dd 70 33 a4 77 7a 5d &.t...uh..p3.wz] 00000020: b1 ba 22 a7 cf cc f7 ef b1 e3 13 ed f1 89 ad ad .."............. 00000030: b8 2a 52 32 65 79 43 99 6f c8 d3 8e b2 5f 50 c9 .*R2eyC.o...._P. 00000040: 08 4a 12 25 79 c2 dd 31 6b b8 77 74 4b 68 4b d4 .J.%y..1k.wtKhK. 00000050: db 4e 92 09 d5 4c 9f 0b fd a9 d1 .N...L..... ``` ```if:python `dehex` takes a string input, in the same format as the output described above, and returns binary output. ``` ```if:java `dehex` takes a string input, in the same format as the output described above, and returns byte array. ``` ```if:cpp `dehex` takes a string input, in the same format as the output described above, and returns `vector<char>`. ``` **Note:** all inputs will be valid, so validating it is not necessary. --- ## My other katas If you enjoyed this kata then please try [my other katas](https://www.codewars.com/users/anter69/authored)! :-) #### *Translations are welcome!* (except for ruby)
algorithms
def hexdump(data): return '\n' . join('{:08x}: {:48} {}' . format(i, ' ' . join( map('{:02x}' . format, data[i: i + 16])), bytes(b if 32 <= b < 127 else ord( '.') for b in data[i: i + 16]). decode() ) for i in range(0, len(data), 16)) def dehex(text): return bytes(int(b, 16) for line in text . splitlines() for b in line[10: 58]. split())
Hex Dump
5ab3be5f6a176bef4e00012d
[ "Algorithms" ]
https://www.codewars.com/kata/5ab3be5f6a176bef4e00012d
5 kyu
Complete the function that accepts a valid string and returns an integer. Wait, that would be too easy! Every character of the string should be converted to the hex value of its ascii code, then the result should be the sum of the numbers in the hex strings (ignore letters). ## Examples ``` "Yo" ==> "59 6f" ==> 5 + 9 + 6 = 20 "Hello, World!" ==> 91 "Forty4Three" ==> 113 ```
reference
def hex_hash(code): return sum(int(d) for c in code for d in hex(ord(c)) if d . isdigit())
Hex Hash Sum
5ab363ff6a176b29880000dd
[ "Mathematics", "Security", "Fundamentals" ]
https://www.codewars.com/kata/5ab363ff6a176b29880000dd
7 kyu
You will be given a 2d char array <strong>data. The task is to rearrange the elements in the SAME order, diagonally, like this: c h a c a c r a c ==> h a e t e r r t r here's another example j a v a j v o t c o d e ==> a c e c t a c o a d a o another one! T h i s A r r a y T i r y s r Y s y i S s O c r a z Y ==> h A a S c z t L a I t s R l y B a d s r i O a I R B d In other words, consider the order in which you read books (from left to right then down a line). Take the characters in that order, and place them back in so that you can read them diagonally. The diagonals run from bottom left to top right. The first diagonal starts at element[0][0]. # Note: the ascii value of chars is does not affect the ordering. All array dimensions will be greater than 0. ------------------------------------------------------------------------------------------------ # Check out my other kata! <a title="Matrix Diagonal Sort OMG" href="https://www.codewars.com/kata/5ab1f8d38d28f67410000090">Matrix Diagonal Sort OMG</a> <a title="String -> N iterations -> String" href="https://www.codewars.com/kata/5ae43ed6252e666a6b0000a4">String -> N iterations -> String</a> <a title="String -> X iterations -> String" href="https://www.codewars.com/kata/5ae64f28d2ee274164000118">String -> X iterations -> String</a> <a title="ANTISTRING" href="https://www.codewars.com/kata/5ab349e01aaf060cd0000069">ANTISTRING</a> <a title="Array - squareUp b!" href="https://www.codewars.com/kata/5a8bcd980025e99381000099">Array - squareUp b!</a> <a title="Matrix - squareUp b!" href="https://www.codewars.com/kata/5a972f30ba1bb5a2590000a0">Matrix - squareUp b!</a> <a title="Infinitely Nested Radical Expressions" href="https://www.codewars.com/kata/5af2b240d2ee2764420000a2">Infinitely Nested Radical Expressions</a> <a title="pipi Numbers!" href="https://www.codewars.com/kata/5af27e3ed2ee278c2c0000e2">pipi Numbers!</a>
algorithms
def diagonal_sort(data): if not data: return data p, lX, lY = 0, len(data), len(data[0]) lst = [[''] * lY for _ in range(lX)] for z in range(lX + lY - 1): x, y = min(lX - 1, z), max(0, z - lX + 1) while 1: lst[x][y] = data[p / / lY][p % lY] x, y, p = x - 1, y + 1, p + 1 if x < 0 or y == lY: break return lst diagonalSort = diagonal_sort
Arrange Matrix by Diagonals -- OMG
5ab1f8d38d28f67410000090
[ "Algorithms", "Matrix" ]
https://www.codewars.com/kata/5ab1f8d38d28f67410000090
6 kyu
Your computer has forgotten how to speak ASCII! (or Unicode, whatever) It can only communicate in binary, and it has something important to tell you. Write a function which will receive a long string of binary code and convert it to a string. Remember, in Python binary output starts with '0b'. As an example: `binary_to_string('0b10000110b11000010b1110100') == 'Cat'` Input may consist of upper and lower case letters and numbers, in binary form of course, as well as special symbols. The input to your function will always be one string of binary. ~~~if:fortran *NOTE: In Fortran, your returned string may* **not** *contain redundant leading/trailing whitespace. You may also assume that the input string will not contain redundant leading/trailing whitespace.* ~~~
reference
def binary_to_string(binary): return '' . join(chr(int(b, 2)) for b in binary[2:]. split('0b'))
Binary to string
5ab3495595df9ec78f0000b4
[ "Binary", "Strings", "Fundamentals" ]
https://www.codewars.com/kata/5ab3495595df9ec78f0000b4
7 kyu
Your task is to write regular expression that validates gregorian date in format "DD.MM.YYYY" Correct date examples: ```python "23.12.2008" "01.08.1994" ``` Incorrect examples: ```python "12.23.2008" "01-Aug-1994" " 01.08.1994" ``` Notes: * maximum length of validator is 400 characters to avoid hardcoding. (shortest solution to date is 170 characters) * validator should process leap days (February, 29) correctly. * the date is Gregorian, it's important to determine if year is leap: https://en.wikipedia.org/wiki/Gregorian_calendar
reference
date_validator = ( '(((' '(0[1-9]|1\d|2[0-8])\.(0[1-9]|1[012])|' # 01-28 of any month '(29|30)\.(0[13-9]|1[012])|' # 29-30 of months, except February '(31\.(0[13578]|1[02])))\.' # 31 of long months '([1-9]\d{3}|\d{3}[1-9]))|' # any year, except 0000 '(29\.02\.(' # leap day '\d\d([2468][048]|[13579][26]|0[48])|' # leap years (mod 4) '([2468][048]|[13579][26]|0[48])00' # leap years (mod 400) ')))$')
Regex for Gregorian date validation
5ab23a9c1cec39668c000055
[ "Strings", "Regular Expressions", "Fundamentals" ]
https://www.codewars.com/kata/5ab23a9c1cec39668c000055
5 kyu
Freddy has a really fat left pinky finger, and every time Freddy tries to type an ```A```, he accidentally hits the CapsLock key! Given a string that Freddy wants to type, emulate the keyboard misses where each ```A``` supposedly pressed is replaced with CapsLock, and return the string that Freddy actually types. It doesn't matter if the ```A``` in the string is capitalized or not. When CapsLock is enabled, capitalization is reversed, but punctuation is not affected. Examples: ``` "The quick brown fox jumps over the lazy dog." -> "The quick brown fox jumps over the lZY DOG." "The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the blessings of life: and whenever these great objects are not obtained, the people have a right to alter the government, and to take measures necessary for their safety, prosperity and happiness." -> "The end of the institution, mINTENnce, ND dministrTION OF GOVERNMENT, IS TO SECURE THE EXISTENCE OF THE BODY POLITIC, TO PROTECT IT, nd to furnish the individuLS WHO COMPOSE IT WITH THE POWER OF ENJOYING IN Sfety ND TRnquillity their nTURl rights, ND THE BLESSINGS OF LIFE: nd whenever these greT OBJECTS re not obtINED, THE PEOPLE Hve RIGHT TO lter the government, ND TO Tke meSURES NECESSry for their sFETY, PROSPERITY nd hPPINESS." "aAaaaaAaaaAAaAa" -> "" ``` (Adapted from https://codegolf.stackexchange.com/questions/158132/no-a-just-caps-lock)
reference
def fat_fingers(s): if not s: return s swap = [False] return '' . join(c . swapcase() if swap[0] else c for c in s if c not in "aA" or swap . __setitem__(0, not swap[0]))
Fat Fingers
5aa99584fd5777ee9a0001f1
[ "Strings", "Fundamentals" ]
https://www.codewars.com/kata/5aa99584fd5777ee9a0001f1
6 kyu
According to [Gary Chapman](https://en.wikipedia.org/wiki/Gary_Chapman_(author)), marriage counselor and the author of ["The Five Love Languages"](https://en.wikipedia.org/wiki/The_Five_Love_Languages) books, there are five major ways to express our love towards someone: *words of affirmation, quality time, gifts, acts of service,* and *physical touch*. These are called the love languages. Usually, everyone has a main language: the one that he/she "speaks" and understands best. In a relationship, it's important to find your partner's main love language, so that you get along better with each other. ### Your task Unfortunately, your relationship got worse lately... After a long discussion with your partner, you agreed to give yourself a few weeks to improve it, otherwise you split up... You will be given a `partner` instance, and `n` weeks. The `partner` has a `.response` method, and the responses may be: `"positive"` or `"neutral"`. You can try to get a response once a day, thus you have `n * 7` tries in total to find the main love language of your partner! ```if-not:haskell The love languages are: `"words", "acts", "gifts", "time", "touch"` (available predefined as `LOVE_LANGUAGES`) ``` ```if:haskell The love languages are: `Words, Acts, Gifts, Time, Touch` ( available `Preloaded` as `LoveLanguage` ) ``` #### Notes: * Your partner will sometimes give a positive response to any love language (a "false positive"), but the main one has a much higher possibility. On the other hand, you may get a neutral response even for the correct language, but with a low possibility (a "false negative"). * There will be 50 tests. There is a slight chance (about 0.5%) to fail a test even with a proper solution, due to the randomness. So if you get 49/50, just run the tests again. ### Examples ```python main love language: "words" partner.response("words") --> "positive" partner.response("acts") --> "neutral" partner.response("words") --> "positive" partner.response("time") --> "neutral" partner.response("acts") --> "positive" # false positive partner.response("gifts") --> "neutral" partner.response("words") --> "neutral" # false negative etc. ``` ```haskell main love language: Words response Words partner -> Positive response Acts partner -> Neutral response Words partner -> Positive response Time partner -> Neutral response Acts partner -> Positive -- false positive response Gifts partner -> Neutral response Words partner -> Neutral -- false negative etc. ``` ~~~if:haskell ## Notes `Preloaded` exports the following: ```haskell data LoveLanguage = Words | Acts | Gifts | Time | Touch deriving (Show,Eq,Ord,Enum,Bounded) data Reaction = Neutral | Positive deriving (Show,Eq,Ord,Enum,Bounded) type Partner response :: LoveLanguage -> Partner -> IO Reaction ``` ~~~ Happy coding, and **DO** try this at home! :-) --- ### My other katas If you enjoyed this kata then please try [my other katas](https://www.codewars.com/collections/katas-created-by-anter69)! :-) #### *Translations are welcome!*
algorithms
import random def love_language(partner, weeks): rst = [0, 0, 0, 0, 0] for i in range(0, weeks * 7): if (partner . response(LOVE_LANGUAGES[i % 5]) == 'positive'): rst[i % 5] += 1 return LOVE_LANGUAGES[rst . index(max(rst))]
The 5 Love Languages
5aa7a581fd8c06b552000177
[ "Machine Learning", "Algorithms", "Data Science" ]
https://www.codewars.com/kata/5aa7a581fd8c06b552000177
6 kyu
Generate and return **all** possible increasing arithmetic progressions of six primes `[a, b, c, d, e, f]` between the given limits. Note: the upper and lower limits are inclusive. An arithmetic progression is a sequence where the difference between consecutive numbers is the same, such as: 2, 4, 6, 8. A prime number is a number that is divisible only by itself and 1 (e.g. 2, 3, 5, 7, 11) Your solutions should be returned as lists inside a list in ascending order of the first item (if there are multiple lists with same first item, return in ascending order for the second item etc) are the e.g: `[ [a, b, c, d, e, f], [g, h, i, j, k, l] ]` where `a < g`. If there are no solutions, return an empty list: `[]` ## Examples ```javascript 0, 200 ==> [ [7, 37, 67, 97, 127, 157] ] 150, 1000 ==> [ [157, 307, 457, 607, 757, 907], [239, 359, 479, 599, 719, 839], [281, 401, 521, 641, 761, 881], [359, 389, 419, 449, 479, 509], [503, 593, 683, 773, 863, 953], [541, 571, 601, 631, 661, 691], [641, 701, 761, 821, 881, 941] ] ```
reference
def is_prime(n): return all(n % d for d in range(3, int(n * * .5) + 1, 2)) def primes_a_p(lower_limit, upper_limit): a_p = [] for n in range(lower_limit | 1, upper_limit, 2): for gap in range(30, (upper_limit - n) / / 5 + 1, 30): sequence = [n + i * gap for i in range(6)] if all(map(is_prime, sequence)): a_p . append(sequence) return a_p
Arithmetic Progression of Primes
5aa7ce59373c2e3ed30000cb
[ "Fundamentals" ]
https://www.codewars.com/kata/5aa7ce59373c2e3ed30000cb
6 kyu
In this kata you're expected to find the longest consecutive sequence of positive squares that sums up to a number. E.g, ** 595 = 6<sup>2</sup> + 7<sup>2</sup> + 8<sup>2</sup> + 9<sup>2</sup> + 10<sup>2</sup> + 11<sup>2</sup> + 12<sup>2</sup> **. ```if:python Your task is to write the function `longest_sequence(n)` that either finds the longest consecutive sequence of squares that sums to the number `n`, or determines that no such sequence exists. ``` ```if:javascript Your task is to write the function `longestSequence(n)` that either finds the longest consecutive sequence of squares that sums to the number `n`, or determines that no such sequence exists. ``` ```if:haskell Your task is to write the function `longestSequence :: Integer -> [Integer]` that either finds the longest consecutive sequence of squares that sums to the argument, or determines that no such sequence exists. ``` ```python longest_sequence(50) # => [3, 4, 5] # 9 + 16 + 25 = 50 longest_sequence(595) # => [6, 7, 8, 9, 10, 11, 12] longest_sequence(10) # => [] ``` ```javascript longestSequence(50) // => [3, 4, 5] // 9 + 16 + 25 = 50 longestSequence(595) // => [6, 7, 8, 9, 10, 11, 12] longestSequence(10) // => [] ``` ```haskell longestSequence 50 -> [3, 4, 5] -- 9 + 16 + 25 = 50 longestSequence 595 -> [6, 7, 8, 9, 10, 11, 12] longestSequence 10 -> [] ``` ```if:python,haskell Return an empty list if no such sequence exists. ``` ```if:javascript Return an empty array if no such sequence exists. ```
algorithms
def longest_sequence(n): l = r = s = 1 while s != 0 and s != n: if s > n: s -= l * l l += 1 else: r += 1 s += r * r return range(l, r + 1) if s == n else []
Longest Consecutive Sequence of Squares
5aa69e68ba1bb5ecdf000557
[ "Mathematics", "Algorithms" ]
https://www.codewars.com/kata/5aa69e68ba1bb5ecdf000557
6 kyu
This kata generalizes [Twice Linear](https://www.codewars.com/kata/5672682212c8ecf83e000050). You may want to attempt that kata first. ## Sequence Consider an integer sequence `U(m)` defined as: 1. `m` is a given non-empty set of positive integers. 2. `U(m)[0] = 1`, the first number is always 1. 3. For each `x` in `U(m)`, and each `y` in `m`, `x * y + 1` must also be in `U(m)`. 4. No other numbers are in `U(m)`. 5. `U(m)` is sorted, with no duplicates. ### Sequence Examples #### `U(2, 3) = [1, 3, 4, 7, 9, 10, 13, 15, 19, 21, 22, 27, ...]` 1 produces 3 and 4, since `1 * 2 + 1 = 3`, and `1 * 3 + 1 = 4`. 3 produces 7 and 10, since `3 * 2 + 1 = 7`, and `3 * 3 + 1 = 10`. #### `U(5, 7, 8) = [1, 6, 8, 9, 31, 41, 43, 46, 49, 57, 64, 65, 73, 156, 206, ...]` 1 produces 6, 8, and 9. 6 produces 31, 43, and 49. ## Task: Implement `n_linear` or `nLinear`: given a set of postive integers `m`, and an index `n`, find `U(m)[n]`, the `n`th value in the `U(m)` sequence. ### Tips * Tests use large n values. Slow algorithms may time-out. * Tests use large values in the m set. Algorithms which multiply further than neccessary may overflow. * Linear run time and memory usage is possible. * How can you build the sequence iteratively, without growing extra data structures?
refactoring
from heapq import * def n_linear(ms, n): lst = [1] * (n + 1) q = [(1 + v, v, 1) for v in ms] heapify(q) for i in range(1, n + 1): v, x, j = heappop(q) lst[i] = v heappush(q, (lst[j] * x + 1, x, j + 1)) while q[0][0] == lst[i]: v, x, j = heappop(q) heappush(q, (lst[j] * x + 1, x, j + 1)) return lst[n]
N Linear
5aa417aa4a6b344e2200009d
[ "Algorithms", "Mathematics", "Refactoring" ]
https://www.codewars.com/kata/5aa417aa4a6b344e2200009d
4 kyu
Given a mathematical equation that has `*,+,-,/`, reverse it as follows: ```Haskell solve("100*b/y") = "y/b*100" solve("a+b-c/d*30") = "30*d/c-b+a" ``` More examples in test cases. Good luck! Please also try: [Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2) [Simple remove duplicates](https://www.codewars.com/kata/5ba38ba180824a86850000f7)
algorithms
import re def solve(eq): return '' . join(reversed(re . split(r'(\W+)', eq)))
Simple equation reversal
5aa3af22ba1bb5209f000037
[ "Algorithms" ]
https://www.codewars.com/kata/5aa3af22ba1bb5209f000037
7 kyu
Given that ``` f0 = '0' f1 = '01' f2 = '010' = f1 + f0 f3 = '01001' = f2 + f1 ``` You will be given a number and your task is to return the `nth` fibonacci string. For example: ``` solve(2) = '010' solve(3) = '01001' ``` More examples in test cases. Good luck! If you like sequence Katas, you will enjoy this Kata: [Simple Prime Streaming](https://www.codewars.com/kata/5a908da30025e995880000e3)
algorithms
def solve(n): a, b = '01' for _ in range(n): a, b = a + b, a return a
Simple fibonacci strings
5aa39ba75084d7cf45000008
[ "Algorithms" ]
https://www.codewars.com/kata/5aa39ba75084d7cf45000008
7 kyu
You're given an ancient book that unfortunately has a few pages in the wrong position, fortunately your computer has a list of every page number in order from ``1`` to ``n``. You're supplied with an array of numbers, and should return an array with each page number that is out of place. Incorrect page numbers may appear next to each other. Duplicate incorrect page numbers are possible. Example: ``` Given: list = [1,2,10,3,4,5,8,6,7] Return: [10,8] ``` Your returning list should have the incorrect page numbers in the order they were found.
algorithms
def find_page_number(pages): n, miss = 1, [] for i in pages: if i != n: miss . append(i) else: n += 1 return miss
Disorganised page lists
5aa20a964a6b34417c00008d
[ "Arrays", "Lists", "Algorithms" ]
https://www.codewars.com/kata/5aa20a964a6b34417c00008d
7 kyu
# Story The construction of the new Death Star is almost complete. It only needs a certain amount of 3 materials – iron, steel, and chromium. The emperor wants the construction finished within a week because he senses an impending rebel attack and knows the battle station will be destroyed if it is not completed within this timeframe. He has already ordered enough material delivered to the station within a week. The problem is, the rebels are attacking the supply routes and there are different amounts of material arriving at the station each week. Will the station be ready in time or will it be destroyed? # Task The required resources are: * 100 Gt of iron * 75 Gt of steel * 50 Gt of chromium The input will consist of an array with 8 elements: * The first 7 elements are the shipments - 3-elements-long arrays where each number corresponds to the amount of material that was ordered (iron, steel, and chromium) * The last element is a number representing the day of the rebel attack (0-indexed) - any materials which should have been delivered that day will be lost, and later shipments will be cancelled due to the trading route becoming unsafe The output will be one of the two possible string: * In case enough resources were delivered before the attack, return `"The station is completed!"` * Otherwise, return `"The station is destroyed! It needed X iron, Y steel and Z chromium for completion."`, where `X`, `Y` and `Z` are the quantities of the respective material
reference
def death_star(week, attack): iron = sum(w[0] for w in week[: attack]) steel = sum(w[1] for w in week[: attack]) chromium = sum(w[2] for w in week[: attack]) if (iron >= 100 and steel >= 75 and chromium >= 50): return 'The station is completed!' else: return f'The station is destroyed! It needed { max ( 0 , 100 - iron )} iron, { max ( 0 , 75 - steel )} steel and { max ( 0 , 50 - chromium )} chromium for completion.'
Death Star Construction
5a996f3d5084d73a7100040c
[ "Fundamentals" ]
https://www.codewars.com/kata/5a996f3d5084d73a7100040c
7 kyu
# Task **_Given_** an *array/list [] of n integers* , *find maximum triplet sum in the array* **_Without duplications_** . ___ # Notes : * **_Array/list_** size is *at least 3* . * **_Array/list_** numbers could be a *mixture of positives , negatives and zeros* . * **_Repetition_** of numbers in *the array/list could occur* , So **_(duplications are not included when summing)_**. ___ # Input >> Output Examples ```cpp 1- maxTriSum ({3,2,6,8,2,3}) ==> return (17) ``` ## **_Explanation_**: * As the **_triplet_** that *maximize the sum* **_{6,8,3}_** in order , **_their sum is (17)_** * *Note* : **_duplications_** *are not included when summing* , **(i.e) the numbers added only once** . ___ ```cpp 2- maxTriSum ({2,1,8,0,6,4,8,6,2,4}) ==> return (18) ``` ## **_Explanation_**: * As the **_triplet_** that *maximize the sum* **_{8, 6, 4}_** in order , **_their sum is (18)_** , * *Note* : **_duplications_** *are not included when summing* , **(i.e) the numbers added only once** . ___ ```cpp 3- maxTriSum ({-7,12,-7,29,-5,0,-7,0,0,29}) ==> return (41) ``` ## **_Explanation_**: * As the **_triplet_** that *maximize the sum* **_{12 , 29 , 0}_** in order , **_their sum is (41)_** , * *Note* : **_duplications_** *are not included when summing* , **(i.e) the numbers added only once** . ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ___ ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def max_tri_sum(numbers): return sum(sorted(set(numbers))[- 3:])
Maximum Triplet Sum (Array Series #7)
5aa1bcda373c2eb596000112
[ "Fundamentals", "Arrays" ]
https://www.codewars.com/kata/5aa1bcda373c2eb596000112
7 kyu
The queen can be moved any number of unoccupied squares in a straight line vertically, horizontally, or diagonally, thus combining the moves of the rook and bishop. The queen captures by occupying the square on which an enemy piece sits. (wikipedia: https://en.wikipedia.org/wiki/Queen_(chess)). ## Task: Write a function ```availableMoves(position)``` which returns possibly moves of chess queen. Returned value should be an ```array``` with possible moves sorted alphabetically, exluded starting position. For example when input position is ```A1``` return value should be: ```["A2", "A3", "A4", "A5", "A6", "A7", "A8", "B1", "B2", "C1", "C3", "D1", "D4", "E1", "E5", "F1", "F6", "G1", "G7", "H1", "H8"]``` ``` A B C D E F G H + - + - + - + - + - + - + - + - + 1 | Q | x | x | x | x | x | x | x | + - + - + - + - + - + - + - + - + 2 | x | x | | | | | | | + - + - + - + - + - + - + - + - + 3 | x | | x | | | | | | + - + - + - + - + - + - + - + - + 4 | x | | | x | | | | | + - + - + - + - + - + - + - + - + 5 | x | | | | x | | | | + - + - + - + - + - + - + - + - + 6 | x | | | | | x | | | + - + - + - + - + - + - + - + - + 7 | x | | | | | | x | | + - + - + - + - + - + - + - + - + 8 | x | | | | | | | x | + - + - + - + - + - + - + - + - + Q = queen x = available move ``` ## Input: - input position can be any type (array, number, string and so on). If input position is not a string then return empty array. - valid input position is one letter from ```A``` to ```H``` with number from ```1``` to ```8```, for example ```A1```, ```C8```, ```B3```. If input is invalid (for example ```A10``` or ```H0```) then return empty array.
reference
from itertools import product BOARD = set(map("" . join, product("ABCDEFGH", "12345678"))) def available_moves(position): if isinstance(position, str) and position in BOARD: return sorted(p for p in BOARD - {position} if abs(ord(p[0]) - ord(position[0])) == abs(int(p[1]) - int(position[1])) or position[0] == p[0] or p[1] == position[1]) return []
The queen on the chessboard
5aa1031a7c7a532be30000e5
[ "Arrays", "Fundamentals" ]
https://www.codewars.com/kata/5aa1031a7c7a532be30000e5
6 kyu
_Based on [Project Euler problem 35](https://projecteuler.net/problem=35)_ A circular prime is a prime in which every circular permutation of that number is also prime. Circular permutations are created by rotating the digits of the number, for example: `197, 971, 719`. One-digit primes are circular primes by definition. Complete the function that dertermines if a number is a circular prime. There are 100 random tests for numbers up to 10000.
algorithms
def circular_permutations(n): n = str(n) return [int(n[i:] + n[: i]) for i in range(len(n))] def is_prime(n): return n > 1 and all(n % i != 0 for i in range(2, int(n * * 0.5) + 1)) def circular_prime(n): return all(is_prime(x) for x in circular_permutations(n))
Circular Primes
56b2333e2542c2aadb000079
[ "Algorithms" ]
https://www.codewars.com/kata/56b2333e2542c2aadb000079
7 kyu
Given an array with exactly 5 strings `"a"`, `"b"` or `"c"` (`char`s in Java, `character`s in Fortran), check if the array contains three and two of the same values. ## Examples ``` ["a", "a", "a", "b", "b"] ==> true // 3x "a" and 2x "b" ["a", "b", "c", "b", "c"] ==> false // 1x "a", 2x "b" and 2x "c" ["a", "a", "a", "a", "a"] ==> false // 5x "a" ```
reference
def check_three_and_two(array): return {array . count(x) for x in set(array)} == {2, 3}
Check three and two
5a9e86705ee396d6be000091
[ "Arrays", "Fundamentals" ]
https://www.codewars.com/kata/5a9e86705ee396d6be000091
7 kyu
[Georg Cantor's](http://en.wikipedia.org/wiki/Georg_Cantor) in one of his proofs used following sequence: <pre> 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 ... 3/1 3/2 3/3 ... 4/1 4/2 ... 5/1 ... </pre> There are many ways to order those expressions. In this kata we'll use this approach: ![](https://lh3.googleusercontent.com/pw/AMWts8B7hRB_u5UCFeGF_hdGQUb0wb8vqgWGK-OwdJzkDqokYyQHlKHn6SOjDFLXzMfBL6o5EpCKfEIp52wK8ki3FKIuKLqnDYLzAmCZJdKqqNgWvt5XIBoWh20hBHCyV6l4ectFyRQ0JSLa-Vt-Ctzg10W2=w454-h404-no?authuser=0) So sequence is: ```javascript 1/1, 1/2, 2/1, 3/1, 2/2, 1/3, 1/4 ... ``` Your task is to return ```nth``` element of this sequence. Input: ```n``` - positive integer (max 268435455) Output: string - ```nth``` expression of sequence - ```'a/b'``` where ```a``` and ```b``` are integers.
algorithms
def cantor(n: int) - > str: if n == 1: return '1/1' else: k = 1 while n > k: n -= k k += 1 if k % 2 == 0: return str(n) + '/' + str(k - n + 1) else: return str(k - n + 1) + '/' + str(n)
Cantor's pairing function
543b9113def6343e43000875
[ "Mathematics", "Algorithms" ]
https://www.codewars.com/kata/543b9113def6343e43000875
6 kyu
"Hello Traveler. I wanna play a game" There is a game called [23 Matches](http://ascii-world.wikidot.com/23-matches). Rules: there are 23 matches on the table. Each turn a player takes 1, 2 or 3 matches away. Player who takes the last match - loses. This is generalized version of the game. Here we have **X** matches and we can take up to **Y** matches away each turn. Example: X = 13, Y = 4 There are X = 13 matches on table Player 1 takes 1 match -> 12 left on table Player 2 takes 4 matches -> 8 left on table Player 1 takes 2 matches -> 6 left on table Player 2 takes 3 matches -> 3 left on table Player 1 takes 2 matches -> 1 left on table Player 2 takes last match Player 2 loses. You're about to write a BOT to compete with my bot. To do this - implement function `createBot`/`create_bot` which accepts two arguments: * `X` - initial number of matches on table (20 <= X <= 1000) * `Y` - max number of matches to be taken away each turn (2 <= Y <= 19) Your function must return an object of following structure: ```javascript //example bot let myBot = { name: "Optional name as string", makeMove: matchesStillOnTable => matchesToTake } ``` ```python # example bot my_bot = Bot( name = 'Bot', make_move = lambda matches_still_on_table: matches_to_take ) ``` Your bot will always start the game. The game is alwas winable for your bot - there are no cheap tricks or edgy corner cases.
algorithms
from collections import namedtuple Bot = namedtuple('Bot', ('name', 'make_move')) def create_bot(x, y): return Bot( name='🏆', make_move=lambda on_table: (on_table - 1) % (y + 1) or 1)
23 Matches. Or more...
5a9dbc735ee396ef590001de
[ "Puzzles", "Games", "Algorithms", "Game Solvers" ]
https://www.codewars.com/kata/5a9dbc735ee396ef590001de
6 kyu
# Concept Multicast IP addresses, which range from `224.0.0.0` to `239.255.255.255`, are defined by the leading address bits of `1110`. In Classless Inter-Domain Routing (CIDR) prefix, this group is `224.0.0.0/4`.<sup>[1](#mcastIp)</sup> To support IP multicasting, the Internet authorities have reserved the multicast MAC address range of `01:00:5E:00:00:00` to `01:00:5E:7F:FF:FF`. That means lowest `23` bits of the MAC address are available for mapping.<sup>[2](#mcastMac)</sup> To create a multicast MAC address, the lower 23 bits of the MAC address are set to the corresponding lower 23 bits of the IP address. For example, `224.0.0.1` should be mapped to MAC address `01:00:5E:00:00:01`. Since lowest 23 bits is not enough to fit all multicast IP addresses, some IP will be mapped to same MAC address. For example, `224.0.0.1` and `225.0.0.1` both are mapped to `01:00:5E:00:00:01`. # Task Here you need to write a function to translate a multicast address to valid MAC address. All inputs are valid multicast IP addresses, you must return a string with MAC address. Characters must be capitalized. # Reference 1. <a name="mcastIp"/>[HOST GROUP ADDRESSES, Section 4, RFC 1112](https://tools.ietf.org/html/rfc1112#section-4) 2. <a name="mcastMac"/>[Extensions to an Ethernet Local Network Module, Section 6.4, RFC 1112](https://tools.ietf.org/html/rfc1112#section-6.4)
reference
def mcast_ip_to_mac(ip_string): ip = ip_string . split(".") return "01:00:5E:%0.2X:%0.2X:%0.2X" % (int(ip[1]) % 128, int(ip[2]), int(ip[3]))
Multicast IP Address to MAC address mapping
5a9d43ceba1bb52492000080
[ "Parsing", "Fundamentals" ]
https://www.codewars.com/kata/5a9d43ceba1bb52492000080
6 kyu
# Disclaimer This Kata is an insane step-up from [my previous Kata](https://www.codewars.com/kata/59951f21d65a27e95d00004f), so I recommend to solve it first before trying this one. # Problem Description Let's imagine a function `F(n)`, which is defined over the integers in the range of `1 <= n <= max_n`, and `0 <= F(n) <= max_fn` for every `n`. There are `(1 + max_fn) ** max_n` possible definitions of `F` in total. Out of those definitions, how many `F`s satisfy the following equations? Since your answer will be very large, please give your answer **modulo 12345787**. * `F(n) + F(n + 1) <= max_fn` for `1 <= n < max_n` * `F(max_n) + F(1) <= max_fn` # Constraints `1 <= max_n <= 10 ** 9` `1 <= max_fn <= 10` The inputs will be always valid integers. # Examples ```python # F(1) + F(1) <= 1, F(1) = 0 insane_cls(1, 1) == 1 # F = (0, 0), (0, 1), (1, 0) insane_cls(2, 1) == 3 # F = (0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0) insane_cls(3, 1) == 4 # F = (0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, 0), # (0, 1, 0, 1), (1, 0, 0, 0), (1, 0, 1, 0) insane_cls(4, 1) == 7 # F = (0), (1) insane_cls(1, 2) == 2 # F = (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0) insane_cls(2, 2) == 6 # F = (0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 1, 0), (0, 1, 1), # (0, 2, 0), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1), (2, 0, 0) insane_cls(3, 2) == 11 insane_cls(4, 2) == 26 ``` # Acknowledgement This problem was designed as a hybrid of [Project Euler #209: Circular Logic](https://projecteuler.net/problem=209) and [Project Euler #164: Numbers for which no three consecutive digits have a sum greater than a given value](https://projecteuler.net/problem=164). If you enjoyed this Kata, please also have a look at [my other Katas](https://www.codewars.com/users/Bubbler/authored)!
algorithms
''' Let G be an unweighted graph with max_fn + 1 nodes, labeled from 0 to max_fn, and let there be an edge between two nodes A and B if A + B <= max_fn. Let A be the adjacency matrix representation of G, such that A[i][j] = 1 if there is an edge between node i and j, and A[i][j] = 0 otherwise. Then A[i][j] = {1 if i + j <= max_fn {0 otherwise Note that this is a triangular matrix. The Nth power of an unweighted adjacency matrix contains the number of paths of exactly N edges that connects two nodes. In other words, A^N[i][j] counts the number of ways to define a function G(N) such that G(1) = i and G(N + 1) = j and G(n) + G(n + 1) <= max_fn for all n in [1, N]. This means that the diagonal elements A^N[i][i] counts the number of definitions of F(n) where F(1) = i, with N = max_n. To find the number of definitions of F(n), we thus have to sum the diagonal elements of A^N, which is equivalent to computing its trace. ''' import numpy as np MOD = 12345787 def matmodpow(mat, b, m): if b == 0: return np . identity(mat . shape[0], dtype=np . int64) ret = matmodpow(mat @ mat % m, b / / 2, m) return ret @ mat % m if b % 2 else ret def insane_cls(max_n, max_fn): adj = np . flipud(np . tri(max_fn + 1, dtype=np . int64)) return np . trace(matmodpow(adj, max_n, MOD)) % MOD
Insane Circular Limited Sums
59953009d65a278783000062
[ "Algorithms", "Mathematics" ]
https://www.codewars.com/kata/59953009d65a278783000062
3 kyu
# Problem Description Let's imagine a function `F(n)`, which is defined over the integers in the range of `1 <= n <= max_n`, and `0 <= F(n) <= max_fn` for every `n`. There are `(1 + max_fn) ** max_n` possible definitions of `F` in total. Out of those definitions, how many `F`s satisfy the following equations? Since your answer will be very large, please give your answer **modulo 12345787**. * `F(n) + F(n + 1) <= max_fn` for `1 <= n < max_n` * `F(max_n) + F(1) <= max_fn` # Constraints `1 <= max_n <= 100` `1 <= max_fn <= 5` The inputs will be always valid integers. # Examples ```python # F(1) + F(1) <= 1, F(1) = 0 circular_limited_sums(1, 1) == 1 # F = (0, 0), (0, 1), (1, 0) circular_limited_sums(2, 1) == 3 # F = (0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0) circular_limited_sums(3, 1) == 4 # F = (0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 1, 0), (0, 1, 0, 0), # (0, 1, 0, 1), (1, 0, 0, 0), (1, 0, 1, 0) circular_limited_sums(4, 1) == 7 # F = (0), (1) circular_limited_sums(1, 2) == 2 # F = (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0) circular_limited_sums(2, 2) == 6 # F = (0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 1, 0), (0, 1, 1), # (0, 2, 0), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1), (2, 0, 0) circular_limited_sums(3, 2) == 11 circular_limited_sums(4, 2) == 26 ``` # Acknowledgement This problem was designed as a hybrid of [Project Euler #209: Circular Logic](https://projecteuler.net/problem=209) and [Project Euler #164: Numbers for which no three consecutive digits have a sum greater than a given value](https://projecteuler.net/problem=164). If you enjoyed this Kata, please also have a look at [my other Katas](https://www.codewars.com/users/Bubbler/authored)!
algorithms
def circular_limited_sums(max_n, max_fn): if max_n == 1: return sum([1 for i in range(max_fn + 1) if i + i <= max_fn]) % 12345787 nexts = [list(filter(lambda x: i + x <= max_fn, range(max_fn + 1))) for i in range(max_fn + 1)] result = 0 for ii in range(max_fn + 1): v = [[1 if e in nexts[ii] else 0 for e in range(max_fn + 1)]] for _ in range(max_n - 2): v . append([0 for i in range(max_fn + 1)]) for i, e in enumerate(v[- 2]): for j in nexts[i]: v[- 1][j] += e result += sum([e for i, e in enumerate(v[- 1]) if i + ii <= max_fn]) return result % 12345787
Circular Limited Sums
59951f21d65a27e95d00004f
[ "Algorithms", "Mathematics", "Dynamic Programming" ]
https://www.codewars.com/kata/59951f21d65a27e95d00004f
4 kyu
# Problem Description You build a string of length `l` which entirely consists of `n` types of characters `1`, `2`, ..., `n`. Let's define such a string "permutation-free" if it has no substring which is a permutation of `12...n` (in other words, substring of length `n` which contains all types of characters exactly once). For `n = 2`, it means that '12' and '21' are not allowed, so the only possible permutation-free strings are 11...1 and 22...2. For `n = 3`, strings like 1111, 3311, and 1223 are permutation-free, while **123**2, 3**231**, and **312**2 are not. How many permutation-free strings can you make, given the values of `n` and `l`? Since your answer will be very large, please give your answer **modulo 12345787**. # Constraints `3 <= n <= 5` `n <= l <= 100` The inputs will be always valid integers. # Examples ```python permutation_free(3, 3) == 3 ** 3 - 3! == 21 permutation_free(3, 4) == 51 permutation_free(3, 5) == 123 permutation_free(3, 10) == 10089 permutation_free(4, 4) == 4 ** 4 - 4! = 232 permutation_free(4, 5) == 856 permutation_free(4, 10) == 3160 permutation_free(5, 5) == 5 ** 5 - 5! = 3005 permutation_free(5, 6) == 14545 permutation_free(5, 10) == 8001745 ``` # Acknowledgement This problem was inspired by [Project Euler #458: Permutations of Project](https://projecteuler.net/problem=458). If you enjoyed this Kata, please also have a look at [my other Katas](https://www.codewars.com/users/Bubbler/authored)!
algorithms
import numpy as np def permutation_free(n, l): m = np . tril(np . ones((n, n), object), - 1) + \ np . diagflat(range(n, 0, - 1)) return (np . matrix(np . vstack((m[1:], m[0, :: - 1]))) * * l)[0, 0] * n % 12345787
Permutation-free Strings
59b53be0bf10a4b39300001f
[ "Algorithms", "Dynamic Programming", "Mathematics" ]
https://www.codewars.com/kata/59b53be0bf10a4b39300001f
3 kyu
# Disclaimer This Kata is an insane step-up from [my previous Kata](https://www.codewars.com/kata/599266b417bc9785f2000001), so I recommend to solve it first before trying this one. # Problem Description You have a row of `n` square tiles, which are colored black and the side length is 1. You also have infinite supplies of three kinds of rectangular tiles: * Red tiles of Length `r` * Green tiles of Length `g` * Blue tiles of Length `b` All tiles have integer lengths and share the same height of 1. Now, you want to replace some black square tiles with your colored tiles. However, you are quite picky, and you want to use *exactly two types of colored tiles* (RGB). You can leave black gaps as much as you want. In how many ways can you replace black tiles with your colored tiles? Since your answer will be very large, please give your answer **modulo 12345787**. # Example For `n = 6` and `(r, g, b) = (2, 3, 4)`, these are the eight possible arrangements using exactly two colors (R, G, B denote red, green, blue tiles respectively, and a dot is a black tile): ``` RRGGG. RR.GGG .RRGGG GGGRR. GGG.RR .GGGRR RRBBBB BBBBRR ``` # Constraints `5 <= n <= 10 ** 9` **Note the size of n!** Most solutions that solve the easier one will timeout with large inputs. `2 <= r, g, b <= 5` Some of the values of `r`, `g`, or `b` may be the same. The inputs will be always valid integers. # More Examples ```python # One Red (length 2) and one Green (length 3): two arrangements insane_tri_bicolor_tiling(5, 2, 3, 4) == 2 # One Red (length 2) and one Green (length 3): 6 arrangements # One Red (length 2) and one Blue (length 4): 2 arrangements insane_tri_bicolor_tiling(6, 2, 3, 4) == 8 insane_tri_bicolor_tiling(10, 2, 3, 4) == 248 # For these cases, think about tiling with dominos first # and then coloring them with two colors. insane_tri_bicolor_tiling(5, 2, 2, 2) == 18 insane_tri_bicolor_tiling(6, 2, 2, 2) == 54 ``` ```javascript // One Red (length 2) and one Green (length 3): two arrangements insaneTriBicolorTiling(5, 2, 3, 4) == 2 // One Red (length 2) and one Green (length 3): 6 arrangements // One Red (length 2) and one Blue (length 4): 2 arrangements insaneTriBicolorTiling(6, 2, 3, 4) == 8 insaneTriBicolorTiling(10, 2, 3, 4) == 248 // For these cases, think about tiling with dominos first // and then coloring them with two colors. insaneTriBicolorTiling(5, 2, 2, 2) == 18 insaneTriBicolorTiling(6, 2, 2, 2) == 54 ``` # Acknowledgement This problem was inspired by [Project Euler #116: Red, Green, or Blue Tiles](https://projecteuler.net/problem=116) and [Project Euler #117: Red, Green, and Blue Tiles](https://projecteuler.net/problem=117). If you enjoyed this Kata, please also have a look at [my other Katas](https://www.codewars.com/users/Bubbler/authored)!
algorithms
import numpy as np from itertools import combinations modulus = 12345787 def f(n, colors): a = np . matrix([ [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0] ]) for color in colors: a[0, color - 1] += 1 b = np . zeros((5, 1)) b[0, 0] = 1 # res = a^n * b % modulus res = np . identity(5) while n > 0: if n % 2: res = res . dot(a) % modulus n / /= 2 a = a . dot(a) % modulus return int(res . dot(b)[0]) def insane_tri_bicolor_tiling(n, r, g, b): return sum(f(n, [a, b]) - f(n, [a]) - f(n, [b]) + 1 for a, b in combinations([r, g, b], 2) if n >= a + b) % modulus
Insane Tri-Bicolor Tiling
59928e2889d6a01970000051
[ "Algorithms", "Fundamentals", "Mathematics", "Performance" ]
https://www.codewars.com/kata/59928e2889d6a01970000051
3 kyu
### Please also check out other katas in [Domino Tiling series](https://www.codewars.com/collections/5d19554d13dba80026a74ff5)! --- # Task A domino is a rectangular block with `2` units wide and `1` unit high. A domino can be placed on a grid in two ways: horizontal or vertical. ``` ## or # # ``` You have infinitely many dominoes, and you want to fill a board that is `N` units wide and `3` units high: ``` <--- N ---> ############### ############### ############### ``` The task is to find **the number of ways** you can fill the given grid with dominoes. # The Twist But you quickly realize that the answer is zero for any odd `N`, because (obviously) you can't cover odd number of cells with dominoes! So you decide to introduce one **unit block** (1 unit wide and 1 unit high) to cover the final gap when needed (you don't need this block when `N` is even). The following shows some possible tilings for `N = 5`. Note that, unlike my previous Kata, the numbers do not represent the colors (they are just for convenience). Also note that the unit block (marked as 'X') can be placed **anywhere on the board**, making the answers for odd numbers way higher than even ones. ``` 11255 1122X 14456 3X267 33447 13356 34467 55667 22X77 ``` Since the answer will be very large, please give your answer **modulo 12345787**. # Examples ```python # Even input three_by_n(2) == 3 three_by_n(4) == 11 three_by_n(10) == 571 three_by_n(20) == 413403 # Odd input (the numbers grow much faster than even inputs) three_by_n(1) == 2 three_by_n(3) == 18 three_by_n(5) == 106 three_by_n(11) == 11542 three_by_n(21) == 3287999 # You must handle big values three_by_n(9999) == 6311027 three_by_n(10000) == 12003229 ``` ```javascript // Even input threeByN(2) == 3 threeByN(4) == 11 threeByN(10) == 571 threeByN(20) == 413403 // Odd input (the numbers grow much faster than even inputs) threeByN(1) == 2 threeByN(3) == 18 threeByN(5) == 106 threeByN(11) == 11542 threeByN(21) == 3287999 // You must handle big values threeByN(9999) == 6311027 threeByN(10000) == 12003229 ``` # Constraints `1 <= N <= 10000` All inputs are valid integers.
games
""" def three_by_n_without_hole_missing_top(n): # the first column can be _11, _12 assert n%2 == 1 if n == 1: return 1 return three_by_n_without_hole_missing_top(n-2) \ + three_by_n_without_hole(n-1) def three_by_n_without_hole(n): # the first column can be 112, 122, 123 # the first two cases are the same by symmetry assert n%2 == 0 if n == 0: return 1 return three_by_n_without_hole_missing_top(n-1)*2 \ + three_by_n_without_hole(n-2) def three_by_n_with_hole_missing_top(n): # the first column can be _X1, _1X, _11, _12 # the second case is impossible because it would have to look like: # _225588... # 114477.... # X336699... # the fourth case is divided into two cases, # depending on whether the next column is X12 or 312 assert n%2 == 0 if n == 0: return 0 return three_by_n_without_hole_missing_top(n-1) \ + three_by_n_with_hole(n-1) \ + three_by_n_with_hole_missing_top(n-2) \ + three_by_n_without_hole(n-2) def three_by_n_with_hole(n): # the first column can be X11, X12, 1X2, 11X, 12X, 112, 122, 123 # by symmetry: # case 4 = case 1 # case 5 = case 2 # case 7 = case 6 # note that case 3 is impossible because it would have to look like: # 114477.... # X225588... # 336699.... assert n%2 == 1 if n == 1: return 2 return three_by_n_without_hole(n-1)*2 \ + three_by_n_without_hole_missing_top(n-2)*2 \ + three_by_n_with_hole_missing_top(n-1)*2 \ + three_by_n_with_hole(n-2) """ # naive algorithm def mat_mul(A, B): n = len(A) # the top left entry is A[0][0]*B[0][0] + A[0][1]*B[1][0] + ... return [[sum(A[i][k] * B[k][j] % 12345787 for k in range(n)) % 12345787 for j in range(n)] for i in range(n)] # exponentiation by squaring def mat_pow(A, k): n = len(A) res = [[0 + (i == j) for j in range(n)] for i in range(n)] # A^0 while k: if k % 2 == 1: res = mat_mul(res, A) A = mat_mul(A, A) k / /= 2 return res # let: # A = three_by_n_without_hole_missing_top # B = three_by_n_without_hole # C = three_by_n_with_hole_missing_top # D = three_by_n_with_hole # initial cases: # A[1] = 1 # B[0] = 1 # C[0] = 0 # D[1] = 2 # recursive formulas: # A[n] = A[n-2] + B[n-1] # B[n] = 2A[n-1] + B[n-2] # C[n] = A[n-1] + B[n-2] + C[n-2] + D[n-1] # D[n] = 2A[n-2] + 2B[n-1] + 2C[n-1] + D[n-2] # adjust parity # A[2k+1] = A[2(k-1)+1] + B[2k] # B[2k] = 2A[2(k-1)+1] + B[2(k-1)] # C[2k] = A[2(k-1)+1] + B[2(k-1)] + C[2(k-1)] + D[2(k-1)+1] # D[2k+1] = 2A[2(k-1)+1] + 2B[2k] + 2C[2k] + D[2(k-1)+1] # offset # A[2k+1] = 3A[2(k-1)+1] + B[2(k-1)] # B[2k] = 2A[2(k-1)+1] + B[2(k-1)] # C[2k] = A[2(k-1)+1] B[2(k-1)] + C[2(k-1)] + D[2(k-1)+1] # D[2k+1] = 8A[2(k-1)+1] + 4B[2(k-1)] + 2C[2(k-1)] + 3D[2(k-1)+1] def three_by_n_without_hole(n): res = mat_pow([[3, 1], [2, 1]], n / / 2) return res[0][0] def three_by_n_with_hole(n): res = mat_pow([[3, 1, 0, 0], [2, 1, 0, 0], [1, 1, 1, 1], [8, 4, 2, 3]], n / / 2) return (res[3][0] + res[3][1] + 2 * res[3][3]) % 12345787 def three_by_n(n): if n % 2 == 1: return three_by_n_with_hole(n) return three_by_n_without_hole(n)
Domino Tiling - 3 x N Board
5993dcfca6a7632807000017
[ "Algorithms", "Mathematics", "Dynamic Programming", "Puzzles" ]
https://www.codewars.com/kata/5993dcfca6a7632807000017
4 kyu
Let's create some scrolling text! Your task is to complete the function which takes a string, and returns an array with all possible rotations of the given string, **in uppercase**. ## Example `scrollingText("codewars")` should return: ```javascript [ "CODEWARS", "ODEWARSC", "DEWARSCO", "EWARSCOD", "WARSCODE", "ARSCODEW" "RSCODEWA", "SCODEWAR" ] ``` Good luck!
reference
def scrolling_text(text): text = text . upper() return [text[i:] + text[: i] for i in range(len(text))]
Scrolling Text
5a995c2aba1bb57f660001fd
[ "Strings", "Arrays", "Fundamentals" ]
https://www.codewars.com/kata/5a995c2aba1bb57f660001fd
7 kyu
You are given two positive integers `a` and `b` (`a < b <= 20000`). Complete the function which returns a list of all those numbers in the interval `[a, b)` whose digits are made up of prime numbers (`2, 3, 5, 7`) but which are not primes themselves. Be careful about your timing! Good luck :) Check my other katas: <a href="https://www.codewars.com/kata/5a805d8cafa10f8b930005ba">Find Nearest square number </a> <a href="https://www.codewars.com/kata/5a8059b1fd577709860000f6">Alphabetically ordered </a> <a href="https://www.codewars.com/kata/5a805631ba1bb55b0c0000b8">Case-sensitive! </a> <a href="https://www.codewars.com/kata/6402205dca1e64004b22b8de">Find your caterer </a>
reference
from math import sqrt def is_prime(n): if n < 2: return False for x in range(2, int(sqrt(n)) + 1): if n % x == 0: return False return True def all_dig_prime(n): for d in str(n): if d not in "2357": return False return True def not_primes(a, b): res = [] for i in range(a, b): if all_dig_prime(i) and not is_prime(i): res . append(i) return res
Not prime numbers
5a9a70cf5084d74ff90000f7
[ "Fundamentals", "Performance", "Algorithms" ]
https://www.codewars.com/kata/5a9a70cf5084d74ff90000f7
6 kyu
# Definition (Primorial Of a Number) *Is similar to factorial of a number*, **_In primorial_**, not all the natural numbers get multiplied, **_only prime numbers are multiplied to calculate the primorial of a number_**. It's denoted with **_P_**<sub>**_#_**</sub> and it is the product of the first n prime numbers. ___ # Task **_Given_** *a number N* , **_calculate its primorial_**. ![!alt](https://i.imgur.com/mdX8dJP.png) ![!alt](https://i.imgur.com/mdX8dJP.png) ___ # Notes * **_Only positive_** numbers *will be passed (N > 0)* . ___ # Input >> Output Examples: ``` cpp 1- numPrimorial (3) ==> return (30) ``` ```prolog 1 - num_primorial(3, 30). ``` ```rust 1 - num_primorial(3) // 30 ``` ```clojure 1 - (num-primorial 3) ;; 30 ``` ## **_Explanation_**: **_Since_** *the passed number is (3)* ,**_Then_** **_the primorial_** *should obtained by multiplying* ```2 * 3 * 5 = 30 .``` ### Mathematically written as , **_P_**<sub>3</sub>**_#_** = 30 . ___ ```cpp 2- numPrimorial (5) ==> return (2310) ``` ```prolog 2 - num_primorial(5, 2310). ``` ```rust 2 - num_primorial(5) // 2310 ``` ```clojure 2 - (num-primorial 5) ;; 2310 ``` ## **_Explanation_**: **_Since_** *the passed number is (5)* ,**_Then_** **_the primorial_** *should obtained by multiplying* ``` 2 * 3 * 5 * 7 * 11 = 2310 .``` ### Mathematically written as , **_P_**<sub>5</sub>**_#_** = 2310 . ___ ```cpp 3- numPrimorial (6) ==> return (30030) ``` ```prolog 3 - num_primorial(6, 30030). ``` ```rust 3 - num_primorial(6) // 30030 ``` ```clojure 3 - (num-primorial 6) ;; 30030 ``` ## **_Explanation_**: **_Since_** *the passed number is (6)* ,**_Then_** **_the primorial_** *should obtained by multiplying* ``` 2 * 3 * 5 * 7 * 11 * 13 = 30030 .``` ### Mathematically written as , **_P_**<sub>6</sub>**_#_** = 30030 . ___ ___ ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def num_primorial(n): primorial, x, n = 2, 3, n-1 while n: if all(x % d for d in range(3, int(x ** .5) + 1, 2)): primorial *= x n -= 1 x += 2 return primorial
Primorial Of a Number
5a99a03e4a6b34bb3c000124
[ "Fundamentals", "Arrays", "Number Theory" ]
https://www.codewars.com/kata/5a99a03e4a6b34bb3c000124
6 kyu
For "x", determine how many positive integers less than or equal to "x" are odd but not prime. Assume "x" is an integer between 1 and 10000. Example: 5 has three odd numbers (1,3,5) and only the number 1 is not prime, so the answer is 1 Example: 10 has five odd numbers (1,3,5,7,9) and only 1 and 9 are not prime, so the answer is 2
algorithms
def odd_not_prime(n): return 1 + sum(any(not x % y for y in range(3, int(x * * .5) + 1, 2)) for x in range(1, n + 1, 2))
Odd Not Prime
5a9996fa8e503f2b4a002e7a
[ "Algorithms" ]
https://www.codewars.com/kata/5a9996fa8e503f2b4a002e7a
7 kyu
You get a list of integers. Return a new list by adding each consecutive pair of the list. ## Examples ```python [1, 1, 1, 1] --> [2, 2, 2] # [1+1, 1+1, 1+1] [1, 2, 3, 4] --> [3, 5, 7] # [1+2, 2+3, 3+4] [1, 10, 100] --> [11, 110] # [1+10, 10+100] ``` ## Restriction ~~~if:python,ruby Your code size can be maximum 60 characters. ~~~
reference
def make_new_list(l): return list(map(sum, zip(l, l[1:])))
[ Code Golf ] Add 2 values for each
5a99a1418e503ffb8300384c
[ "Restricted", "Fundamentals" ]
https://www.codewars.com/kata/5a99a1418e503ffb8300384c
7 kyu
Your program will receive an array of complex numbers represented as strings. Your task is to write the `complexSum` function which have to return the sum as a string. Complex numbers can be written in the form of `a+bi`, such as `2-3i` where `2` is the real part, `3` is the imaginary part, and `i` is the "imaginary unit". When you add two complex numbers, the real and the imaginary part needs to be added separately,so for example `2+3i + 5-i = (2+5)+(3i-i) = 7+2i` Both the complex and the imaginary part can be 0, so `123`, `-2i` or `i` are also complex numbers. Complex numbers must be returned in their shortest form, so e.g. `0+1*i` should be just `i`, and `10+0i` should be `10`. This is also how you will get them! For simplicity, the coefficients will always be integers. If the array is empty, return `0`. Have fun! :)
reference
def complexSum(l): z = sum(complex(s . replace('i', 'j')) for s in l) x, y = round(z . real), round(z . imag) if y == 0: return str(x) sign = '-' if y < 0 else ('' if x == 0 else '+') y = abs(y) x = '' if x == 0 else str(x) y = '' if y == 1 else str(y) return '{}{}{}i' . format(x, sign, y)
Really Complex Sum
5a981424373c2e479c00017f
[ "Regular Expressions", "Fundamentals" ]
https://www.codewars.com/kata/5a981424373c2e479c00017f
6 kyu
`$i$` is the imaginary unit, it is defined by `$i² = -1$`, therefore it is a solution to `$x² + 1 = 0$`. ## Your Task Complete the function `pofi` that returns `$i$` to the power of a given non-negative integer in its simplest form, as a string (answer may contain `$i$`). ~~~if:fortran *NOTE: Your returned character string is* **not** *permitted to contain redundant trailing whitespace.* ~~~
reference
def pofi(n): return ['1', 'i', '-1', '-i'][n % 4]
Powers of i
5a97387e5ee396e70a00016d
[ "Mathematics", "Fundamentals" ]
https://www.codewars.com/kata/5a97387e5ee396e70a00016d
7 kyu
While using public transport we could see simple displays with a ticker. It often provides information about next stations and expected arrival time. Let's implement a function which will return a chunk of text to be displayed on a display of fixed width. The function should take `text` to display, `width` of the display and `tick` as a step of the ticker. The function will be called many times with `tick` parameter constantly incrementing. At very beginning the display is empty. At first step only one character should be displayed in the most right position and so on. When the message is displayed, it should be dissapear char by char to left position and return to blank state of the display. After that cycle should start again. For example ```javascript ticker('Hello world!', 10, 4) // ' Hell' ``` ```python ticker('Hello world!', 10, 4) # ' Hell' ``` We could expect that our function will be called from simple script like this one ```javascript const demo = (text, width) => { let tick = 0; setInterval(_ => { someDisplayFunction(ticker(text, width, tick)); tick++ }, 100); } ``` ```python def demo(text, width): for tick in range(100): someDisplayFunction(ticker(text, width, tick)); ```
reference
def ticker(text, width, tick): tick %= len(text) + width text = ' ' * width + text + ' ' * width return text[tick: tick + width]
Ticker
5a959662373c2e761d000183
[ "Fundamentals" ]
https://www.codewars.com/kata/5a959662373c2e761d000183
6 kyu
Create a bot that can play the darts game <a href="https://en.wikipedia.org/wiki/Darts#Scoring">501</a>: <li>Two players throw in turn three darts at a <a href="https://en.wikipedia.org/wiki/Darts#Scoring">dartboard</a></li> <li>Both players start a <i>leg</i> with a score of 501</li> <li>After each throw their score is lowered by the score thrown on the board</li> <li>The first player to end up with a score of exactly 0 after a hit in the doubles ring or bull's eye wins the leg</li> <li>When a player reaches a score lower than 2 it is called a <i>bust</i>. The turn goes immediatly to the other player and the score is reset to the score after the previous set of 3 darts</li> <br> Your bot can play another bot on a preloaded Playground. The Playground tells the bot before each throw their needed score (between 501 and 2) and a bot should return coordinates on a dartboard. <b style="color:lightgreen">Be aware! The Playground adds a small random deviation to the coordinates and then determines the actual score of the throw on the dart board.</b>. Your bot needs to be able to anticipate on unexpected scores! <br><br> To finish this kata successfully your bot must compete with The Power, a bot named after Phil 'The Power' Taylor. He is considered by many as the greatest darts player ever, and this bot is using many of his game characteristics. This kata is successfully finished if your bot: <br><br> <li>wins most legs in a 'best of 10,001' with The Power</li> <li>exceeds the 3-Dart Average of 96.14 of Phil Taylor in the <a href="https://en.wikipedia.org/wiki/2005_PDC_World_Darts_Championship">PDC World Darts Championship of 2005</a></li> <br><br><img style="height:200px" src="https://www.totalposter.com/tp-images/products/large/act0822049.jpg" /><br><br> <b style='font-size:16px'>Task:</b><br><br> <ul> <li>Finish method:</li> ```csharp public double[] GetCoordinates(int score) ``` ```java public double[] getCoordinates(int score) ``` ```python def get_coordinates(score) ``` <li><b>Input:</b>`score` is an integer in the range of 2 until 501 (start of a leg). Scoring rules of the 501 game can be found <a href="https://en.wikipedia.org/wiki/Darts#Scoring">here</a>.</li><br><li> <b>Output:</b> x- and y-coordinates of the desired landing spot of your dart on a dartboard. The unit is millimeters. The center of the board is (0, 0). If the aim is 3 centimeters lower than the Bull's Eye and 5 centimeters to the left, this is written as: ```csharp { -50, -30 } ``` ```java { -50, -30 } ``` ```python (-50, -30) ``` <br><img style="height:264px" src="https://upload.wikimedia.org/wikipedia/commons/4/42/Dartboard.svg"></li> <br><li>The diameters of the circles on a <a href="https://en.wikipedia.org/wiki/Darts#Scoring">standard dartboard</a> are:</li><ul><li>Bull's eye: `12.70 mm`</li><li>Bull: `31.8 mm`</li><li>Triple ring inner circle: `198 mm`</li><li>Triple ring outer circle: `214 mm`</li><li>Double ring inner circle: `324 mm`</li><li>Double ring outer circle: `340 mm`</li></ul> </a></li></ul> <b style='font-size:16px'>Note:</b><br><br> <li>C# only: you can use the `ICanPlayABestOf3()` unit test to analyse the game.</li> <li>For a good understanding of this kata you might want to finish the related kata <a style="color:lightgreen" href="https://www.codewars.com/kata/lets-play-darts">Let's Play Darts!</a> first.</li>
algorithms
import math angleGoal = [0, 72, 306, 270, 36, 108, 0, 234, 198, 144, 342, 180, 126, 18, 162, 324, 216, 288, 54, 252, 90] distGoal = [0, 138, 166, 103] # bullseye, single, double, triple def get_coordinates(score): if score >= 66: theta = angleGoal[20] depth = distGoal[3] elif score == 50: theta = 0 depth = 0 elif score / 2 == int(score / 2) and score < 41: theta = angleGoal[score / / 2] depth = distGoal[2] elif 40 < score <= 60: theta = angleGoal[score - 40] depth = distGoal[1] elif score == 63: theta = angleGoal[11] depth = distGoal[3] elif score > 22: theta = angleGoal[19] depth = distGoal[1] else: theta = angleGoal[3] depth = distGoal[1] x = depth * math . cos(math . radians(theta)) y = depth * math . sin(math . radians(theta)) return x, y
Let's Play Darts: Beat The Power!
58756f1054486312c5000a64
[ "Games", "Algorithms" ]
https://www.codewars.com/kata/58756f1054486312c5000a64
5 kyu
In this Kata, you will count the number of times the first string occurs in the second. ```Haskell solve("zaz","zazapulz") = 4 because they are ZAZapulz, ZAzapulZ, ZazApulZ, zaZApulZ ``` More examples in test cases. Good luck! Please also try [Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2)
algorithms
def solve(a, b): if len(a) is 1: return b . count(a) index = [x for x in range(len(b) - 1) if b[x] is a[0]] return sum(solve(a[1:], b[x + 1:]) for x in index)
Simple repeated words
5a942c461a60f677730032df
[ "Algorithms" ]
https://www.codewars.com/kata/5a942c461a60f677730032df
6 kyu
# Task : **_Given_** *a List [] of n integers* , **_find minimum number_** to be **inserted** in a *list*, so that **_sum of all elements of list_** should *equal the closest prime number* . ___ # Notes * **_List size_** is *at least 2* . * **_List's numbers_** will only **_positives_** (n > 0) . * **_Repetition_** of numbers in the list **_could occur_** . * **_The newer list's sum_** should *equal the closest prime number* . ___ # Input >> Output Examples ```cpp 1- minimumNumber ({3,1,2}) ==> return (1) ``` ## **_Explanation_**: * **_Since_** , **the sum** of the list's elements equal to **_(6)_** , *the minimum number to be inserted to transform the sum to prime number* is **_(1)_** , *which will make **_the sum of the List_** equal the closest prime number **_(7)_*** . ___ ```cpp 2- minimumNumber ({2,12,8,4,6}) ==> return (5) ``` ## **_Explanation_**: * **_Since_** , **the sum** of the list's elements equal to **_(32)_** , *the minimum number to be inserted to transform the sum to prime number* is **_(5)_** , *which will make **_the sum of the List_** equal the closest prime number **_(37)_*** . ___ ```cpp 3- minimumNumber ({50,39,49,6,17,28}) ==> return (2) ``` ## **_Explanation_**: * **_Since_** , **the sum** of the list's elements equal to **_(189)_** , *the minimum number to be inserted to transform the sum to prime number* is **_(2)_** , *which will make **_the sum of the List_** equal the closest prime number **_(191)_*** . ___ ___ ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def check_prime(number): for i in range(2, number): if number % i == 0: return False return True def minimum_number(numbers): suma = sum(numbers) while check_prime(suma) != True: suma = suma + 1 print(suma) return suma - sum(numbers)
Transform To Prime
5a946d9fba1bb5135100007c
[ "Fundamentals", "Arrays" ]
https://www.codewars.com/kata/5a946d9fba1bb5135100007c
6 kyu
In this Kata, we will calculate the **minimum positive number that is not a possible sum** from a list of positive integers. ``` solve([1,2,8,7]) = 4 => we can get 1, 2, 3 (from 1+2), but we cannot get 4. 4 is the minimum number not possible from the list. solve([4,1,2,3,12]) = 11. We can get 1, 2, 3, 4, 4+1=5, 4+2=6,4+3=7,4+3+1=8,4+3+2=9,4+3+2+1=10. But not 11. solve([2,3,2,3,4,2,12,3]) = 1. We cannot get 1. ``` More examples in test cases. Good luck!
algorithms
def solve(xs): m = 0 for x in sorted(xs): if x > m + 1: break m += x return m + 1
Simple missing sum
5a941f3a4a6b34edf900006f
[ "Algorithms" ]
https://www.codewars.com/kata/5a941f3a4a6b34edf900006f
6 kyu
You are given an array with several `"even"` words, one `"odd"` word, and some numbers mixed in. Determine if any of the numbers in the array is the index of the `"odd"` word. If so, return `true`, otherwise `false`.
algorithms
def odd_ball(arr): return arr . index("odd") in arr
Odds-Index
5a941f4e1a60f6e8a70025fe
[ "Algorithms" ]
https://www.codewars.com/kata/5a941f4e1a60f6e8a70025fe
7 kyu
In this Kata, you will be given a number and your task will be to return the nearest prime number. ```Haskell solve(4) = 3. The nearest primes are 3 and 5. If difference is equal, pick the lower one. solve(125) = 127 ``` We'll be testing for numbers up to `1E10`. `500` tests. More examples in test cases. Good luck! If you like Prime Katas, you will enjoy this Kata: [Simple Prime Streaming](https://www.codewars.com/kata/5a908da30025e995880000e3)
algorithms
from itertools import count from gmpy2 import is_prime def solve(n): return next(b for a in count(0) for b in [n - a, n + a] if is_prime(b))
Simple nearest prime
5a9078e24a6b340b340000b8
[ "Algorithms" ]
https://www.codewars.com/kata/5a9078e24a6b340b340000b8
6 kyu
The number ```89``` is the first positive integer that has a particular, curious property: The square of ```89``` is ```7921```; ```89² = 7921``` The reverse of ```7921``` is ```1297```, and ```1297``` is a prime number. The cube of ```89``` is ```704969```; ```89³ = 704969``` The reverse of ```704969``` is ```969407```, and ```969407``` is a prime number. The first four terms of this sequence having this special property are: ``` n-th term term value 1 89 2 271 3 325 4 328 ``` Create a function ```sq_cub_rev_prime()```, that receives the ordinal number of the sequence and outputs its correspoding value. Use the above table to show how the function should work: ```python sq_cub_rev_prime(1) == 89 sq_cub_rev_prime(2) == 271 sq_cub_rev_prime(3) == 325 sq_cub_rev_prime(4) == 328 ``` Your code will be tested up to the 250th term This is not a registered sequence of OESIS, so if you are one of the first ten people that solve this kata, you may have the privilege to register the sequence at https://oeis.org, with your name. If you do so, please, mention in your biography that you are a Codewarrior. Memoize your results to pass the tests. Enjoy it!
algorithms
sq_cub_rev_prime = (None, 89, 271, 325, 328, 890, 1025, 1055, 1081, 1129, 1169, 1241, 2657, 2710, 3112, 3121, 3149, 3244, 3250, 3263, 3280, 3335, 3346, 3403, 4193, 4222, 4231, 4289, 4291, 5531, 5584, 5653, 5678, 5716, 5791, 5795, 5836, 5837, 8882, 8900, 8926, 8942, 9664, 9794, 9875, 9962, 10178, 10250, 10393, 10429, 10499, 10550, 10577, 10651, 10679, 10717, 10718, 10739, 10756, 10762, 10810, 10844, 10895, 10898, 10943, 10996, 11035, 11039, 11084, 11137, 11159, 11164, 11182, 11191, 11290, 11351, 11371, 11575, 11690, 11695, 11707, 11722, 11732, 11795, 11827, 11861, 11885, 12109, 12124, 12242, 12268, 12304, 12361, 12362, 12410, 12433, 12436, 12535, 19144, 19267, 19271, 19273, 19385, 19433, 19442, 19451, 19501, 19564, 19597, 19603, 19631, 19637, 19766, 19846, 19865, 19871, 19909, 19927, 26464, 26491, 26570, 26579, 26621, 26704, 26944, 26965, 27001, 27029, 27052, 27100, 27101, 31120, 31210, 31223, 31237, 31261, 31327, 31331, 31351, 31463, 31469, 31490, 31534, 31561, 31657, 31726, 31739, 31784, 31807, 31883, 31928, 31978, 32066, 32072, 32213, 32255, 32308, 32431, 32440, 32446, 32500, 32539, 32564, 32573, 32630, 32656, 32708, 32749, 32759, 32800, 32888, 32969, 33059, 33254, 33325, 33338, 33350, 33404, 33460, 33475, 33509, 33568, 33575, 33701, 33833, 34030, 34112, 34159, 34163, 41351, 41429, 41473, 41501, 41608, 41639, 41839, 41879, 41930, 41933, 41992, 42029, 42089, 42103, 42121, 42179, 42220, 42235, 42310, 42326, 42385, 42463, 42466, 42524, 42575, 42607, 42682, 42782, 42839, 42890, 42910, 42982, 43045, 43049, 54986, 54991, 55073, 55310, 55492, 55589, 55598, 55603, 55651).__getitem__
Square and Cube of a Number Become Prime When Reversed
5644a69f7849c9c097000073
[ "Fundamentals", "Mathematics", "Memoization", "Algorithms" ]
https://www.codewars.com/kata/5644a69f7849c9c097000073
4 kyu
Given a name, turn that name into a perfect square matrix (nested array with the amount of arrays equivalent to the length of each array). You will need to add periods (`.`) to the end of the name if necessary, to turn it into a matrix. If the name has a length of 0, return `"name must be at least one letter"` ## Examples ```javascript "Bill" ==> [ ["B", "i"], ["l", "l"] ] "Frank" ==> [ ["F", "r", "a"], ["n", "k", "."], [".", ".", "."] ] ```
algorithms
from math import ceil def matrixfy(s): if not s: return "name must be at least one letter" x = ceil(len(s) * * .5) it = iter(s . ljust(x * x, '.')) return [[next(it) for _ in range(x)] for _ in range(x)]
Name to Matrix
5a91e0793e9156ccb0003f6e
[ "Strings", "Arrays", "Algorithms", "Matrix" ]
https://www.codewars.com/kata/5a91e0793e9156ccb0003f6e
6 kyu
Consider a sequence made up of the consecutive prime numbers. This infinite sequence would start with: ```python "2357111317192329313741434753596167717379..." ``` You will be given two numbers: `a` and `b`, and your task will be to return `b` elements starting from index `a` in this sequence. ``` For example: solve(10,5) == `19232` Because these are 5 elements from index 10 in the sequence. ``` Tests go up to about index `20000`. More examples in test cases. Good luck! Please also try [Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2)
algorithms
def solve(a, b): primes = "2357111317192329313741434753596167717379838997101103107109113127131137139149151157163167173179181191193197199211223227229233239241251257263269271277281283293307311313317331337347349353359367373379383389397401409419421431433439443449457461463467479487491499503509521523541547557563569571577587593599601607613617619631641643647653659661673677683691701709719727733739743751757761769773787797809811821823827829839853857859863877881883887907911919929937941947953967971977983991997100910131019102110311033103910491051106110631069108710911093109711031109111711231129115111531163117111811187119312011213121712231229123112371249125912771279128312891291129713011303130713191321132713611367137313811399140914231427142914331439144714511453145914711481148314871489149314991511152315311543154915531559156715711579158315971601160716091613161916211627163716571663166716691693169716991709172117231733174117471753175917771783178717891801181118231831184718611867187118731877187918891901190719131931193319491951197319791987199319971999200320112017202720292039205320632069208120832087208920992111211321292131213721412143215321612179220322072213222122372239224322512267226922732281228722932297230923112333233923412347235123572371237723812383238923932399241124172423243724412447245924672473247725032521253125392543254925512557257925912593260926172621263326472657265926632671267726832687268926932699270727112713271927292731274127492753276727772789279127972801280328192833283728432851285728612879288728972903290929172927293929532957296329692971299930013011301930233037304130493061306730793083308931093119312131373163316731693181318731913203320932173221322932513253325732593271329933013307331333193323332933313343334733593361337133733389339134073413343334493457346134633467346934913499351135173527352935333539354135473557355935713581358335933607361336173623363136373643365936713673367736913697370137093719372737333739376137673769377937933797380338213823383338473851385338633877388138893907391139173919392339293931394339473967398940014003400740134019402140274049405140574073407940914093409941114127412941334139415341574159417742014211421742194229423142414243425342594261427142734283428942974327433743394349435743634373439143974409442144234441444744514457446344814483449345074513451745194523454745494561456745834591459746034621463746394643464946514657466346734679469147034721472347294733475147594783478747894793479948014813481748314861487148774889490349094919493149334937494349514957496749694973498749934999500350095011502150235039505150595077508150875099510151075113511951475153516751715179518951975209522752315233523752615273527952815297530353095323533353475351538153875393539954075413541754195431543754415443544954715477547954835501550355075519552155275531555755635569557355815591562356395641564756515653565756595669568356895693570157115717573757415743574957795783579158015807581358215827583958435849585158575861586758695879588158975903592359275939595359815987600760116029603760436047605360676073607960896091610161136121613161336143615161636173619761996203621162176221622962476257626362696271627762876299630163116317632363296337634363536359636163676373637963896397642164276449645164696473648164916521652965476551655365636569657165776581659966076619663766536659666166736679668966916701670367096719673367376761676367796781679167936803682368276829683368416857686368696871688368996907691169176947694969596961696769716977698369916997700170137019702770397043705770697079710371097121712771297151715971777187719372077211721372197229723772437247725372837297730773097321733173337349735173697393741174177433745174577459747774817487748974997507751775237529753775417547754975597561757375777583758975917603760776217639764376497669767376817687769176997703771777237727774177537757775977897793781778237829784178537867787378777879788379017907791979277933793779497951796379938009801180178039805380598069808180878089809381018111811781238147816181678171817981918209821982218231823382378243826382698273828782918293829783118317832983538363836983778387838984198423842984318443844784618467850185138521852785378539854385638573858185978599860986238627862986418647866386698677868186898693869987078713871987318737874187478753876187798783880388078819882188318837883988498861886388678887889389238929893389418951896389698971899990019007901190139029904190439049905990679091910391099127913391379151915791619173918191879199920392099221922792399241925792779281928392939311931993239337934193439349937193779391939794039413941994219431943394379439946194639467947394799491949795119521953395399547955195879601961396199623962996319643964996619677967996899697971997219733973997439749976797699781978797919803981198179829983398399851985798599871988398879901990799239929993199419949996799731000710009100371003910061100671006910079100911009310099101031011110133101391014110151101591016310169101771018110193102111022310243102471025310259102671027110273102891030110303103131032110331103331033710343103571036910391103991042710429104331045310457104591046310477104871049910501105131052910531105591056710589105971060110607106131062710631106391065110657106631066710687106911070910711107231072910733107391075310771107811078910799108311083710847108531085910861108671088310889108911090310909109371093910949109571097310979109871099311003110271104711057110591106911071110831108711093111131111711119111311114911159111611117111173111771119711213112391124311251112571126111273112791128711299113111131711321113291135111353113691138311393113991141111423114371144311447114671147111483114891149111497115031151911527115491155111579115871159311597116171162111633116571167711681116891169911701117171171911731117431177711779117831178911801118071181311821118271183111833118391186311867118871189711903119091192311927119331193911941119531195911969119711198111987120071201112037120411204312049120711207312097121011210712109121131211912143121491215712161121631219712203122111222712239122411225112253122631226912277122811228912301123231232912343123471237312377123791239112401124091241312421124331243712451124571247312479124871249112497125031251112517125271253912541125471255312569125771258312589126011261112613126191263712641126471265312659126711268912697127031271312721127391274312757127631278112791127991280912821128231282912841128531288912893128991290712911129171291912923129411295312959129671297312979129831300113003130071300913033130371304313049130631309313099131031310913121131271314713151131591316313171131771318313187132171321913229132411324913259132671329113297133091331313327133311333713339133671338113397133991341113417134211344113451134571346313469134771348713499135131352313537135531356713577135911359713613136191362713633136491366913679136811368713691136931369713709137111372113723137291375113757137591376313781137891379913807138291383113841138591387313877138791388313901139031390713913139211393113933139631396713997139991400914011140291403314051140571407114081140831408714107141431414914153141591417314177141971420714221142431424914251142811429314303143211432314327143411434714369143871438914401144071441114419144231443114437144471444914461144791448914503145191453314537145431454914551145571456114563145911459314621146271462914633146391465314657146691468314699147131471714723147311473714741147471475314759147671477114779147831479714813148211482714831148431485114867148691487914887148911489714923149291493914947149511495714969149831501315017150311505315061150731507715083150911510115107151211513115137151391514915161151731518715193151991521715227152331524115259152631526915271152771528715289152991530715313153191532915331153491535915361153731537715383153911540115413154271543915443154511546115467154731549315497155111552715541155511555915569155811558315601156071561915629156411564315647156491566115667156711567915683157271573115733157371573915749157611576715773157871579115797158031580915817158231585915877158811588715889159011590715913159191592315937159591597115973159911600116007160331605716061160631606716069160731608716091160971610316111161271613916141161831618716189161931621716223162291623116249162531626716273163011631916333163391634916361163631636916381164111641716421164271643316447164511645316477164811648716493165191652916547165531656116567165731660316607166191663116633166491665116657166611667316691166931669916703167291674116747167591676316787168111682316829168311684316871168791688316889169011690316921169271693116937169431696316979169811698716993170111702117027170291703317041170471705317077170931709917107171171712317137171591716717183171891719117203172071720917231172391725717291172931729917317173211732717333173411735117359173771738317387173891739317401174171741917431174431744917467174711747717483174891749117497175091751917539175511756917573175791758117597175991760917623176271765717659176691768117683177071771317729177371774717749177611778317789177911780717827178371783917851178631788117891179031790917911179211792317929179391795717959179711797717981179871798918013180411804318047180491805918061180771808918097181191812118127181311813318143181491816918181181911819918211182171822318229182331825118253182571826918287182891830118307183111831318329183411835318367183711837918397184011841318427184331843918443184511845718461184811849318503185171852118523185391854118553185831858718593186171863718661186711867918691187011871318719187311874318749187571877318787187931879718803188391885918869188991891118913189171891918947189591897318979190011900919013190311903719051190691907319079190811908719121191391914119157191631918119183192071921119213192191923119237192491925919267192731928919301193091931919333193731937919381193871939119403194171942119423194271942919433194411944719457194631946919471194771948319489195011950719531195411954319553195591957119577195831959719603196091966119681196871969719699197091971719727197391975119753197591976319777197931980119813198191984119843198531986119867198891989119913199191992719937199491996119963199731997919991199931999720011200212002320029200472005120063200712008920101201072011320117201232012920143201472014920161201732017720183202012021920231202332024920261202692028720297203232032720333203412034720353203572035920369203892039320399204072041120431204412044320477204792048320507205092052120533205432054920551205632059320599206112062720639206412066320681206932070720717207192073120743207472074920753207592077120773207892080720809208492085720873208792088720897208992090320921209292093920947209592096320981209832100121011210132101721019210232103121059210612106721089211012110721121211392114321149211572116321169211792118721191211932121121221212272124721269212772128321313213172131921323213412134721377213792138321391213972140121407214192143321467214812148721491214932149921503215172152121523215292155721559215632156921577215872158921599216012161121613216172164721649216612167321683217012171321727217372173921751217572176721773217872179921803218172182121839218412185121859218632187121881218932191121929219372194321961219772199121997220032201322027220312203722039220512206322067220732207922091220932210922111221232212922133221472215322157221592217122189221932222922247222592227122273222772227922283222912230322307223432234922367223692238122391223972240922433224412244722453224692248122483225012251122531225412254322549225672257122573226132261922621226372263922643226512266922679226912269722699227092271722721227272273922741227512276922777227832278722807228112281722853228592286122871228772290122907229212293722943229612296322973229932300323011230172302123027230292303923041230532305723059230632307123081230872309923117231312314323159231672317323189231972320123203232092322723251232692327923291232932329723311233212332723333233392335723369233712339923417234312344723459234732349723509235312353723539235492355723561235632356723581235932359923603236092362323627236292363323663236692367123677236872368923719237412374323747237532376123767237732378923801238132381923827238312383323857238692387323879238872389323899239092391123917239292395723971239772398123993240012400724019240232402924043240492406124071240772408324091240972410324107241092411324121241332413724151241692417924181241972420324223242292423924247242512428124317243292433724359243712437324379243912440724413244192442124439244432446924473244812449924509245172452724533245472455124571245932461124623246312465924671246772468324691246972470924733247492476324767247812479324799248092482124841248472485124859248772488924907249172491924923249432495324967249712497724979249892501325031250332503725057250732508725097251112511725121251272514725153251632516925171251832518925219252292523725243252472525325261253012530325307253092532125339253432534925357253672537325391254092541125423254392544725453254572546325469254712552325537255412556125577255792558325589256012560325609256212563325639256432565725667256732567925693257032571725733257412574725759257632577125793257992580125819258412584725849258672587325889259032591325919259312593325939259432595125969259812599725999260032601726021260292604126053260832609926107261112611326119261412615326161261712617726183261892620326209262272623726249262512626126263262672629326297263092631726321263392634726357263712638726393263992640726417264232643126437264492645926479264892649726501265132653926557265612657326591265972662726633266412664726669266812668326687266932669926701267112671326717267232672926731267372675926777267832680126813268212683326839268492686126863268792688126891268932690326921269272694726951269532695926981269872699327011270172703127043270592706127067270732707727091271032710727109271272714327179271912719727211272392724127253272592727127277272812728327299273292733727361273672739727407274092742727431274372744927457274792748127487275092752727529275392754127551275812758327611276172763127647276532767327689276912769727701277332773727739277432774927751277632776727773277792779127793277992780327809278172782327827278472785127883278932790127917279192794127943279472795327961279672798327997280012801928027280312805128057280692808128087280972809928109281112812328151281632818128183282012821128219282292827728279282832828928297283072830928319283492835128387283932840328409284112842928433284392844728463284772849328499285132851728537285412854728549285592857128573285792859128597286032860728619286212862728631286432864928657286612866328669286872869728703287112872328729287512875328759287712878928793288072881328817288372884328859288672887128879289012890928921289272893328949289612897929009290172902129023290272903329059290632907729101291232912929131291372914729153291672917329179291912920129207292092922129231292432925129269292872929729303293112932729333293392934729363293832938729389293992940129411294232942929437294432945329473294832950129527295312953729567295692957329581295872959929611296292963329641296632966929671296832971729723297412975329759297612978929803298192983329837298512986329867298732987929881299172992129927299472995929983299893001130013300293004730059300713008930091300973010330109301133011930133301373013930161301693018130187301973020330211302233024130253302593026930271302933030730313303193032330341303473036730389303913040330427304313044930467304693049130493304973050930517305293053930553305573055930577305933063130637306433064930661306713067730689306973070330707307133072730757307633077330781308033080930817308293083930841308513085330859308693087130881308933091130931309373094130949309713097730983310133101931033310393105131063310693107931081310913112131123311393114731151311533115931177311813118331189311933121931223312313123731247312493125331259312673127131277313073131931321313273133331337313573137931387313913139331397314693147731481314893151131513315173153131541315433154731567315733158331601316073162731643316493165731663316673168731699317213172331727317293174131751317693177131793317993181731847318493185931873318833189131907319573196331973319813199132003320093202732029320513205732059320633206932077320833208932099321173211932141321433215932173321833218932191322033221332233322373225132257322613229732299323033230932321323233232732341323533235932363323693237132377323813240132411324133242332429324413244332467324793249132497325033250732531325333253732561325633256932573325793258732603326093261132621326333264732653326873269332707327133271732719327493277132779327833278932797328013280332831328333283932843328693288732909329113291732933329393294132957329693297132983329873299332999330133302333029330373304933053330713307333083330913310733113331193314933151331613317933181331913319933203332113322333247332873328933301333113331733329333313334333347333493335333359333773339133403334093341333427334573346133469334793348733493335033352133529335333354733563335693357733581335873358933599336013361333617336193362333629336373364133647336793370333713337213373933749337513375733767337693377333791337973380933811338273382933851338573386333871338893389333911339233393133937339413396133967339973401934031340333403934057340613412334127341293414134147341573415934171341833421134213342173423134253342593426134267342733428334297343013430334313343193432734337343513436134367343693438134403344213442934439344573446934471344833448734499345013451134513345193453734543345493458334589345913460334607346133463134649346513466734673346793468734693347033472134729347393474734757347593476334781348073481934841348433484734849348713487734883348973491334919349393494934961349633498135023350273505135053350593506935081350833508935099351073511135117351293514135149351533515935171352013522135227352513525735267352793528135291353113531735323353273533935353353633538135393354013540735419354233543735447354493546135491355073550935521355273553135533355373554335569355733559135593355973560335617356713567735729357313574735753357593577135797358013580335809358313583735839358513586335869358793589735899359113592335933359513596335969359773598335993359993600736011360133601736037360613606736073360833609736107361093613136137361513616136187361913620936217362293624136251362633626936277362933629936307363133631936341363433635336373363833638936433364513645736467364693647336479364933649736523365273652936541365513655936563365713658336587365993660736629366373664336653366713667736683366913669736709367133672136739367493676136767367793678136787367913679336809368213683336847368573687136877368873689936901369133691936923369293693136943369473697336979369973700337013370193702137039370493705737061370873709737117371233713937159371713718137189371993720137217372233724337253372733727737307373093731337321373373733937357373613736337369373793739737409374233744137447374633748337489374933750137507375113751737529375373754737549375613756737571375733757937589375913760737619376333764337649376573766337691376933769937717377473778137783377993781137813378313784737853378613787137879378893789737907379513795737963379673798737991379933799738011380393804738053380693808338113381193814938153381673817738183381893819738201382193823138237382393826138273382813828738299383033831738321383273832938333383513837138377383933843138447384493845338459384613850138543385573856138567385693859338603386093861138629386393865138653386693867138677386933869938707387113871338723387293873738747387493876738783387913880338821388333883938851388613886738873388913890338917389213892338933389533895938971389773899339019390233904139043390473907939089390973910339107391133911939133391393915739161391633918139191391993920939217392273922939233392393924139251392933930139313393173932339341393433935939367393713937339383393973940939419394393944339451394613949939503395093951139521395413955139563395693958139607396193962339631396593966739671396793970339709397193972739733397493976139769397793979139799398213982739829398393984139847398573986339869398773988339887399013992939937399533997139979399833998940009400134003140037400394006340087400934009940111401234012740129401514015340163401694017740189401934021340231402374024140253402774028340289403434035140357403614038740423404274042940433404594047140483404874049340499405074051940529405314054340559405774058340591405974060940627406374063940693406974069940709407394075140759407634077140787408014081340819408234082940841408474084940853408674087940883408974090340927409334093940949409614097340993410114101741023410394104741051410574107741081411134111741131411414114341149411614117741179411834118941201412034121341221412274123141233412434125741263412694128141299413334134141351413574138141387413894139941411414134144341453414674147941491415074151341519415214153941543415494157941593415974160341609416114161741621416274164141647416514165941669416814168741719417294173741759417614177141777418014180941813418434184941851418634187941887418934189741903419114192741941419474195341957419594196941981419834199942013420174201942023420434206142071420734208342089421014213142139421574216942179421814218742193421974220942221422234222742239422574228142283422934229942307423234233142337423494235942373423794239142397424034240742409424334243742443424514245742461424634246742473424874249142499425094253342557425694257142577425894261142641426434264942667426774268342689426974270142703427094271942727427374274342751427674277342787427934279742821428294283942841428534285942863428994290142923429294293742943429534296142967429794298943003430134301943037430494305143063430674309343103431174313343151431594317743189432014320743223432374326143271432834329143313433194332143331433914339743399434034341143427434414345143457434814348743499435174354143543435734357743579435914359743607436094361343627436334364943651436614366943691437114371743721437534375943777437814378343787437894379343801438534386743889438914391343933439434395143961439634396943973439874399143997440174402144027440294404144053440594407144087440894410144111441194412344129441314415944171441794418944201442034420744221442494425744263442674426944273442794428144293443514435744371443814438344389444174444944453444834449144497445014450744519445314453344537445434454944563445794458744617446214462344633446414464744651446574468344687446994470144711447294474144753447714477344777447894479744809448194483944843448514486744879448874489344909449174492744939449534495944963449714498344987450074501345053450614507745083451194512145127451314513745139451614517945181451914519745233452474525945263452814528945293453074531745319453294533745341453434536145377453894540345413454274543345439454814549145497455034552345533455414555345557455694558745589455994561345631456414565945667456734567745691456974570745737457514575745763457674577945817458214582345827458334584145853458634586945887458934594345949459534595945971459794598946021460274604946051460614607346091460934609946103461334614146147461534617146181461834618746199462194622946237462614627146273462794630146307463094632746337463494635146381463994641146439464414644746451464574647146477464894649946507465114652346549465594656746573465894659146601466194663346639466434664946663466794668146687466914670346723467274674746751467574676946771468074681146817468194682946831468534686146867468774688946901469194693346957469934699747017470414705147057470594708747093471114711947123471294713747143471474714947161471894720747221472374725147269472794728747293472974730347309473174733947351473534736347381473874738947407474174741947431474414745947491474974750147507475134752147527475334754347563475694758147591475994760947623476294763947653476574765947681476994770147711477134771747737477414774347777477794779147797478074780947819478374784347857478694788147903479114791747933479394794747951479634796947977479814801748023480294804948073480794809148109481194812148131481574816348179481874819348197482214823948247482594827148281482994831148313483374834148353483714838348397484074840948413484374844948463484734847948481484874849148497485234852748533485394854148563485714858948593486114861948623486474864948661486734867748679487314873348751487574876148767487794878148787487994880948817488214882348847488574885948869488714888348889489074894748953489734898948991490034900949019490314903349037490434905749069490814910349109491174912149123491394915749169491714917749193491994920149207492114922349253492614927749279492974930749331493334933949363493674936949391493934940949411494174942949433494514945949463494774948149499495234952949531495374954749549495594959749603496134962749633496394966349667496694968149697497114972749739497414974749757497834978749789498014980749811498234983149843498534987149877498914991949921499274993749939499434995749991499934999950021500235003350047500515005350069500775008750093501015011150119501235012950131501475015350159501775020750221502275023150261502635027350287502915031150321503295033350341503595036350377503835038750411504175042350441504595046150497505035051350527505395054350549505515058150587505915059350599506275064750651506715068350707507235074150753507675077350777507895082150833508395084950857508675087350891508935090950923509295095150957509695097150989509935100151031510435104751059510615107151109511315113351137511515115751169511935119751199512035121751229512395124151257512635128351287513075132951341513435134751349513615138351407514135141951421514275143151437514395144951461514735147951481514875150351511515175152151539515515156351577515815159351599516075161351631516375164751659516735167951683516915171351719517215174951767517695178751797518035181751827518295183951853518595186951871518935189951907519135192951941519495197151973519775199152009520215202752051520575206752069520815210352121521275214752153521635217752181521835218952201522235223752249522535225952267522895229152301523135232152361523635236952379523875239152433524535245752489525015251152517525295254152543525535256152567525715257952583526095262752631526395266752673526915269752709527115272152727527335274752757527695278352807528135281752837528595286152879528835288952901529035291952937529515295752963529675297352981529995300353017530475305153069530775308753089530935310153113531175312953147531495316153171531735318953197532015323153233532395326753269532795328153299533095332353327533535335953377533815340153407534115341953437534415345353479535035350753527535495355153569535915359353597536095361153617536235362953633536395365353657536815369353699537175371953731537595377353777537835379153813538195383153849538575386153881538875389153897538995391753923539275393953951539595398753993540015401154013540375404954059540835409154101541215413354139541515416354167541815419354217542515426954277542875429354311543195432354331543475436154367543715437754401544035440954413544195442154437544435444954469544935449754499545035451754521545395454154547545595456354577545815458354601546175462354629546315464754667546735467954709547135472154727547515476754773547795478754799548295483354851548695487754881549075491754919549415494954959549735497954983550015500955021550495505155057550615507355079551035510955117551275514755163551715520155207552135521755219552295524355249552595529155313553315533355337553395534355351553735538155399554115543955441554575546955487555015551155529555415554755579555895560355609556195562155631556335563955661556635566755673556815569155697557115571755721557335576355787557935579955807558135581755819558235582955837558435584955871558895589755901559035592155927559315593355949559675598755997560035600956039560415605356081560875609356099561015611356123561315614956167561715617956197562075620956237562395624956263562675626956299563115633356359563695637756383563935640156417564315643756443564535646756473564775647956489565015650356509565195652756531565335654356569565915659756599566115662956633566595666356671566815668756701567115671356731567375674756767567735677956783568075680956813568215682756843568575687356891568935689756909569115692156923569295694156951569575696356983569895699356999570375704157047570595707357077570895709757107571195713157139571435714957163571735717957191571935720357221572235724157251572595726957271572835728757301573295733157347573495736757373573835738957397574135742757457574675748757493575035752757529575575755957571575875759357601576375764157649576535766757679576895769757709577135771957727577315773757751577735778157787577915779357803578095782957839578475785357859578815789957901579175792357943579475797357977579915801358027580315804358049580575806158067580735809958109581115812958147581515815358169581715818958193581995820758211582175822958231582375824358271583095831358321583375836358367583695837958391583935840358411584175842758439584415845158453584775848158511585375854358549585675857358579586015860358613586315865758661586795868758693586995871158727587335874158757587635877158787587895883158889588975890158907589095891358921589375894358963589675897958991589975900959011590215902359029590515905359063590695907759083590935910759113591195912359141591495915959167591835919759207592095921959221592335923959243592635927359281593335934159351593575935959369593775938759393593995940759417594195944159443594475945359467594715947359497595095951359539595575956159567595815961159617596215962759629596515965959663596695967159693596995970759723597295974359747597535977159779597915979759809598335986359879598875992159929599515995759971599815999960013600176002960037600416007760083600896009160101601036010760127601336013960149601616016760169602096021760223602516025760259602716028960293603176033160337603436035360373603836039760413604276044360449604576049360497605096052160527605396058960601606076061160617606236063160637606476064960659606616067960689607036071960727607336073760757607616076360773607796079360811608216085960869608876088960899609016091360917609196092360937609436095360961610016100761027610316104361051610576109161099611216112961141611516115361169612116122361231612536126161283612916129761331613336133961343613576136361379613816140361409614176144161463614696147161483614876149361507615116151961543615476155361559615616158361603616096161361627616316163761643616516165761667616736168161687617036171761723617296175161757617816181361819618376184361861618716187961909619276193361949619616196761979619816198761991620036201162017620396204762053620576207162081620996211962129621316213762141621436217162189621916220162207622136221962233622736229762299623036231162323623276234762351623836240162417624236245962467624736247762483624976250162507625336253962549625636258162591625976260362617626276263362639626536265962683626876270162723627316274362753627616277362791628016281962827628516286162869628736289762903629216292762929629396296962971629816298362987629896302963031630596306763073630796309763103631136312763131631496317963197631996321163241632476327763281632996331163313633176333163337633476335363361633676337763389633916339763409634196342163439634436346363467634736348763493634996352163527635336354163559635776358763589635996360163607636116361763629636476364963659636676367163689636916369763703637096371963727637376374363761637736378163793637996380363809638236383963841638536385763863639016390763913639296394963977639976400764013640196403364037640636406764081640916410964123641516415364157641716418764189642176422364231642376427164279642836430164303643196432764333643736438164399644036443364439644516445364483644896449964513645536456764577645796459164601646096461364621646276463364661646636466764679646936470964717647476476364781647836479364811648176484964853648716487764879648916490164919649216492764937649516496964997650036501165027650296503365053650636507165089650996510165111651196512365129651416514765167651716517365179651836520365213652396525765267652696528765293653096532365327653536535765371653816539365407654136541965423654376544765449654796549765519655216553765539655436555165557655636557965581655876559965609656176562965633656476565165657656776568765699657016570765713657176571965729657316576165777657896580965827658316583765839658436585165867658816589965921659276592965951659576596365981659836599366029660376604166047660676607166083660896610366107661096613766161661696617366179661916622166239662716629366301663376634366347663596636166373663776638366403664136643166449664576646366467664916649966509665236652966533665416655366569665716658766593666016661766629666436665366683666976670166713667216673366739667496675166763667916679766809668216684166851668536686366877668836688966919669236693166943669476694966959669736697767003670216703367043670496705767061670736707967103671216712967139671416715367157671696718167187671896721167213672176721967231672476726167271672736728967307673396734367349673696739167399674096741167421674276742967433674476745367477674816748967493674996751167523675316753767547675596756767577675796758967601676076761967631676516767967699677096772367733677416775167757677596776367777677836778967801678076781967829678436785367867678836789167901679276793167933679396794367957679616796767979679876799368023680416805368059680716808768099681116811368141681476816168171682076820968213682196822768239682616827968281683116832968351683716838968399684376844368447684496847368477684836848968491685016850768521685316853968543685676858168597686116863368639686596866968683686876869968711687136872968737687436874968767687716877768791688136881968821688636887968881688916889768899689036890968917689276894768963689936900169011690196902969031690616906769073691096911969127691436914969151691636919169193691976920369221692336923969247692576925969263693136931769337693416937169379693836938969401694036942769431694396945769463694676947369481694916949369497694996953969557695936962369653696616967769691696976970969737697396976169763697676977969809698216982769829698336984769857698596987769899699116992969931699416995969991699977000170003700097001970039700517006170067700797009970111701177012170123701397014170157701637017770181701837019970201702077022370229702377024170249702717028970297703097031370321703277035170373703797038170393704237042970439704517045770459704817048770489705017050770529705377054970571705737058370589706077061970621706277063970657706637066770687707097071770729707537076970783707937082370841708437084970853708677087770879708917090170913709197092170937709497095170957709697097970981709917099770999710117102371039710597106971081710897111971129711437114771153711617116771171711917120971233712377124971257712617126371287712937131771327713297133371339713417134771353713597136371387713897139971411714137141971429714377144371453714717147371479714837150371527715377154971551715637156971593715977163371647716637167171693716997170771711717137171971741717617177771789718077180971821718377184371849718617186771879718817188771899719097191771933719417194771963719717198371987719937199972019720317204372047720537207372077720897209172101721037210972139721617216772169721737221172221722237222772229722517225372269722717227772287723077231372337723417235372367723797238372421724317246172467724697248172493724977250372533725477255172559725777261372617726237264372647726497266172671726737267972689727017270772719727277273372739727637276772797728177282372859728697287172883728897289372901729077291172923729317293772949729537295972973729777299773009730137301973037730397304373061730637307973091731217312773133731417318173189732377324373259732777329173303733097332773331733517336173363733697337973387734177342173433734537345973471734777348373517735237352973547735537356173571735837358973597736077360973613736377364373651736737367973681736937369973709737217372773751737577377173783738197382373847738497385973867738777388373897739077393973943739517396173973739997401774021740277404774051740717407774093740997410174131741437414974159741617416774177741897419774201742037420974219742317425774279742877429374297743117431774323743537435774363743777438174383744117441374419744417444974453744717448974507745097452174527745317455174561745677457374587745977460974611746237465374687746997470774713747177471974729747317474774759747617477174779747977482174827748317484374857748617486974873748877489174897749037492374929749337494174959750117501375017750297503775041750797508375109751337514975161751677516975181751937520975211752177522375227752397525375269752777528975307753237532975337753477535375367753777538975391754017540375407754317543775479755037551175521755277553375539755417555375557755717557775583756117561775619756297564175653756597567975683756897570375707757097572175731757437576775773757817578775793757977582175833758537586975883759137593175937759417596775979759837598975991759977600176003760317603976079760817609176099761037612376129761477615776159761637620776213762317624376249762537625976261762837628976303763337634376367763697637976387764037642176423764417646376471764817648776493765077651176519765377654176543765617657976597766037660776631766497665176667766737667976697767177673376753767577677176777767817680176819768297683176837768477687176873768837690776913769197694376949769617696376991770037701777023770297704177047770697708177093771017713777141771537716777171771917720177213772377723977243772497726177263772677726977279772917731777323773397734777351773597736977377773837741777419774317744777471774777747977489774917750977513775217752777543775497755177557775637756977573775877759177611776177762177641776477765977681776877768977699777117771377719777237773177743777477776177773777837779777801778137783977849778637786777893778997792977933779517796977977779837799978007780177803178041780497805978079781017812178137781397815778163781677817378179781917819378203782297823378241782597827778283783017830778311783177834178347783677840178427784377843978467784797848778497785097851178517785397854178553785697857178577785837859378607786237864378649786537869178697787077871378721787377877978781787877879178797788037880978823788397885378857788777888778889788937890178919789297894178977789797898979031790397904379063790877910379111791337913979147791517915379159791817918779193792017922979231792417925979273792797928379301793097931979333793377934979357793677937979393793977939979411794237942779433794517948179493795317953779549795597956179579795897960179609796137962179627796317963379657796697968779691796937969779699797577976979777798017981179813798177982379829798417984379847798617986779873798897990179903799077993979943799677997379979799877999779999800218003980051800718007780107801118014180147801498015380167801738017780191802078020980221802318023380239802518026380273802798028780309803178032980341803478036380369803878040780429804478044980471804738048980491805138052780537805578056780599806038061180621806278062980651806578066980671806778068180683806878070180713807378074780749807618077780779807838078980803808098081980831808338084980863808978090980911809178092380929809338095380963809898100181013810178101981023810318104181043810478104981071810778108381097811018111981131811578116381173811818119781199812038122381233812398128181283812938129981307813318134381349813538135981371813738140181409814218143981457814638150981517815278153381547815518155381559815638156981611816198162981637816478164981667816718167781689817018170381707817278173781749817618176981773817998181781839818478185381869818838189981901819198192981931819378194381953819678197181973820038200782009820138202182031820378203982051820678207382129821398214182153821638217182183821898219382207822178221982223822318223782241822618226782279823018230782339823498235182361823738238782393824218245782463824698247182483824878249382499825078252982531825498255982561825678257182591826018260982613826198263382651826578269982721827238272782729827578275982763827818278782793827998281182813828378284782883828898289182903829138293982963829818299783003830098302383047830598306383071830778308983093831018311783137831778320383207832198322183227832318323383243832578326783269832738329983311833398334183357833838338983399834018340783417834238343183437834438344983459834718347783497835378355783561835638357983591835978360983617836218363983641836538366383689837018371783719837378376183773837778379183813838338384383857838698387383891839038391183921839338393983969839838398784011840178404784053840598406184067840898412184127841318413784143841638417984181841918419984211842218422384229842398424784263842998430784313843178431984347843498437784389843918440184407844218443184437844438444984457844638446784481844998450384509845218452384533845518455984589846298463184649846538465984673846918469784701847138471984731847378475184761847878479384809848118482784857848598486984871849138491984947849618496784977849798499185009850218502785037850498506185081850878509185093851038510985121851338514785159851938519985201852138522385229852378524385247852598529785303853138533185333853618536385369853818541185427854298543985447854518545385469854878551385517855238553185549855718557785597856018560785619856218562785639856438566185667856698569185703857118571785733857518578185793858178581985829858318583785843858478585385889859038590985931859338599185999860118601786027860298606986077860838611186113861178613186137861438616186171861798618386197862018620986239862438624986257862638626986287862918629386297863118632386341863518635386357863698637186381863898639986413864238644186453864618646786477864918650186509865318653386539865618657386579865878659986627866298667786689866938671186719867298674386753867678677186783868138683786843868518685786861868698692386927869298693986951869598696986981869938701187013870378704187049870718708387103871078711987121871338714987151871798718187187872118722187223872518725387257872778728187293872998731387317873238733787359873838740387407874218742787433874438747387481874918750987511875178752387539875418754787553875578755987583875878758987613876238762987631876418764387649876718767987683876918769787701877198772187739877438775187767877938779787803878118783387853878698787787881878878791187917879318794387959879618797387977879918800188003880078801988037880698807988093881178812988169881778821188223882378824188259882618828988301883218832788337883398837988397884118842388427884638846988471884938849988513885238854788589885918860788609886438865188657886618866388667886818872188729887418874788771887898879388799888018880788811888138881788819888438885388861888678887388883888978890388919889378895188969889938899789003890098901789021890418905189057890698907189083890878910189107891138911989123891378915389189892038920989213892278923189237892618926989273892938930389317893298936389371893818938789393893998941389417894318944389449894598947789491895018951389519895218952789533895618956389567895918959789599896038961189627896338965389657896598966989671896818968989753897598976789779897838979789809898198982189833898398984989867898918989789899899098991789923899398995989963899778998389989900019000790011900179001990023900319005390059900679007190073900899010790121901279014990163901739018790191901979019990203902179022790239902479026390271902819028990313903539035990371903739037990397904019040390407904379043990469904739048190499905119052390527905299053390547905839059990617906199063190641906479065990677906799069790703907099073190749907879079390803908219082390833908419084790863908879090190907909119091790931909479097190977909899099791009910199103391079910819109791099911219112791129911399114191151911539115991163911839119391199912299123791243912499125391283912919129791303913099133191367913699137391381913879139391397914119142391433914539145791459914639149391499915139152991541915719157391577915839159191621916319163991673916919170391711917339175391757917719178191801918079181191813918239183791841918679187391909919219193991943919519195791961919679196991997920039200992033920419205192077920839210792111921199214392153921739217792179921899220392219922219222792233922379224392251922699229792311923179233392347923539235792363923699237792381923839238792399924019241392419924319245992461924679247992489925039250792551925579256792569925819259392623926279263992641926479265792669926719268192683926939269992707927179272392737927539276192767927799278992791928019280992821928319284992857928619286392867928939289992921929279294192951929579295992987929939300193047930539305993077930839308993097931039311393131931339313993151931699317993187931999322993239932419325193253932579326393281932839328793307933199332393329933379337193377933839340793419934279346393479934819348793491934939349793503935239352993553935579355993563935819360193607936299363793683937019370393719937399376193763937879380993811938279385193871938879388993893939019391193913939239393793941939499396793971939799398393997940079400994033940499405794063940799409994109941119411794121941519415394169942019420794219942299425394261942739429194307943099432194327943319434394349943519437994397943999442194427944339443994441944479446394477944839451394529945319454194543945479455994561945739458394597946039461394621946499465194687946939470994723947279474794771947779478194789947939481194819948239483794841948479484994873948899490394907949339494994951949619499394999950039500995021950279506395071950839508795089950939510195107951119513195143951539517795189951919520395213952199523195233952399525795261952679527395279952879531195317953279533995369953839539395401954139541995429954419544395461954679547195479954839550795527955319553995549955619556995581955979560395617956219562995633956519570195707957139571795723957319573795747957739578395789957919580195803958139581995857958699587395881958919591195917959239592995947959579595995971959879598996001960139601796043960539605996079960979613796149961579616796179961819619996211962219622396233962599626396269962819628996293963239632996331963379635396377964019641996431964439645196457964619646996479964879649396497965179652796553965579658196587965899660196643966619666796671966979670396731967379673996749967579676396769967799678796797967999682196823968279684796851968579689396907969119693196953969599697396979969899699797001970039700797021970399707397081971039711797127971519715797159971699717197177971879721397231972419725997283973019730397327973679736997373973799738197387973979742397429974419745397459974639749997501975119752397547975499755397561975719757797579975839760797609976139764997651976739768797711977299777197777977879778997813978299784197843978479784997859978619787197879978839791997927979319794397961979679797397987980099801198017980419804798057980819810198123981299814398179982079821398221982279825198257982699829798299983179832198323983279834798369983779838798389984079841198419984299844398453984599846798473984799849198507985199853398543985619856398573985979862198627986399864198663986699868998711987139871798729987319873798773987799880198807988099883798849988679886998873988879889398897988999890998911989279892998939989479895398963989819899398999990139901799023990419905399079990839908999103991099911999131991339913799139991499917399181991919922399233992419925199257992599927799289993179934799349993679937199377993919939799401994099943199439994699948799497995239952799529995519955999563995719957799581996079961199623996439966199667996799968999707997099971399719997219973399761997679978799793998099981799823998299983399839998599987199877998819990199907999239992999961999719998999991100003100019100043100049100057100069100103100109100129100151100153100169100183100189100193100207100213100237100267100271100279100291100297100313100333100343100357100361100363100379100391100393100403100411100417100447100459100469100483100493100501100511100517100519100523100537100547100549100559100591100609100613100621100649100669100673100693100699100703100733100741100747100769100787100799100801100811100823100829100847100853100907100913100927100931100937100943100957100981100987100999101009101021101027101051101063101081101089101107101111101113101117101119101141101149101159101161101173101183101197101203101207101209101221101267101273101279101281101287101293101323101333101341101347101359101363101377101383101399101411101419101429101449101467101477101483101489101501101503101513101527101531101533101537101561101573101581101599101603101611101627101641101653101663101681101693101701101719101723101737101741101747101749101771101789101797101807101833101837101839101863101869101873101879101891101917101921101929101939101957101963101977101987101999102001102013102019102023102031102043102059102061102071102077102079102101102103102107102121102139102149102161102181102191102197102199102203102217102229102233102241102251102253102259102293102299102301102317102329102337102359102367102397102407102409102433102437102451102461102481102497102499102503102523102533102539102547102551102559102563102587102593102607102611102643102647102653102667102673102677102679102701102761102763102769102793102797102811102829102841102859102871102877102881102911102913102929102931102953102967102983103001103007103043103049103067103069103079103087103091103093103099103123103141103171103177103183103217103231103237103289103291103307103319103333103349103357103387103391103393103399103409103421103423103451103457103471103483103511103529103549103553103561103567103573103577103583103591103613103619103643103651103657103669103681103687103699103703103723103769103787103801103811103813103837103841103843103867103889103903103913103919103951103963103967103969103979103981103991103993103997104003104009104021104033104047104053104059104087104089104107104113104119104123104147104149104161104173104179104183104207104231104233104239104243104281104287104297104309104311104323104327104347104369104381104383104393104399104417104459104471104473104479104491104513104527104537104543104549104551104561104579104593104597104623104639104651104659104677104681104683104693104701104707104711104717104723104729104743104759104761104773104779104789104801104803104827104831104849104851104869104879104891104911104917104933104947104953104959104971104987104999105019105023105031105037105071105097105107105137105143105167105173105199105211105227105229105239105251105253105263105269105277105319105323105331105337105341105359105361105367105373105379105389105397105401105407105437105449105467105491105499105503105509105517105527105529105533105541105557105563105601105607105613105619105649105653105667105673105683105691105701105727105733105751105761105767105769105817105829105863105871105883105899105907105913105929105943105953105967105971105977105983105997106013106019106031106033106087106103106109106121106123106129106163106181106187106189106207106213106217106219106243106261106273106277106279106291106297106303106307106319106321106331106349106357106363106367106373106391106397106411106417106427106433106441106451106453106487106501106531106537106541106543106591106619106621106627106637106649106657106661106663106669106681106693106699106703106721106727106739106747106751106753106759106781106783106787106801106823106853106859106861106867106871106877106903106907106921106937106949106957106961106963106979106993107021107033107053107057107069107071107077107089107099107101107119107123107137107171107183107197107201107209107227107243107251107269107273107279107309107323107339107347107351107357107377107441107449107453107467107473107507107509107563107581107599107603107609107621107641107647107671107687107693107699107713107717107719107741107747107761107773107777107791107827107837107839107843107857107867107873107881107897107903107923107927107941107951107971107981107999108007108011108013108023108037108041108061108079108089108107108109108127108131108139108161108179108187108191108193108203108211108217108223108233108247108263108271108287108289108293108301108343108347108359108377108379108401108413108421108439108457108461108463108497108499108503108517108529108533108541108553108557108571108587108631108637108643108649108677108707108709108727108739108751108761108769108791108793108799108803108821108827108863108869108877108881108883108887108893108907108917108923108929108943108947108949108959108961108967108971108991109001109013109037109049109063109073109097109103109111109121109133109139109141109147109159109169109171109199109201109211109229109253109267109279109297109303109313109321109331109357109363109367109379109387109391109397109423109433109441109451109453109469109471109481109507109517109519109537109541109547109567109579109583109589109597109609109619109621109639109661109663109673109717109721109741109751109789109793109807109819109829109831109841109843109847109849109859109873109883109891109897109903109913109919109937109943109961109987110017110023110039110051110059110063110069110083110119110129110161110183110221110233110237110251110261110269110273110281110291110311110321110323110339110359110419110431110437110441110459110477110479110491110501110503110527110533110543110557110563110567110569110573110581110587110597110603110609110623110629110641110647110651110681110711110729110731110749110753110771110777110807110813110819110821110849110863110879110881110899110909110917110921110923110927110933110939110947110951110969110977110989111029111031111043111049111053111091111103111109111119111121111127111143111149111187111191111211111217111227111229111253111263111269111271111301111317111323111337111341111347111373111409111427111431111439111443111467111487111491111493111497111509111521111533111539111577111581111593111599111611111623111637111641111653111659111667111697111721111731111733111751111767111773111779111781111791111799111821111827111829111833111847111857111863111869111871111893111913111919111949111953111959111973111977111997112019112031112061112067112069112087112097112103112111112121112129112139112153112163112181112199112207112213112223112237112241112247112249112253112261112279112289112291112297112303112327112331112337112339112349112361112363112397112403112429112459112481112501112507112543112559112571112573112577112583112589112601112603112621112643112657112663112687112691112741112757112759112771112787112799112807112831112843112859112877112901112909112913112919112921112927112939112951112967112979112997113011113017113021113023113027113039113041113051113063113081113083113089113093113111113117113123113131113143113147113149113153113159113161113167113171113173113177113189113209113213113227113233113279113287113327113329113341113357113359113363113371113381113383113417113437113453113467113489113497113501113513113537113539113557113567113591113621113623113647113657113683113717113719113723113731113749113759113761113777113779113783113797113809113819113837113843113891113899113903113909113921113933113947113957113963113969113983113989114001114013114031114041114043114067114073114077114083114089114113114143114157114161114167114193114197114199114203114217114221114229114259114269114277114281114299114311114319114329114343114371114377114407114419114451114467114473114479114487114493114547114553114571114577114593114599114601114613114617114641114643114649114659114661114671114679114689114691114713114743114749114757114761114769114773114781114797114799114809114827114833114847114859114883114889114901114913114941114967114973114997115001115013115019115021115057115061115067115079115099115117115123115127115133115151115153115163115183115201115211115223115237115249115259115279115301115303115309115319115321115327115331115337115343115361115363115399115421115429115459115469115471115499115513115523115547115553115561115571115589115597115601115603115613115631115637115657115663115679115693115727115733115741115751115757115763115769115771115777115781115783115793115807115811115823115831115837115849115853115859115861115873115877115879115883115891115901115903115931115933115963115979115981115987116009116027116041116047116089116099116101116107116113116131116141116159116167116177116189116191116201116239116243116257116269116273116279116293116329116341116351116359116371116381116387116411116423116437116443116447116461116471116483116491116507116531116533116537116539116549116579116593116639116657116663116681116687116689116707116719116731116741116747116789116791116797116803116819116827116833116849116867116881116903116911116923116927116929116933116953116959116969116981116989116993117017117023117037117041117043117053117071117101117109117119117127117133117163117167117191117193117203117209117223117239117241117251117259117269117281117307117319117329117331117353117361117371117373117389117413117427117431117437117443117497117499117503117511117517117529117539117541117563117571117577117617117619117643117659117671117673117679117701117703117709117721117727117731117751117757117763117773117779117787117797117809117811117833117839117841117851117877117881117883117889117899117911117917117937117959117973117977117979117989117991118033118037118043118051118057118061118081118093118127118147118163118169118171118189118211118213118219118247118249118253118259118273118277118297118343118361118369118373118387118399118409118411118423118429118453118457118463118471118493118529118543118549118571118583118589118603118619118621118633118661118669118673118681118687118691118709118717118739118747118751118757118787118799118801118819118831118843118861118873118891118897118901118903118907118913118927118931118967118973119027119033119039119047119057119069119083119087119089119099119101119107119129119131119159119173119179119183119191119227119233119237119243119267119291119293119297119299119311119321119359119363119389119417119419119429119447119489119503119513119533119549119551119557119563119569119591119611119617119627119633119653119657119659119671119677119687119689119699119701119723119737119747119759119771119773119783119797119809119813119827119831119839119849119851119869119881119891119921119923119929119953119963119971119981119983119993120011120017120041120047120049120067120077120079120091120097120103120121120157120163120167120181120193120199120209120223120233120247120277120283120293120299120319120331120349120371120383120391120397120401120413120427120431120473120503120511120539120551120557120563120569120577120587120607120619120623120641120647120661120671120677120689120691120709120713120721120737120739120749120763120767120779120811120817120823120829120833120847120851120863120871120877120889120899120907120917120919120929120937120941120943120947120977120997121001121007121013121019121021121039121061121063121067121081121123121139121151121157121169121171121181121189121229121259121267121271121283121291121309121313121321121327121333121343121349121351121357121367121369121379121403121421121439121441121447121453121469121487121493121501121507121523121531121547121553121559121571121577121579121591121607121609121621121631121633121637121661121687121697121711121721121727121763121787121789121843121853121867121883121889121909121921121931121937121949121951121963121967121993121997122011122021122027122029122033122039122041122051122053122069122081122099122117122131122147122149122167122173122201122203122207122209122219122231122251122263122267122273122279122299122321122323122327122347122363122387122389122393122399122401122443122449122453122471122477122489122497122501122503122509122527122533122557122561122579122597122599122609122611122651122653122663122693122701122719122741122743122753122761122777122789122819122827122833122839122849122861122867122869122887122891122921122929122939122953122957122963122971123001123007123017123031123049123059123077123083123091123113123121123127123143123169123191123203123209123217123229123239123259123269123289123307123311123323123341123373123377123379123397123401123407123419123427123433123439123449123457123479123491123493123499123503123517123527123547123551123553123581123583123593123601123619123631123637123653123661123667123677123701123707123719123727123731123733123737123757123787123791123803123817123821123829123833123853123863123887123911123923123931123941123953123973123979123983123989123997124001124021124067124087124097124121124123124133124139124147124153124171124181124183124193124199124213124231124247124249124277124291124297124301124303124309124337124339124343124349124351124363124367124427124429124433124447124459124471124477124489124493124513124529124541124543124561124567124577124601124633124643124669124673124679124693124699124703124717124721124739124753124759124769124771124777124781124783124793124799124819124823124847124853124897124907124909124919124951124979124981124987124991125003125017125029125053125063125093125101125107125113125117125119125131125141125149125183125197125201125207125219125221125231125243125261125269125287125299125303125311125329125339125353125371125383125387125399125407125423125429125441125453125471125497125507125509125527125539125551125591125597125617125621125627125639125641125651125659125669125683125687125693125707125711125717125731125737125743125753125777125789125791125803125813125821125863125887125897125899125921125927125929125933125941125959125963126001126011126013126019126023126031126037126041126047126067126079126097126107126127126131126143126151126173126199126211126223126227126229126233126241126257126271126307126311126317126323126337126341126349126359126397126421126433126443126457126461126473126481126487126491126493126499126517126541126547126551126583126601126611126613126631126641126653126683126691126703126713126719126733126739126743126751126757126761126781126823126827126839126851126857126859126913126923126943126949126961126967126989127031127033127037127051127079127081127103127123127133127139127157127163127189127207127217127219127241127247127249127261127271127277127289127291127297127301127321127331127343127363127373127399127403127423127447127453127481127487127493127507127529127541127549127579127583127591127597127601127607127609127637127643127649127657127663127669127679127681127691127703127709127711127717127727127733127739127747127763127781127807127817127819127837127843127849127859127867127873127877127913127921127931127951127973127979127997128021128033128047128053128099128111128113128119128147128153128159128173128189128201128203128213128221128237128239128257128273128287128291128311128321128327128339128341128347128351128377128389128393128399128411128413128431128437128449128461128467128473128477128483128489128509128519128521128549128551128563128591128599128603128621128629128657128659128663128669128677128683128693128717128747128749128761128767128813128819128831128833128837128857128861128873128879128903128923128939128941128951128959128969128971128981128983128987128993129001129011129023129037129049129061129083129089129097129113129119129121129127129169129187129193129197129209129221129223129229129263129277129281129287129289129293129313129341129347129361129379129401129403129419129439129443129449129457129461129469129491129497129499129509129517129527129529129533129539129553129581129587129589129593129607129629129631129641129643129671129707129719129733129737129749129757129763129769129793129803129841129853129887129893129901129917129919129937129953129959129967129971130003130021130027130043130051130057130069130073130079130087130099130121130127130147130171130183130199130201130211130223130241130253130259130261130267130279130303130307130337130343130349130363130367130369130379130399130409130411130423130439130447130457130469130477130483130489130513130517130523130531130547130553130579130589130619130621130631130633130639130643130649130651130657130681130687130693130699130729130769130783130787130807130811130817130829130841130843130859130873130927130957130969130973130981130987131009131011131023131041131059131063131071131101131111131113131129131143131149131171131203131213131221131231131249131251131267131293131297131303131311131317131321131357131363131371131381131413131431131437131441131447131449131477131479131489131497131501131507131519131543131561131581131591131611131617131627131639131641131671131687131701131707131711131713131731131743131749131759131771131777131779131783131797131837131839131849131861131891131893131899131909131927131933131939131941131947131959131969132001132019132047132049132059132071132103132109132113132137132151132157132169132173132199132229132233132241132247132257132263132283132287132299132313132329132331132347132361132367132371132383132403132409132421132437132439132469132491132499132511132523132527132529132533132541132547132589132607132611132619132623132631132637132647132661132667132679132689132697132701132707132709132721132739132749132751132757132761132763132817132833132851132857132859132863132887132893132911132929132947132949132953132961132967132971132989133013133033133039133051133069133073133087133097133103133109133117133121133153133157133169133183133187133201133213133241133253133261133271133277133279133283133303133319133321133327133337133349133351133379133387133391133403133417133439133447133451133481133493133499133519133541133543133559133571133583133597133631133633133649133657133669133673133691133697133709133711133717133723133733133769133781133801133811133813133831133843133853133873133877133919133949133963133967133979133981133993133999134033134039134047134053134059134077134081134087134089134093134129134153134161134171134177134191134207134213134219134227134243134257134263134269134287134291134293134327134333134339134341134353134359134363134369134371134399134401134417134437134443134471134489134503134507134513134581134587134591134593134597134609134639134669134677134681134683134699134707134731134741134753134777134789134807134837134839134851134857134867134873134887134909134917134921134923134947134951134989134999135007135017135019135029135043135049135059135077135089135101135119135131135151135173135181135193135197135209135211135221135241135257135271135277135281135283135301135319135329135347135349135353135367135389135391135403135409135427135431135433135449135461135463135467135469135479135497135511135533135559135571135581135589135593135599135601135607135613135617135623135637135647135649135661135671135697135701135719135721135727135731135743135757135781135787135799135829135841135851135859135887135893135899135911135913135929135937135977135979136013136027136033136043136057136067136069136093136099136111136133136139136163136177136189136193136207136217136223136237136247136261136273136277136303136309136319136327136333136337136343136351136361136373136379136393136397136399136403136417136421136429136447136453136463136471136481136483136501136511136519136523136531136537136541136547136559136573136601136603136607136621136649136651136657136691136693136709136711136727136733136739136751136753136769136777136811136813136841136849136859136861136879136883136889136897136943136949136951136963136973136979136987136991136993136999137029137077137087137089137117137119137131137143137147137153137177137183137191137197137201137209137219137239137251137273137279137303137321137339137341137353137359137363137369137383137387137393137399137413137437137443137447137453137477137483137491137507137519137537137567137573137587137593137597137623137633137639137653137659137699137707137713137723137737137743137771137777137791137803137827137831137849137867137869137873137909137911137927137933137941137947137957137983137993137999138007138041138053138059138071138077138079138101138107138113138139138143138157138163138179138181138191138197138209138239138241138247138251138283138289138311138319138323138337138349138371138373138389138401138403138407138427138433138449138451138461138469138493138497138511138517138547138559138563138569138571138577138581138587138599138617138629138637138641138647138661138679138683138727138731138739138763138793138797138799138821138829138841138863138869138883138889138893138899138917138923138937138959138967138977139021139033139067139079139091139109139121139123139133139169139177139187139199139201139241139267139273139291139297139301139303139309139313139333139339139343139361139367139369139387139393139397139409139423139429139439139457139459139483139487139493139501139511139537139547139571139589139591139597139609139619139627139661139663139681139697139703139709139721139729139739139747139753139759139787139801139813139831139837139861139871139883139891139901139907139921139939139943139967139969139981139987139991139999140009140053140057140069140071140111140123140143140159140167140171140177140191140197140207140221140227140237140249140263140269140281140297140317140321140333140339140351140363140381140401140407140411140417140419140423140443140449140453140473140477140521140527140533140549140551140557140587140593140603140611140617140627140629140639140659140663140677140681140683140689140717140729140731140741140759140761140773140779140797140813140827140831140837140839140863140867140869140891140893140897140909140929140939140977140983140989141023141041141061141067141073141079141101141107141121141131141157141161141179141181141199141209141221141223141233141241141257141263141269141277141283141301141307141311141319141353141359141371141397141403141413141439141443141461141481141497141499141509141511141529141539141551141587141601141613141619141623141629141637141649141653141667141671141677141679141689141697141707141709141719141731141761141767141769141773141793141803141811141829141833141851141853141863141871141907141917141931141937141941141959141961141971141991142007142019142031142039142049142057142061142067142097142099142111142123142151142157142159142169142183142189142193142211142217142223142231142237142271142297142319142327142357142369142381142391142403142421142427142433142453142469142501142529142537142543142547142553142559142567142573142589142591142601142607142609142619142657142673142697142699142711142733142757142759142771142787142789142799142811142837142841142867142871142873142897142903142907142939142949142963142969142973142979142981142993143053143063143093143107143111143113143137143141143159143177143197143239143243143249143257143261143263143281143287143291143329143333143357143387143401143413143419143443143461143467143477143483143489143501143503143509143513143519143527143537143551143567143569143573143593143609143617143629143651143653143669143677143687143699143711143719143729143743143779143791143797143807143813143821143827143831143833143873143879143881143909143947143953143971143977143981143999144013144031144037144061144071144073144103144139144161144163144167144169144173144203144223144241144247144253144259144271144289144299144307144311144323144341144349144379144383144407144409144413144427144439144451144461144479144481144497144511144539144541144563144569144577144583144589144593144611144629144659144667144671144701144709144719144731144737144751144757144763144773144779144791144817144829144839144847144883144887144889144899144917144931144941144961144967144973144983145007145009145021145031145037145043145063145069145091145109145121145133145139145177145193145207145213145219145253145259145267145283145289145303145307145349145361145381145391145399145417145423145433145441145451145459145463145471145477145487145501145511145513145517145531145543145547145549145577145589145601145603145633145637145643145661145679145681145687145703145709145721145723145753145757145759145771145777145799145807145819145823145829145861145879145897145903145931145933145949145963145967145969145987145991146009146011146021146023146033146051146057146059146063146077146093146099146117146141146161146173146191146197146203146213146221146239146249146273146291146297146299146309146317146323146347146359146369146381146383146389146407146417146423146437146449146477146513146519146521146527146539146543146563146581146603146609146617146639146647146669146677146681146683146701146719146743146749146767146777146801146807146819146833146837146843146849146857146891146893146917146921146933146941146953146977146983146987146989147011147029147031147047147073147083147089147097147107147137147139147151147163147179147197147209147211147221147227147229147253147263147283147289147293147299147311147319147331147341147347147353147377147391147397147401147409147419147449147451147457147481147487147503147517147541147547147551147557147571147583147607147613147617147629147647147661147671147673147689147703147709147727147739147743147761147769147773147779147787147793147799147811147827147853147859147863147881147919147937147949147977147997148013148021148061148063148073148079148091148123148139148147148151148153148157148171148193148199148201148207148229148243148249148279148301148303148331148339148361148367148381148387148399148403148411148429148439148457148469148471148483148501148513148517148531148537148549148573148579148609148627148633148639148663148667148669148691148693148711148721148723148727148747148763148781148783148793148817148829148853148859148861148867148873148891148913148921148927148931148933148949148957148961148991148997149011149021149027149033149053149057149059149069149077149087149099149101149111149113149119149143149153149159149161149173149183149197149213149239149249149251149257149269149287149297149309149323149333149341149351149371149377149381149393149399149411149417149419149423149441149459149489149491149497149503149519149521149531149533149543149551149561149563149579149603149623149627149629149689149711149713149717149729149731149749149759149767149771149791149803149827149837149839149861149867149873149893149899149909149911149921149939149953149969149971149993150001150011150041150053150061150067150077150083150089150091150097150107150131150151150169150193150197150203150209150211150217150221150223150239150247150287150299150301150323150329150343150373150377150379150383150401150407150413150427150431150439150473150497150503150517150523150533150551150559150571150583150587150589150607150611150617150649150659150697150707150721150743150767150769150779150791150797150827150833150847150869150881150883150889150893150901150907150919150929150959150961150967150979150989150991151007151009151013151027151049151051151057151091151121151141151153151157151163151169151171151189151201151213151237151241151243151247151253151273151279151289151303151337151339151343151357151379151381151391151397151423151429151433151451151471151477151483151499151507151517151523151531151537151549151553151561151573151579151597151603151607151609151631151637151643151651151667151673151681151687151693151703151717151729151733151769151771151783151787151799151813151817151841151847151849151871151883151897151901151903151909151937151939151967151969152003152017152027152029152039152041152063152077152081152083152093152111152123152147152183152189152197152203152213152219152231152239152249152267152287152293152297152311152363152377152381152389152393152407152417152419152423152429152441152443152459152461152501152519152531152533152539152563152567152597152599152617152623152629152639152641152657152671152681152717152723152729152753152767152777152783152791152809152819152821152833152837152839152843152851152857152879152897152899152909152939152941152947152953152959152981152989152993153001153059153067153071153073153077153089153107153113153133153137153151153191153247153259153269153271153277153281153287153313153319153337153343153353153359153371153379153407153409153421153427153437153443153449153457153469153487153499153509153511153521153523153529153533153557153563153589153607153611153623153641153649153689153701153719153733153739153743153749153757153763153817153841153871153877153887153889153911153913153929153941153947153949153953153991153997154001154027154043154057154061154067154073154079154081154087154097154111154127154153154157154159154181154183154211154213154229154243154247154267154277154279154291154303154313154321154333154339154351154369154373154387154409154417154423154439154459154487154493154501154523154543154571154573154579154589154591154613154619154621154643154667154669154681154691154699154723154727154733154747154753154769154787154789154799154807154823154841154849154871154873154877154883154897154927154933154937154943154981154991155003155009155017155027155047155069155081155083155087155119155137155153155161155167155171155191155201155203155209155219155231155251155269155291155299155303155317155327155333155371155377155381155383155387155399155413155423155443155453155461155473155501155509155521155537155539155557155569155579155581155593155599155609155621155627155653155657155663155671155689155693155699155707155717155719155723155731155741155747155773155777155783155797155801155809155821155833155849155851155861155863155887155891155893155921156007156011156019156041156059156061156071156089156109156119156127156131156139156151156157156217156227156229156241156253156257156259156269156307156319156329156347156353156361156371156419156421156437156467156487156491156493156511156521156539156577156589156593156601156619156623156631156641156659156671156677156679156683156691156703156707156719156727156733156749156781156797156799156817156823156833156841156887156899156901156913156941156943156967156971156979157007157013157019157037157049157051157057157061157081157103157109157127157133157141157163157177157181157189157207157211157217157219157229157231157243157247157253157259157271157273157277157279157291157303157307157321157327157349157351157363157393157411157427157429157433157457157477157483157489157513157519157523157543157559157561157571157579157627157637157639157649157667157669157679157721157733157739157747157769157771157793157799157813157823157831157837157841157867157877157889157897157901157907157931157933157951157991157999158003158009158017158029158047158071158077158113158129158141158143158161158189158201158209158227158231158233158243158261158269158293158303158329158341158351158357158359158363158371158393158407158419158429158443158449158489158507158519158527158537158551158563158567158573158581158591158597158611158617158621158633158647158657158663158699158731158747158749158759158761158771158777158791158803158843158849158863158867158881158909158923158927158941158959158981158993159013159017159023159059159073159079159097159113159119159157159161159167159169159179159191159193159199159209159223159227159233159287159293159311159319159337159347159349159361159389159403159407159421159431159437159457159463159469159473159491159499159503159521159539159541159553159563159569159571159589159617159623159629159631159667159671159673159683159697159701159707159721159737159739159763159769159773159779159787159791159793159799159811159833159839159853159857159869159871159899159911159931159937159977159979160001160009160019160031160033160049160073160079160081160087160091160093160117160141160159160163160169160183160201160207160217160231160243160253160309160313160319160343160357160367160373160387160397160403160409160423160441160453160481160483160499160507160541160553160579160583160591160603160619160621160627160637160639160649160651160663160669160681160687160697160709160711160723160739160751160753160757160781160789160807160813160817160829160841160861160877160879160883160903160907160933160967160969160981160997161009161017161033161039161047161053161059161071161087161093161123161137161141161149161159161167161201161221161233161237161263161267161281161303161309161323161333161339161341161363161377161387161407161411161453161459161461161471161503161507161521161527161531161543161561161563161569161573161591161599161611161627161639161641161659161683161717161729161731161741161743161753161761161771161773161779161783161807161831161839161869161873161879161881161911161921161923161947161957161969161971161977161983161999162007162011162017162053162059162079162091162109162119162143162209162221162229162251162257162263162269162277162287162289162293162343162359162389162391162413162419162439162451162457162473162493162499162517162523162527162529162553162557162563162577162593162601162611162623162629162641162649162671162677162683162691162703162709162713162727162731162739162749162751162779162787162791162821162823162829162839162847162853162859162881162889162901162907162917162937162947162971162973162989162997163003163019163021163027163061163063163109163117163127163129163147163151163169163171163181163193163199163211163223163243163249163259163307163309163321163327163337163351163363163367163393163403163409163411163417163433163469163477163481163483163487163517163543163561163567163573163601163613163621163627163633163637163643163661163673163679163697163729163733163741163753163771163781163789163811163819163841163847163853163859163861163871163883163901163909163927163973163979163981163987163991163993163997164011164023164039164051164057164071164089164093164113164117164147164149164173164183164191164201164209164231164233164239164249164251164267164279164291164299164309164321164341164357164363164371164377164387164413164419164429164431164443164447164449164471164477164503164513164531164569164581164587164599164617164621164623164627164653164663164677164683164701164707164729164743164767164771164789164809164821164831164837164839164881164893164911164953164963164987164999165001165037165041165047165049165059165079165083165089165103165133165161165173165181165203165211165229165233165247165287165293165311165313165317165331165343165349165367165379165383165391165397165437165443165449165457165463165469165479165511165523165527165533165541165551165553165559165569165587165589165601165611165617165653165667165673165701165703165707165709165713165719165721165749165779165799165811165817165829165833165857165877165883165887165901165931165941165947165961165983166013166021166027166031166043166063166081166099166147166151166157166169166183166189166207166219166237166247166259166273166289166297166301166303166319166349166351166357166363166393166399166403166409166417166429166457166471166487166541166561166567166571166597166601166603166609166613166619166627166631166643166657166667166669166679166693166703166723166739166741166781166783166799166807166823166841166843166847166849166853166861166867166871166909166919166931166949166967166973166979166987167009167017167021167023167033167039167047167051167071167077167081167087167099167107167113167117167119167149167159167173167177167191167197167213167221167249167261167267167269167309167311167317167329167339167341167381167393167407167413167423167429167437167441167443167449167471167483167491167521167537167543167593167597167611167621167623167627167633167641167663167677167683167711167729167747167759167771167777167779167801167809167861167863167873167879167887167891167899167911167917167953167971167987168013168023168029168037168043168067168071168083168089168109168127168143168151168193168197168211168227168247168253168263168269168277168281168293168323168331168347168353168391168409168433168449168451168457168463168481168491168499168523168527168533168541168559168599168601168617168629168631168643168673168677168697168713168719168731168737168743168761168769168781168803168851168863168869168887168893168899168901168913168937168943168977168991169003169007169009169019169049169063169067169069169079169093169097169111169129169151169159169177169181169199169217169219169241169243169249169259169283169307169313169319169321169327169339169343169361169369169373169399169409169427169457169471169483169489169493169501169523169531169553169567169583169591169607169627169633169639169649169657169661169667169681169691169693169709169733169751169753169769169777169783169789169817169823169831169837169843169859169889169891169909169913169919169933169937169943169951169957169987169991170003170021170029170047170057170063170081170099170101170111170123170141170167170179170189170197170207170213170227170231170239170243170249170263170267170279170293170299170327170341170347170351170353170363170369170371170383170389170393170413170441170447170473170483170497170503170509170537170539170551170557170579170603170609170627170633170641170647170669170689170701170707170711170741170749170759170761170767170773170777170801170809170813170827170837170843170851170857170873170881170887170899170921170927170953170957170971171007171023171029171043171047171049171053171077171079171091171103171131171161171163171167171169171179171203171233171251171253171263171271171293171299171317171329171341171383171401171403171427171439171449171467171469171473171481171491171517171529171539171541171553171559171571171583171617171629171637171641171653171659171671171673171679171697171707171713171719171733171757171761171763171793171799171803171811171823171827171851171863171869171877171881171889171917171923171929171937171947172001172009172021172027172031172049172069172079172093172097172127172147172153172157172169172171172181172199172213172217172219172223172243172259172279172283172297172307172313172321172331172343172351172357172373172399172411172421172423172427172433172439172441172489172507172517172519172541172553172561172573172583172589172597172603172607172619172633172643172649172657172663172673172681172687172709172717172721172741172751172759172787172801172807172829172849172853172859172867172871172877172883172933172969172973172981172987172993172999173021173023173039173053173059173081173087173099173137173141173149173177173183173189173191173207173209173219173249173263173267173273173291173293173297173309173347173357173359173429173431173473173483173491173497173501173531173539173543173549173561173573173599173617173629173647173651173659173669173671173683173687173699173707173713173729173741173743173773173777173779173783173807173819173827173839173851173861173867173891173897173909173917173923173933173969173977173981173993174007174017174019174047174049174061174067174071174077174079174091174101174121174137174143174149174157174169174197174221174241174257174259174263174281174289174299174311174329174331174337174347174367174389174407174413174431174443174457174467174469174481174487174491174527174533174569174571174583174599174613174617174631174637174649174653174659174673174679174703174721174737174749174761174763174767174773174799174821174829174851174859174877174893174901174907174917174929174931174943174959174989174991175003175013175039175061175067175069175079175081175103175129175141175211175229175261175267175277175291175303175309175327175333175349175361175391175393175403175411175433175447175453175463175481175493175499175519175523175543175573175601175621175631175633175649175663175673175687175691175699175709175723175727175753175757175759175781175783175811175829175837175843175853175859175873175891175897175909175919175937175939175949175961175963175979175991175993176017176021176023176041176047176051176053176063176081176087176089176123176129176153176159176161176179176191176201176207176213176221176227176237176243176261176299176303176317176321176327176329176333176347176353176357176369176383176389176401176413176417176419176431176459176461176467176489176497176503176507176509176521176531176537176549176551176557176573176591176597176599176609176611176629176641176651176677176699176711176713176741176747176753176777176779176789176791176797176807176809176819176849176857176887176899176903176921176923176927176933176951176977176983176989177007177011177013177019177043177091177101177109177113177127177131177167177173177209177211177217177223177239177257177269177283177301177319177323177337177347177379177383177409177421177427177431177433177467177473177481177487177493177511177533177539177553177589177601177623177647177677177679177691177739177743177761177763177787177791177797177811177823177839177841177883177887177889177893177907177913177917177929177943177949177953177967177979178001178021178037178039178067178069178091178093178103178117178127178141178151178169178183178187178207178223178231178247178249178259178261178289178301178307178327178333178349178351178361178393178397178403178417178439178441178447178469178481178487178489178501178513178531178537178559178561178567178571178597178601178603178609178613178621178627178639178643178681178691178693178697178753178757178781178793178799178807178813178817178819178831178853178859178873178877178889178897178903178907178909178921178931178933178939178951178973178987179021179029179033179041179051179057179083179089179099179107179111179119179143179161179167179173179203179209179213179233179243179261179269179281179287179317179321179327179351179357179369179381179383179393179407179411179429179437179441179453179461179471179479179483179497179519179527179533179549179563179573179579179581179591179593179603179623179633179651179657179659179671179687179689179693179717179719179737179743179749179779179801179807179813179819179821179827179833179849179897179899179903179909179917179923179939179947179951179953179957179969179981179989179999180001180007180023180043180053180071180073180077180097180137180161180179180181180211180221180233180239180241180247180259180263180281180287180289180307180311180317180331180337180347180361180371180379180391180413180419180437180463180473180491180497180503180511180533180539180541180547180563180569180617180623180629180647180667180679180701180731180749180751180773180779180793180797180799180811180847180871180883180907180949180959181001181003181019181031181039181061181063181081181087181123181141181157181183181193181199181201181211181213181219181243181253181273181277181283181297181301181303181361181387181397181399181409181421181439181457181459181499181501181513181523181537181549181553181603181607181609181619181639181667181669181693181711181717181721181729181739181751181757181759181763181777181787181789181813181837181871181873181889181891181903181913181919181927181931181943181957181967181981181997182009182011182027182029182041182047182057182059182089182099182101182107182111182123182129182131182141182159182167182177182179182201182209182233182239182243182261182279182297182309182333182339182341182353182387182389182417182423182431182443182453182467182471182473182489182503182509182519182537182549182561182579182587182593182599182603182617182627182639182641182653182657182659182681182687182701182711182713182747182773182779182789182803182813182821182839182851182857182867182887182893182899182921182927182929182933182953182957182969182981182999183023183037183041183047183059183067183089183091183119183151183167183191183203183247183259183263183283183289183299183301183307183317183319183329183343183349183361183373183377183383183389183397183437183439183451183461183473183479183487183497183499183503183509183511183523183527183569183571183577183581183587183593183611183637183661183683183691183697183707183709183713183761183763183797183809183823183829183871183877183881183907183917183919183943183949183959183971183973183979184003184007184013184031184039184043184057184073184081184087184111184117184133184153184157184181184187184189184199184211184231184241184259184271184273184279184291184309184321184333184337184351184369184409184417184441184447184463184477184487184489184511184517184523184553184559184567184571184577184607184609184627184631184633184649184651184669184687184693184703184711184721184727184733184753184777184823184829184831184837184843184859184879184901184903184913184949184957184967184969184993184997184999185021185027185051185057185063185069185071185077185089185099185123185131185137185149185153185161185167185177185183185189185221185233185243185267185291185299185303185309185323185327185359185363185369185371185401185429185441185467185477185483185491185519185527185531185533185539185543185551185557185567185569185593185599185621185641185651185677185681185683185693185699185707185711185723185737185747185749185753185767185789185797185813185819185821185831185833185849185869185873185893185897185903185917185923185947185951185957185959185971185987185993186007186013186019186023186037186041186049186071186097186103186107186113186119186149186157186161186163186187186191186211186227186229186239186247186253186259186271186283186299186301186311186317186343186377186379186391186397186419186437186451186469186479186481186551186569186581186583186587186601186619186629186647186649186653186671186679186689186701186707186709186727186733186743186757186761186763186773186793186799186841186859186869186871186877186883186889186917186947186959187003187009187027187043187049187067187069187073187081187091187111187123187127187129187133187139187141187163187171187177187181187189187193187211187217187219187223187237187273187277187303187337187339187349187361187367187373187379187387187393187409187417187423187433187441187463187469187471187477187507187513187531187547187559187573187597187631187633187637187639187651187661187669187687187699187711187721187751187763187787187793187823187843187861187871187877187883187897187907187909187921187927187931187951187963187973187987188011188017188021188029188107188137188143188147188159188171188179188189188197188249188261188273188281188291188299188303188311188317188323188333188351188359188369188389188401188407188417188431188437188443188459188473188483188491188519188527188533188563188579188603188609188621188633188653188677188681188687188693188701188707188711188719188729188753188767188779188791188801188827188831188833188843188857188861188863188869188891188911188927188933188939188941188953188957188983188999189011189017189019189041189043189061189067189127189139189149189151189169189187189199189223189229189239189251189253189257189271189307189311189337189347189349189353189361189377189389189391189401189407189421189433189437189439189463189467189473189479189491189493189509189517189523189529189547189559189583189593189599189613189617189619189643189653189661189671189691189697189701189713189733189743189757189767189797189799189817189823189851189853189859189877189881189887189901189913189929189947189949189961189967189977189983189989189997190027190031190051190063190093190097190121190129190147190159190181190207190243190249190261190271190283190297190301190313190321190331190339190357190367190369190387190391190403190409190471190507190523190529190537190543190573190577190579190583190591190607190613190633190639190649190657190667190669190699190709190711190717190753190759190763190769190783190787190793190807190811190823190829190837190843190871190889190891190901190909190913190921190979190997191021191027191033191039191047191057191071191089191099191119191123191137191141191143191161191173191189191227191231191237191249191251191281191297191299191339191341191353191413191441191447191449191453191459191461191467191473191491191497191507191509191519191531191533191537191551191561191563191579191599191621191627191657191669191671191677191689191693191699191707191717191747191749191773191783191791191801191803191827191831191833191837191861191899191903191911191929191953191969191977191999192007192013192029192037192043192047192053192091192097192103192113192121192133192149192161192173192187192191192193192229192233192239192251192259192263192271192307192317192319192323192341192343192347192373192377192383192391192407192431192461192463192497192499192529192539192547192553192557192571192581192583192587192601192611192613192617192629192631192637192667192677192697192737192743192749192757192767192781192791192799192811192817192833192847192853192859192877192883192887192889192917192923192931192949192961192971192977192979192991193003193009193013193031193043193051193057193073193093193133193139193147193153193163193181193183193189193201193243193247193261193283193301193327193337193357193367193373193379193381193387193393193423193433193441193447193451193463193469193493193507193513193541193549193559193573193577193597193601193603193607193619193649193663193679193703193723193727193741193751193757193763193771193789193793193799193811193813193841193847193859193861193871193873193877193883193891193937193939193943193951193957193979193993194003194017194027194057194069194071194083194087194093194101194113194119194141194149194167194179194197194203194239194263194267194269194309194323194353194371194377194413194431194443194471194479194483194507194521194527194543194569194581194591194609194647194653194659194671194681194683194687194707194713194717194723194729194749194767194771194809194813194819194827194839194861194863194867194869194891194899194911194917194933194963194977194981194989195023195029195043195047195049195053195071195077195089195103195121195127195131195137195157195161195163195193195197195203195229195241195253195259195271195277195281195311195319195329195341195343195353195359195389195401195407195413195427195443195457195469195479195493195497195511195527195539195541195581195593195599195659195677195691195697195709195731195733195737195739195743195751195761195781195787195791195809195817195863195869195883195887195893195907195913195919195929195931195967195971195973195977195991195997196003196033196039196043196051196073196081196087196111196117196139196159196169196171196177196181196187196193196201196247196271196277196279196291196303196307196331196337196379196387196429196439196453196459196477196499196501196519196523196541196543196549196561196579196583196597196613196643196657196661196663196681196687196699196709196717196727196739196751196769196771196799196817196831196837196853196871196873196879196901196907196919196927196961196991196993197003197009197023197033197059197063197077197083197089197101197117197123197137197147197159197161197203197207197221197233197243197257197261197269197273197279197293197297197299197311197339197341197347197359197369197371197381197383197389197419197423197441197453197479197507197521197539197551197567197569197573197597197599197609197621197641197647197651197677197683197689197699197711197713197741197753197759197767197773197779197803197807197831197837197887197891197893197909197921197927197933197947197957197959197963197969197971198013198017198031198043198047198073198083198091198097198109198127198139198173198179198193198197198221198223198241198251198257198259198277198281198301198313198323198337198347198349198377198391198397198409198413198427198437198439198461198463198469198479198491198503198529198533198553198571198589198593198599198613198623198637198641198647198659198673198689198701198719198733198761198769198811198817198823198827198829198833198839198841198851198859198899198901198929198937198941198943198953198959198967198971198977198997199021199033199037199039199049199081199103199109199151199153199181199193199207199211199247199261199267199289199313199321199337199343199357199373199379199399199403199411199417199429199447199453199457199483199487199489199499199501199523199559199567199583199601199603199621199637199657199669199673199679199687199697199721199729199739199741199751199753199777199783199799199807199811199813199819199831199853199873199877199889199909199921199931199933199961199967199999200003200009200017200023200029200033200041200063200087200117200131200153200159200171200177200183200191200201200227200231200237200257200273200293200297200323200329200341200351200357200363200371200381200383200401200407200437200443200461200467200483200513200569200573200579200587200591200597200609200639200657200671200689200699200713200723200731200771200779200789200797200807200843200861200867200869200881200891200899200903200909200927200929200971200983200987200989201007201011201031201037201049201073201101201107201119201121201139201151201163201167201193201203201209201211201233201247201251201281201287201307201329201337201359201389201401201403201413201437201449201451201473201491201493201497201499201511201517201547201557201577201581201589201599201611201623201629201653201661201667201673201683201701201709201731201743201757201767201769201781201787201791201797201809201821201823201827201829201833201847201881201889201893201907201911201919201923201937201947201953201961201973201979201997202001202021202031202049202061202063202067202087202099202109202121202127202129202183202187202201202219202231202243202277202289202291202309202327202339202343202357202361202381202387202393202403202409202441202471202481202493202519202529202549202567202577202591202613202621202627202637202639202661202667202679202693202717202729202733202747202751202753202757202777202799202817202823202841202859202877202879202889202907202921202931202933202949202967202973202981202987202999203011203017203023203039203051203057203117203141203173203183203207203209203213203221203227203233203249203279203293203309203311203317203321203323203339203341203351203353203363203381203383203387203393203417203419203429203431203449203459203461203531203549203563203569203579203591203617203627203641203653203657203659203663203669203713203761203767203771203773203789203807203809203821203843203857203869203873203897203909203911203921203947203953203969203971203977203989203999204007204013204019204023204047204059204067204101204107204133204137204143204151204161204163204173204233204251204299204301204311204319204329204331204353204359204361204367204371204377204397204427204431204437204439204443204461204481204487204509204511204517204521204557204563204583204587204599204601204613204623204641204667204679204707204719204733204749204751204781204791204793204797204803204821204857204859204871204887204913204917204923204931204947204973204979204983205019205031205033205043205063205069205081205097205103205111205129205133205141205151205157205171205187205201205211205213205223205237205253205267205297205307205319205327205339205357205391205397205399205417205421205423205427205433205441205453205463205477205483205487205493205507205519205529205537205549205553205559205589205603205607205619205627205633205651205657205661205663205703205721205759205763205783205817205823205837205847205879205883205913205937205949205951205957205963205967205981205991205993206009206021206027206033206039206047206051206069206077206081206083206123206153206177206179206183206191206197206203206209206221206233206237206249206251206263206273206279206281206291206299206303206341206347206351206369206383206399206407206411206413206419206447206461206467206477206483206489206501206519206527206543206551206593206597206603206623206627206639206641206651206699206749206779206783206803206807206813206819206821206827206879206887206897206909206911206917206923206933206939206951206953206993207013207017207029207037207041207061207073207079207113207121207127207139207169207187207191207197207199207227207239207241207257207269207287207293207301207307207329207331207341207343207367207371207377207401207409207433207443207457207463207469207479207481207491207497207509207511207517207521207523207541207547207551207563207569207589207593207619207629207643207653207661207671207673207679207709207719207721207743207763207769207797207799207811207821207833207847207869207877207923207931207941207947207953207967207971207973207997208001208003208009208037208049208057208067208073208099208111208121208129208139208141208147208189208207208213208217208223208231208253208261208277208279208283208291208309208319208333208337208367208379208387208391208393208409208433208441208457208459208463208469208489208493208499208501208511208513208519208529208553208577208589208591208609208627208631208657208667208673208687208697208699208721208729208739208759208787208799208807208837208843208877208889208891208907208927208931208933208961208963208991208993208997209021209029209039209063209071209089209123209147209159209173209179209189209201209203209213209221209227209233209249209257209263209267209269209299209311209317209327209333209347209353209357209359209371209381209393209401209431209441209449209459209471209477209497209519209533209543209549209563209567209569209579209581209597209621209623209639209647209659209669209687209701209707209717209719209743209767209771209789209801209809209813209819209821209837209851209857209861209887209917209927209929209939209953209959209971209977209983209987210011210019210031210037210053210071210097210101210109210113210127210131210139210143210157210169210173210187210191210193210209210229210233210241210247210257210263210277210283210299210317210319210323210347210359210361210391210401210403210407210421210437210461210467210481210487210491210499210523210527210533210557210599210601210619210631210643210659210671210709210713210719210731210739210761210773210803210809210811210823210827210839210853210857210869210901210907210911210913210923210929210943210961210967211007211039211049211051211061211063211067211073211093211097211129211151211153211177211187211193211199211213211217211219211229211231211241211247211271211283211291211297211313211319211333211339211349211369211373211403211427211433211441211457211469211493211499211501211507211543211559211571211573211583211597211619211639211643211657211661211663211681211691211693211711211723211727211741211747211777211781211789211801211811211817211859211867211873211877211879211889211891211927211931211933211943211949211969211979211997212029212039212057212081212099212117212123212131212141212161212167212183212203212207212209212227212239212243212281212293212297212353212369212383212411212419212423212437212447212453212461212467212479212501212507212557212561212573212579212587212593212627212633212651212669212671212677212683212701212777212791212801212827212837212843212851212867212869212873212881212897212903212909212917212923212969212981212987212999213019213023213029213043213067213079213091213097213119213131213133213139213149213173213181213193213203213209213217213223213229213247213253213263213281213287213289213307213319213329213337213349213359213361213383213391213397213407213449213461213467213481213491213523213533213539213553213557213589213599213611213613213623213637213641213649213659213713213721213727213737213751213791213799213821213827213833213847213859213881213887213901213919213929213943213947213949213953213973213977213989214003214007214009214021214031214033214043214051214063214069214087214091214129214133214141214147214163214177214189214211214213214219214237214243214259214283214297214309214351214363214373214381214391214399214433214439214451214457214463214469214481214483214499214507214517214519214531214541214559214561214589214603214607214631214639214651214657214663214667214673214691214723214729214733214741214759214763214771214783214787214789214807214811214817214831214849214853214867214883214891214913214939214943214967214987214993215051215063215077215087215123215141215143215153215161215179215183215191215197215239215249215261215273215279215297215309215317215329215351215353215359215381215389215393215399215417215443215447215459215461215471215483215497215503215507215521215531215563215573215587215617215653215659215681215687215689215693215723215737215753215767215771215797215801215827215833215843215851215857215863215893215899215909215921215927215939215953215959215981215983216023216037216061216071216091216103216107216113216119216127216133216149216157216173216179216211216217216233216259216263216289216317216319216329216347216371216373216379216397216401216421216431216451216481216493216509216523216551216553216569216571216577216607216617216641216647216649216653216661216679216703216719216731216743216751216757216761216779216781216787216791216803216829216841216851216859216877216899216901216911216917216919216947216967216973216991217001217003217027217033217057217069217081217111217117217121217157217163217169217199217201217207217219217223217229217241217253217271217307217309217313217319217333217337217339217351217361217363217367217369217387217397217409217411217421217429217439217457217463217489217499217517217519217559217561217573217577217579217619217643217661217667217681217687217691217697217717217727217733217739217747217771217781217793217823217829217849217859217901217907217909217933217937217969217979217981218003218021218047218069218077218081218083218087218107218111218117218131218137218143218149218171218191218213218227218233218249218279218287218357218363218371218381218389218401218417218419218423218437218447218453218459218461218479218509218513218521218527218531218549218551218579218591218599218611218623218627218629218641218651218657218677218681218711218717218719218723218737218749218761218783218797218809218819218833218839218843218849218857218873218887218923218941218947218963218969218971218987218989218993219001219017219019219031219041219053219059219071219083219091219097219103219119219133219143219169219187219217219223219251219277219281219293219301219311219313219353219361219371219377219389219407219409219433219437219451219463219467219491219503219517219523219529219533219547219577219587219599219607219613219619219629219647219649219677219679219683219689219707219721219727219731219749219757219761219763219767219787219797219799219809219823219829219839219847219851219871219881219889219911219917219931219937219941219943219953219959219971219977219979219983220009220013220019220021220057220063220123220141220147220151220163220169220177220189220217220243220279220291220301220307220327220333220351220357220361220369220373220391220399220403220411220421220447220469220471220511220513220529220537220543220553220559220573220579220589220613220663220667220673220681220687220699220709220721220747220757220771220783220789220793220807220811220841220859220861220873220877220879220889220897220901220903220907220919220931220933220939220973221021221047221059221069221071221077221083221087221093221101221159221171221173221197221201221203221209221219221227221233221239221251221261221281221303221311221317221327221393221399221401221411221413221447221453221461221471221477221489221497221509221537221539221549221567221581221587221603221621221623221653221657221659221671221677221707221713221717221719221723221729221737221747221773221797221807221813221827221831221849221873221891221909221941221951221953221957221987221989221999222007222011222023222029222041222043222059222067222073222107222109222113222127222137222149222151222161222163222193222197222199222247222269222289222293222311222317222323222329222337222347222349222361222367222379222389222403222419222437222461222493222499222511222527222533222553222557222587222601222613222619222643222647222659222679222707222713222731222773222779222787222791222793222799222823222839222841222857222863222877222883222913222919222931222941222947222953222967222977222979222991223007223009223019223037223049223051223061223063223087223099223103223129223133223151223207223211223217223219223229223241223243223247223253223259223273223277223283223291223303223313223319223331223337223339223361223367223381223403223423223429223439223441223463223469223481223493223507223529223543223547223549223577223589223621223633223637223667223679223681223697223711223747223753223757223759223781223823223829223831223837223841223843223849223903223919223921223939223963223969223999224011224027224033224041224047224057224069224071224101224113224129224131224149224153224171224177224197224201224209224221224233224239224251224261224267224291224299224303224309224317224327224351224359224363224401224423224429224443224449224461224467224473224491224501224513224527224563224569224579224591224603224611224617224629224633224669224677224683224699224711224717224729224737224743224759224771224797224813224831224863224869224881224891224897224909224911224921224929224947224951224969224977224993225023225037225061225067225077225079225089225109225119225133225143225149225157225161225163225167225217225221225223225227225241225257225263225287225289225299225307225341225343225347225349225353225371225373225383225427225431225457225461225479225493225499225503225509225523225527225529225569225581225583225601225611225613225619225629225637225671225683225689225697225721225733225749225751225767225769225779225781225809225821225829225839225859225871225889225919225931225941225943225949225961225977225983225989226001226007226013226027226063226087226099226103226123226129226133226141226169226183226189226199226201226217226231226241226267226283226307226313226337226357226367226379226381226397226409226427226433226451226453226463226483226487226511226531226547226549226553226571226601226609226621226631226637226643226649226657226663226669226691226697226741226753226769226777226783226789226799226813226817226819226823226843226871226901226903226907226913226937226943226991227011227027227053227081227089227093227111227113227131227147227153227159227167227177227189227191227207227219227231227233227251227257227267227281227299227303227363227371227377227387227393227399227407227419227431227453227459227467227471227473227489227497227501227519227531227533227537227561227567227569227581227593227597227603227609227611227627227629227651227653227663227671227693227699227707227719227729227743227789227797227827227849227869227873227893227947227951227977227989227993228013228023228049228061228077228097228103228113228127228131228139228181228197228199228203228211228223228233228251228257228281228299228301228307228311228331228337228341228353228359228383228409228419228421228427228443228451228457228461228469228479228509228511228517228521228523228539228559228577228581228587228593228601228611228617228619228637228647228677228707228713228731228733228737228751228757228773228793228797228799228829228841228847228853228859228869228881228883228887228901228911228913228923228929228953228959228961228983228989229003229027229037229081229093229123229127229133229139229153229157229171229181229189229199229213229217229223229237229247229249229253229261229267229283229309229321229343229351229373229393229399229403229409229423229433229459229469229487229499229507229519229529229547229549229553229561229583229589229591229601229613229627229631229637229639229681229693229699229703229711229717229727229739229751229753229759229763229769229771229777229781229799229813229819229837229841229847229849229897229903229937229939229949229961229963229979229981230003230017230047230059230063230077230081230089230101230107230117230123230137230143230149230189230203230213230221230227230233230239230257230273230281230291230303230309230311230327230339230341230353230357230369230383230387230389230393230431230449230453230467230471230479230501230507230539230551230561230563230567230597230611230647230653230663230683230693230719230729230743230761230767230771230773230779230807230819230827230833230849230861230863230873230891230929230933230939230941230959230969230977230999231001231017231019231031231041231053231067231079231107231109231131231169231197231223231241231269231271231277231289231293231299231317231323231331231347231349231359231367231379231409231419231431231433231443231461231463231479231481231493231503231529231533231547231551231559231563231571231589231599231607231611231613231631231643231661231677231701231709231719231779231799231809231821231823231827231839231841231859231871231877231893231901231919231923231943231947231961231967232003232007232013232049232051232073232079232081232091232103232109232117232129232153232171232187232189232207232217232259232303232307232333232357232363232367232381232391232409232411232417232433232439232451232457232459232487232499232513232523232549232567232571232591232597232607232621232633232643232663232669232681232699232709232711232741232751232753232777232801232811232819232823232847232853232861232871232877232891232901232907232919232937232961232963232987233021233069233071233083233113233117233141233143233159233161233173233183233201233221233231233239233251233267233279233293233297233323233327233329233341233347233353233357233371233407233417233419233423233437233477233489233509233549233551233557233591233599233609233617233621233641233663233669233683233687233689233693233713233743233747233759233777233837233851233861233879233881233911233917233921233923233939233941233969233983233993234007234029234043234067234083234089234103234121234131234139234149234161234167234181234187234191234193234197234203234211234217234239234259234271234281234287234293234317234319234323234331234341234343234361234383234431234457234461234463234467234473234499234511234527234529234539234541234547234571234587234589234599234613234629234653234659234673234683234713234721234727234733234743234749234769234781234791234799234803234809234811234833234847234851234863234869234893234907234917234931234947234959234961234967234977234979234989235003235007235009235013235043235051235057235069235091235099235111235117235159235171235177235181235199235211235231235241235243235273235289235307235309235337235349235369235397235439235441235447235483235489235493235513235519235523235537235541235553235559235577235591235601235607235621235661235663235673235679235699235723235747235751235783235787235789235793235811235813235849235871235877235889235891235901235919235927235951235967235979235997236017236021236053236063236069236077236087236107236111236129236143236153236167236207236209236219236231236261236287236293236297236323236329236333236339236377236381236387236399236407236429236449236461236471236477236479236503236507236519236527236549236563236573236609236627236641236653236659236681236699236701236707236713236723236729236737236749236771236773236779236783236807236813236867236869236879236881236891236893236897236909236917236947236981236983236993237011237019237043237053237067237071237073237089237091237137237143237151237157237161237163237173237179237203237217237233237257237271237277237283237287237301237313237319237331237343237361237373237379237401237409237467237487237509237547237563237571237581237607237619237631237673237683237689237691237701237707237733237737237749237763237767237781237791237821237851237857237859237877237883237901237911237929237959237967237971237973237977237997238001238009238019238031238037238039238079238081238093238099238103238109238141238151238157238159238163238171238181238201238207238213238223238229238237238247238261238267238291238307238313238321238331238339238361238363238369238373238397238417238423238439238451238463238471238477238481238499238519238529238531238547238573238591238627238639238649238657238673238681238691238703238709238723238727238729238747238759238781238789238801238829238837238841238853238859238877238879238883238897238919238921238939238943238949238967238991239017239023239027239053239069239081239087239119239137239147239167239171239179239201239231239233239237239243239251239263239273239287239297239329239333239347239357239383239387239389239417239423239429239431239441239461239489239509239521239527239531239539239543239557239567239579239587239597239611239623239633239641239671239689239699239711239713239731239737239753239779239783239803239807239831239843239849239851239857239873239879239893239929239933239947239957239963239977239999240007240011240017240041240043240047240049240059240073240089240101240109240113240131240139240151240169240173240197240203240209240257240259240263240271240283240287240319240341240347240349240353240371240379240421240433240437240473240479240491240503240509240517240551240571240587240589240599240607240623240631240641240659240677240701240707240719240727240733240739240743240763240769240797240811240829240841240853240859240869240881240883240893240899240913240943240953240959240967240997241013241027241037241049241051241061241067241069241079241093241117241127241141241169241177241183241207241229241249241253241259241261241271241291241303241313241321241327241333241337241343241361241363241391241393241421241429241441241453241463241469241489241511241513241517241537241543241559241561241567241589241597241601241603241639241643241651241663241667241679241687241691241711241727241739241771241781241783241793241807241811241817241823241847241861241867241873241877241883241903241907241919241921241931241939241951241963241973241979241981241993242009242057242059242069242083242093242101242119242129242147242161242171242173242197242201242227242243242257242261242273242279242309242329242357242371242377242393242399242413242419242441242447242449242453242467242479242483242491242509242519242521242533242551242591242603242617242621242629242633242639242647242659242677242681242689242713242729242731242747242773242779242789242797242807242813242819242863242867242873242887242911242923242927242971242989242999243011243031243073243077243091243101243109243119243121243137243149243157243161243167243197243203243209243227243233243239243259243263243301243311243343243367243391243401243403243421243431243433243437243461243469243473243479243487243517243521243527243533243539243553243577243583243587243589243613243623243631243643243647243671243673243701243703243707243709243769243781243787243799243809243829243839243851243857243863243871243889243911243917243931243953243973243989244003244009244021244033244043244087244091244109244121244129244141244147244157244159244177244199244217244219244243244247244253244261244291244297244301244303244313244333244339244351244357244367244379244381244393244399244403244411244423244429244451244457244463244471244481244493244507244529244547244553244561244567244583244589244597244603244619244633244637244639244667244669244687244691244703244711244721244733244747244753244759244781244787244813244837244841244843244859244861244873244877244889244897244901244939244943244957244997245023245029245033245039245071245083245087245107245129245131245149245171245173245177245183245209245251245257245261245269245279245291245299245317245321245339245383245389245407245411245417245419245437245471245473245477245501245513245519245521245527245533245561245563245587245591245593245621245627245629245639245653245671245681245683245711245719245723245741245747245753245759245771245783245789245821245849245851245863245881245897245899245909245911245941245963245977245981245983245989246011246017246049246073246097246119246121246131246133246151246167246173246187246193246203246209246217246223246241246247246251246271246277246289246317246319246329246343246349246361246371246391246403246439246469246473246497246509246511246523246527246539246557246569246577246599246607246611246613246637246641246643246661246683246689246707246709246713246731246739246769246773246781246787246793246803246809246811246817246833246839246889246899246907246913246919246923246929246931246937246941246947246971246979247001247007247031247067247069247073247087247099247141247183247193247201247223247229247241247249247259247279247301247309247337247339247343247363247369247381247391247393247409247421247433247439247451247463247501247519247529247531247547247553247579247591247601247603247607247609247613247633247649247651247691247693247697247711247717247729247739247759247769247771247781247799247811247813247829247847247853247873247879247889247901247913247939247943247957247991247993247997247999248021248033248041248051248057248063248071248077248089248099248117248119248137248141248161248167248177248179248189248201248203248231248243248257248267248291248293248299248309248317248323248351248357248371248389248401248407248431248441248447248461248473248477248483248509248533248537248543248569248579248587248593248597248609248621248627248639248641248657248683248701248707248719248723248737248749248753248779248783248789248797248813248821248827248839248851248861248867248869248879248887248891248893248903248909248971248981248987249017249037249059249079249089249097249103249107249127249131249133249143249181249187249199249211249217249229249233249253249257249287249311249317249329249341249367249377249383249397249419249421249427249433249437249439249449249463249497249499249503249517249521249533249539249541249563249583249589249593249607249647249659249671249677249703249721249727249737249749249763249779249797249811249827249833249853249857249859249863249871249881249911249923249943249947249967249971249973249989250007250013250027250031250037250043250049250051250057250073250091250109250123250147250153250169250199250253250259250267250279250301250307250343250361250403250409250423250433250441250451250489250499250501250543250583250619250643250673250681250687250693250703250709250721250727250739250741250751250753250777250787250793250799250807250813250829250837250841250853250867250871250889250919250949250951250963250967250969250979250993251003251033251051251057251059251063251071251081251087251099251117251143251149251159251171251177251179251191251197251201251203251219251221251231251233251257251261251263251287251291251297251323251347251353251359251387251393251417251429251431251437251443251467251473251477251483251491251501251513251519251527251533251539251543251561251567251609251611251621251623251639251653251663251677251701251707251737251761251789251791251809251831251833251843251857251861251879251887251893251897251903251917251939251941251947251969251971251983252001252013252017252029252037252079252101252139252143252151252157252163252169252173252181252193252209252223252233252253252277252283252289252293252313252319252323252341252359252383252391252401252409252419252431252443252449252457252463252481252509252533252541252559252583252589252607252611252617252641252667252691252709252713252727252731252737252761252767252779252817252823252827252829252869252877252881252887252893252899252911252913252919252937252949252971252979252983253003253013253049253063253081253103253109253133253153253157253159253229253243253247253273253307253321253343253349253361253367253369253381253387253417253423253427253433253439253447253469253481253493253501253507253531253537253543253553253567253573253601253607253609253613253633253637253639253651253661253679253681253703253717253733253741253751253763253769253777253787253789253801253811253819253823253853253867253871253879253901253907253909253919253937253949253951253969253987253993253999254003254021254027254039254041254047254053254071254083254119254141254147254161254179254197254207254209254213254249254257254279254281254291254299254329254369254377254383254389254407254413254437254447254461254489254491254519254537254557254593254623254627254647254659254663254699254713254729254731254741254747254753254773254777254783254791254803254827254831254833254857254869254873254879254887254899254911254927254929254941254959254963254971254977254987254993255007255019255023255043255049255053255071255077255083255097255107255121255127255133255137255149255173255179255181255191255193255197255209255217255239255247255251255253255259255313255329255349255361255371255383255413255419255443255457255467255469255473255487255499255503255511255517255523255551255571255587255589255613255617255637255641255649255653255659255667255679255709255713255733255743255757255763255767255803255839255841255847255851255859255869255877255887255907255917255919255923255947255961255971255973255977255989256019256021256031256033256049256057256079256093256117256121256129256133256147256163256169256181256187256189256199256211256219256279256301256307256313256337256349256363256369256391256393256423256441256469256471256483256489256493256499256517256541256561256567256577256579256589256603256609256639256643256651256661256687256699256721256723256757256771256799256801256813256831256873256877256889256901256903256931256939256957256967256981257003257017257053257069257077257093257099257107257123257141257161257171257177257189257219257221257239257249257263257273257281257287257293257297257311257321257339257351257353257371257381257399257401257407257437257443257447257459257473257489257497257501257503257519257539257561257591257611257627257639257657257671257687257689257707257711257713257717257731257783257791257797257837257857257861257863257867257869257879257893257903257921257947257953257981257987257989257993258019258023258031258061258067258101258107258109258113258119258127258131258143258157258161258173258197258211258233258241258253258277258283258299258317258319258329258331258337258353258373258389258403258407258413258421258437258443258449258469258487258491258499258521258527258539258551258563258569258581258607258611258613258617258623258631258637258659258673258677258691258697258703258707258721258733258737258743258763258779258787258803258809258827258847258871258887258917258919258949258959258967258971258977258983258991259001259009259019259033259099259121259123259151259157259159259163259169259177259183259201259211259213259219259229259271259277259309259321259339259379259381259387259397259411259421259429259451259453259459259499259507259517259531259537259547259577259583259603259619259621259627259631259639259643259657259667259681259691259697259717259723259733259751259771259781259783259801259813259823259829259837259841259867259907259933259937259943259949259967259991259993260003260009260011260017260023260047260081260089260111260137260171260179260189260191260201260207260209260213260231260263260269260317260329260339260363260387260399260411260413260417260419260441260453260461260467260483260489260527260539260543260549260551260569260573260581260587260609260629260647260651260671260677260713260717260723260747260753260761260773260791260807260809260849260857260861260863260873260879260893260921260941260951260959260969260983260987260999261011261013261017261031261043261059261061261071261077261089261101261127261167261169261223261229261241261251261271261281261301261323261329261337261347261353261379261389261407261427261431261433261439261451261463261467261509261523261529261557261563261577261581261587261593261601261619261631261637261641261643261673261697261707261713261721261739261757261761261773261787261791261799261823261847261881261887261917261959261971261973261977261983262007262027262049262051262069262079262103262109262111262121262127262133262139262147262151262153262187262193262217262231262237262253262261262271262303262313262321262331262337262349262351262369262387262391262399262411262433262459262469262489262501262511262513262519262541262543262553262567262583262597262621262627262643262649262651262657262681262693262697262709262723262733262739262741262747262781262783262807262819262853262877262883262897262901262909262937262949262957262981263009263023263047263063263071263077263083263089263101263111263119263129263167263171263183263191263201263209263213263227263239263257263267263269263273263287263293263303263323263369263383263387263399263401263411263423263429263437263443263489263491263503263513263519263521263533263537263561263567263573263591263597263609263611263621263647263651263657263677263723263729263737263759263761263803263819263821263827263843263849263863263867263869263881263899263909263911263927263933263941263951263953263957263983264007264013264029264031264053264059264071264083264091264101264113264127264133264137264139264167264169264179264211264221264263264269264283264289264301264323264331264343264349264353264359264371264391264403264437264443264463264487264527264529264553264559264577264581264599264601264619264631264637264643264659264697264731264739264743264749264757264763264769264779264787264791264793264811264827264829264839264871264881264889264893264899264919264931264949264959264961264977264991264997265003265007265021265037265079265091265093265117265123265129265141265151265157265163265169265193265207265231265241265247265249265261265271265273265277265313265333265337265339265381265399265403265417265423265427265451265459265471265483265493265511265513265541265543265547265561265567265571265579265607265613265619265621265703265709265711265717265729265739265747265757265781265787265807265813265819265831265841265847265861265871265873265883265891265921265957265961265987266003266009266023266027266029266047266051266053266059266081266083266089266093266099266111266117266129266137266153266159266177266183266221266239266261266269266281266291266293266297266333266351266353266359266369266381266401266411266417266447266449266477266479266489266491266521266549266587266599266603266633266641266647266663266671266677266681266683266687266689266701266711266719266759266767266797266801266821266837266839266863266867266891266897266899266909266921266927266933266947266953266957266971266977266983266993266999267017267037267049267097267131267133267139267143267167267187267193267199267203267217267227267229267233267259267271267277267299267301267307267317267341267353267373267389267391267401267403267413267419267431267433267439267451267469267479267481267493267497267511267517267521267523267541267551267557267569267581267587267593267601267611267613267629267637267643267647267649267661267667267671267677267679267713267719267721267727267737267739267749267763267781267791267797267803267811267829267833267857267863267877267887267893267899267901267907267913267929267941267959267961268003268013268043268049268063268069268091268123268133268153268171268189268199268207268211268237268253268267268271268283268291268297268343268403268439268459268487268493268501268507268517268519268529268531268537268547268573268607268613268637268643268661268693268721268729268733268747268757268759268771268777268781268783268789268811268813268817268819268823268841268843268861268883268897268909268913268921268927268937268969268973268979268993268997268999269023269029269039269041269057269063269069269089269117269131269141269167269177269179269183269189269201269209269219269221269231269237269251269257269281269317269327269333269341269351269377269383269387269389269393269413269419269429269431269441269461269473269513269519269527269539269543269561269573269579269597269617269623269641269651269663269683269701269713269719269723269741269749269761269779269783269791269851269879269887269891269897269923269939269947269953269981269987270001270029270031270037270059270071270073270097270121270131270133270143270157270163270167270191270209270217270223270229270239270241270269270271270287270299270307270311270323270329270337270343270371270379270407270421270437270443270451270461270463270493270509270527270539270547270551270553270563270577270583270587270593270601270619270631270653270659270667270679270689270701270709270719270737270749270761270763270791270797270799270821270833270841270859270899270913270923270931270937270953270961270967270973271003271013271021271027271043271057271067271079271097271109271127271129271163271169271177271181271211271217271231271241271253271261271273271277271279271289271333271351271357271363271367271393271409271429271451271463271471271483271489271499271501271517271549271553271571271573271597271603271619271637271639271651271657271693271703271723271729271753271769271771271787271807271811271829271841271849271853271861271867271879271897271903271919271927271939271967271969271981272003272009272011272029272039272053272059272093272131272141272171272179272183272189272191272201272203272227272231272249272257272263272267272269272287272299272317272329272333272341272347272351272353272359272369272381272383272399272407272411272417272423272449272453272477272507272533272537272539272549272563272567272581272603272621272651272659272683272693272717272719272737272759272761272771272777272807272809272813272863272879272887272903272911272917272927272933272959272971272981272983272989272999273001273029273043273047273059273061273067273073273083273107273113273127273131273149273157273181273187273193273233273253273269273271273281273283273289273311273313273323273349273359273367273433273457273473273503273517273521273527273551273569273601273613273617273629273641273643273653273697273709273719273727273739273773273787273797273803273821273827273857273881273899273901273913273919273929273941273943273967273971273979273997274007274019274033274061274069274081274093274103274117274121274123274139274147274163274171274177274187274199274201274213274223274237274243274259274271274277274283274301274333274349274357274361274403274423274441274451274453274457274471274489274517274529274579274583274591274609274627274661274667274679274693274697274709274711274723274739274751274777274783274787274811274817274829274831274837274843274847274853274861274867274871274889274909274931274943274951274957274961274973274993275003275027275039275047275053275059275083275087275129275131275147275153275159275161275167275183275201275207275227275251275263275269275299275309275321275323275339275357275371275389275393275399275419275423275447275449275453275459275461275489275491275503275521275531275543275549275573275579275581275591275593275599275623275641275651275657275669275677275699275711275719275729275741275767275773275783275813275827275837275881275897275911275917275921275923275929275939275941275963275969275981275987275999276007276011276019276037276041276043276047276049276079276083276091276113276137276151276173276181276187276191276209276229276239276247276251276257276277276293276319276323276337276343276347276359276371276373276389276401276439276443276449276461276467276487276499276503276517276527276553276557276581276587276589276593276599276623276629276637276671276673276707276721276739276763276767276779276781276817276821276823276827276833276839276847276869276883276901276907276917276919276929276949276953276961276977277003277007277021277051277063277073277087277097277099277157277163277169277177277183277213277217277223277231277247277259277261277273277279277297277301277309277331277363277373277411277421277427277429277483277493277499277513277531277547277549277567277577277579277597277601277603277637277639277643277657277663277687277691277703277741277747277751277757277787277789277793277813277829277847277859277883277889277891277897277903277919277961277993277999278017278029278041278051278063278071278087278111278119278123278143278147278149278177278191278207278209278219278227278233278237278261278269278279278321278329278347278353278363278387278393278413278437278459278479278489278491278497278501278503278543278549278557278561278563278581278591278609278611278617278623278627278639278651278671278687278689278701278717278741278743278753278767278801278807278809278813278819278827278843278849278867278879278881278891278903278909278911278917278947278981279001279007279023279029279047279073279109279119279121279127279131279137279143279173279179279187279203279211279221279269279311279317279329279337279353279397279407279413279421279431279443279451279479279481279511279523279541279551279553279557279571279577279583279593279607279613279619279637279641279649279659279679279689279707279709279731279751279761279767279779279817279823279847279857279863279883279913279919279941279949279967279977279991280001280009280013280031280037280061280069280097280099280103280121280129280139280183280187280199280207280219280223280229280243280249280253280277280297280303280321280327280337280339280351280373280409280411280451280463280487280499280507280513280537280541280547280549280561280583280589280591280597280603280607280613280627280639280673280681280697280699280703280711280717280729280751280759280769280771280811280817280837280843280859280871280879280883280897280909280913280921280927280933280939280949280957280963280967280979280997281023281033281053281063281069281081281117281131281153281159281167281189281191281207281227281233281243281249281251281273281279281291281297281317281321281327281339281353281357281363281381281419281423281429281431281509281527281531281539281549281551281557281563281579281581281609281621281623281627281641281647281651281653281663281669281683281717281719281737281747281761281767281777281783281791281797281803281807281833281837281839281849281857281867281887281893281921281923281927281933281947281959281971281989281993282001282011282019282053282059282071282089282091282097282101282103282127282143282157282167282221282229282239282241282253282281282287282299282307282311282313282349282377282383282389282391282407282409282413282427282439282461282481282487282493282559282563282571282577282589282599282617282661282671282677282679282683282691282697282703282707282713282767282769282773282797282809282827282833282847282851282869282881282889282907282911282913282917282959282973282977282991283001283007283009283027283051283079283093283097283099283111283117283121283133283139283159283163283181283183283193283207283211283267283277283289283303283369283397283403283411283447283463283487283489283501283511283519283541283553283571283573283579283583283601283607283609283631283637283639283669283687283697283721283741283763283769283771283793283799283807283813283817283831283837283859283861283873283909283937283949283957283961283979284003284023284041284051284057284059284083284093284111284117284129284131284149284153284159284161284173284191284201284227284231284233284237284243284261284267284269284293284311284341284357284369284377284387284407284413284423284429284447284467284477284483284489284507284509284521284527284539284551284561284573284587284591284593284623284633284651284657284659284681284689284701284707284723284729284731284737284741284743284747284749284759284777284783284803284807284813284819284831284833284839284857284881284897284899284917284927284957284969284989285007285023285031285049285071285079285091285101285113285119285121285139285151285161285179285191285199285221285227285251285281285283285287285289285301285317285343285377285421285433285451285457285463285469285473285497285517285521285533285539285553285557285559285569285599285611285613285629285631285641285643285661285667285673285697285707285709285721285731285749285757285763285767285773285781285823285827285839285841285871285937285949285953285977285979285983285997286001286009286019286043286049286061286063286073286103286129286163286171286199286243286249286289286301286333286367286369286381286393286397286411286421286427286453286457286459286469286477286483286487286493286499286513286519286541286543286547286553286589286591286609286613286619286633286651286673286687286697286703286711286721286733286751286753286763286771286777286789286801286813286831286859286873286927286973286981286987286999287003287047287057287059287087287093287099287107287117287137287141287149287159287167287173287179287191287219287233287237287239287251287257287269287279287281287291287297287321287327287333287341287347287383287387287393287437287449287491287501287503287537287549287557287579287597287611287629287669287671287681287689287701287731287747287783287789287801287813287821287849287851287857287863287867287873287887287921287933287939287977288007288023288049288053288061288077288089288109288137288179288181288191288199288203288209288227288241288247288257288283288293288307288313288317288349288359288361288383288389288403288413288427288433288461288467288481288493288499288527288529288539288551288559288571288577288583288647288649288653288661288679288683288689288697288731288733288751288767288773288803288817288823288833288839288851288853288877288907288913288929288931288947288973288979288989288991288997289001289019289021289031289033289039289049289063289067289099289103289109289111289127289129289139289141289151289169289171289181289189289193289213289241289243289249289253289273289283289291289297289309289319289343289349289361289369289381289397289417289423289439289453289463289469289477289489289511289543289559289573289577289589289603289607289637289643289657289669289717289721289727289733289741289759289763289771289789289837289841289843289847289853289859289871289889289897289937289951289957289967289973289987289999290011290021290023290027290033290039290041290047290057290083290107290113290119290137290141290161290183290189290201290209290219290233290243290249290317290327290347290351290359290369290383290393290399290419290429290441290443290447290471290473290489290497290509290527290531290533290539290557290593290597290611290617290621290623290627290657290659290663290669290671290677290701290707290711290737290761290767290791290803290821290827290837290839290861290869290879290897290923290959290963290971290987290993290999291007291013291037291041291043291077291089291101291103291107291113291143291167291169291173291191291199291209291217291253291257291271291287291293291299291331291337291349291359291367291371291373291377291419291437291439291443291457291481291491291503291509291521291539291547291559291563291569291619291647291649291661291677291689291691291701291721291727291743291751291779291791291817291829291833291853291857291869291877291887291899291901291923291971291979291983291997292021292027292037292057292069292079292081292091292093292133292141292147292157292181292183292223292231292241292249292267292283292301292309292319292343292351292363292367292381292393292427292441292459292469292471292477292483292489292493292517292531292541292549292561292573292577292601292627292631292661292667292673292679292693292703292709292711292717292727292753292759292777292793292801292807292819292837292841292849292867292879292909292921292933292969292973292979292993293021293071293081293087293093293099293107293123293129293147293149293173293177293179293201293207293213293221293257293261293263293269293311293329293339293351293357293399293413293431293441293453293459293467293473293483293507293543293599293603293617293621293633293639293651293659293677293681293701293717293723293729293749293767293773293791293803293827293831293861293863293893293899293941293957293983293989293999294001294013294023294029294043294053294059294067294103294127294131294149294157294167294169294179294181294199294211294223294227294241294247294251294269294277294289294293294311294313294317294319294337294341294347294353294383294391294397294403294431294439294461294467294479294499294509294523294529294551294563294629294641294647294649294659294673294703294731294751294757294761294773294781294787294793294799294803294809294821294829294859294869294887294893294911294919294923294947294949294953294979294989294991294997295007295033295037295039295049295073295079295081295111295123295129295153295187295199295201295219295237295247295259295271295277295283295291295313295319295333295357295363295387295411295417295429295433295439295441295459295513295517295541295553295567295571295591295601295663295693295699295703295727295751295759295769295777295787295819295831295837295843295847295853295861295871295873295877295879295901295903295909295937295943295949295951295961295973295993296011296017296027296041296047296071296083296099296117296129296137296159296183296201296213296221296237296243296249296251296269296273296279296287296299296347296353296363296369296377296437296441296473296477296479296489296503296507296509296519296551296557296561296563296579296581296587296591296627296651296663296669296683296687296693296713296719296729296731296741296749296753296767296771296773296797296801296819296827296831296833296843296909296911296921296929296941296969296971296981296983296987297019297023297049297061297067297079297083297097297113297133297151297161297169297191297233297247297251297257297263297289297317297359297371297377297391297397297403297421297439297457297467297469297481297487297503297509297523297533297581297589297601297607297613297617297623297629297641297659297683297691297707297719297727297757297779297793297797297809297811297833297841297853297881297889297893297907297911297931297953297967297971297989297991298013298021298031298043298049298063298087298093298099298153298157298159298169298171298187298201298211298213298223298237298247298261298283298303298307298327298339298343298349298369298373298399298409298411298427298451298477298483298513298559298579298583298589298601298607298621298631298651298667298679298681298687298691298693298709298723298733298757298759298777298799298801298817298819298841298847298853298861298897298937298943298993298999299011299017299027299029299053299059299063299087299099299107299113299137299147299171299179299191299197299213299239299261299281299287299311299317299329299333299357299359299363299371299389299393299401299417299419299447299471299473299477299479299501299513299521299527299539299567299569299603299617299623299653299671299681299683299699299701299711299723299731299743299749299771299777299807299843299857299861299881299891299903299909299933299941299951299969299977299983299993300007300017300023300043300073300089300109300119300137300149300151300163300187300191300193300221300229300233300239300247300277300299300301300317300319300323300331300343300347300367300397300413300427300431300439300463300481300491300493300497300499300511300557300569300581300583300589300593300623300631300647300649300661300667300673300683300691300719300721300733300739300743300749300757300761300779300787300799300809300821300823300851300857300869300877300889300893300929300931300953300961300967300973300977300997301013301027301039301051301057301073301079301123301127301141301153301159301177301181301183301211301219301237301241301243301247301267301303301319301331301333301349301361301363301381301403301409301423301429301447301459301463301471301487301489301493301501301531301577301579301583301591301601301619301627301643301649301657301669301673301681301703301711301747301751301753301759301789301793301813301831301841301843301867301877301897301901301907301913301927301933301943301949301979301991301993301997301999302009302053302111302123302143302167302171302173302189302191302213302221302227302261302273302279302287302297302299302317302329302399302411302417302429302443302459302483302507302513302551302563302567302573302579302581302587302593302597302609302629302647302663302681302711302723302747302759302767302779302791302801302831302833302837302843302851302857302873302891302903302909302921302927302941302959302969302971302977302983302989302999303007303011303013303019303029303049303053303073303089303091303097303119303139303143303151303157303187303217303257303271303283303287303293303299303307303313303323303337303341303361303367303371303377303379303389303409303421303431303463303469303473303491303493303497303529303539303547303551303553303571303581303587303593303613303617303619303643303647303649303679303683303689303691303703303713303727303731303749303767303781303803303817303827303839303859303871303889303907303917303931303937303959303983303997304009304013304021304033304039304049304063304067304069304081304091304099304127304151304153304163304169304193304211304217304223304253304259304279304301304303304331304349304357304363304373304391304393304411304417304429304433304439304457304459304477304481304489304501304511304517304523304537304541304553304559304561304597304609304631304643304651304663304687304709304723304729304739304751304757304763304771304781304789304807304813304831304847304849304867304879304883304897304901304903304907304933304937304943304949304961304979304981305017305021305023305029305033305047305069305093305101305111305113305119305131305143305147305209305219305231305237305243305267305281305297305329305339305351305353305363305369305377305401305407305411305413305419305423305441305449305471305477305479305483305489305497305521305533305551305563305581305593305597305603305611305621305633305639305663305717305719305741305743305749305759305761305771305783305803305821305839305849305857305861305867305873305917305927305933305947305971305999306011306023306029306041306049306083306091306121306133306139306149306157306167306169306191306193306209306239306247306253306259306263306301306329306331306347306349306359306367306377306389306407306419306421306431306437306457306463306473306479306491306503306511306517306529306533306541306563306577306587306589306643306653306661306689306701306703306707306727306739306749306763306781306809306821306827306829306847306853306857306871306877306883306893306899306913306919306941306947306949306953306991307009307019307031307033307067307079307091307093307103307121307129307147307163307169307171307187307189307201307243307253307259307261307267307273307277307283307289307301307337307339307361307367307381307397307399307409307423307451307471307481307511307523307529307537307543307577307583307589307609307627307631307633307639307651307669307687307691307693307711307733307759307817307823307831307843307859307871307873307891307903307919307939307969308003308017308027308041308051308081308093308101308107308117308129308137308141308149308153308213308219308249308263308291308293308303308309308311308317308323308327308333308359308383308411308423308437308447308467308489308491308501308507308509308519308521308527308537308551308569308573308587308597308621308639308641308663308681308701308713308723308761308773308801308809308813308827308849308851308857308887308899308923308927308929308933308939308951308989308999309007309011309013309019309031309037309059309079309083309091309107309109309121309131309137309157309167309173309193309223309241309251309259309269309271309277309289309293309311309313309317309359309367309371309391309403309433309437309457309461309469309479309481309493309503309521309523309539309541309559309571309577309583309599309623309629309637309667309671309677309707309713309731309737309769309779309781309797309811309823309851309853309857309877309899309929309931309937309977309989310019310021310027310043310049310081310087310091310111310117310127310129310169310181310187310223310229310231310237310243310273310283310291310313310333310357310361310363310379310397310423310433310439310447310459310463310481310489310501310507310511310547310553310559310567310571310577310591310627310643310663310693310697310711310721310727310729310733310741310747310771310781310789310801310819310823310829310831310861310867310883310889310901310927310931310949310969310987310997311009311021311027311033311041311099311111311123311137311153311173311177311183311189311197311203311237311279311291311293311299311303311323311329311341311347311359311371311393311407311419311447311453311473311533311537311539311551311557311561311567311569311603311609311653311659311677311681311683311687311711311713311737311743311747311749311791311803311807311821311827311867311869311881311897311951311957311963311981312007312023312029312031312043312047312071312073312083312089312101312107312121312161312197312199312203312209312211312217312229312233312241312251312253312269312281312283312289312311312313312331312343312349312353312371312383312397312401312407312413312427312451312469312509312517312527312551312553312563312581312583312589312601312617312619312623312643312673312677312679312701312703312709312727312737312743312757312773312779312799312839312841312857312863312887312899312929312931312937312941312943312967312971312979312989313003313009313031313037313081313087313109313127313129313133313147313151313153313163313207313211313219313241313249313267313273313289313297313301313307313321313331313333313343313351313373313381313387313399313409313471313477313507313517313543313549313553313561313567313571313583313589313597313603313613313619313637313639313661313669313679313699313711313717313721313727313739313741313763313777313783313829313849313853313879313883313889313897313909313921313931313933313949313961313969313979313981313987313991313993313997314003314021314059314063314077314107314113314117314129314137314159314161314173314189314213314219314227314233314239314243314257314261314263314267314299314329314339314351314357314359314399314401314407314423314441314453314467314491314497314513314527314543314549314569314581314591314597314599314603314623314627314641314651314693314707314711314719314723314747314761314771314777314779314807314813314827314851314879314903314917314927314933314953314957314983314989315011315013315037315047315059315067315083315097315103315109315127315179315181315193315199315223315247315251315257315269315281315313315349315361315373315377315389315407315409315421315437315449315451315461315467315481315493315517315521315527315529315547315551315559315569315589315593315599315613315617315631315643315671315677315691315697315701315703315739315743315751315779315803315811315829315851315857315881315883315893315899315907315937315949315961315967315977316003316031316033316037316051316067316073316087316097316109316133316139316153316177316189316193316201316213316219316223316241316243316259316271316291316297316301316321316339316343316363316373316391316403316423316429316439316453316469316471316493316499316501316507316531316567316571316577316583316621316633316637316649316661316663316681316691316697316699316703316717316753316759316769316777316783316793316801316817316819316847316853316859316861316879316891316903316907316919316937316951316957316961316991317003317011317021317029317047317063317071317077317087317089317123317159317171317179317189317197317209317227317257317263317267317269317279317321317323317327317333317351317353317363317371317399317411317419317431317437317453317459317483317489317491317503317539317557317563317587317591317593317599317609317617317621317651317663317671317693317701317711317717317729317731317741317743317771317773317777317783317789317797317827317831317839317857317887317903317921317923317957317959317963317969317971317983317987318001318007318023318077318103318107318127318137318161318173318179318181318191318203318209318211318229318233318247318259318271318281318287318289318299318301318313318319318323318337318347318349318377318403318407318419318431318443318457318467318473318503318523318557318559318569318581318589318601318629318641318653318671318677318679318683318691318701318713318737318743318749318751318781318793318809318811318817318823318833318841318863318881318883318889318907318911318917318919318949318979319001319027319031319037319049319057319061319069319093319097319117319127319129319133319147319159319169319183319201319211319223319237319259319279319289319313319321319327319339319343319351319357319387319391319399319411319427319433319439319441319453319469319477319483319489319499319511319519319541319547319567319577319589319591319601319607319639319673319679319681319687319691319699319727319729319733319747319757319763319811319817319819319829319831319849319883319897319901319919319927319931319937319967319973319981319993320009320011320027320039320041320053320057320063320081320083320101320107320113320119320141320143320149320153320179320209320213320219320237320239320267320269320273320291320293320303320317320329320339320377320387320389320401320417320431320449320471320477320483320513320521320533320539320561320563320591320609320611320627320647320657320659320669320687320693320699320713320741320759320767320791320821320833320839320843320851320861320867320899320911320923320927320939320941320953321007321017321031321037321047321053321073321077321091321109321143321163321169321187321193321199321203321221321227321239321247321289321301321311321313321319321323321329321331321341321359321367321371321383321397321403321413321427321443321449321467321469321509321547321553321569321571321577321593321611321617321619321631321647321661321679321707321709321721321733321743321751321757321779321799321817321821321823321829321833321847321851321889321901321911321947321949321961321983321991322001322009322013322037322039322051322057322067322073322079322093322097322109322111322139322169322171322193322213322229322237322243322247322249322261322271322319322327322339322349322351322397322403322409322417322429322433322459322463322501322513322519322523322537322549322559322571322573322583322589322591322607322613322627322631322633322649322669322709322727322747322757322769322771322781322783322807322849322859322871322877322891322901322919322921322939322951322963322969322997322999323003323009323027323053323077323083323087323093323101323123323131323137323149323201323207323233323243323249323251323273323333323339323341323359323369323371323377323381323383323413323419323441323443323467323471323473323507323509323537323549323567323579323581323591323597323599323623323641323647323651323699323707323711323717323759323767323789323797323801323803323819323837323879323899323903323923323927323933323951323957323987324011324031324053324067324073324089324097324101324113324119324131324143324151324161324179324199324209324211324217324223324239324251324293324299324301324319324329324341324361324391324397324403324419324427324431324437324439324449324451324469324473324491324497324503324517324523324529324557324587324589324593324617324619324637324641324647324661324673324689324697324707324733324743324757324763324773324781324791324799324809324811324839324847324869324871324889324893324901324931324941324949324953324977324979324983324991324997325001325009325019325021325027325043325051325063325079325081325093325133325153325163325181325187325189325201325217325219325229325231325249325271325301325307325309325319325333325343325349325379325411325421325439325447325453325459325463325477325487325513325517325537325541325543325571325597325607325627325631325643325667325673325681325691325693325697325709325723325729325747325751325753325769325777325781325783325807325813325849325861325877325883325889325891325901325921325939325943325951325957325987325993325999326023326057326063326083326087326099326101326113326119326141326143326147326149326153326159326171326189326203326219326251326257326309326323326351326353326369326437326441326449326467326479326497326503326537326539326549326561326563326567326581326593326597326609326611326617326633326657326659326663326681326687326693326701326707326737326741326773326779326831326863326867326869326873326881326903326923326939326941326947326951326983326993326999327001327007327011327017327023327059327071327079327127327133327163327179327193327203327209327211327247327251327263327277327289327307327311327317327319327331327337327343327347327401327407327409327419327421327433327443327463327469327473327479327491327493327499327511327517327529327553327557327559327571327581327583327599327619327629327647327661327667327673327689327707327721327737327739327757327779327797327799327809327823327827327829327839327851327853327869327871327881327889327917327923327941327953327967327979327983328007328037328043328051328061328063328067328093328103328109328121328127328129328171328177328213328243328249328271328277328283328291328303328327328331328333328343328357328373328379328381328397328411328421328429328439328481328511328513328519328543328579328589328591328619328621328633328637328639328651328667328687328709328721328753328777328781328787328789328813328829328837328847328849328883328891328897328901328919328921328931328961328981329009329027329053329059329081329083329089329101329111329123329143329167329177329191329201329207329209329233329243329257329267329269329281329293329297329299329309329317329321329333329347329387329393329401329419329431329471329473329489329503329519329533329551329557329587329591329597329603329617329627329629329639329657329663329671329677329683329687329711329717329723329729329761329773329779329789329801329803329863329867329873329891329899329941329947329951329957329969329977329993329999330017330019330037330041330047330053330061330067330097330103330131330133330139330149330167330199330203330217330227330229330233330241330247330271330287330289330311330313330329330331330347330359330383330389330409330413330427330431330433330439330469330509330557330563330569330587330607330611330623330641330643330653330661330679330683330689330697330703330719330721330731330749330767330787330791330793330821330823330839330853330857330859330877330887330899330907330917330943330983330997331013331027331031331043331063331081331099331127331141331147331153331159331171331183331207331213331217331231331241331249331259331277331283331301331307331319331333331337331339331349331367331369331391331399331423331447331451331489331501331511331519331523331537331543331547331549331553331577331579331589331603331609331613331651331663331691331693331697331711331739331753331769331777331781331801331819331841331843331871331883331889331897331907331909331921331937331943331957331967331973331997331999332009332011332039332053332069332081332099332113332117332147332159332161332179332183332191332201332203332207332219332221332251332263332273332287332303332309332317332393332399332411332417332441332447332461332467332471332473332477332489332509332513332561332567332569332573332611332617332623332641332687332699332711332729332743332749332767332779332791332803332837332851332873332881332887332903332921332933332947332951332987332989332993333019333023333029333031333041333049333071333097333101333103333107333131333139333161333187333197333209333227333233333253333269333271333283333287333299333323333331333337333341333349333367333383333397333419333427333433333439333449333451333457333479333491333493333497333503333517333533333539333563333581333589333623333631333647333667333673333679333691333701333713333719333721333737333757333769333779333787333791333793333803333821333857333871333911333923333929333941333959333973333989333997334021334031334043334049334057334069334093334099334127334133334157334171334177334183334189334199334231334247334261334289334297334319334331334333334349334363334379334387334393334403334421334423334427334429334447334487334493334507334511334513334541334547334549334561334603334619334637334643334651334661334667334681334693334699334717334721334727334751334753334759334771334777334783334787334793334843334861334877334889334891334897334931334963334973334987334991334993335009335021335029335033335047335051335057335077335081335089335107335113335117335123335131335149335161335171335173335207335213335221335249335261335273335281335299335323335341335347335381335383335411335417335429335449335453335459335473335477335507335519335527335539335557335567335579335591335609335633335641335653335663335669335681335689335693335719335729335743335747335771335807335809335813335821335833335843335857335879335893335897335917335941335953335957335999336029336031336041336059336079336101336103336109336113336121336143336151336157336163336181336199336211336221336223336227336239336247336251336253336263336307336317336353336361336373336397336403336419336437336463336491336499336503336521336527336529336533336551336563336571336577336587336593336599336613336631336643336649336653336667336671336683336689336703336727336757336761336767336769336773336793336799336803336823336827336829336857336863336871336887336899336901336911336929336961336977336983336989336997337013337021337031337039337049337069337081337091337097337121337153337189337201337213337217337219337223337261337277337279337283337291337301337313337327337339337343337349337361337367337369337397337411337427337453337457337487337489337511337517337529337537337541337543337583337607337609337627337633337639337651337661337669337681337691337697337721337741337751337759337781337793337817337837337853337859337861337867337871337873337891337901337903337907337919337949337957337969337973337999338017338027338033338119338137338141338153338159338161338167338171338183338197338203338207338213338231338237338251338263338267338269338279338287338293338297338309338321338323338339338341338347338369338383338389338407338411338413338423338431338449338461338473338477338497338531338543338563338567338573338579338581338609338659338669338683338687338707338717338731338747338753338761338773338777338791338803338839338851338857338867338893338909338927338959338993338999339023339049339067339071339091339103339107339121339127339137339139339151339161339173339187339211339223339239339247339257339263339289339307339323339331339341339373339389339413339433339467339491339517339527339539339557339583339589339601339613339617339631339637339649339653339659339671339673339679339707339727339749339751339761339769339799339811339817339821339827339839339841339863339887339907339943339959339991340007340027340031340037340049340057340061340063340073340079340103340111340117340121340127340129340169340183340201340211340237340261340267340283340297340321340337340339340369340381340387340393340397340409340429340447340451340453340477340481340519340541340559340573340577340579340583340591340601340619340633340643340649340657340661340687340693340709340723340757340777340787340789340793340801340811340819340849340859340877340889340897340903340909340913340919340927340931340933340937340939340957340979340999341017341027341041341057341059341063341083341087341123341141341171341179341191341203341219341227341233341269341273341281341287341293341303341311341321341323341333341339341347341357341423341443341447341459341461341477341491341501341507341521341543341557341569341587341597341603341617341623341629341641341647341659341681341687341701341729341743341749341771341773341777341813341821341827341839341851341863341879341911341927341947341951341953341959341963341983341993342037342047342049342059342061342071342073342077342101342107342131342143342179342187342191342197342203342211342233342239342241342257342281342283342299342319342337342341342343342347342359342371342373342379342389342413342421342449342451342467342469342481342497342521342527342547342553342569342593342599342607342647342653342659342673342679342691342697342733342757342761342791342799342803342821342833342841342847342863342869342871342889342899342929342949342971342989343019343037343051343061343073343081343087343127343141343153343163343169343177343193343199343219343237343243343253343261343267343289343303343307343309343313343327343333343337343373343379343381343391343393343411343423343433343481343489343517343529343531343543343547343559343561343579343583343589343591343601343627343631343639343649343661343667343687343709343727343769343771343787343799343801343813343817343823343829343831343891343897343901343913343933343939343943343951343963343997344017344021344039344053344083344111344117344153344161344167344171344173344177344189344207344209344213344221344231344237344243344249344251344257344263344269344273344291344293344321344327344347344353344363344371344417344423344429344453344479344483344497344543344567344587344599344611344621344629344639344653344671344681344683344693344719344749344753344759344791344797344801344807344819344821344843344857344863344873344887344893344909344917344921344941344957344959344963344969344987345001345011345017345019345041345047345067345089345109345133345139345143345181345193345221345227345229345259345263345271345307345311345329345379345413345431345451345461345463345473345479345487345511345517345533345547345551345571345577345581345599345601345607345637345643345647345659345673345679345689345701345707345727345731345733345739345749345757345769345773345791345803345811345817345823345853345869345881345887345889345907345923345937345953345979345997346013346039346043346051346079346091346097346111346117346133346139346141346147346169346187346201346207346217346223346259346261346277346303346309346321346331346337346349346361346369346373346391346393346397346399346417346421346429346433346439346441346447346453346469346501346529346543346547346553346559346561346589346601346607346627346639346649346651346657346667346669346699346711346721346739346751346763346793346831346849346867346873346877346891346903346933346939346943346961346963347003347033347041347051347057347059347063347069347071347099347129347131347141347143347161347167347173347177347183347197347201347209347227347233347239347251347257347287347297347299347317347329347341347359347401347411347437347443347489347509347513347519347533347539347561347563347579347587347591347609347621347629347651347671347707347717347729347731347747347759347771347773347779347801347813347821347849347873347887347891347899347929347933347951347957347959347969347981347983347987347989347993348001348011348017348031348043348053348077348083348097348149348163348181348191348209348217348221348239348241348247348253348259348269348287348307348323348353348367348389348401348407348419348421348431348433348437348443348451348457348461348463348487348527348547348553348559348563348571348583348587348617348629348637348643348661348671348709348731348739348757348763348769348779348811348827348833348839348851348883348889348911348917348919348923348937348949348989348991349007349039349043349051349079349081349093349099349109349121349133349171349177349183349187349199349207349211349241349291349303349313349331349337349343349357349369349373349379349381349387349397349399349403349409349411349423349471349477349483349493349499349507349519349529349553349567349579349589349603349637349663349667349697349709349717349729349753349759349787349793349801349813349819349829349831349837349841349849349871349903349907349913349919349927349931349933349939349949349963349967349981350003350029350033350039350087350089350093350107350111350137350159350179350191350213350219350237350249350257350281350293350347350351350377350381350411350423350429350431350437350443350447350453350459350503350521350549350561350563350587350593350617350621350629350657350663350677350699350711350719350729350731350737350741350747350767350771350783350789350803350809350843350851350869350881350887350891350899350941350947350963350971350981350983350989351011351023351031351037351041351047351053351059351061351077351079351097351121351133351151351157351179351217351223351229351257351259351269351287351289351293351301351311351341351343351347351359351361351383351391351397351401351413351427351437351457351469351479351497351503351517351529351551351563351587351599351643351653351661351667351691351707351727351731351733351749351751351763351773351779351797351803351811351829351847351851351859351863351887351913351919351929351931351959351971351991352007352021352043352049352057352069352073352081352097352109352111352123352133352181352193352201352217352229352237352249352267352271352273352301352309352327352333352349352357352361352367352369352381352399352403352409352411352421352423352441352459352463352481352483352489352493352511352523352543352549352579352589352601352607352619352633352637352661352691352711352739352741352753352757352771352813352817352819352831352837352841352853352867352883352907352909352931352939352949352951352973352991353011353021353047353053353057353069353081353099353117353123353137353147353149353161353173353179353201353203353237353263353293353317353321353329353333353341353359353389353401353411353429353443353453353459353471353473353489353501353527353531353557353567353603353611353621353627353629353641353653353657353677353681353687353699353711353737353747353767353777353783353797353807353813353819353833353867353869353879353891353897353911353917353921353929353939353963354001354007354017354023354031354037354041354043354047354073354091354097354121354139354143354149354163354169354181354209354247354251354253354257354259354271354301354307354313354317354323354329354337354353354371354373354377354383354391354401354421354439354443354451354461354463354469354479354533354539354551354553354581354587354619354643354647354661354667354677354689354701354703354727354737354743354751354763354779354791354799354829354833354839354847354869354877354881354883354911354953354961354971354973354979354983354997355007355009355027355031355037355039355049355057355063355073355087355093355099355109355111355127355139355171355193355211355261355297355307355321355331355339355343355361355363355379355417355427355441355457355463355483355499355501355507355513355517355519355529355541355549355559355571355573355591355609355633355643355651355669355679355697355717355721355723355753355763355777355783355799355811355819355841355847355853355867355891355909355913355933355937355939355951355967355969356023356039356077356093356101356113356123356129356137356141356143356171356173356197356219356243356261356263356287356299356311356327356333356351356387356399356441356443356449356453356467356479356501356509356533356549356561356563356567356579356591356621356647356663356693356701356731356737356749356761356803356819356821356831356869356887356893356927356929356933356947356959356969356977356981356989356999357031357047357073357079357083357103357107357109357131357139357169357179357197357199357211357229357239357241357263357271357281357283357293357319357347357349357353357359357377357389357421357431357437357473357503357509357517357551357559357563357569357571357583357587357593357611357613357619357649357653357659357661357667357671357677357683357689357703357727357733357737357739357767357779357781357787357793357809357817357823357829357839357859357883357913357967357977357983357989357997358031358051358069358073358079358103358109358153358157358159358181358201358213358219358223358229358243358273358277358279358289358291358297358301358313358327358331358349358373358417358427358429358441358447358459358471358483358487358499358531358541358571358573358591358597358601358607358613358637358667358669358681358691358697358703358711358723358727358733358747358753358769358783358793358811358829358847358859358861358867358877358879358901358903358907358909358931358951358973358979358987358993358999359003359017359027359041359063359069359101359111359129359137359143359147359153359167359171359207359209359231359243359263359267359279359291359297359299359311359323359327359353359357359377359389359407359417359419359441359449359477359479359483359501359509359539359549359561359563359581359587359599359621359633359641359657359663359701359713359719359731359747359753359761359767359783359837359851359869359897359911359929359981359987360007360023360037360049360053360071360089360091360163360167360169360181360187360193360197360223360229360233360257360271360277360287360289360293360307360317360323360337360391360407360421360439360457360461360497360509360511360541360551360589360593360611360637360649360653360749360769360779360781360803360817360821360823360827360851360853360863360869360901360907360947360949360953360959360973360977360979360989361001361003361013361033361069361091361093361111361159361183361211361213361217361219361223361237361241361271361279361313361321361327361337361349361351361357361363361373361409361411361421361433361441361447361451361463361469361481361499361507361511361523361531361541361549361561361577361637361643361649361651361663361679361687361723361727361747361763361769361787361789361793361799361807361843361871361873361877361901361903361909361919361927361943361961361967361973361979361993362003362027362051362053362059362069362081362093362099362107362137362143362147362161362177362191362203362213362221362233362237362281362291362293362303362309362333362339362347362353362357362363362371362377362381362393362407362419362429362431362443362449362459362473362521362561362569362581362599362629362633362657362693362707362717362723362741362743362749362753362759362801362851362863362867362897362903362911362927362941362951362953362969362977362983362987363017363019363037363043363047363059363061363067363119363149363151363157363161363173363179363199363211363217363257363269363271363277363313363317363329363343363359363361363367363371363373363379363397363401363403363431363437363439363463363481363491363497363523363529363533363541363551363557363563363569363577363581363589363611363619363659363677363683363691363719363731363751363757363761363767363773363799363809363829363833363841363871363887363889363901363911363917363941363947363949363959363967363977363989364027364031364069364073364079364103364127364129364141364171364183364187364193364213364223364241364267364271364289364291364303364313364321364333364337364349364373364379364393364411364417364423364433364447364451364459364471364499364513364523364537364541364543364571364583364601364607364621364627364643364657364669364687364691364699364717364739364747364751364753364759364801364829364853364873364879364883364891364909364919364921364937364943364961364979364993364997365003365017365021365039365063365069365089365107365119365129365137365147365159365173365179365201365213365231365249365251365257365291365293365297365303365327365333365357365369365377365411365413365419365423365441365461365467365471365473365479365489365507365509365513365527365531365537365557365567365569365587365591365611365627365639365641365669365683365689365699365747365749365759365773365779365791365797365809365837365839365851365903365929365933365941365969365983366001366013366019366029366031366053366077366097366103366127366133366139366161366167366169366173366181366193366199366211366217366221366227366239366259366269366277366287366293366307366313366329366341366343366347366383366397366409366419366433366437366439366461366463366467366479366497366511366517366521366547366593366599366607366631366677366683366697366701366703366713366721366727366733366787366791366811366829366841366851366853366859366869366881366889366901366907366917366923366941366953366967366973366983366997367001367007367019367021367027367033367049367069367097367121367123367127367139367163367181367189367201367207367219367229367231367243367259367261367273367277367307367309367313367321367357367369367391367397367427367453367457367469367501367519367531367541367547367559367561367573367597367603367613367621367637367649367651367663367673367687367699367711367721367733367739367751367771367777367781367789367819367823367831367841367849367853367867367879367883367889367909367949367957368021368029368047368059368077368083368089368099368107368111368117368129368141368149368153368171368189368197368227368231368233368243368273368279368287368293368323368327368359368363368369368399368411368443368447368453368471368491368507368513368521368531368539368551368579368593368597368609368633368647368651368653368689368717368729368737368743368773368783368789368791368801368803368833368857368873368881368899368911368939368947368957369007369013369023369029369067369071369077369079369097369119369133369137369143369169369181369191369197369211369247369253369263369269369283369293369301369319369331369353369361369407369409369419369469369487369491369539369553369557369581369637369647369659369661369673369703369709369731369739369751369791369793369821369827369829369833369841369851369877369893369913369917369947369959369961369979369983369991369997370003370009370021370033370057370061370067370081370091370103370121370133370147370159370169370193370199370207370213370217370241370247370261370373370387370399370411370421370423370427370439370441370451370463370471370477370483370493370511370529370537370547370561370571370597370603370609370613370619370631370661370663370673370679370687370693370723370759370793370801370813370837370871370873370879370883370891370897370919370949371027371029371057371069371071371083371087371099371131371141371143371153371177371179371191371213371227371233371237371249371251371257371281371291371299371303371311371321371333371339371341371353371359371383371387371389371417371447371453371471371479371491371509371513371549371561371573371587371617371627371633371639371663371669371699371719371737371779371797371831371837371843371851371857371869371873371897371927371929371939371941371951371957371971371981371999372013372023372037372049372059372061372067372107372121372131372137372149372167372173372179372223372241372263372269372271372277372289372293372299372311372313372353372367372371372377372397372401372409372413372443372451372461372473372481372497372511372523372539372607372611372613372629372637372653372661372667372677372689372707372709372719372733372739372751372763372769372773372797372803372809372817372829372833372839372847372859372871372877372881372901372917372941372943372971372973372979373003373007373019373049373063373073373091373127373151373157373171373181373183373187373193373199373207373211373213373229373231373273373291373297373301373327373339373343373349373357373361373363373379373393373447373453373459373463373487373489373501373517373553373561373567373613373621373631373649373657373661373669373693373717373721373753373757373777373783373823373837373859373861373903373909373937373943373951373963373969373981373987373999374009374029374039374041374047374063374069374083374089374093374111374117374123374137374149374159374173374177374189374203374219374239374287374291374293374299374317374321374333374347374351374359374389374399374441374443374447374461374483374501374531374537374557374587374603374639374641374653374669374677374681374683374687374701374713374719374729374741374753374761374771374783374789374797374807374819374837374839374849374879374887374893374903374909374929374939374953374977374981374987374989374993375017375019375029375043375049375059375083375091375097375101375103375113375119375121375127375149375157375163375169375203375209375223375227375233375247375251375253375257375259375281375283375311375341375359375367375371375373375391375407375413375443375449375451375457375467375481375509375511375523375527375533375553375559375563375569375593375607375623375631375643375647375667375673375703375707375709375743375757375761375773375779375787375799375833375841375857375899375901375923375931375967375971375979375983375997376001376003376009376021376039376049376063376081376097376099376127376133376147376153376171376183376199376231376237376241376283376291376297376307376351376373376393376399376417376463376469376471376477376483376501376511376529376531376547376573376577376583376589376603376609376627376631376633376639376657376679376687376699376709376721376729376757376759376769376787376793376801376807376811376819376823376837376841376847376853376889376891376897376921376927376931376933376949376963376969377011377021377051377059377071377099377123377129377137377147377171377173377183377197377219377231377257377263377287377291377297377327377329377339377347377353377369377371377387377393377459377471377477377491377513377521377527377537377543377557377561377563377581377593377599377617377623377633377653377681377687377711377717377737377749377761377771377779377789377801377809377827377831377843377851377873377887377911377963377981377999378011378019378023378041378071378083378089378101378127378137378149378151378163378167378179378193378223378229378239378241378253378269378277378283378289378317378353378361378379378401378407378439378449378463378467378493378503378509378523378533378551378559378569378571378583378593378601378619378629378661378667378671378683378691378713378733378739378757378761378779378793378809378817378821378823378869378883378893378901378919378929378941378949378953378967378977378997379007379009379013379033379039379073379081379087379097379103379123379133379147379157379163379177379187379189379199379207379273379277379283379289379307379319379333379343379369379387379391379397379399379417379433379439379441379451379459379499379501379513379531379541379549379571379573379579379597379607379633379649379663379667379679379681379693379699379703379721379723379727379751379777379787379811379817379837379849379853379859379877379889379903379909379913379927379931379963379979379993379997379999380041380047380059380071380117380129380131380141380147380179380189380197380201380203380207380231380251380267380269380287380291380299380309380311380327380329380333380363380377380383380417380423380441380447380453380459380461380483380503380533380557380563380591380621380623380629380641380651380657380707380713380729380753380777380797380803380819380837380839380843380867380869380879380881380909380917380929380951380957380971380977380983381001381011381019381037381047381061381071381077381097381103381167381169381181381209381221381223381233381239381253381287381289381301381319381323381343381347381371381373381377381383381389381401381413381419381439381443381461381467381481381487381509381523381527381529381533381541381559381569381607381629381631381637381659381673381697381707381713381737381739381749381757381761381791381793381817381841381853381859381911381917381937381943381949381977381989381991382001382003382021382037382061382069382073382087382103382117382163382171382189382229382231382241382253382267382271382303382331382351382357382363382373382391382427382429382457382463382493382507382511382519382541382549382553382567382579382583382589382601382621382631382643382649382661382663382693382703382709382727382729382747382751382763382769382777382801382807382813382843382847382861382867382871382873382883382919382933382939382961382979382999383011383023383029383041383051383069383077383081383083383099383101383107383113383143383147383153383171383179383219383221383261383267383281383291383297383303383321383347383371383393383399383417383419383429383459383483383489383519383521383527383533383549383557383573383587383609383611383623383627383633383651383657383659383681383683383693383723383729383753383759383767383777383791383797383807383813383821383833383837383839383869383891383909383917383923383941383951383963383969383983383987384001384017384029384049384061384067384079384089384107384113384133384143384151384157384173384187384193384203384227384247384253384257384259384277384287384289384299384301384317384331384343384359384367384383384403384407384437384469384473384479384481384487384497384509384533384547384577384581384589384599384611384619384623384641384673384691384697384701384719384733384737384751384757384773384779384817384821384827384841384847384851384889384907384913384919384941384961384973385001385013385027385039385057385069385079385081385087385109385127385129385139385141385153385159385171385193385199385223385249385261385267385279385289385291385321385327385331385351385379385391385393385397385403385417385433385471385481385493385501385519385531385537385559385571385573385579385589385591385597385607385621385631385639385657385661385663385709385739385741385771385783385793385811385817385831385837385843385859385877385897385901385907385927385939385943385967385991385997386017386039386041386047386051386083386093386117386119386129386131386143386149386153386159386161386173386219386227386233386237386249386263386279386297386299386303386329386333386339386363386369386371386381386383386401386411386413386429386431386437386471386489386501386521386537386543386549386569386587386609386611386621386629386641386647386651386677386689386693386713386719386723386731386747386777386809386839386851386887386891386921386927386963386977386987386989386993387007387017387031387047387071387077387083387089387109387137387151387161387169387173387187387197387199387203387227387253387263387269387281387307387313387329387341387371387397387403387433387437387449387463387493387503387509387529387551387577387587387613387623387631387641387659387677387679387683387707387721387727387743387749387763387781387791387799387839387853387857387911387913387917387953387967387971387973387977388009388051388057388067388081388099388109388111388117388133388159388163388169388177388181388183388187388211388231388237388253388259388273388277388301388313388319388351388363388369388373388391388403388459388471388477388481388483388489388499388519388529388541388567388573388621388651388657388673388691388693388697388699388711388727388757388777388781388789388793388813388823388837388859388879388891388897388901388903388931388933388937388961388963388991389003389023389027389029389041389047389057389083389089389099389111389117389141389149389161389167389171389173389189389219389227389231389269389273389287389297389299389303389357389369389381389399389401389437389447389461389479389483389507389513389527389531389533389539389561389563389567389569389579389591389621389629389651389659389663389687389699389713389723389743389749389761389773389783389791389797389819389839389849389867389891389897389903389911389923389927389941389947389953389957389971389981389989389999390001390043390067390077390083390097390101390107390109390113390119390151390157390161390191390193390199390209390211390223390263390281390289390307390323390343390347390353390359390367390373390389390391390407390413390419390421390433390437390449390463390479390487390491390493390499390503390527390539390553390581390647390653390671390673390703390707390721390727390737390739390743390751390763390781390791390809390821390829390851390869390877390883390889390893390953390959390961390967390989390991391009391019391021391031391049391057391063391067391073391103391117391133391151391159391163391177391199391217391219391231391247391249391273391283391291391301391331391337391351391367391373391379391387391393391397391399391403391441391451391453391487391519391537391553391579391613391619391627391631391639391661391679391691391693391711391717391733391739391751391753391757391789391801391817391823391847391861391873391879391889391891391903391907391921391939391961391967391987391999392011392033392053392059392069392087392099392101392111392113392131392143392149392153392159392177392201392209392213392221392233392239392251392261392263392267392269392279392281392297392299392321392333392339392347392351392363392383392389392423392437392443392467392473392477392489392503392519392531392543392549392569392593392599392611392629392647392663392669392699392723392737392741392759392761392767392803392807392809392827392831392837392849392851392857392879392893392911392923392927392929392957392963392969392981392983393007393013393017393031393059393073393077393079393083393097393103393109393121393137393143393157393161393181393187393191393203393209393241393247393257393271393287393299393301393311393331393361393373393377393383393401393403393413393451393473393479393487393517393521393539393541393551393557393571393577393581393583393587393593393611393629393637393649393667393671393677393683393697393709393713393721393727393739393749393761393779393797393847393853393857393859393863393871393901393919393929393931393947393961393977393989393997394007394019394039394049394063394073394099394123394129394153394157394169394187394201394211394223394241394249394259394271394291394319394327394357394363394367394369394393394409394411394453394481394489394501394507394523394529394549394571394577394579394601394619394631394633394637394643394673394699394717394721394727394729394733394739394747394759394787394811394813394817394819394829394837394861394879394897394931394943394963394967394969394981394987394993395023395027395039395047395069395089395093395107395111395113395119395137395141395147395159395173395189395191395201395231395243395251395261395273395287395293395303395309395321395323395377395383395407395429395431395443395449395453395459395491395509395513395533395537395543395581395597395611395621395627395657395671395677395687395701395719395737395741395749395767395803395849395851395873395887395891395897395909395921395953395959395971396001396029396031396041396043396061396079396091396103396107396119396157396173396181396197396199396203396217396239396247396259396269396293396299396301396311396323396349396353396373396377396379396413396427396437396443396449396479396509396523396527396533396541396547396563396577396581396601396619396623396629396631396637396647396667396679396703396709396713396719396733396833396871396881396883396887396919396931396937396943396947396953396971396983396997397013397027397037397051397057397063397073397093397099397127397151397153397181397183397211397217397223397237397253397259397283397289397297397301397303397337397351397357397361397373397379397427397429397433397459397469397489397493397517397519397541397543397547397549397567397589397591397597397633397643397673397687397697397721397723397729397751397753397757397759397763397799397807397811397829397849397867397897397907397921397939397951397963397973397981398011398023398029398033398039398053398059398063398077398087398113398117398119398129398143398149398171398207398213398219398227398249398261398267398273398287398303398311398323398339398341398347398353398357398369398393398407398417398423398441398459398467398471398473398477398491398509398539398543398549398557398569398581398591398609398611398621398627398669398681398683398693398711398729398731398759398771398813398819398821398833398857398863398887398903398917398921398933398941398969398977398989399023399031399043399059399067399071399079399097399101399107399131399137399149399151399163399173399181399197399221399227399239399241399263399271399277399281399283399353399379399389399391399401399403399409399433399439399473399481399491399493399499399523399527399541399557399571399577399583399587399601399613399617399643399647399667399677399689399691399719399727399731399739399757399761399769399781399787399793399851399853399871399887399899399911399913399937399941399953399979399983399989400009400031400033400051400067400069400087400093400109400123400151400157400187400199400207400217400237400243400247400249400261400277400291400297400307400313400321400331400339400381400391400409400417400429400441400457400471400481400523400559400579400597400601400607400619400643400651400657400679400681400703400711400721400723400739400753400759400823400837400849400853400859400871400903400927400931400943400949400963400997401017401029401039401053401057401069401077401087401101401113401119401161401173401179401201401209401231401237401243401279401287401309401311401321401329401341401347401371401381401393401407401411401417401473401477401507401519401537401539401551401567401587401593401627401629401651401669401671401689401707401711401743401771401773401809401813401827401839401861401867401887401903401909401917401939401953401957401959401981401987401993402023402029402037402043402049402053402071402089402091402107402131402133402137402139402197402221402223402239402253402263402277402299402307402313402329402331402341402343402359402361402371402379402383402403402419402443402487402503402511402517402527402529402541402551402559402581402583402587402593402601402613402631402691402697402739402751402757402761402763402767402769402797402803402817402823402847402851402859402863402869402881402923402943402947402949402991403001403003403037403043403049403057403061403063403079403097403103403133403141403159403163403181403219403241403243403253403261403267403289403301403309403327403331403339403363403369403387403391403433403439403483403499403511403537403547403549403553403567403577403591403603403607403621403649403661403679403681403687403703403717403721403729403757403783403787403817403829403831403849403861403867403877403889403901403933403951403957403969403979403981403993404009404011404017404021404029404051404081404099404113404119404123404161404167404177404189404191404197404213404221404249404251404267404269404273404291404309404321404323404357404381404387404389404399404419404423404429404431404449404461404483404489404497404507404513404527404531404533404539404557404597404671404693404699404713404773404779404783404819404827404837404843404849404851404941404951404959404969404977404981404983405001405011405029405037405047405049405071405073405089405091405143405157405179405199405211405221405227405239405241405247405253405269405277405287405299405323405341405343405347405373405401405407405413405437405439405473405487405491405497405499405521405527405529405541405553405577405599405607405611405641405659405667405677405679405683405689405701405703405709405719405731405749405763405767405781405799405817405827405829405857405863405869405871405893405901405917405947405949405959405967405989405991405997406013406027406037406067406073406093406117406123406169406171406177406183406207406247406253406267406271406309406313406327406331406339406349406361406381406397406403406423406447406481406499406501406507406513406517406531406547406559406561406573406577406579406583406591406631406633406649406661406673406697406699406717406729406739406789406807406811406817406837406859406873406883406907406951406969406981406993407023407047407059407083407119407137407149407153407177407179407191407203407207407219407221407233407249407257407263407273407287407291407299407311407317407321407347407357407359407369407377407383407401407437407471407483407489407501407503407509407521407527407567407573407579407587407599407621407633407639407651407657407669407699407707407713407717407723407741407747407783407789407791407801407807407821407833407843407857407861407879407893407899407917407923407947407959407969407971407977407993408011408019408041408049408071408077408091408127408131408137408169408173408197408203408209408211408217408223408229408241408251408263408271408283408311408337408341408347408361408379408389408403408413408427408431408433408437408461408469408479408491408497408533408539408553408563408607408623408631408637408643408659408677408689408691408701408703408713408719408743408763408769408773408787408803408809408817408841408857408869408911408913408923408943408953408959408971408979408997409007409021409027409033409043409063409069409081409099409121409153409163409177409187409217409237409259409261409267409271409289409291409327409333409337409349409351409369409379409391409397409429409433409441409463409471409477409483409499409517409523409529409543409573409579409589409597409609409639409657409691409693409709409711409723409729409733409753409769409777409781409813409817409823409831409841409861409867409879409889409891409897409901409909409933409943409951409961409967409987409993409999410009410029410063410087410093410117410119410141410143410149410171410173410203410231410233410239410243410257410279410281410299410317410323410339410341410353410359410383410387410393410401410411410413410453410461410477410489410491410497410507410513410519410551410561410587410617410621410623410629410651410659410671410687410701410717410731410741410747410749410759410783410789410801410807410819410833410857410899410903410929410953410983410999411001411007411011411013411031411041411049411067411071411083411101411113411119411127411143411157411167411193411197411211411233411241411251411253411259411287411311411337411347411361411371411379411409411421411443411449411469411473411479411491411503411527411529411557411563411569411577411583411589411611411613411617411637411641411667411679411683411703411707411709411721411727411737411739411743411751411779411799411809411821411823411833411841411883411919411923411937411941411947411967411991412001412007412019412031412033412037412039412051412067412073412081412099412109412123412127412133412147412157412171412187412189412193412201412211412213412219412249412253412273412277412289412303412333412339412343412387412397412411412457412463412481412487412493412537412561412567412571412589412591412603412609412619412627412637412639412651412663412667412717412739412771412793412807412831412849412859412891412901412903412939412943412949412967412987413009413027413033413053413069413071413081413087413089413093413111413113413129413141413143413159413167413183413197413201413207413233413243413251413263413267413293413299413353413411413417413429413443413461413477413521413527413533413537413551413557413579413587413597413629413653413681413683413689413711413713413719413737413753413759413779413783413807413827413849413863413867413869413879413887413911413923413951413981414013414017414019414031414049414053414061414077414083414097414101414107414109414131414157414179414199414203414209414217414221414241414259414269414277414283414311414313414329414331414347414361414367414383414389414397414413414431414433414451414457414461414467414487414503414521414539414553414559414571414577414607414611414629414641414643414653414677414679414683414691414697414703414707414709414721414731414737414763414767414769414773414779414793414803414809414833414857414871414889414893414899414913414923414929414949414959414971414977414991415013415031415039415061415069415073415087415097415109415111415133415141415147415153415159415171415187415189415201415213415231415253415271415273415319415343415379415381415391415409415427415447415469415477415489415507415517415523415543415553415559415567415577415603415607415609415627415631415643415651415661415669415673415687415691415697415717415721415729415759415783415787415799415801415819415823415861415873415879415901415931415937415949415951415957415963415969415979415993415999416011416023416071416077416089416107416147416149416153416159416167416201416219416239416243416249416257416263416281416291416333416359416387416389416393416399416401416407416413416417416419416441416443416459416473416477416491416497416501416503416513416531416543416573416579416593416621416623416629416659416677416693416719416761416797416821416833416839416849416851416873416881416887416947416957416963416989417007417017417019417023417037417089417097417113417119417127417133417161417169417173417181417187417191417203417217417227417239417251417271417283417293417311417317417331417337417371417377417379417383417419417437417451417457417479417491417493417509417511417523417541417553417559417577417581417583417617417623417631417643417649417671417691417719417721417727417731417733417737417751417763417773417793417811417821417839417863417869417881417883417899417931417941417947417953417959417961417983417997418007418009418027418031418043418051418069418073418079418087418109418129418157418169418177418181418189418199418207418219418259418273418279418289418303418321418331418337418339418343418349418351418357418373418381418391418423418427418447418459418471418493418511418553418559418597418601418603418631418633418637418657418667418699418709418721418739418751418763418771418783418787418793418799418811418813418819418837418843418849418861418867418871418883418889418909418921418927418933418939418961418981418987418993418997419047419051419053419057419059419087419141419147419161419171419183419189419191419201419231419249419261419281419291419297419303419317419329419351419383419401419417419423419429419443419449419459419467419473419477419483419491419513419527419537419557419561419563419567419579419591419597419599419603419609419623419651419687419693419701419711419743419753419777419789419791419801419803419821419827419831419873419893419921419927419929419933419953419959419999420001420029420037420041420047420073420097420103420149420163420191420193420221420241420253420263420269420271420293420307420313420317420319420323420331420341420349420353420361420367420383420397420419420421420439420457420467420479420481420499420503420521420551420557420569420571420593420599420613420671420677420683420691420731420737420743420757420769420779420781420799420803420809420811420851420853420857420859420899420919420929420941420967420977420997421009421019421033421037421049421079421081421093421103421121421123421133421147421159421163421177421181421189421207421241421273421279421303421313421331421339421349421361421381421397421409421417421423421433421453421459421469421471421483421493421501421517421559421607421609421621421633421639421643421657421661421691421697421699421703421709421711421717421727421739421741421783421801421807421831421847421891421907421913421943421973421987421997422029422041422057422063422069422077422083422087422089422099422101422111422113422129422137422141422183422203422209422231422239422243422249422267422287422291422309422311422321422339422353422363422369422377422393422407422431422453422459422479422537422549422551422557422563422567422573422581422621422627422657422689422701422707422711422749422753422759422761422789422797422803422827422857422861422867422869422879422881422893422897422899422911422923422927422969422987423001423013423019423043423053423061423067423083423091423097423103423109423121423127423133423173423179423191423209423221423229423233423251423257423259423277423281423287423289423299423307423323423341423347423389423403423413423427423431423439423457423461423463423469423481423497423503423509423541423547423557423559423581423587423601423617423649423667423697423707423713423727423749423751423763423769423779423781423791423803423823423847423853423859423869423883423887423931423949423961423977423989423991424001424003424007424019424027424037424079424091424093424103424117424121424129424139424147424157424163424169424187424199424223424231424243424247424261424267424271424273424313424331424339424343424351424397424423424429424433424451424471424481424493424519424537424547424549424559424573424577424597424601424639424661424667424679424687424693424709424727424729424757424769424771424777424811424817424819424829424841424843424849424861424867424889424891424903424909424913424939424961424967424997425003425027425039425057425059425071425083425101425107425123425147425149425189425197425207425233425237425251425273425279425281425291425297425309425317425329425333425363425377425387425393425417425419425423425441425443425471425473425489425501425519425521425533425549425563425591425603425609425641425653425681425701425713425779425783425791425801425813425819425837425839425851425857425861425869425879425899425903425911425939425959425977425987425989426007426011426061426073426077426089426091426103426131426161426163426193426197426211426229426233426253426287426301426311426319426331426353426383426389426401426407426421426427426469426487426527426541426551426553426563426583426611426631426637426641426661426691426697426707426709426731426737426739426743426757426761426763426773426779426787426799426841426859426863426871426889426893426913426917426919426931426941426971426973426997427001427013427039427043427067427069427073427079427081427103427117427151427169427181427213427237427241427243427247427249427279427283427307427309427327427333427351427369427379427381427403427417427421427423427429427433427439427447427451427457427477427513427517427523427529427541427579427591427597427619427621427681427711427717427723427727427733427751427781427787427789427813427849427859427877427879427883427913427919427939427949427951427957427967427969427991427993427997428003428023428027428033428039428041428047428083428093428137428143428147428149428161428167428173428177428221428227428231428249428251428273428297428299428303428339428353428369428401428411428429428471428473428489428503428509428531428539428551428557428563428567428569428579428629428633428639428657428663428671428677428683428693428731428741428759428777428797428801428807428809428833428843428851428863428873428899428951428957428977429007429017429043429083429101429109429119429127429137429139429161429181429197429211429217429223429227429241429259429271429277429281429283429329429347429349429361429367429389429397429409429413429427429431429449429463429467429469429487429497429503429509429511429521429529429547429551429563429581429587429589429599429631429643429659429661429673429677429679429683429701429719429727429731429733429773429791429797429817429823429827429851429853429881429887429889429899429901429907429911429917429929429931429937429943429953429971429973429991430007430009430013430019430057430061430081430091430093430121430139430147430193430259430267430277430279430289430303430319430333430343430357430393430411430427430433430453430487430499430511430513430517430543430553430571430579430589430601430603430649430663430691430697430699430709430723430739430741430747430751430753430769430783430789430799430811430819430823430841430847430861430873430879430883430891430897430907430909430921430949430957430979430981430987430999431017431021431029431047431051431063431077431083431099431107431141431147431153431173431191431203431213431219431237431251431257431267431269431287431297431311431329431339431363431369431377431381431399431423431429431441431447431449431479431513431521431533431567431581431597431603431611431617431621431657431659431663431671431693431707431729431731431759431777431797431801431803431807431831431833431857431863431867431869431881431887431891431903431911431929431933431947431983431993432001432007432023432031432037432043432053432059432067432073432097432121432137432139432143432149432161432163432167432199432203432227432241432251432277432281432287432301432317432323432337432343432349432359432373432389432391432401432413432433432437432449432457432479432491432499432503432511432527432539432557432559432569432577432587432589432613432631432637432659432661432713432721432727432737432743432749432781432793432797432799432833432847432857432869432893432907432923432931432959432961432979432983432989433003433033433049433051433061433073433079433087433093433099433117433123433141433151433187433193433201433207433229433241433249433253433259433261433267433271433291433309433319433337433351433357433361433369433373433393433399433421433429433439433453433469433471433501433507433513433549433571433577433607433627433633433639433651433661433663433673433679433681433703433723433729433747433759433777433781433787433813433817433847433859433861433877433883433889433931433943433963433967433981434009434011434029434039434081434087434107434111434113434117434141434167434179434191434201434209434221434237434243434249434261434267434293434297434303434311434323434347434353434363434377434383434387434389434407434411434431434437434459434461434471434479434501434509434521434561434563434573434593434597434611434647434659434683434689434699434717434719434743434761434783434803434807434813434821434827434831434839434849434857434867434873434881434909434921434923434927434933434939434947434957434963434977434981434989435037435041435059435103435107435109435131435139435143435151435161435179435181435187435191435221435223435247435257435263435277435283435287435307435317435343435349435359435371435397435401435403435419435427435437435439435451435481435503435529435541435553435559435563435569435571435577435583435593435619435623435637435641435647435649435653435661435679435709435731435733435739435751435763435769435779435817435839435847435857435859435881435889435893435907435913435923435947435949435973435983435997436003436013436027436061436081436087436091436097436127436147436151436157436171436181436217436231436253436273436279436283436291436307436309436313436343436357436399436417436427436439436459436463436477436481436483436507436523436529436531436547436549436571436591436607436621436627436649436651436673436687436693436717436727436729436739436741436757436801436811436819436831436841436853436871436889436913436957436963436967436973436979436993436999437011437033437071437077437083437093437111437113437137437141437149437153437159437191437201437219437237437243437263437273437279437287437293437321437351437357437363437387437389437401437413437467437471437473437497437501437509437519437527437533437539437543437557437587437629437641437651437653437677437681437687437693437719437729437743437753437771437809437819437837437849437861437867437881437909437923437947437953437959437977438001438017438029438047438049438091438131438133438143438169438203438211438223438233438241438253438259438271438281438287438301438313438329438341438377438391438401438409438419438439438443438467438479438499438517438521438523438527438533438551438569438589438601438611438623438631438637438661438667438671438701438707438721438733438761438769438793438827438829438833438847438853438869438877438887438899438913438937438941438953438961438967438979438983438989439007439009439063439081439123439133439141439157439163439171439183439199439217439253439273439279439289439303439339439349439357439367439381439409439421439427439429439441439459439463439471439493439511439519439541439559439567439573439577439583439601439613439631439639439661439667439687439693439697439709439723439729439753439759439763439771439781439787439799439811439823439849439853439861439867439883439891439903439919439949439961439969439973439981439991440009440023440039440047440087440093440101440131440159440171440177440179440183440203440207440221440227440239440261440269440281440303440311440329440333440339440347440371440383440389440393440399440431440441440443440471440497440501440507440509440527440537440543440549440551440567440569440579440581440641440651440653440669440677440681440683440711440717440723440731440753440761440773440807440809440821440831440849440863440893440903440911440939440941440953440959440983440987440989441011441029441041441043441053441073441079441101441107441109441113441121441127441157441169441179441187441191441193441229441247441251441257441263441281441307441319441349441359441361441403441421441443441449441461441479441499441517441523441527441547441557441563441569441587441607441613441619441631441647441667441697441703441713441737441751441787441797441799441811441827441829441839441841441877441887441907441913441923441937441953441971442003442007442009442019442027442031442033442061442069442097442109442121442139442147442151442157442171442177442181442193442201442207442217442229442237442243442271442283442291442319442327442333442363442367442397442399442439442447442457442469442487442489442499442501442517442531442537442571442573442577442579442601442609442619442633442691442699442703442721442733442747442753442763442769442777442781442789442807442817442823442829442831442837442843442861442879442903442919442961442963442973442979442987442991442997443011443017443039443041443057443059443063443077443089443117443123443129443147443153443159443161443167443171443189443203443221443227443231443237443243443249443263443273443281443291443293443341443347443353443363443369443389443407443413443419443423443431443437443453443467443489443501443533443543443551443561443563443567443587443591443603443609443629443659443687443689443701443711443731443749443753443759443761443771443777443791443837443851443867443869443873443879443881443893443899443909443917443939443941443953443983443987443999444001444007444029444043444047444079444089444109444113444121444127444131444151444167444173444179444181444187444209444253444271444281444287444289444293444307444341444343444347444349444401444403444421444443444449444461444463444469444473444487444517444523444527444529444539444547444553444557444569444589444607444623444637444641444649444671444677444701444713444739444767444791444793444803444811444817444833444841444859444863444869444877444883444887444893444901444929444937444953444967444971444979445001445019445021445031445033445069445087445091445097445103445141445157445169445183445187445199445229445261445271445279445283445297445307445321445339445363445427445433445447445453445463445477445499445507445537445541445567445573445583445589445597445619445631445633445649445657445691445699445703445741445747445769445771445789445799445807445829445847445853445871445877445883445891445931445937445943445967445969446003446009446041446053446081446087446111446123446129446141446179446189446191446197446221446227446231446261446263446273446279446293446309446323446333446353446363446387446389446399446401446417446441446447446461446473446477446503446533446549446561446569446597446603446609446647446657446713446717446731446753446759446767446773446819446827446839446863446881446891446893446909446911446921446933446951446969446983447001447011447019447053447067447079447101447107447119447133447137447173447179447193447197447211447217447221447233447247447257447259447263447311447319447323447331447353447401447409447427447439447443447449447451447463447467447481447509447521447527447541447569447571447611447617447637447641447677447683447701447703447743447749447757447779447791447793447817447823447827447829447841447859447877447883447893447901447907447943447961447983447991448003448013448027448031448057448067448073448093448111448121448139448141448157448159448169448177448187448193448199448207448241448249448303448309448313448321448351448363448367448373448379448387448397448421448451448519448531448561448597448607448627448631448633448667448687448697448703448727448733448741448769448793448801448807448829448843448853448859448867448871448873448879448883448907448927448939448969448993448997448999449003449011449051449077449083449093449107449117449129449131449149449153449161449171449173449201449203449209449227449243449249449261449263449269449287449299449303449311449321449333449347449353449363449381449399449411449417449419449437449441449459449473449543449549449557449563449567449569449591449609449621449629449653449663449671449677449681449689449693449699449741449759449767449773449783449797449807449821449833449851449879449921449929449941449951449959449963449971449987449989450001450011450019450029450067450071450077450083450101450103450113450127450137450161450169450193450199450209450217450223450227450239450257450259450277450287450293450299450301450311450343450349450361450367450377450383450391450403450413450421450431450451450473450479450481450487450493450503450529450533450557450563450581450587450599450601450617450641450643450649450677450691450707450719450727450761450767450787450797450799450803450809450811450817450829450839450841450847450859450881450883450887450893450899450913450917450929450943450949450971450991450997451013451039451051451057451069451093451097451103451109451159451177451181451183451201451207451249451277451279451301451303451309451313451331451337451343451361451387451397451411451439451441451481451499451519451523451541451547451553451579451601451609451621451637451657451663451667451669451679451681451691451699451709451723451747451753451771451783451793451799451823451831451837451859451873451879451897451901451903451909451921451933451937451939451961451967451987452009452017452027452033452041452077452083452087452131452159452161452171452191452201452213452227452233452239452269452279452293452297452329452363452377452393452401452443452453452497452519452521452531452533452537452539452549452579452587452597452611452629452633452671452687452689452701452731452759452773452797452807452813452821452831452857452869452873452923452953452957452983452989453023453029453053453073453107453119453133453137453143453157453161453181453197453199453209453217453227453239453247453269453289453293453301453311453317453329453347453367453371453377453379453421453451453461453527453553453559453569453571453599453601453617453631453637453641453643453659453667453671453683453703453707453709453737453757453797453799453823453833453847453851453877453889453907453913453923453931453949453961453977453983453991454009454021454031454033454039454061454063454079454109454141454151454159454183454199454211454213454219454229454231454247454253454277454297454303454313454331454351454357454361454379454387454409454417454451454453454483454501454507454513454541454543454547454577454579454603454609454627454637454673454679454709454711454721454723454759454763454777454799454823454843454847454849454859454889454891454907454919454921454931454943454967454969454973454991455003455011455033455047455053455093455099455123455149455159455167455171455177455201455219455227455233455237455261455263455269455291455309455317455321455333455339455341455353455381455393455401455407455419455431455437455443455461455471455473455479455489455491455513455527455531455537455557455573455579455597455599455603455627455647455659455681455683455687455701455711455717455737455761455783455789455809455827455831455849455863455881455899455921455933455941455953455969455977455989455993455999456007456013456023456037456047456061456091456107456109456119456149456151456167456193456223456233456241456283456293456329456349456353456367456377456403456409456427456439456451456457456461456499456503456517456523456529456539456553456557456559456571456581456587456607456611456613456623456641456647456649456653456679456683456697456727456737456763456767456769456791456809456811456821456871456877456881456899456901456923456949456959456979456991457001457003457013457021457043457049457057457087457091457097457099457117457139457151457153457183457189457201457213457229457241457253457267457271457277457279457307457319457333457339457363457367457381457393457397457399457403457411457421457433457459457469457507457511457517457547457553457559457571457607457609457621457643457651457661457669457673457679457687457697457711457739457757457789457799457813457817457829457837457871457889457903457913457943457979457981457987458009458027458039458047458053458057458063458069458119458123458173458179458189458191458197458207458219458239458309458317458323458327458333458357458363458377458399458401458407458449458477458483458501458531458533458543458567458569458573458593458599458611458621458629458639458651458663458669458683458701458719458729458747458789458791458797458807458819458849458863458879458891458897458917458921458929458947458957458959458963458971458977458981458987458993459007459013459023459029459031459037459047459089459091459113459127459167459169459181459209459223459229459233459257459271459293459301459313459317459337459341459343459353459373459377459383459397459421459427459443459463459467459469459479459509459521459523459593459607459611459619459623459631459647459649459671459677459691459703459749459763459791459803459817459829459841459847459883459913459923459929459937459961460013460039460051460063460073460079460081460087460091460099460111460127460147460157460171460181460189460211460217460231460247460267460289460297460301460337460349460373460379460387460393460403460409460417460451460463460477460531460543460561460571460589460609460619460627460633460637460643460657460673460697460709460711460721460771460777460787460793460813460829460841460843460871460891460903460907460913460919460937460949460951460969460973460979460981460987460991461009461011461017461051461053461059461093461101461119461143461147461171461183461191461207461233461239461257461269461273461297461299461309461317461323461327461333461359461381461393461407461411461413461437461441461443461467461479461507461521461561461569461581461599461603461609461627461639461653461677461687461689461693461707461717461801461803461819461843461861461887461891461917461921461933461957461971461977461983462013462041462067462073462079462097462103462109462113462131462149462181462191462199462221462239462263462271462307462311462331462337462361462373462377462401462409462419462421462437462443462467462481462491462493462499462529462541462547462557462569462571462577462589462607462629462641462643462653462659462667462673462677462697462713462719462727462733462739462773462827462841462851462863462871462881462887462899462901462911462937462947462953462983463003463031463033463093463103463157463181463189463207463213463219463231463237463247463249463261463283463291463297463303463313463319463321463339463343463363463387463399463433463447463451463453463457463459463483463501463511463513463523463531463537463549463579463613463627463633463643463649463663463679463693463711463717463741463747463753463763463781463787463807463823463829463831463849463861463867463873463889463891463907463919463921463949463963463973463987463993464003464011464021464033464047464069464081464089464119464129464131464137464141464143464171464173464197464201464213464237464251464257464263464279464281464291464309464311464327464351464371464381464383464413464419464437464447464459464467464479464483464521464537464539464549464557464561464587464591464603464617464621464647464663464687464699464741464747464749464753464767464771464773464777464801464803464809464813464819464843464857464879464897464909464917464923464927464939464941464951464953464963464983464993464999465007465011465013465019465041465061465067465071465077465079465089465107465119465133465151465161465163465167465169465173465187465209465211465259465271465277465281465293465299465317465319465331465337465373465379465383465407465419465433465463465469465523465529465541465551465581465587465611465631465643465649465659465679465701465721465739465743465761465781465797465799465809465821465833465841465887465893465901465917465929465931465947465977465989466009466019466027466033466043466061466069466073466079466087466091466121466139466153466171466181466183466201466243466247466261466267466273466283466303466321466331466339466357466369466373466409466423466441466451466483466517466537466547466553466561466567466573466579466603466619466637466649466651466673466717466723466729466733466747466751466777466787466801466819466853466859466897466909466913466919466951466957466997467003467009467017467021467063467081467083467101467119467123467141467147467171467183467197467209467213467237467239467261467293467297467317467329467333467353467371467399467417467431467437467447467471467473467477467479467491467497467503467507467527467531467543467549467557467587467591467611467617467627467629467633467641467651467657467669467671467681467689467699467713467729467737467743467749467773467783467813467827467833467867467869467879467881467893467897467899467903467927467941467953467963467977468001468011468019468029468049468059468067468071468079468107468109468113468121468133468137468151468157468173468187468191468199468239468241468253468271468277468289468319468323468353468359468371468389468421468439468451468463468473468491468493468499468509468527468551468557468577468581468593468599468613468619468623468641468647468653468661468667468683468691468697468703468709468719468737468739468761468773468781468803468817468821468841468851468859468869468883468887468889468893468899468913468953468967468973468983469009469031469037469069469099469121469127469141469153469169469193469207469219469229469237469241469253469267469279469283469303469321469331469351469363469367469369469379469397469411469429469439469457469487469501469529469541469543469561469583469589469613469627469631469649469657469673469687469691469717469723469747469753469757469769469787469793469801469811469823469841469849469877469879469891469907469919469939469957469969469979469993470021470039470059470077470081470083470087470089470131470149470153470161470167470179470201470207470209470213470219470227470243470251470263470279470297470299470303470317470333470347470359470389470399470411470413470417470429470443470447470453470461470471470473470489470501470513470521470531470539470551470579470593470597470599470609470621470627470647470651470653470663470669470689470711470719470731470749470779470783470791470819470831470837470863470867470881470887470891470903470927470933470941470947470957470959470993470999471007471041471061471073471089471091471101471137471139471161471173471179471187471193471209471217471241471253471259471277471281471283471299471301471313471353471389471391471403471407471439471451471467471481471487471503471509471521471533471539471553471571471589471593471607471617471619471641471649471659471671471673471677471683471697471703471719471721471749471769471781471791471803471817471841471847471853471871471893471901471907471923471929471931471943471949471959471997472019472027472051472057472063472067472103472111472123472127472133472139472151472159472163472189472193472247472249472253472261472273472289472301472309472319472331472333472349472369472391472393472399472411472421472457472469472477472523472541472543472559472561472573472597472631472639472643472669472687472691472697472709472711472721472741472751472763472793472799472817472831472837472847472859472883472907472909472921472937472939472963472993473009473021473027473089473101473117473141473147473159473167473173473191473197473201473203473219473227473257473279473287473293473311473321473327473351473353473377473381473383473411473419473441473443473453473471473477473479473497473503473507473513473519473527473531473533473549473579473597473611473617473633473647473659473719473723473729473741473743473761473789473833473839473857473861473867473887473899473911473923473927473929473939473951473953473971473981473987473999474017474029474037474043474049474059474073474077474101474119474127474137474143474151474163474169474197474211474223474241474263474289474307474311474319474337474343474347474359474379474389474391474413474433474437474443474479474491474497474499474503474533474541474547474557474569474571474581474583474619474629474647474659474667474671474707474709474737474751474757474769474779474787474809474811474839474847474857474899474907474911474917474923474931474937474941474949474959474977474983475037475051475073475081475091475093475103475109475141475147475151475159475169475207475219475229475243475271475273475283475289475297475301475327475331475333475351475367475369475379475381475403475417475421475427475429475441475457475469475483475511475523475529475549475583475597475613475619475621475637475639475649475669475679475681475691475693475697475721475729475751475753475759475763475777475789475793475807475823475831475837475841475859475877475879475889475897475903475907475921475927475933475957475973475991475997476009476023476027476029476039476041476059476081476087476089476101476107476111476137476143476167476183476219476233476237476243476249476279476299476317476347476351476363476369476381476401476407476419476423476429476467476477476479476507476513476519476579476587476591476599476603476611476633476639476647476659476681476683476701476713476719476737476743476753476759476783476803476831476849476851476863476869476887476891476911476921476929476977476981476989477011477013477017477019477031477047477073477077477091477131477149477163477209477221477229477259477277477293477313477317477329477341477359477361477383477409477439477461477469477497477511477517477523477539477551477553477557477571477577477593477619477623477637477671477677477721477727477731477739477767477769477791477797477809477811477821477823477839477847477857477863477881477899477913477941477947477973477977477991478001478039478063478067478069478087478099478111478129478139478157478169478171478189478199478207478213478241478243478253478259478271478273478321478339478343478351478391478399478403478411478417478421478427478433478441478451478453478459478481478483478493478523478531478571478573478579478589478603478627478631478637478651478679478697478711478727478729478739478741478747478763478769478787478801478811478813478823478831478843478853478861478871478879478897478901478913478927478931478937478943478963478967478991478999479023479027479029479041479081479131479137479147479153479189479191479201479209479221479231479239479243479263479267479287479299479309479317479327479357479371479377479387479419479429479431479441479461479473479489479497479509479513479533479543479561479569479581479593479599479623479629479639479701479749479753479761479771479777479783479797479813479821479833479839479861479879479881479891479903479909479939479951479953479957479971480013480017480019480023480043480047480049480059480061480071480091480101480107480113480133480143480157480167480169480203480209480287480299480317480329480341480343480349480367480373480379480383480391480409480419480427480449480451480461480463480499480503480509480517480521480527480533480541480553480563480569480583480587480647480661480707480713480731480737480749480761480773480787480803480827480839480853480881480911480919480929480937480941480959480967480979480989481001481003481009481021481043481051481067481073481087481093481097481109481123481133481141481147481153481157481171481177481181481199481207481211481231481249481297481301481303481307481343481363481373481379481387481409481417481433481447481469481489481501481513481531481549481571481577481589481619481633481639481651481667481673481681481693481697481699481721481751481753481769481787481801481807481813481837481843481847481849481861481867481879481883481909481939481963481997482017482021482029482033482039482051482071482093482099482101482117482123482179482189482203482213482227482231482233482243482263482281482309482323482347482351482359482371482387482393482399482401482407482413482423482437482441482483482501482507482509482513482519482527482539482569482593482597482621482627482633482641482659482663482683482687482689482707482711482717482719482731482743482753482759482767482773482789482803482819482827482837482861482863482873482897482899482917482941482947482957482971483017483031483061483071483097483127483139483163483167483179483209483211483221483229483233483239483247483251483281483289483317483323483337483347483367483377483389483397483407483409483433483443483467483481483491483499483503483523483541483551483557483563483577483611483619483629483643483649483671483697483709483719483727483733483751483757483761483767483773483787483809483811483827483829483839483853483863483869483883483907483929483937483953483971483991484019484027484037484061484067484079484091484111484117484123484129484151484153484171484181484193484201484207484229484243484259484283484301484303484327484339484361484369484373484397484411484417484439484447484457484459484487484489484493484531484543484577484597484607484609484613484621484639484643484691484703484727484733484751484763484769484777484787484829484853484867484927484951484987484999485021485029485041485053485059485063485081485101485113485123485131485137485161485167485171485201485207485209485263485311485347485351485363485371485383485389485411485417485423485437485447485479485497485509485519485543485567485587485593485603485609485647485657485671485689485701485717485729485731485753485777485819485827485831485833485893485899485909485923485941485959485977485993486023486037486041486043486053486061486071486091486103486119486133486139486163486179486181486193486203486221486223486247486281486293486307486313486323486329486331486341486349486377486379486389486391486397486407486433486443486449486481486491486503486509486511486527486539486559486569486583486589486601486617486637486641486643486653486667486671486677486679486683486697486713486721486757486767486769486781486797486817486821486833486839486869486907486923486929486943486947486949486971486977486991487007487013487021487049487051487057487073487079487093487099487111487133487177487183487187487211487213487219487247487261487283487303487307487313487349487363487381487387487391487397487423487427487429487447487457487463487469487471487477487481487489487507487561487589487601487603487607487637487649487651487657487681487691487703487709487717487727487733487741487757487769487783487789487793487811487819487829487831487843487873487889487891487897487933487943487973487979487997488003488009488011488021488051488057488069488119488143488149488153488161488171488197488203488207488209488227488231488233488239488249488261488263488287488303488309488311488317488321488329488333488339488347488353488381488399488401488407488417488419488441488459488473488503488513488539488567488573488603488611488617488627488633488639488641488651488687488689488701488711488717488723488729488743488749488759488779488791488797488821488827488833488861488879488893488897488909488921488947488959488981488993489001489011489019489043489053489061489101489109489113489127489133489157489161489179489191489197489217489239489241489257489263489283489299489329489337489343489361489367489389489407489409489427489431489439489449489457489479489487489493489529489539489551489553489557489571489613489631489653489659489673489677489679489689489691489733489743489761489791489793489799489803489817489823489833489847489851489869489871489887489901489911489913489941489943489959489961489977489989490001490003490019490031490033490057490097490103490111490117490121490151490159490169490183490201490207490223490241490247490249490267490271490277490283490309490313490339490367490393490417490421490453490459490463490481490493490499490519490537490541490543490549490559490571490573490577490579490591490619490627490631490643490661490663490697490733490741490769490771490783490829490837490849490859490877490891490913490921490927490937490949490951490957490967490969490991490993491003491039491041491059491081491083491129491137491149491159491167491171491201491213491219491251491261491273491279491297491299491327491329491333491339491341491353491357491371491377491417491423491429491461491483491489491497491501491503491527491531491537491539491581491591491593491611491627491633491639491651491653491669491677491707491719491731491737491747491773491783491789491797491819491833491837491851491857491867491873491899491923491951491969491977491983492007492013492017492029492047492053492059492061492067492077492083492103492113492227492251492253492257492281492293492299492319492377492389492397492403492409492413492421492431492463492467492487492491492511492523492551492563492587492601492617492619492629492631492641492647492659492671492673492707492719492721492731492757492761492763492769492781492799492839492853492871492883492893492901492911492967492979493001493013493021493027493043493049493067493093493109493111493121493123493127493133493139493147493159493169493177493193493201493211493217493219493231493243493249493277493279493291493301493313493333493351493369493393493397493399493403493433493447493457493463493481493523493531493541493567493573493579493583493607493621493627493643493657493693493709493711493721493729493733493747493777493793493807493811493813493817493853493859493873493877493897493919493931493937493939493967493973493979493993494023494029494041494051494069494077494083494093494101494107494129494141494147494167494191494213494237494251494257494267494269494281494287494317494327494341494353494359494369494381494383494387494407494413494441494443494471494497494519494521494539494561494563494567494587494591494609494617494621494639494647494651494671494677494687494693494699494713494719494723494731494737494743494749494759494761494783494789494803494843494849494873494899494903494917494927494933494939494959494987495017495037495041495043495067495071495109495113495119495133495139495149495151495161495181495199495211495221495241495269495277495289495301495307495323495337495343495347495359495361495371495377495389495401495413495421495433495437495449495457495461495491495511495527495557495559495563495569495571495587495589495611495613495617495619495629495637495647495667495679495701495707495713495749495751495757495769495773495787495791495797495799495821495827495829495851495877495893495899495923495931495947495953495959495967495973495983496007496019496039496051496063496073496079496123496127496163496187496193496211496229496231496259496283496289496291496297496303496313496333496339496343496381496399496427496439496453496459496471496477496481496487496493496499496511496549496579496583496609496631496669496681496687496703496711496733496747496763496789496813496817496841496849496871496877496889496891496897496901496913496919496949496963496997496999497011497017497041497047497051497069497093497111497113497117497137497141497153497171497177497197497239497257497261497269497279497281497291497297497303497309497323497339497351497389497411497417497423497449497461497473497479497491497501497507497509497521497537497551497557497561497579497587497597497603497633497659497663497671497677497689497701497711497719497729497737497741497771497773497801497813497831497839497851497867497869497873497899497929497957497963497969497977497989497993497999498013498053498061498073498089498101498103498119498143498163498167498181498209498227498257498259498271498301498331498343498361498367498391498397498401498403498409498439498461498467498469498493498497498521498523498527498551498557498577498583498599498611498613498643498647498653498679498689498691498733498739498749498761498767498779498781498787498791498803498833498857498859498881498907498923498931498937498947498961498973498977498989499021499027499033499039499063499067499099499117499127499129499133499139499141499151499157499159499181499183499189499211499229499253499267499277499283499309499321499327499349499361499363499391499397499403499423499439499459499481499483499493499507499519499523499549499559499571499591499601499607499621499633499637499649499661499663499669499673499679499687499691499693499711499717499729499739499747499781499787499801499819499853499879499883499897499903499927499943499957499969499973499979500009500029500041500057500069500083500107500111500113500119500153500167500173500177500179500197500209500231500233500237500239500249500257500287500299500317500321500333500341500363500369500389500393500413500417500431500443500459500471500473500483500501500509500519500527500567500579500587500603500629500671500677500693500699500713500719500723500729500741500777500791500807500809500831500839500861500873500881500887500891500909500911500921500923500933500947500953500957500977501001501013501019501029501031501037501043501077501089501103501121501131501133501139501157501173501187501191501197501203501209501217501223501229501233501257501271501287501299501317501341501343501367501383501401501409501419501427501451501463501493501503501511501563501577501593501601501617501623501637501659501691501701501703501707501719501731501769501779501803501817501821501827501829501841501863501889501911501931501947501953501967501971501997502001502013502039502043502057502063502079502081502087502093502121502133502141502171502181502217502237502247502259502261502277502301502321502339502393502409502421502429502441502451502487502499502501502507502517502543502549502553502591502597502613502631502633502643502651502669502687502699502703502717502729502769502771502781502787502807502819502829502841502847502861502883502919502921502937502961502973503003503017503039503053503077503123503131503137503147503159503197503207503213503227503231503233503249503267503287503297503303503317503339503351503359503369503381503383503389503407503413503423503431503441503453503483503501503543503549503551503563503593503599503609503611503621503623503647503653503663503707503717503743503753503771503777503779503791503803503819503821503827503851503857503869503879503911503927503929503939503947503959503963503969503983503989504001504011504017504047504061504073504103504121504139504143504149504151504157504181504187504197504209504221504247504269504289504299504307504311504323504337504349504353504359504377504379504389504403504457504461504473504479504521504523504527504547504563504593504599504607504617504619504631504661504667504671504677504683504727504767504787504797504799504817504821504851504853504857504871504877504893504901504929504937504943504947504953504967504983504989504991505027505031505033505049505051505061505067505073505091505097505111505117505123505129505139505157505159505181505187505201505213505231505237505277505279505283505301505313505319505321505327505339505357505367505369505399505409505411505429505447505459505469505481505493505501505511505513505523505537505559505573505601505607505613505619505633505639505643505657505663505669505691505693505709505711505727505759505763505777505781505811505819505823505867505871505877505907505919505927505949505961505969505979506047506071506083506101506113506119506131506147506171506173506183506201506213506251506263506269506281506291506327506329506333506339506347506351506357506381506393506417506423506449506459506461506479506491506501506507506531506533506537506551506563506573506591506593506599506609506629506647506663506683506687506689506699506729506731506743506773506783506791506797506809506837506843506861506873506887506893506899506903506911506929506941506963506983506993506999507029507049507071507077507079507103507109507113507119507137507139507149507151507163507193507197507217507289507301507313507317507329507347507349507359507361507371507383507401507421507431507461507491507497507499507503507523507557507571507589507593507599507607507631507641507667507673507691507697507713507719507743507757507779507781507797507803507809507821507827507839507883507901507907507917507919507937507953507961507971507979508009508019508021508033508037508073508087508091508097508103508129508159508171508187508213508223508229508237508243508259508271508273508297508301508327508331508349508363508367508373508393508433508439508451508471508477508489508499508513508517508531508549508559508567508577508579508583508619508621508637508643508661508693508709508727508771508789508799508811508817508841508847508867508901508903508909508913508919508931508943508951508957508961508969508973508987509023509027509053509063509071509087509101509123509137509147509149509203509221509227509239509263509281509287509293509297509317509329509359509363509389509393509413509417509429509441509449509477509513509521509543509549509557509563509569509573509581509591509603509623509633509647509653509659509681509687509689509693509699509723509731509737509741509767509783509797509801509833509837509843509863509867509879509909509911509921509939509947509959509963509989510007510031510047510049510061510067510073510077510079510089510101510121510127510137510157510179510199510203510217510227510233510241510247510253510271510287510299510311510319510331510361510379510383510401510403510449510451510457510463510481510529510551510553510569510581510583510589510611510613510617510619510677510683510691510707510709510751510767510773510793510803510817510823510827510847510889510907510919510931510941510943510989511001511013511019511033511039511057511061511087511109511111511123511151511153511163511169511171511177511193511201511211511213511223511237511243511261511279511289511297511327511333511337511351511361511387511391511409511417511439511447511453511457511463511477511487511507511519511523511541511549511559511573511579511583511591511603511627511631511633511669511691511703511711511723511757511787511793511801511811511831511843511859511867511873511891511897511909511933511939511961511963511991511997512009512011512021512047512059512093512101512137512147512167512207512249512251512269512287512311512321512333512353512389512419512429512443512467512497512503512507512521512531512537512543512569512573512579512581512591512593512597512609512621512641512657512663512671512683512711512713512717512741512747512761512767512779512797512803512819512821512843512849512891512899512903512917512921512927512929512959512977512989512999513001513013513017513031513041513047513053513059513067513083513101513103513109513131513137513157513167513169513173513203513239513257513269513277513283513307513311513313513319513341513347513353513367513371513397513407513419513427513431513439513473513479513481513509513511513529513533513593513631513641513649513673513679513683513691513697513719513727513731513739513749513761513767513769513781513829513839513841513871513881513899513917513923513937513943513977513991514001514009514013514021514049514051514057514061514079514081514093514103514117514123514127514147514177514187514201514219514229514243514247514249514271514277514289514309514313514333514343514357514361514379514399514417514429514433514453514499514513514519514523514529514531514543514561514571514621514637514639514643514649514651514669514681514711514733514739514741514747514751514757514769514783514793514819514823514831514841514847514853514859514867514873514889514903514933514939514949514967515041515087515089515111515143515149515153515173515191515227515231515233515237515279515293515311515323515351515357515369515371515377515381515401515429515477515507515519515539515563515579515587515597515611515621515639515651515653515663515677515681515687515693515701515737515741515761515771515773515777515783515803515813515839515843515857515861515873515887515917515923515929515941515951515969515993516017516023516049516053516077516091516127516151516157516161516163516169516179516193516199516209516223516227516233516247516251516253516277516283516293516319516323516349516359516361516371516377516391516407516421516431516433516437516449516457516469516493516499516517516521516539516541516563516587516589516599516611516617516619516623516643516653516673516679516689516701516709516713516721516727516757516793516811516821516829516839516847516871516877516883516907516911516931516947516949516959516973516977516979516991517003517043517061517067517073517079517081517087517091517129517151517169517177517183517189517207517211517217517229517241517243517249517261517267517277517289517303517337517343517367517373517381517393517399517403517411517417517457517459517469517471517481517487517499517501517507517511517513517547517549517553517571517577517589517597517603517609517613517619517637517639517711517717517721517729517733517739517747517817517823517831517861517873517877517901517919517927517931517949517967517981517991517999518017518047518057518059518083518099518101518113518123518129518131518137518153518159518171518179518191518207518209518233518237518239518249518261518291518299518311518327518341518387518389518411518417518429518431518447518467518471518473518509518521518533518543518579518587518597518611518621518657518689518699518717518729518737518741518743518747518759518761518767518779518801518803518807518809518813518831518863518867518893518911518933518953518981518983518989519011519031519037519067519083519089519091519097519107519119519121519131519151519161519193519217519227519229519247519257519269519283519287519301519307519349519353519359519371519373519383519391519413519427519433519457519487519499519509519521519523519527519539519551519553519577519581519587519611519619519643519647519667519683519691519703519713519733519737519769519787519793519797519803519817519863519881519889519907519917519919519923519931519943519947519971519989519997520019520021520031520043520063520067520073520103520111520123520129520151520193520213520241520279520291520297520307520309520313520339520349520357520361520363520369520379520381520393520409520411520423520427520433520447520451520529520547520549520567520571520589520607520609520621520631520633520649520679520691520699520703520717520721520747520759520763520787520813520837520841520853520867520889520913520921520943520957520963520967520969520981521009521021521023521039521041521047521051521063521107521119521137521153521161521167521173521177521179521201521231521243521251521267521281521299521309521317521329521357521359521363521369521377521393521399521401521429521447521471521483521491521497521503521519521527521533521537521539521551521557521567521581521603521641521657521659521669521671521693521707521723521743521749521753521767521777521789521791521809521813521819521831521861521869521879521881521887521897521903521923521929521981521993521999522017522037522047522059522061522073522079522083522113522127522157522161522167522191522199522211522227522229522233522239522251522259522281522283522289522317522323522337522371522373522383522391522409522413522439522449522469522479522497522517522521522523522541522553522569522601522623522637522659522661522673522677522679522689522703522707522719522737522749522757522761522763522787522811522827522829522839522853522857522871522881522883522887522919522943522947522959522961522989523007523021523031523049523093523097523109523129523169523177523207523213523219523261523297523307523333523349523351523357523387523403523417523427523433523459523463523487523489523493523511523519523541523543523553523571523573523577523597523603523631523637523639523657523667523669523673523681523717523729523741523759523763523771523777523793523801523829523847523867523877523903523907523927523937523949523969523987523997524047524053524057524063524071524081524087524099524113524119524123524149524171524189524197524201524203524219524221524231524243524257524261524269524287524309524341524347524351524353524369524387524389524411524413524429524453524497524507524509524519524521524591524593524599524633524669524681524683524701524707524731524743524789524801524803524827524831524857524863524869524873524893524899524921524933524939524941524947524957524959524963524969524971524981524983524999525001525013525017525029525043525101525127525137525143525157525163525167525191525193525199525209525221525241525247525253525257525299525313525353525359525361525373525377525379525391525397525409525431525433525439525457525461525467525491525493525517525529525533525541525571525583525593525599525607525641525649525671525677525697525709525713525719525727525731525739525769525773525781525809525817525839525869525871525887525893525913525923525937525947525949525953525961525979525983526027526037526049526051526063526067526069526073526087526117526121526139526157526159526189526193526199526213526223526231526249526271526283526289526291526297526307526367526373526381526387526391526397526423526429526441526453526459526483526499526501526511526531526543526571526573526583526601526619526627526633526637526649526651526657526667526679526681526703526709526717526733526739526741526759526763526777526781526829526831526837526853526859526871526909526913526931526937526943526951526957526963526993526997527053527057527063527069527071527081527099527123527129527143527159527161527173527179527203527207527209527237527251527273527281527291527327527333527347527353527377527381527393527399527407527411527419527441527447527453527489527507527533527557527563527581527591527599527603527623527627527633527671527699527701527729527741527749527753527789527803527809527819527843527851527869527881527897527909527921527929527941527981527983527987527993528001528013528041528043528053528091528097528107528127528131528137528163528167528191528197528217528223528247528263528289528299528313528317528329528373528383528391528401528403528413528419528433528469528487528491528509528511528527528559528611528623528629528631528659528667528673528679528691528707528709528719528763528779528791528799528811528821528823528833528863528877528881528883528911528929528947528967528971528973528991529003529007529027529033529037529043529049529051529097529103529117529121529127529129529153529157529181529183529213529229529237529241529259529271529273529301529307529313529327529343529349529357529381529393529411529421529423529471529489529513529517529519529531529547529577529579529603529619529637529649529657529673529681529687529691529693529709529723529741529747529751529807529811529813529819529829529847529871529927529933529939529957529961529973529979529981529987529999530017530021530027530041530051530063530087530093530129530137530143530177530183530197530203530209530227530237530249530251530261530267530279530293530297530303530329530333530339530353530359530389530393530401530429530443530447530501530507530513530527530531530533530539530549530567530597530599530603530609530641530653530659530669530693530701530711530713530731530741530743530753530767530773530797530807530833530837530843530851530857530861530869530897530911530947530969530977530983530989531017531023531043531071531079531101531103531121531133531143531163531169531173531197531203531229531239531253531263531281531287531299531331531337531343531347531353531359531383531457531481531497531521531547531551531569531571531581531589531611531613531623531631531637531667531673531689531701531731531793531799531821531823531827531833531841531847531857531863531871531877531901531911531919531977531983531989531997532001532009532027532033532061532069532093532099532141532153532159532163532183532187532193532199532241532249532261532267532277532283532307532313532327532331532333532349532373532379532391532403532417532421532439532447532451532453532489532501532523532529532531532537532547532561532601532603532607532619532621532633532639532663532669532687532691532709532733532739532751532757532771532781532783532789532801532811532823532849532853532867532907532919532949532951532981532993532999533003533009533011533033533051533053533063533077533089533111533129533149533167533177533189533191533213533219533227533237533249533257533261533263533297533303533317533321533327533353533363533371533389533399533413533447533453533459533509533543533549533573533581533593533633533641533671533693533711533713533719533723533737533747533777533801533809533821533831533837533857533879533887533893533909533921533927533959533963533969533971533989533993533999534007534013534019534029534043534047534049534059534073534077534091534101534113534137534167534173534199534203534211534229534241534253534283534301534307534311534323534329534341534367534371534403534407534431534439534473534491534511534529534553534571534577534581534601534607534617534629534631534637534647534649534659534661534671534697534707534739534799534811534827534839534841534851534857534883534889534913534923534931534943534949534971535013535019535033535037535061535099535103535123535133535151535159535169535181535193535207535219535229535237535243535273535303535319535333535349535351535361535387535391535399535481535487535489535499535511535523535529535547535571535573535589535607535609535627535637535663535669535673535679535697535709535727535741535751535757535771535783535793535811535849535859535861535879535919535937535939535943535957535967535973535991535999536017536023536051536057536059536069536087536099536101536111536141536147536149536189536191536203536213536219536227536233536243536267536273536279536281536287536293536311536323536353536357536377536399536407536423536441536443536447536449536453536461536467536479536491536509536513536531536533536561536563536593536609536621536633536651536671536677536687536699536717536719536729536743536749536771536773536777536779536791536801536803536839536849536857536867536869536891536909536917536923536929536933536947536953536971536989536999537001537007537011537023537029537037537041537067537071537079537091537127537133537143537157537169537181537191537197537221537233537241537269537281537287537307537331537343537347537373537379537401537403537413537497537527537547537569537583537587537599537611537637537661537673537679537703537709537739537743537749537769537773537781537787537793537811537841537847537853537877537883537899537913537919537941537991538001538019538049538051538073538079538093538117538121538123538127538147538151538157538159538163538199538201538247538249538259538267538283538297538301538303538309538331538333538357538367538397538399538411538423538457538471538481538487538511538513538519538523538529538553538561538567538579538589538597538621538649538651538697538709538711538721538723538739538751538763538771538777538789538799538801538817538823538829538841538871538877538921538927538931538939538943538987539003539009539039539047539089539093539101539107539111539113539129539141539153539159539167539171539207539219539233539237539261539267539269539293539303539309539311539321539323539339539347539351539389539401539447539449539479539501539503539507539509539533539573539621539629539633539639539641539653539663539677539687539711539713539723539729539743539761539783539797539837539839539843539849539863539881539897539899539921539947539993540041540061540079540101540119540121540139540149540157540167540173540179540181540187540203540217540233540251540269540271540283540301540307540343540347540349540367540373540377540383540389540391540433540437540461540469540509540511540517540539540541540557540559540577540587540599540611540613540619540629540677540679540689540691540697540703540713540751540769540773540779540781540803540809540823540851540863540871540877540901540907540961540989541001541007541027541049541061541087541097541129541133541141541153541181541193541201541217541231541237541249541267541271541283541301541309541339541349541361541363541369541381541391541417541439541447541469541483541507541511541523541529541531541537541543541547541549541571541577541579541589541613541631541657541661541669541693541699541711541721541727541759541763541771541777541781541799541817541831541837541859541889541901541927541951541967541987541991541993541999542021542023542027542053542063542071542081542083542093542111542117542119542123542131542141542149542153542167542183542189542197542207542219542237542251542261542263542281542293542299542323542371542401542441542447542461542467542483542489542497542519542533542537542539542551542557542567542579542587542599542603542683542687542693542713542719542723542747542761542771542783542791542797542821542831542837542873542891542911542921542923542933542939542947542951542981542987542999543017543019543029543061543097543113543131543139543143543149543157543161543163543187543203543217543223543227543233543241543253543259543281543287543289543299543307543311543313543341543349543353543359543379543383543407543427543463543497543503543509543539543551543553543593543601543607543611543617543637543659543661543671543679543689543703543707543713543769543773543787543791543793543797543811543827543841543853543857543859543871543877543883543887543889543901543911543929543967543971543997544001544007544009544013544021544031544097544099544109544123544129544133544139544171544177544183544199544223544259544273544277544279544367544373544399544403544429544451544471544477544487544501544513544517544543544549544601544613544627544631544651544667544699544717544721544723544727544757544759544771544781544793544807544813544837544861544877544879544883544889544897544903544919544927544937544961544963544979545023545029545033545057545063545087545089545093545117545131545141545143545161545189545203545213545231545239545257545267545291545329545371545387545429545437545443545449545473545477545483545497545521545527545533545543545549545551545579545599545609545617545621545641545647545651545663545711545723545731545747545749545759545773545789545791545827545843545863545873545893545899545911545917545929545933545939545947545959546001546017546019546031546047546053546067546071546097546101546103546109546137546149546151546173546179546197546211546233546239546241546253546263546283546289546317546323546341546349546353546361546367546373546391546461546467546479546509546523546547546569546583546587546599546613546617546619546631546643546661546671546677546683546691546709546719546731546739546781546841546859546863546869546881546893546919546937546943546947546961546967546977547007547021547037547061547087547093547097547103547121547133547139547171547223547229547237547241547249547271547273547291547301547321547357547361547363547369547373547387547397547399547411547441547453547471547483547487547493547499547501547513547529547537547559547567547577547583547601547609547619547627547639547643547661547663547681547709547727547741547747547753547763547769547787547817547819547823547831547849547853547871547889547901547909547951547957547999548003548039548059548069548083548089548099548117548123548143548153548189548201548213548221548227548239548243548263548291548309548323548347548351548363548371548393548399548407548417548423548441548453548459548461548489548501548503548519548521548533548543548557548567548579548591548623548629548657548671548677548687548693548707548719548749548753548761548771548783548791548827548831548833548837548843548851548861548869548893548897548903548909548927548953548957548963549001549011549013549019549023549037549071549089549091549097549121549139549149549161549163549167549169549193549203549221549229549247549257549259549281549313549319549323549331549379549391549403549421549431549443549449549481549503549509549511549517549533549547549551549553549569549587549589549607549623549641549643549649549667549683549691549701549707549713549719549733549737549739549749549751549767549817549833549839549863549877549883549911549937549943549949549977549979550007550009550027550049550061550063550073550111550117550127550129550139550163550169550177550181550189550211550213550241550267550279550283550289550309550337550351550369550379550427550439550441550447550457550469550471550489550513550519550531550541550553550577550607550609550621550631550637550651550657550661550663550679550691550703550717550721550733550757550763550789550801550811550813550831550841550843550859550861550903550909550937550939550951550961550969550973550993550997551003551017551027551039551059551063551069551093551099551107551113551129551143551179551197551207551219551231551233551269551281551297551311551321551339551347551363551381551387551407551423551443551461551483551489551503551519551539551543551549551557551569551581551587551597551651551653551659551671551689551693551713551717551723551729551731551743551753551767551773551801551809551813551843551849551861551909551911551917551927551933551951551959551963551981552001552011552029552031552047552053552059552089552091552103552107552113552127552137552179552193552217552239552241552259552263552271552283552301552317552341552353552379552397552401552403552469552473552481552491552493552511552523552527552553552581552583552589552611552649552659552677552703552707552709552731552749552751552757552787552791552793552809552821552833552841552847552859552883552887552899552913552917552971552983552991553013553037553043553051553057553067553073553093553097553099553103553123553139553141553153553171553181553193553207553211553229553249553253553277553279553309553351553363553369553411553417553433553439553447553457553463553471553481553507553513553517553529553543553549553561553573553583553589553591553601553607553627553643553649553667553681553687553699553703553727553733553747553757553759553769553789553811553837553849553867553873553897553901553919553921553933553961553963553981553991554003554011554017554051554077554087554089554117554123554129554137554167554171554179554189554207554209554233554237554263554269554293554299554303554317554347554377554383554417554419554431554447554453554467554503554527554531554569554573554597554611554627554633554639554641554663554669554677554699554707554711554731554747554753554759554767554779554789554791554797554803554821554833554837554839554843554849554887554891554893554899554923554927554951554959554969554977555029555041555043555053555073555077555083555091555097555109555119555143555167555209555221555251555253555257555277555287555293555301555307555337555349555361555383555391555419555421555439555461555487555491555521555523555557555589555593555637555661555671555677555683555691555697555707555739555743555761555767555823555827555829555853555857555871555931555941555953555967556007556021556027556037556043556051556067556069556093556103556123556159556177556181556211556219556229556243556253556261556267556271556273556279556289556313556321556327556331556343556351556373556399556403556441556459556477556483556487556513556519556537556559556573556579556583556601556607556609556613556627556639556651556679556687556691556693556697556709556723556727556741556753556763556769556781556789556793556799556811556817556819556823556841556849556859556861556867556883556891556931556939556943556957556967556981556987556999557017557021557027557033557041557057557059557069557087557093557153557159557197557201557261557269557273557281557303557309557321557329557339557369557371557377557423557443557449557461557483557489557519557521557533557537557551557567557573557591557611557633557639557663557671557693557717557729557731557741557743557747557759557761557779557789557801557803557831557857557861557863557891557899557903557927557981557987558007558017558029558053558067558083558091558109558113558121558139558149558167558179558197558203558209558223558241558251558253558287558289558307558319558343558401558413558421558427558431558457558469558473558479558491558497558499558521558529558533558539558541558563558583558587558599558611558629558643558661558683558703558721558731558757558769558781558787558791558793558827558829558863558869558881558893558913558931558937558947558973558979558997559001559049559051559067559081559093559099559123559133559157559177559183559201559211559213559217559219559231559243559259559277559297559313559319559343559357559367559369559397559421559451559459559469559483559511559513559523559529559541559547559549559561559571559577559583559591559597559631559633559639559649559667559673559679559687559703559709559739559747559777559781559799559807559813559831559841559849559859559877559883559901559907559913559939559967559973559991560017560023560029560039560047560081560083560089560093560107560113560117560123560137560149560159560171560173560179560191560207560213560221560227560233560237560239560243560249560281560293560297560299560311560317560341560353560393560411560437560447560459560471560477560479560489560491560501560503560531560543560551560561560597560617560621560639560641560653560669560683560689560701560719560737560753560761560767560771560783560797560803560827560837560863560869560873560887560891560893560897560929560939560941560969560977561019561047561053561059561061561079561083561091561097561101561103561109561161561173561181561191561199561229561251561277561307561313561343561347561359561367561373561377561389561409561419561439561461561521561529561551561553561559561599561607561667561703561713561733561761561767561787561797561809561829561839561907561917561923561931561943561947561961561973561983561997562007562019562021562043562091562103562129562147562169562181562193562201562231562259562271562273562283562291562297562301562307562313562333562337562349562351562357562361562399562403562409562417562421562427562439562459562477562493562501562517562519562537562577562579562589562591562607562613562621562631562633562651562663562669562673562691562693562699562703562711562721562739562753562759562763562781562789562813562831562841562871562897562901562909562931562943562949562963562967562973562979562987562997563009563011563021563039563041563047563051563077563081563099563113563117563119563131563149563153563183563197563219563249563263563287563327563351563357563359563377563401563411563413563417563419563447563449563467563489563501563503563543563551563561563587563593563599563623563657563663563723563743563747563777563809563813563821563831563837563851563869563881563887563897563929563933563947563971563987563999564013564017564041564049564059564061564089564097564103564127564133564149564163564173564191564197564227564229564233564251564257564269564271564299564301564307564313564323564353564359564367564371564373564391564401564407564409564419564437564449564457564463564467564491564497564523564533564593564607564617564643564653564667564671564679564701564703564709564713564761564779564793564797564827564871564881564899564917564919564923564937564959564973564979564983564989564997565013565039565049565057565069565109565111565127565163565171565177565183565189565207565237565241565247565259565261565273565283565289565303565319565333565337565343565361565379565381565387565391565393565427565429565441565451565463565469565483565489565507565511565517565519565549565553565559565567565571565583565589565597565603565613565637565651565661565667565723565727565769565771565787565793565813565849565867565889565891565907565909565919565921565937565973565979565997566011566023566047566057566077566089566101566107566131566149566161566173566179566183566201566213566227566231566233566273566311566323566347566387566393566413566417566429566431566437566441566443566453566521566537566539566543566549566551566557566563566567566617566633566639566653566659566677566681566693566701566707566717566719566723566737566759566767566791566821566833566851566857566879566911566939566947566963566971566977566987566999567011567013567031567053567059567067567097567101567107567121567143567179567181567187567209567257567263567277567319567323567367567377567383567389567401567407567439567449567451567467567487567493567499567527567529567533567569567601567607567631567649567653567659567661567667567673567689567719567737567751567761567767567779567793567811567829567841567857567863567871567877567881567883567899567937567943567947567949567961567979567991567997568019568027568033568049568069568091568097568109568133568151568153568163568171568177568187568189568193568201568207568231568237568241568273568279568289568303568349568363568367568387568391568433568439568441568453568471568481568493568523568541568549568577568609568619568627568643568657568669568679568691568699568709568723568751568783568787568807568823568831568853568877568891568903568907568913568921568963568979568987568991568999569003569011569021569047569053569057569071569077569081569083569111569117569137569141569159569161569189569197569201569209569213569237569243569249569251569263569267569269569321569323569369569417569419569423569431569447569461569479569497569507569533569573569579569581569599569603569609569617569623569659569663569671569683569711569713569717569729569731569747569759569771569773569797569809569813569819569831569839569843569851569861569869569887569893569897569903569927569939569957569983570001570013570029570041570043570047570049570071570077570079570083570091570107570109570113570131570139570161570173570181570191570217570221570233570253570329570359570373570379570389570391570403570407570413570419570421570461570463570467570487570491570497570499570509570511570527570529570539570547570553570569570587570601570613570637570643570649570659570667570671570677570683570697570719570733570737570743570781570821570827570839570841570851570853570859570881570887570901570919570937570949570959570961570967570991571001571019571031571037571049571069571093571099571111571133571147571157571163571199571201571211571223571229571231571261571267571279571303571321571331571339571369571381571397571399571409571433571453571471571477571531571541571579571583571589571601571603571633571657571673571679571699571709571717571721571741571751571759571777571783571789571799571801571811571841571847571853571861571867571871571873571877571903571933571939571969571973572023572027572041572051572053572059572063572069572087572093572107572137572161572177572179572183572207572233572239572251572269572281572303572311572321572323572329572333572357572387572399572417572419572423572437572449572461572471572479572491572497572519572521572549572567572573572581572587572597572599572609572629572633572639572651572653572657572659572683572687572699572707572711572749572777572791572801572807572813572821572827572833572843572867572879572881572903572909572927572933572939572941572963572969572993573007573031573047573101573107573109573119573143573161573163573179573197573247573253573263573277573289573299573317573329573341573343573371573379573383573409573437573451573457573473573479573481573487573493573497573509573511573523573527573557573569573571573637573647573673573679573691573719573737573739573757573761573763573787573791573809573817573829573847573851573863573871573883573887573899573901573929573941573953573967573973573977574003574031574033574051574061574081574099574109574127574157574159574163574169574181574183574201574219574261574279574283574289574297574307574309574363574367574373574393574423574429574433574439574477574489574493574501574507574529574543574547574597574619574621574627574631574643574657574667574687574699574703574711574723574727574733574741574789574799574801574813574817574859574907574913574933574939574949574963574967574969575009575027575033575053575063575077575087575119575123575129575131575137575153575173575177575203575213575219575231575243575249575251575257575261575303575317575359575369575371575401575417575429575431575441575473575479575489575503575513575551575557575573575579575581575591575593575611575623575647575651575669575677575689575693575699575711575717575723575747575753575777575791575821575837575849575857575863575867575893575903575921575923575941575957575959575963575987576001576013576019576029576031576041576049576089576101576119576131576151576161576167576179576193576203576211576217576221576223576227576287576293576299576313576319576341576377576379576391576421576427576431576439576461576469576473576493576509576523576529576533576539576551576553576577576581576613576617576637576647576649576659576671576677576683576689576701576703576721576727576731576739576743576749576757576769576787576791576881576883576889576899576943576949576967576977577007577009577033577043577063577067577069577081577097577111577123577147577151577153577169577177577193577219577249577259577271577279577307577327577331577333577349577351577363577387577397577399577427577453577457577463577471577483577513577517577523577529577531577537577547577559577573577589577601577613577627577637577639577667577721577739577751577757577781577799577807577817577831577849577867577873577879577897577901577909577919577931577937577939577957577979577981578021578029578041578047578063578077578093578117578131578167578183578191578203578209578213578251578267578297578299578309578311578317578327578353578363578371578399578401578407578419578441578453578467578477578483578489578497578503578509578533578537578563578573578581578587578597578603578609578621578647578659578687578689578693578701578719578729578741578777578779578789578803578819578821578827578839578843578857578861578881578917578923578957578959578971578999579011579017579023579053579079579083579107579113579119579133579179579197579199579239579251579259579263579277579281579283579287579311579331579353579379579407579409579427579433579451579473579497579499579503579517579521579529579533579539579541579563579569579571579583579587579611579613579629579637579641579643579653579673579701579707579713579721579737579757579763579773579779579809579829579851579869579877579881579883579893579907579947579949579961579967579973579983580001580031580033580079580081580093580133580163580169580183580187580201580213580219580231580259580291580301580303580331580339580343580357580361580373580379580381580409580417580471580477580487580513580529580549580553580561580577580607580627580631580633580639580663580673580687580691580693580711580717580733580747580757580759580763580787580793580807580813580837580843580859580871580889580891580901580913580919580927580939580969580981580997581029581041581047581069581071581089581099581101581137581143581149581171581173581177581183581197581201581227581237581239581261581263581293581303581311581323581333581341581351581353581369581377581393581407581411581429581443581447581459581473581491581521581527581549581551581557581573581597581599581617581639581657581663581683581687581699581701581729581731581743581753581767581773581797581809581821581843581857581863581869581873581891581909581921581941581947581953581981581983582011582013582017582031582037582067582083582119582137582139582157582161582167582173582181582203582209582221582223582227582247582251582299582317582319582371582391582409582419582427582433582451582457582469582499582509582511582541582551582563582587582601582623582643582649582677582689582691582719582721582727582731582737582761582763582767582773582781582793582809582821582851582853582859582887582899582931582937582949582961582971582973582983583007583013583019583021583031583069583087583127583139583147583153583169583171583181583189583207583213583229583237583249583267583273583279583291583301583337583339583351583367583391583397583403583409583417583421583447583459583469583481583493583501583511583519583523583537583543583577583603583613583619583621583631583651583657583669583673583697583727583733583753583769583777583783583789583801583841583853583859583861583873583879583903583909583937583969583981583991583997584011584027584033584053584057584063584081584099584141584153584167584183584203584249584261584279584281584303584347584357584359584377584387584393584399584411584417584429584447584471584473584509584531584557584561584587584593584599584603584609584621584627584659584663584677584693584699584707584713584719584723584737584767584777584789584791584809584849584863584869584873584879584897584911584917584923584951584963584971584981584993584999585019585023585031585037585041585043585049585061585071585073585077585107585113585119585131585149585163585199585217585251585269585271585283585289585313585317585337585341585367585383585391585413585437585443585461585467585493585503585517585547585551585569585577585581585587585593585601585619585643585653585671585677585691585721585727585733585737585743585749585757585779585791585799585839585841585847585853585857585863585877585881585883585889585899585911585913585917585919585953585989585997586009586037586051586057586067586073586087586111586121586123586129586139586147586153586189586213586237586273586277586291586301586309586319586349586361586363586367586387586403586429586433586457586459586463586471586493586499586501586541586543586567586571586577586589586601586603586609586627586631586633586667586679586693586711586723586741586769586787586793586801586811586813586819586837586841586849586871586897586903586909586919586921586933586939586951586961586973586979586981587017587021587033587051587053587057587063587087587101587107587117587123587131587137587143587149587173587179587189587201587219587263587267587269587281587287587297587303587341587371587381587387587413587417587429587437587441587459587467587473587497587513587519587527587533587539587549587551587563587579587599587603587617587621587623587633587659587669587677587687587693587711587731587737587747587749587753587771587773587789587813587827587833587849587863587887587891587897587927587933587947587959587969587971587987587989587999588011588019588037588043588061588073588079588083588097588113588121588131588151588167588169588173588191588199588229588239588241588257588277588293588311588347588359588361588383588389588397588403588433588437588463588481588493588503588509588517588521588529588569588571588619588631588641588647588649588667588673588683588703588733588737588743588767588773588779588811588827588839588871588877588881588893588911588937588941588947588949588953588977589021589027589049589063589109589111589123589139589159589163589181589187589189589207589213589219589231589241589243589273589289589291589297589327589331589349589357589387589409589439589451589453589471589481589493589507589529589531589579589583589591589601589607589609589639589643589681589711589717589751589753589759589763589783589793589807589811589829589847589859589861589873589877589903589921589933589993589997590021590027590033590041590071590077590099590119590123590129590131590137590141590153590171590201590207590243590251590263590267590269590279590309590321590323590327590357590363590377590383590389590399590407590431590437590489590537590543590567590573590593590599590609590627590641590647590657590659590669590713590717590719590741590753590771590797590809590813590819590833590839590867590899590921590923590929590959590963590983590987591023591053591061591067591079591089591091591113591127591131591137591161591163591181591193591233591259591271591287591289591301591317591319591341591377591391591403591407591421591431591443591457591469591499591509591523591553591559591581591599591601591611591623591649591653591659591673591691591709591739591743591749591751591757591779591791591827591841591847591863591881591887591893591901591937591959591973592019592027592049592057592061592073592087592099592121592129592133592139592157592199592217592219592223592237592261592289592303592307592309592321592337592343592351592357592367592369592387592391592393592429592451592453592463592469592483592489592507592517592531592547592561592577592589592597592601592609592621592639592643592649592661592663592681592693592723592727592741592747592759592763592793592843592849592853592861592873592877592897592903592919592931592939592967592973592987592993593003593029593041593051593059593071593081593083593111593119593141593143593149593171593179593183593207593209593213593227593231593233593251593261593273593291593293593297593321593323593353593381593387593399593401593407593429593447593449593473593479593491593497593501593507593513593519593531593539593573593587593597593603593627593629593633593641593647593651593689593707593711593767593777593783593839593851593863593869593899593903593933593951593969593977593987593993594023594037594047594091594103594107594119594137594151594157594161594163594179594193594203594211594227594241594271594281594283594287594299594311594313594329594359594367594379594397594401594403594421594427594449594457594467594469594499594511594521594523594533594551594563594569594571594577594617594637594641594653594667594679594697594709594721594739594749594751594773594793594821594823594827594829594857594889594899594911594917594929594931594953594959594961594977594989595003595037595039595043595057595069595073595081595087595093595097595117595123595129595139595141595157595159595181595183595201595207595229595247595253595261595267595271595277595291595303595313595319595333595339595351595363595373595379595381595411595451595453595481595513595519595523595547595549595571595577595579595613595627595687595703595709595711595717595733595741595801595807595817595843595873595877595927595939595943595949595951595957595961595963595967595981596009596021596027596047596053596059596069596081596083596093596117596119596143596147596159596179596209596227596231596243596251596257596261596273596279596291596293596317596341596363596369596399596419596423596461596489596503596507596537596569596573596579596587596593596599596611596623596633596653596663596669596671596693596707596737596741596749596767596779596789596803596821596831596839596851596857596861596863596879596899596917596927596929596933596941596963596977596983596987597031597049597053597059597073597127597131597133597137597169597209597221597239597253597263597269597271597301597307597349597353597361597367597383597391597403597407597409597419597433597437597451597473597497597521597523597539597551597559597577597581597589597593597599597613597637597643597659597671597673597677597679597689597697597757597761597767597769597781597803597823597827597833597853597859597869597889597899597901597923597929597967597997598007598049598051598057598079598093598099598123598127598141598151598159598163598187598189598193598219598229598261598303598307598333598363598369598379598387598399598421598427598439598447598457598463598487598489598501598537598541598571598613598643598649598651598657598669598681598687598691598711598721598727598729598777598783598789598799598817598841598853598867598877598883598891598903598931598933598963598967598973598981598987598999599003599009599021599023599069599087599117599143599147599149599153599191599213599231599243599251599273599281599303599309599321599341599353599359599371599383599387599399599407599413599419599429599477599479599491599513599519599537599551599561599591599597599603599611599623599629599657599663599681599693599699599701599713599719599741599759599779599783599803599831599843599857599869599891599899599927599933599939599941599959599983599993599999600011600043600053600071600073600091600101600109600167600169600203600217600221600233600239600241600247600269600283600289600293600307600311600317600319600337600359600361600367600371600401600403600407600421600433600449600451600463600469600487600517600529600557600569600577600601600623600631600641600659600673600689600697600701600703600727600751600791600823600827600833600841600857600877600881600883600889600893600931600947600949600959600961600973600979600983601021601031601037601039601043601061601067601079601093601127601147601187601189601193601201601207601219601231601241601247601259601267601283601291601297601309601313601319601333601339601357601379601397601411601423601439601451601457601487601507601541601543601589601591601607601631601651601669601687601697601717601747601751601759601763601771601801601807601813601819601823601831601849601873601883601889601897601903601943601949601961601969601981602029602033602039602047602057602081602083602087602093602099602111602137602141602143602153602179602197602201602221602227602233602257602267602269602279602297602309602311602317602321602333602341602351602377602383602401602411602431602453602461602477602479602489602501602513602521602543602551602593602597602603602621602627602639602647602677602687602689602711602713602717602729602743602753602759602773602779602801602821602831602839602867602873602887602891602909602929602947602951602971602977602983602999603011603013603023603047603077603091603101603103603131603133603149603173603191603203603209603217603227603257603283603311603319603349603389603391603401603431603443603457603467603487603503603521603523603529603541603553603557603563603569603607603613603623603641603667603679603689603719603731603739603749603761603769603781603791603793603817603821603833603847603851603853603859603881603893603899603901603907603913603917603919603923603931603937603947603949603989604001604007604013604031604057604063604069604073604171604189604223604237604243604249604259604277604291604309604313604319604339604343604349604361604369604379604397604411604427604433604441604477604481604517604529604547604559604579604589604603604609604613604619604649604651604661604697604699604711604727604729604733604753604759604781604787604801604811604819604823604829604837604859604861604867604883604907604931604939604949604957604973604997605009605021605023605039605051605069605071605113605117605123605147605167605173605177605191605221605233605237605239605249605257605261605309605323605329605333605347605369605393605401605411605413605443605471605477605497605503605509605531605533605543605551605573605593605597605599605603605609605617605629605639605641605687605707605719605779605789605809605837605849605861605867605873605879605887605893605909605921605933605947605953605977605987605993606017606029606031606037606041606049606059606077606079606083606091606113606121606131606173606181606223606241606247606251606299606301606311606313606323606341606379606383606413606433606443606449606493606497606503606521606527606539606559606569606581606587606589606607606643606649606653606659606673606721606731606733606737606743606757606791606811606829606833606839606847606857606863606899606913606919606943606959606961606967606971606997607001607003607007607037607043607049607063607067607081607091607093607097607109607127607129607147607151607153607157607163607181607199607213607219607249607253607261607301607303607307607309607319607331607337607339607349607357607363607417607421607423607471607493607517607531607549607573607583607619607627607667607669607681607697607703607721607723607727607741607769607813607819607823607837607843607861607883607889607909607921607931607933607939607951607961607967607991607993608011608029608033608087608089608099608117608123608129608131608147608161608177608191608207608213608269608273608297608299608303608339608347608357608359608369608371608383608389608393608401608411608423608429608431608459608471608483608497608519608521608527608581608591608593608609608611608633608653608659608669608677608693608701608737608743608749608759608767608789608819608831608843608851608857608863608873608887608897608899608903608941608947608953608977608987608989608999609043609047609067609071609079609101609107609113609143609149609163609173609179609199609209609221609227609233609241609253609269609277609283609289609307609313609337609359609361609373609379609391609397609403609407609421609437609443609461609487609503609509609517609527609533609541609571609589609593609599609601609607609613609617609619609641609673609683609701609709609743609751609757609779609781609803609809609821609859609877609887609907609911609913609923609929609979609989609991609997610031610063610081610123610157610163610187610193610199610217610219610229610243610271610279610289610301610327610331610339610391610409610417610429610439610447610457610469610501610523610541610543610553610559610567610579610583610619610633610639610651610661610667610681610699610703610721610733610739610741610763610781610783610787610801610817610823610829610837610843610847610849610867610877610879610891610913610919610921610933610957610969610993611011611027611033611057611069611071611081611101611111611113611131611137611147611189611207611213611257611263611279611293611297611323611333611389611393611411611419611441611449611453611459611467611483611497611531611543611549611551611557611561611587611603611621611641611657611671611693611707611729611753611791611801611803611827611833611837611839611873611879611887611903611921611927611939611951611953" return primes[a:a+b] pass
Simple prime streaming
5a908da30025e995880000e3
[ "Algorithms" ]
https://www.codewars.com/kata/5a908da30025e995880000e3
6 kyu
# Task **_Given_** *an array of N integers, you have to find* **_how many times_** *you have to* **_add up the smallest numbers_** *in the array until* **_their Sum_** *becomes greater or equal to* **_K_**. ___ # Notes: * **_List size_** is *at least 3*. * **_All numbers_** *will be* **_positive_**. * **_Numbers_** could *occur more than once* , **_(Duplications may exist)_**. * Threshold **_K_** will *always be reachable*. ___ # Input >> Output Examples ``` minimumSteps({1, 10, 12, 9, 2, 3}, 6) ==> return (2) ``` ## **_Explanation_**: * We *add two smallest elements* **_(1 + 2)_**, *their sum is 3* . * **_Then_** we **_add the next smallest number to it (3 + 3)_** , so *the sum becomes 6* . * **_Now_** the result is greater or equal to **_6_** , *Hence the output is (2) i.e (2) operations are required to do this* . ___ ``` minimumSteps({8 , 9, 4, 2}, 23) ==> return (3) ``` ## **_Explanation_**: * We *add two smallest elements* **_(4 + 2)_**, *their sum is 6* . * **_Then_** we **_add the next smallest number to it (6 + 8)_** , so *the sum becomes 14* . * **_Now_** we **_add the next smallest number (14 + 9)_** , so *the sum becomes 23* . * **_Now_** the result is greater or equal to **_23_** , *Hence the output is (3) i.e (3) operations are required to do this* . ___ ``` minimumSteps({19,98,69,28,75,45,17,98,67}, 464) ==> return (8) ``` ## **_Explanation_**: * We *add two smallest elements* **_(19 + 17)_**, *their sum is 36* . * **_Then_** we **_add the next smallest number to it (36 + 28)_** , so *the sum becomes 64* . * We need to **_keep doing this_** *until **_the sum_** becomes greater or equal to **_K_** (464 in this case)*, which will require **_8_** Steps . ___ ## Expected Time Complexity `O(n Log n)` ___ ___ ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
def minimum_steps(arr, n): arr = sorted(arr) s = 0 for i, v in enumerate(arr): s += v if s >= n: return i
Minimum Steps (Array Series #6)
5a91a7c5fd8c061367000002
[ "Fundamentals", "Arrays" ]
https://www.codewars.com/kata/5a91a7c5fd8c061367000002
7 kyu
Consider the number triangle below, in which each number is equal to the number above plus the number to the left. If there is no number above, assume it's a `0`. ```haskell 1 1 1 1 2 2 1 3 5 5 1 4 9 14 14 ``` The triangle has `5` rows and the sum of the last row is `sum([1,4,9,14,14]) = 42`. You will be given an integer `n` and your task will be to return the sum of the last row of a triangle of `n` rows. In the example above: ```haskell solve(5) = 42 ``` More examples in test cases. Good luck! ```if:javascript ### Note This kata uses native arbitrary precision integer numbers ( `BigInt`, `1n` ). Unfortunately, the testing framework and even native `JSON` do not fully support them yet. `console.log(1n)` and `(1n).toString()` work and can be used for debugging. We apologise for the inconvenience. ```
algorithms
from math import comb def solve(n): """ See: https://en.wikipedia.org/wiki/Catalan's_triangle """ return comb(n << 1, n) / / (n + 1)
Simple number triangle
5a906c895084d7ed740000c2
[ "Algorithms", "Discrete Mathematics" ]
https://www.codewars.com/kata/5a906c895084d7ed740000c2
6 kyu
In this Kata, you will be given an array of integers and your task is to return the number of arithmetic progressions of size `3` that are possible from that list. In each progression, the differences between the elements must be the same. ``` [1, 2, 3, 5, 7, 9] ==> 5 // [1, 2, 3], [1, 3, 5], [1, 5, 9], [3, 5, 7], and [5, 7, 9] ``` All array elements will be unique and sorted. More examples in test cases. Good luck!
algorithms
from itertools import combinations def solve(xs): return sum(1 for a, b, c in combinations(xs, 3) if a - b == b - c)
Simple arithmetic progression
5a903c0557c562cd7500026f
[ "Algorithms" ]
https://www.codewars.com/kata/5a903c0557c562cd7500026f
6 kyu
No Story No Description Only by Thinking and Testing Look at the result of testcase, guess the code! # #Series:<br> <a href="http://www.codewars.com/kata/56d904db9963e9cf5000037d">01:A and B?</a><br> <a href="http://www.codewars.com/kata/56d9292cc11bcc3629000533">02:Incomplete string</a><br> <a href="http://www.codewars.com/kata/56d931ecc443d475d5000003">03:True or False</a><br> <a href="http://www.codewars.com/kata/56d93f249c844788bc000002">04:Something capitalized</a><br> <a href="http://www.codewars.com/kata/56d949281b5fdc7666000004">05:Uniq or not Uniq</a> <br> <a href="http://www.codewars.com/kata/56d98b555492513acf00077d">06:Spatiotemporal index</a><br> <a href="http://www.codewars.com/kata/56d9b46113f38864b8000c5a">07:Math of Primary School</a><br> <a href="http://www.codewars.com/kata/56d9c274c550b4a5c2000d92">08:Math of Middle school</a><br> <a href="http://www.codewars.com/kata/56d9cfd3f3928b4edd000021">09:From nothingness To nothingness</a><br> <a href="http://www.codewars.com/kata/56dae2913cb6f5d428000f77">10:Not perfect? Throw away!</a> <br> <a href="http://www.codewars.com/kata/56db19703cb6f5ec3e001393">11:Welcome to take the bus</a><br> <a href="http://www.codewars.com/kata/56dc41173e5dd65179001167">12:A happy day will come</a><br> <a href="http://www.codewars.com/kata/56dc5a773e5dd6dcf7001356">13:Sum of 15(Hetu Luosliu)</a><br> <a href="http://www.codewars.com/kata/56dd3dd94c9055a413000b22">14:Nebula or Vortex</a><br> <a href="http://www.codewars.com/kata/56dd927e4c9055f8470013a5">15:Sport Star</a><br> <a href="http://www.codewars.com/kata/56de38c1c54a9248dd0006e4">16:Falsetto Rap Concert</a><br> <a href="http://www.codewars.com/kata/56de4d58301c1156170008ff">17:Wind whispers</a><br> <a href="http://www.codewars.com/kata/56de82fb9905a1c3e6000b52">18:Mobile phone simulator</a><br> <a href="http://www.codewars.com/kata/56dfce76b832927775000027">19:Join but not join</a><br> <a href="http://www.codewars.com/kata/56dfd5dfd28ffd52c6000bb7">20:I hate big and small</a><br> <a href="http://www.codewars.com/kata/56e0e065ef93568edb000731">21:I want to become diabetic ;-)</a><br> <a href="http://www.codewars.com/kata/56e0f1dc09eb083b07000028">22:How many blocks?</a><br> <a href="http://www.codewars.com/kata/56e1161fef93568228000aad">23:Operator hidden in a string</a><br> <a href="http://www.codewars.com/kata/56e127d4ef93568228000be2">24:Substring Magic</a><br> <a href="http://www.codewars.com/kata/56eccc08b9d9274c300019b9">25:Report about something</a><br> <a href="http://www.codewars.com/kata/56ee0448588cbb60740013b9">26:Retention and discard I</a><br> <a href="http://www.codewars.com/kata/56eee006ff32e1b5b0000c32">27:Retention and discard II</a><br> <a href="http://www.codewars.com/kata/56eff1e64794404a720002d2">28:How many "word"?</a><br> <a href="http://www.codewars.com/kata/56f167455b913928a8000c49">29:Hail and Waterfall</a><br> <a href="http://www.codewars.com/kata/56f214580cd8bc66a5001a0f">30:Love Forever</a><br> <a href="http://www.codewars.com/kata/56f25b17e40b7014170002bd">31:Digital swimming pool</a><br> <a href="http://www.codewars.com/kata/56f4202199b3861b880013e0">32:Archery contest</a><br> <a href="http://www.codewars.com/kata/56f606236b88de2103000267">33:The repair of parchment</a><br> <a href="http://www.codewars.com/kata/56f6b4369400f51c8e000d64">34:Who are you?</a><br> <a href="http://www.codewars.com/kata/56f7eb14f749ba513b0009c3">35:Safe position</a><br> <br> # #Special recommendation Another series, innovative and interesting, medium difficulty. People who like to challenge, can try these kata: <a href="http://www.codewars.com/kata/56c85eebfd8fc02551000281">Play Tetris : Shape anastomosis</a><br> <a href="http://www.codewars.com/kata/56cd5d09aa4ac772e3000323">Play FlappyBird : Advance Bravely</a><br>
games
def digitsum(n): return sum(map(int, str(n))) def test_it(a, b): return digitsum(a) * digitsum(b)
Thinking & Testing: A * B?
5a90c9ecb171012b47000077
[ "Puzzles", "Games" ]
https://www.codewars.com/kata/5a90c9ecb171012b47000077
6 kyu
In *continuation passing style* programming, the functions, instead of returning a value, take an extra argument which is a *continuation function*, taking the value that would have been returned as its argument. Even the basic operations must take an extra argument. For that end, we defined `add(x,y,k)` and `mult(x,y,k)` functions, which should be used in the solution. <h3>Task</h3> Rewrite the following two simple functions in continuation style: def f(x): return x*2 def g(x): return 10*x+1 So that, the rewritten functions `f` and `g` take an extra parameter, `k`, and *don't return any value*, else the tests will fail. <br> Also, usage of `add` and `mult` will be checked. Finally, use the prepared function `show(x,k)` in place of `print(x)` to produce the following code snippet translated into continuation passing style: def main(): print( f(g(2)) ) For testing, we introduced the `expect_value` method which can retrieve the final value to be returned, using the identity function `id` as the final continuation function. <br> Usage of `id` in this kata means the *end* of the continuation process. (See the example test cases.)
reference
def f(x, k): mult(x, 2, k) def g(x, k): mult(10, x, lambda x: add(x, 1, k)) def main(k): g(2, lambda y: f(y, lambda x: show(x, k)))
Continuation in arguments, part 1
5a90bc1fba1bb5aae800007e
[ "Fundamentals" ]
https://www.codewars.com/kata/5a90bc1fba1bb5aae800007e
6 kyu
# Introduction and Warm-up (Highly recommended) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) ___ # Task **_Given_** an *array/list [] of integers* , **_Construct_** a *product array **_Of same size_** Such That prod[i] is equal to The Product of all the elements of Arr[] except Arr[i]*. ___ # Notes * **_Array/list_** size is *at least 2* . * **_Array/list's numbers_** Will be **_only Positives_** * **_Repetition_** of numbers in *the array/list could occur*. ___ # Input >> Output Examples ``` productArray ({12,20}) ==> return {20,12} ``` ## **_Explanation_**: * **_The first element_** *in prod [] array* **_20_** *is the product of all array's elements except the first element* * **_The second element_** **_12_** *is the product of all array's elements except the second element* . ___ ``` productArray ({1,5,2}) ==> return {10,2,5} ``` ## **_Explanation_**: * **_The first element_** **_10_** *is the product of all array's elements* **_except_** *the first element **_1_*** * **_The second element_** **_2_** *is the product of all array's elements* **_except_** *the second element* **_5_** * **_The Third element_** **_5_** *is the product of all array's elements* **_except_** *the Third element* **_2_**. ___ ``` productArray ({10,3,5,6,2}) return ==> {180,600,360,300,900} ``` ## **_Explanation_**: * **_The first element_** **_180_** *is the product of all array's elements* **_except_** *the first element* **_10_** * **_The second element_** **_600_** *is the product of all array's elements* **_except_** *the second element* **_3_** * **_The Third element_** **_360_** *is the product of all array's elements* **_except_** *the third element* **_5_** * **_The Fourth element_** **_300_** *is the product of all array's elements* **_except_** *the fourth element* **_6_** * *Finally* ,**_The Fifth element_** **_900_** *is the product of all array's elements* **_except_** *the fifth element* **_2_** ___ # [A more challenging version of this kata by Firefly2002](https://www.codewars.com/kata/array-product-sans-n) ___ ___ # [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers) # [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays) # [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored) ___ ## ALL translations are welcomed ## Enjoy Learning !! # Zizou
reference
from operator import mul from functools import reduce def product_array(numbers): tot = reduce(mul, numbers) return [tot / / n for n in numbers]
Product Array (Array Series #5)
5a905c2157c562994900009d
[ "Fundamentals", "Arrays" ]
https://www.codewars.com/kata/5a905c2157c562994900009d
7 kyu