4th Contest Oct 05, 2025
Problem A. Chef and Socks
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Chef needs A dollars to buy himself a new pair of socks for Christmas.
If he has X dollars saved up and his parents give him an additional Y dollars, will Chef be
able to buy new socks?
Input Format
The first and only line of input will contain 3 space-separated integers A, X, and Y
— the cost of the socks, the amount of money Chef has saved up, and the additional
money he received from his parents.
Output Format
Output a single string denoting the answer: "YES" if Chef can afford the socks, and "NO"
otherwise (without quotes).
Each character of the output may be printed in either uppercase or lowercase, i.e., the
strings NO , No , nO , and no will all be treated as equivalent.
Constraints
1 ≤ A, X, Y ≤ 100
Sample 1
Input Output
58 40 88 YES
Chef has 40 dollars and his parents gave him 88 dollars. Now he has 40 + 88 = 128
dollars which allows him to buy socks which cost only 58 dollars.
Page 1 of 18
-
4th Contest Oct 05, 2025
Problem B. Lucky Seven
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Chef considers the number 7 lucky. As a result, he believes that the 7-th letter he sees on a
day is his lucky letter of the day.
You are given a string S of length 10, denoting the first 10 letters Chef saw today.
What is Chef’s lucky letter?
Input Format
The only line of input contains a string S , of length 10.
Output Format
Print a single character: Chef’s lucky letter
.
Constraints
S has a length of 10
S contains only lowercase Latin letters (i.e, the characters 'a' to 'z' )
Sample 1
Input Output
proceeding d
The 7-th character of "proceeding" is `'d'`, and hence that is Chef's lucky letter.
Sample 2
Input Output
outofsight i
Page 2 of 18
-
4th Contest Oct 05, 2025
The 7-th character of "outofsight" is `'i'`, and hence that is Chef's lucky letter.
Page 3 of 18
-
4th Contest Oct 05, 2025
Problem C. Food Balance
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Chef is preparing to cook his dinner.
There are two dishes Chef can make. The first one contains F1 grams of fat and P1 grams
of protein, while the second contains F2 grams of fat and P2 grams of protein.
Chef would like the quantity of fats and proteins he consumes to be as close to each other
as possible, i.e., the absolute difference between the amount of fats and proteins should
be as small as possible.
Help Chef by telling him which dish he’ll choose; or if both dishes have the same
difference.
Input Format
The first and only line of input contains four space-separated integers F1 , P1 , F2 ,
and P2 — the quantities of fat and protein in the first dish and second dish,
respectively.
Output Format
Output a single string:
"First" (without quotes) if Chef will choose the first dish.
"Second" (without quotes) if Chef will choose the second dish.
"Both" (without quotes) if both dishes are equivalent.
Each character of the output may be in either uppercase or lowercase, i.e. if the answer is
Both , then any of the strings BOTH , both , Both , bOTh , and so on will be accepted.
Constraints
Page 4 of 18
-
4th Contest Oct 05, 2025
1 ≤ F1 , P1 , F2 , P2 ≤ 100
Sample 1
Input Output
30 40 35 44 Second
The first dish has a difference of ∣30 − 40∣
= 10 between its fats and proteins, while the
second dish has a difference of ∣35 − 44∣ = 9. Chef will choose the second dish, since it
has a smaller difference.
Sample 2
Input Output
1 100 100 1 Both
The first dish has a difference of ∣1 − 100∣
= 99 between its fats and proteins, while the
second dish has a difference of ∣100 − 1∣ = 99. Both dishes have the same difference.
Sample 3
Input Output
58 56 38 52 First
The first dish has a difference of ∣58 − 56∣
= 2 between its fats and proteins, while the
second dish has a difference of ∣38 − 52∣ = 14. Chef will choose the first dish, since it has
a smaller difference.
Page 5 of 18
-
4th Contest Oct 05, 2025
Problem D. Move Grid
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
You are located at the coordinate (0, 0) on a 2D grid with perpendicular X and Y axes.
You will do the following moves:
first, A units along positive X axis
then, B units along positive Y axis
then, C units along negative X axis
finally, D units along negative Y axis
Find the coordinates of your final position.
Input Format
The first and only line of input contains 4 integers - A, B, C and D .
Output Format
For each test case, output on a new line the X and Y coordinates of your final position.
Constraints
1 ≤ A, B, C, D ≤ 10
Sample 1
Input Output
5 4 7 3 -2 1
Initially, you started at (0, 0) - 5 steps along positive X , so you reached (5, 0) - 4 steps
along positive Y , so you reached (5, 4) - 7 steps along negative X , so you reached (−2, 4)
- 3 steps along negative Y , so you reached (−2, 1)
Page 6 of 18
-
4th Contest Oct 05, 2025
Thus, your final position is (−2, 1).
Sample 2
Input Output
1 1 1 1 0 0
Page 7 of 18
-
4th Contest Oct 05, 2025
Problem E. Max Sixers
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Your favourite cricket player played very well today. He made X(100 ≤ X ≤ 200) runs
from exactly 100 balls. Each ball he scored either 0, 1, 2, 3, 4 or 6 runs.
Unfortunately you missed the match. So now, you are wondering what is the maximum
number of sixers he could have hit? A sixer is a ball where you score 6 runs.
Input Format
The first and only line of input contains X , the total number of runs scored.
Output Format
For each test case, output on a new line the maximum number of 6s.
Constraints
100 ≤ X ≤ 200
Sample 1
Input Output
100 16
The player could have scored 6s on 16 balls, 4 on 1 ball and then 0 on the remaining 83
balls.
Sample 2
Input Output
150 25
The player could have scored 6 on 25 balls, and then 0 on 75 balls.
Page 8 of 18
-
4th Contest Oct 05, 2025
Problem F. Christmas Cake
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Chef plans to celebrate Christmas by baking a cake.
Christmas falls on the 25-th of December.
Every day before Christmas, till the 24-th of December, Chef will bake exactly one
practice cake.
Today is the X -th of December. How many practice cakes will Chef bake starting from
today?
Input Format
The first and only line of input will contain a single integer X — today’s date.
Output Format
For each test case, output a single integer: the number of practice cakes Chef will bake.
Constraints
1 ≤ X ≤ 24
Sample 1
Input Output
18 7
If today is the 18-th of December, Chef will bake one cake on each of the dates
18, 19, 20, 21, 22, 23, 24, which is 7 in total.
Sample 2
Page 9 of 18
-
4th Contest Oct 05, 2025
Input Output
1 24
Chef will bake one cake on every day from 1 to 24, which is 24 cakes in total.
Page 10 of 18
-
4th Contest Oct 05, 2025
Problem G. IPL
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Chef has already prepared dinner, and it’s his favorite time of the day. It’s time for a
fantastic cricket match tonight.
If the number of runs scored in an over is at least 7, Chef cheers “THALA”; otherwise, he
cheers “BOOM”.
You are given X , the number of runs scored in the over.
If X is at least 7, print THALA .
Otherwise, print BOOM .
Input Format
A single integer X , representing number of runs scored in an over.
Output Format
Print THALA if number of runs scored in the over is at least 7, otherwise print BOOM .
You may print each character of the string in uppercase or lowercase (for example, the
strings thALa , thala , Thala , and thalA will all be treated as identical).
Constraints
1 ≤ X ≤ 36
Sample 1
Input Output
7 THALA
- Since the number of runs scored is at least 7, the chef cheers out "THALA".
Page 11 of 18
-
4th Contest Oct 05, 2025
Sample 2
Input Output
4 BOOM
- Since the number of runs scored is less than 7, the chef cheers out "BOOM".
Page 12 of 18
-
4th Contest Oct 05, 2025
Problem H. Selling Coins
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Chef has A silver coins and B gold coins.
He can avail the following 2 deals (multiple times):
Sell 1 silver coin for Rs. 1.
Trade 1 gold coin for 2 silver coins.
Chef is trying to sell all his coins and earn money now. How much money will Chef be able
to earn?
Input Format
The first and only line of each test case contains 2 integers - A and B .
Output Format
For each test case, output on a new line the amount of money Chef can earn.
Constraints
1 ≤ A, B ≤ 10
Sample 1
Input Output
2 1 4
Chef can first trade his gold coin for 2 silver coins. Now he has 4 silver coins in total, and
he sells all of them for Rs. 4.
Sample 2
Page 13 of 18
-
4th Contest Oct 05, 2025
Input Output
10 10 30
Page 14 of 18
-
4th Contest Oct 05, 2025
Problem I. IOI 2024
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
IOI 2024 is being held in Egypt, starting from the 1-st of September and ending on the 8-
th of September.
Given a date X in September, output YES if IOI is ongoing then, otherwise NO .
Input Format
The first and only line of input contains one integer X - the date in September.
Output Format
Output either YES or NO , depending on whether IOI is ongoing on September X .
Each character of the output may be printed in either lowercase or uppercase - that is, the
strings no , NO , No , and nO will all be treated as equivalent.
Constraints
1 ≤ X ≤ 30
Sample 1
Input Output
8 YES
IOI is said to be ongoing even on its last day.
Sample 2
Input Output
9 NO
Page 15 of 18
-
4th Contest Oct 05, 2025
IOI already ended on 8-th of September.
Sample 3
Input Output
3 YES
Page 16 of 18
-
4th Contest Oct 05, 2025
Problem J. Glass Prices
Time Limit 1000 ms
Code Length Limit 50000 B
OS Linux
Chef is buying spectacles, and is now deciding on which frame to purchase.
Chef has narrowed his options down to two choices: a plastic frame that costs X rupees,
and a metal frame that costs Y rupees.
Chef will buy the metal frame if and only if it costs at most twice the price of the plastic
frame - otherwise he will buy the plastic frame.
Can you decide which frame Chef will buy?
Input Format
The first and only line of input will contain two integers X and Y - the price of the
plastic frame and the metal frame, respectively.
Output Format
For each test case, output on a new line the answer: the type of frame Chef will purchase.
This is either the string "PLASTIC" or the string "METAL" (without quotes) depending
on the outcome.
Each letter of the output may be printed in either uppercase or lowercase - for example,
the strings METAL , MeTaL , metal , and mEtAL will all be treated as equivalent.
Constraints
1 ≤ X ≤ 2000
1 ≤ Y ≤ 2000
Sample 1
Page 17 of 18
-
4th Contest Oct 05, 2025
Input Output
499 999 PLASTIC
The plastic frame costs 499 rupees, and the metal one costs 999 rupees.
2 × 499 = 998 is less than 999, so Chef will prefer the plastic frame.
Sample 2
Input Output
499 998 METAL
The plastic frame costs 499 rupees, and the metal one costs 998 rupees.
2 × 499 = 998 is equal to 998, so Chef will prefer the metal frame.
Sample 3
Input Output
698 1099 METAL
The plastic frame costs 698 rupees, and the metal one costs 1099 rupees.
2 × 698 = 1396 is greater than 1099, so Chef will prefer the metal frame.
Page 18 of 18
-