Insurance CodeChef Solution

Problem – Insurance CodeChef Solution

Chef bought car insurance. The policy of the insurance is:

  • The maximum rebatable amount for any damage is Rs X lakhs.
  • If the amount required for repairing the damage is ≤X lakhs, that amount is rebated in full.

Chef’s car meets an accident and required Rs Y lakhs for repairing.

Determine the amount that will be rebated by the insurance company.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • The first and only line of each test case contains two space-separated integers X and Y.

Output Format

For each test case, output the amount (in lakhs) that will be rebated by the insurance company.


  • 1≤T≤1000
  • 1≤X,Y≤30

Sample 1:

Input: 4
5 3
5 8
4 4
15 12
Output: 3


Test case 1: The damages require only Rs 3 lakh which is below the upper cap, so the entire Rs 3 lakh will be rebated.

Test case 2: The damages require Rs 8 lakh which is above the upper cap, so only Rs 5 lakh will be rebated.

Test case 3: The damages require only Rs 4 lakh which is equal to the upper cap, so the whole Rs 4 lakh will be rebated.

Test case 4: The damages require Rs 15 lakh which is above the upper cap, so only Rs 12 lakh will be rebated.

Insurance CodeChef Solution in C++17

using namespace std;
#define int long long int
int32_t main()
    int t;
        int x,y;

Insurance CodeChef Solution in Pyth 3

for i in range(T):
    if X>=Y:

Insurance CodeChef Solution in Java

import java.util.*;
import java.lang.*;

class Codechef
	public static void main (String[] args) throws java.lang.Exception
			Scanner scn= new Scanner(;    // is a standard input stream  
        int T= scn.nextInt();
       for(int i=0; i<T; i++){
        int X= scn.nextInt();
        int Y= scn.nextInt();
Insurance CodeChef Solution Review:

In our experience, we suggest you solve this Insurance CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Insurance CodeChef Solution

Find on CodeChef


I hope this Insurance CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *