Exercise_1 : ATM

Jiayi would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja’s account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 $US. Calculate Pooja’s account balance after an attempted transaction.


Input

Positive integer 0 < X <= 2000 - the amount of cash which Pooja wishes to withdraw.
Nonnegative number 0<= Y <= 2000 with two digits of precision - Pooja’s initial account balance.


Output

Output the account balance after the attempted transaction, given as a number with two digits of precision. If there is not enough money in the account to complete the transaction, output the current bank balance.


Examples

  1. Input:
  2. 30 120.00
  3. Output:
  4. 89.50
  5. ----------------
  6. Input:
  7. 42 120.00
  8. Output:
  9. 120.00
  10. ----------------
  11. Input:
  12. 300 120.00
  13. Output:
  14. 120.00

Autograder

https://www.codechef.com/submit/LUCKFOUR


Exercise_2 : Lucky Four

Kostya likes the number 4 much. Of course! This number has such a lot of properties, like:

  • Four is the smallest composite number;
  • It is also the smallest Smith number;
  • The smallest non-cyclic group has four elements;
  • Four is the maximal degree of the equation that can be solved in radicals;
  • There is four-color theorem that states that any map can be colored in no more than four colors in such a way that no two adjacent regions are colored in the same color;
  • Lagrange’s four-square theorem states that every positive integer can be written as the sum of at most four square numbers;
  • Four is the maximum number of dimensions of a real division algebra;
  • In bases 6 and 12, 4 is a 1-automorphic number;
  • And there are a lot more cool stuff about this number!

Impressed by the power of this number, Kostya has begun to look for occurrences of four anywhere. He has a list of T integers, for each of them he wants to calculate the number of occurrences of the digit 4 in the decimal representation. He is too busy now, so please help him.


Input

The first line of input consists of a single integer T, denoting the number of integers in Kostya’s list.
Then, there are T lines, each of them contain a single integer from the list.


Output

Output T lines. Each of these lines should contain the number of occurences of the digit 4 in the respective integer from Kostya’s list.


Constraints

  • 1T10
  • (Subtask 1): 0 ≤ Numbers from the list ≤ 9 - 33 points.
  • (Subtask 2): 0 ≤ Numbers from the list ≤ 10 - 67 points.

Example

Input:
5
447474
228
6664
40
81

Output:
4
0
1
1
0

Autograder

https://www.codechef.com/submit/LUCKFOUR


Exercise_3 : Mahasena

Pyhton for 家毅:midterm exercise - 图1

Kattapa, as you all know (Actually, I don’t konw…) was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as Mahasena.

Kattapa was known to be a very superstitious person.

  1. He believed that a soldier is “lucky” if the soldier is holding an even number of weapons, and “unlucky” otherwise.
  2. He considered the army as “READY FOR BATTLE” if the count of “lucky” soldiers is strictly greater than the count of “unlucky” soldiers, and “NOT READY” otherwise.

Given the number of weapons each soldier is holding, your task is to determine whether the army formed by all these soldiers is “READY FOR BATTLE” or “NOT READY”.


Input

The first line of input consists of a single integer N denoting the number of soldiers. The second line of input consists of N space separated integers A, A, …, A, where A denotes the number of weapons that the i soldier is holding.


Output

Generate one line output saying “READY FOR BATTLE”, if the army satisfies the conditions that Kattapa requires or “NOT READY” otherwise (quotes for clarity).


Constraints

  • 1N100
  • 1A100

Example 1

Input:
1
1

Output:
NOT READY


Example 2

Input:
1
2

Output:
READY FOR BATTLE


Example 3

Input:
4
11 12 13 14

Output:
NOT READY


Example 4

Input:
3
2 3 4

Output:
READY FOR BATTLE


Example 5

Input:
5
1 2 3 4 5

Output:
NOT READY


Please remember to save your answes in your local repository.


Exercise_4 : Studying Alphabet

Chef 有个叫 Jeff 的弟弟。最近 Jeff 正在学习识字。Jeff 现在只认识字母表中的一部分字母。为了帮助 Jeff 学习识字,Chef 送给他一本书,里面有一篇包含了 N 个单词的文章。在这篇文章中,Jeff 只能读懂那些只由他认识的字母构成的单词。现在,Chef 想要知道这篇文章里哪些单词是 Jeff 能读懂的,哪些又是 Jeff 读不懂的。请你帮帮 Chef 吧!


Input

输入的第一行包含一个由小写字母组成的字符串 S,表示 Jeff 认识的字母。每个字母在 S 中 最多只会出现一次。 输入的第二行包含一个整数 N,表示书中单词的数量。 之后的 N 行输入每一行包含一个由小写字母组成的字符串 Wi,表示书中的第 i 个单词。


Output

对于每个单词,如果 Jeff 能读懂这个单词,输出“Yes”(不含引号);否则输出“No”。


Constraints

  • 1 ≤ |S| ≤ 26
  • 1 ≤ N ≤ 1000
  • 1 ≤ |W | ≤ 12
  • 每个字母在 S 中只会出现最多一次。
  • Si , Wi 只包含小写拉丁字母。

Example

Input:
act
2
cat
dog

Output:
Yes
No


Exercise_5 : Covid Run (新冠逃亡)

Covid-19 正在迅速传播!有 N 个城市,编号 0 到 N − 1,排成一个环。城市 0 和城市 1 相连, 城市 1 和城市 2 相连,……,城市 (N − 2) 和城市 (N − 1) 相连,城市 (N − 1) 和城市 0 相连。 目前,病毒在城市 X。每一天,它会从当前城市传播到其右边的第 K 个城市,也就是说从城市 X 传播到城市 (X + K) mod N。当病毒从一座城市传播到另一座城市的时候,这两座城市之间的其 他城市并不会被感染。一座城市如果被感染了,那么它会一直处于被感染的状态。你住在城市 Y 。请 求出病毒是否会传播到你的城市,如果是的则输出YES,否则输出NO。


Input

  • 输入的第一行包含一个整数 T,表示数据组数。接下来是 T 组数据。
  • 每组数据仅包含一行四个整数 N, K, X, Y ,分别表示城市总数、每次传播“跳跃”的大小、病 毒当前所在城市、以及你居住的城市。

Output

对每组数据输出一行,如果病毒将会在有限天后传播到你的城市,则输出YES;否则输出NO。


Constraints

  • 1 ≤ T ≤ 100
  • 1 ≤ N ≤ 1000
  • 0 ≤ X, Y ≤ N − 1
  • 0 ≤ K ≤ 1000

Example

输入
2
6 2 5 3
12 3 4 2

输出
YES
NO